Dead code removal.
We're not using any of this code, and we won't be at any forseeable point in the future, so just remove it.
Austin S. Hemmelgarn committed
Jun 5, 2018 at 15:42 UTC
8dcbea4ff501e9dd4cfeb5cf3d7ddd6c6ed058a8
1 file changed
-247
python.d/python_modules/third_party/boinc_client.py
-247
@@ -201,83 +201,6 @@ class Enum(object):
201
return cls.name(Enum.UNKNOWN)
202
203
204
-class NetworkStatus(Enum):
205
- ''' Values of "network_status" '''
206
- ONLINE = 0 #// have network connections open
207
- WANT_CONNECTION = 1 #// need a physical connection
208
- WANT_DISCONNECT = 2 #// don't have any connections, and don't need any
209
- LOOKUP_PENDING = 3 #// a website lookup is pending (try again later)
210
-
211
- @classmethod
212
- def name(cls, v):
213
- if v == cls.UNKNOWN: return "unknown"
214
- elif v == cls.ONLINE: return "online" # misleading
215
- elif v == cls.WANT_CONNECTION: return "need connection"
216
- elif v == cls.WANT_DISCONNECT: return "don't need connection"
217
- elif v == cls.LOOKUP_PENDING: return "reference site lookup pending"
218
- else: return super(NetworkStatus, cls).name(v)
219
-
220
-
221
-class SuspendReason(Enum):
222
- ''' bitmap defs for task_suspend_reason, network_suspend_reason
223
- Note: doesn't need to be a bitmap, but keep for compatibility
224
- '''
225
- NOT_SUSPENDED = 0 # Not in original API
226
- BATTERIES = 1
227
- USER_ACTIVE = 2
228
- USER_REQ = 4
229
- TIME_OF_DAY = 8
230
- BENCHMARKS = 16
231
- DISK_SIZE = 32
232
- CPU_THROTTLE = 64
233
- NO_RECENT_INPUT = 128
234
- INITIAL_DELAY = 256
235
- EXCLUSIVE_APP_RUNNING = 512
236
- CPU_USAGE = 1024
237
- NETWORK_QUOTA_EXCEEDED = 2048
238
- OS = 4096
239
- WIFI_STATE = 4097
240
- BATTERY_CHARGING = 4098
241
- BATTERY_OVERHEATED = 4099
242
-
243
- @classmethod
244
- def name(cls, v):
245
- if v == cls.UNKNOWN: return "unknown reason"
246
- elif v == cls.BATTERIES: return "on batteries"
247
- elif v == cls.USER_ACTIVE: return "computer is in use"
248
- elif v == cls.USER_REQ: return "user request"
249
- elif v == cls.TIME_OF_DAY: return "time of day"
250
- elif v == cls.BENCHMARKS: return "CPU benchmarks in progress"
251
- elif v == cls.DISK_SIZE: return "need disk space - check preferences"
252
- elif v == cls.NO_RECENT_INPUT: return "no recent user activity"
253
- elif v == cls.INITIAL_DELAY: return "initial delay"
254
- elif v == cls.EXCLUSIVE_APP_RUNNING: return "an exclusive app is running"
255
- elif v == cls.CPU_USAGE: return "CPU is busy"
256
- elif v == cls.NETWORK_QUOTA_EXCEEDED: return "network bandwidth limit exceeded"
257
- elif v == cls.OS: return "requested by operating system"
258
- elif v == cls.WIFI_STATE: return "not connected to WiFi network"
259
- elif v == cls.BATTERY_CHARGING: return "battery is recharging"
260
- elif v == cls.BATTERY_OVERHEATED: return "battery is overheated"
261
- else: return super(SuspendReason, cls).name(v)
262
-
263
-
264
-class RunMode(Enum):
265
- ''' Run modes for CPU, GPU, network,
266
- controlled by Activity menu and snooze button
267
- '''
268
- ALWAYS = 1
269
- AUTO = 2
270
- NEVER = 3
271
- RESTORE = 4
272
- #// restore permanent mode - used only in set_X_mode() GUI RPC
273
-
274
- @classmethod
275
- def name(cls, v):
276
- # all other modes use the fallback name
277
- if v == cls.AUTO: return "according to prefs"
278
- else: return super(RunMode, cls).name(v)
279
-
280
-
204
class CpuSched(Enum):
205
''' values of ACTIVE_TASK::scheduler_state and ACTIVE_TASK::next_scheduler_state
206
"SCHEDULED" is synonymous with "executing" except when CPU throttling
@@ -382,118 +305,6 @@ class VersionInfo(_Struct):
305
return "{0}{1}".format(self.__class__.__name__, self._tuple)
306
307
385
-class CcStatus(_Struct):
386
- def __init__(self):
387
- self.network_status = NetworkStatus.UNKNOWN
388
- self.ams_password_error = False
389
- self.manager_must_quit = False
390
-
391
- self.task_suspend_reason = SuspendReason.UNKNOWN #// bitmap
392
- self.task_mode = RunMode.UNKNOWN
393
- self.task_mode_perm = RunMode.UNKNOWN #// same, but permanent version
394
- self.task_mode_delay = 0.0 #// time until perm becomes actual
395
-
396
- self.network_suspend_reason = SuspendReason.UNKNOWN
397
- self.network_mode = RunMode.UNKNOWN
398
- self.network_mode_perm = RunMode.UNKNOWN
399
- self.network_mode_delay = 0.0
400
-
401
- self.gpu_suspend_reason = SuspendReason.UNKNOWN
402
- self.gpu_mode = RunMode.UNKNOWN
403
- self.gpu_mode_perm = RunMode.UNKNOWN
404
- self.gpu_mode_delay = 0.0
405
-
406
- self.disallow_attach = False
407
- self.simple_gui_only = False
408
-
409
-
410
-class HostInfo(_Struct):
411
- def __init__(self):
412
- self.timezone = 0 #// local STANDARD time - UTC time (in seconds)
413
- self.domain_name = ""
414
- self.ip_addr = ""
415
- self.host_cpid = ""
416
-
417
- self.p_ncpus = 0 #// Number of CPUs on host
418
- self.p_vendor = "" #// Vendor name of CPU
419
- self.p_model = "" #// Model of CPU
420
- self.p_features = ""
421
- self.p_fpops = 0.0 #// measured floating point ops/sec of CPU
422
- self.p_iops = 0.0 #// measured integer ops/sec of CPU
423
- self.p_membw = 0.0 #// measured memory bandwidth (bytes/sec) of CPU
424
- #// The above are per CPU, not total
425
- self.p_calculated = 0.0 #// when benchmarks were last run, or zero
426
- self.p_vm_extensions_disabled = False
427
-
428
- self.m_nbytes = 0 #// Size of memory in bytes
429
- self.m_cache = 0 #// Size of CPU cache in bytes (L1 or L2?)
430
- self.m_swap = 0 #// Size of swap space in bytes
431
-
432
- self.d_total = 0 #// Total disk space on volume containing
433
- #// the BOINC client directory.
434
- self.d_free = 0 #// how much is free on that volume
435
-
436
- self.os_name = "" #// Name of operating system
437
- self.os_version = "" #// Version of operating system
438
-
439
- #// the following is non-empty if VBox is installed
440
- self.virtualbox_version = ""
441
-
442
- self.coprocs = [] # COPROCS
443
-
444
- # The following are currently unused (not in RPC XML)
445
- self.serialnum = "" #// textual description of coprocessors
446
-
447
- @classmethod
448
- def parse(cls, xml):
449
- if not isinstance(xml, ElementTree.Element):
450
- xml = ElementTree.fromstring(xml)
451
-
452
- # parse main XML
453
- hostinfo = super(HostInfo, cls).parse(xml)
454
-
455
- # parse each coproc in coprocs list
456
- aux = []
457
- for c in hostinfo.coprocs:
458
- aux.append(Coproc.parse(c))
459
- hostinfo.coprocs = aux
460
-
461
- return hostinfo
462
-
463
-
464
-class Coproc(_Struct):
465
- ''' represents a set of identical coprocessors on a particular computer.
466
- Abstract class;
467
- objects will always be a derived class (COPROC_CUDA, COPROC_ATI)
468
- Used in both client and server.
469
- '''
470
- def __init__(self):
471
- self.type = "" #// must be unique
472
- self.count = 0 #// how many are present
473
- self.peak_flops = 0.0
474
- self.used = 0.0 #// how many are in use (used by client)
475
- self.have_cuda = False #// True if this GPU supports CUDA on this computer
476
- self.have_cal = False #// True if this GPU supports CAL on this computer
477
- self.have_opencl = False #// True if this GPU supports openCL on this computer
478
- self.available_ram = 0
479
- self.specified_in_config = False
480
- #// If true, this coproc was listed in cc_config.xml
481
- #// rather than being detected by the client.
482
-
483
- #// the following are used in both client and server for work-fetch info
484
- self.req_secs = 0.0
485
- #// how many instance-seconds of work requested
486
- self.req_instances = 0.0
487
- #// client is requesting enough jobs to use this many instances
488
- self.estimated_delay = 0
489
- #// resource will be saturated for this long
490
-
491
- self.opencl_device_count = 0
492
- self.last_print_time = 0.0
493
-
494
- #self.opencl_prop = None # OPENCL_DEVICE_PROP
495
-
496
-
308
class Result(_Struct):
309
''' Also called "task" in some contexts '''
310
def __init__(self):
@@ -668,20 +479,6 @@ class BoincClient(object):
479
''' Return VersionInfo instance with core client version info '''
480
return VersionInfo.parse(self.rpc.call('<exchange_versions/>'))
481
671
- def get_cc_status(self):
672
- ''' Return CcStatus instance containing basic status, such as
673
- CPU / GPU / Network active/suspended, etc
674
- '''
675
- if not self.connected: self.connect()
676
- try:
677
- return CcStatus.parse(self.rpc.call('<get_cc_status/>'))
678
- except socket.error:
679
- self.connected = False
680
-
681
- def get_host_info(self):
682
- ''' Get information about host hardware and usage. '''
683
- return HostInfo.parse(self.rpc.call('<get_host_info/>'))
684
-
482
def get_tasks(self):
483
''' Same as get_results(active_only=False) '''
484
return self.get_results(False)
@@ -703,50 +500,6 @@ class BoincClient(object):
500
501
return results
502
706
- def set_mode(self, component, mode, duration=0):
707
- ''' Do the real work of set_{run,gpu,network}_mode()
708
- This method is not part of the original API.
709
- Valid components are 'run' (or 'cpu'), 'gpu', 'network' (or 'net')
710
- '''
711
- component = component.replace('cpu', 'run')
712
- component = component.replace('net', 'network')
713
- try:
714
- reply = self.rpc.call("<set_{0}_mode><{1}/>\n<duration>{2]</duration>\n</set_{0}_mode>".format(component, RunMode.name(mode).lower(), duration))
715
- return (reply.tag == 'success')
716
- except socket.error:
717
- return False
718
-
719
- def set_run_mode(self, mode, duration=0):
720
- ''' Set the run mode (RunMode.NEVER/AUTO/ALWAYS/RESTORE)
721
- NEVER will suspend all activity, including CPU, GPU and Network
722
- AUTO will run according to preferences.
723
- If duration is zero, mode is permanent. Otherwise revert to last
724
- permanent mode after duration seconds elapse.
725
- '''
726
- return self.set_mode('cpu', mode, duration)
727
-
728
- def set_gpu_mode(self, mode, duration=0):
729
- ''' Set the GPU run mode, similar to set_run_mode() but for GPU only
730
- '''
731
- return self.set_mode('gpu', mode, duration)
732
-
733
- def set_network_mode(self, mode, duration=0):
734
- ''' Set the Network run mode, similar to set_run_mode()
735
- but for network activity only
736
- '''
737
- return self.set_mode('net', mode, duration)
738
-
739
- def run_benchmarks(self):
740
- ''' Run benchmarks. Computing will suspend during benchmarks '''
741
- return self.rpc.call('<run_benchmarks/>').tag == "success"
742
-
743
- def quit(self):
744
- ''' Tell the core client to exit '''
745
- if self.rpc.call('<quit/>').tag == "success":
746
- self.connected = False
747
- return True
748
- return False
749
-
503
504
def read_gui_rpc_password():
505
''' Read password string from GUI_RPC_PASSWD_FILE file, trim the last CR