sciveo 0.0.48__tar.gz → 0.0.49__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {sciveo-0.0.48 → sciveo-0.0.49}/PKG-INFO +3 -1
  2. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/__init__.py +5 -0
  3. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/tools/daemon.py +11 -0
  4. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/tools/synchronized.py +11 -0
  5. sciveo-0.0.49/sciveo/common/tools/timers.py +56 -0
  6. sciveo-0.0.49/sciveo/monitoring/network.py +86 -0
  7. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/monitoring/start.py +11 -0
  8. sciveo-0.0.49/sciveo/version.py +2 -0
  9. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo.egg-info/PKG-INFO +3 -1
  10. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo.egg-info/SOURCES.txt +2 -0
  11. sciveo-0.0.49/sciveo.egg-info/requires.txt +12 -0
  12. {sciveo-0.0.48 → sciveo-0.0.49}/setup.py +18 -0
  13. sciveo-0.0.48/sciveo/version.py +0 -2
  14. sciveo-0.0.48/sciveo.egg-info/requires.txt +0 -5
  15. {sciveo-0.0.48 → sciveo-0.0.49}/README.md +0 -0
  16. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/api/__init__.py +0 -0
  17. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/api/base.py +0 -0
  18. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/api/upload.py +0 -0
  19. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/__init__.py +0 -0
  20. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/configuration.py +0 -0
  21. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/model.py +0 -0
  22. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/optimizers.py +0 -0
  23. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/sampling.py +0 -0
  24. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/tools/__init__.py +0 -0
  25. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/tools/formating.py +0 -0
  26. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/tools/hardware.py +0 -0
  27. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/common/tools/logger.py +0 -0
  28. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/content/__init__.py +0 -0
  29. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/content/dataset.py +0 -0
  30. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/content/experiment.py +0 -0
  31. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/content/project.py +0 -0
  32. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/content/runner.py +0 -0
  33. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/monitoring/__init__.py +0 -0
  34. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo/monitoring/monitor.py +0 -0
  35. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo.egg-info/dependency_links.txt +0 -0
  36. {sciveo-0.0.48 → sciveo-0.0.49}/sciveo.egg-info/top_level.txt +0 -0
  37. {sciveo-0.0.48 → sciveo-0.0.49}/setup.cfg +0 -0
  38. {sciveo-0.0.48 → sciveo-0.0.49}/test/test_configuration.py +0 -0
  39. {sciveo-0.0.48 → sciveo-0.0.49}/test/test_monitoring.py +0 -0
  40. {sciveo-0.0.48 → sciveo-0.0.49}/test/test_runner.py +0 -0
  41. {sciveo-0.0.48 → sciveo-0.0.49}/test/test_sampling.py +0 -0
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.0.48
3
+ Version: 0.0.49
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
+ Provides-Extra: net
7
+ Provides-Extra: all
6
8
 
7
9
  # SCIVEO - ML/Scientific Experiments Management Client
8
10
 
@@ -21,6 +21,7 @@ try:
21
21
  from sciveo.content.runner import ProjectRunner
22
22
  from sciveo.content.dataset import Dataset
23
23
  from sciveo.monitoring.start import MonitorStart
24
+ from sciveo.monitoring.network import NetworkTools
24
25
  from sciveo.version import __version__
25
26
 
26
27
 
@@ -47,5 +48,9 @@ try:
47
48
  def monitor(**kwargs):
48
49
  MonitorStart(**kwargs)()
49
50
 
51
+ # Network tools
52
+ def network(**kwargs):
53
+ return NetworkTools(**kwargs)
54
+
50
55
  except ImportError as e:
51
56
  pass
@@ -1,3 +1,14 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2023
10
+ #
11
+
1
12
  import threading
2
13
  import time
3
14
 
@@ -1,3 +1,14 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2023
10
+ #
11
+
1
12
  import threading
2
13
  import uuid
3
14
  import copy
@@ -0,0 +1,56 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2023
10
+ #
11
+
12
+ import time
13
+
14
+
15
+ class FPSCounter:
16
+ def __init__(self, period=10, tag=""):
17
+ self.period = period
18
+ self.tag = tag
19
+ self.n = 0
20
+ self.t1 = time.time()
21
+
22
+ def update(self):
23
+ self.n += 1
24
+ t2 = time.time()
25
+ if t2 - self.t1 > self.period:
26
+ print(type(self).__name__, self.tag, "FPS", self.n / (t2 - self.t1))
27
+ self.n = 0
28
+ self.t1 = time.time()
29
+
30
+
31
+ class TimerExec:
32
+ def __init__(self, fn, period=1.0):
33
+ self.fn = fn
34
+ self.period = period
35
+ self.t1 = time.time()
36
+
37
+ def run(self):
38
+ t2 = time.time()
39
+ if t2 - self.t1 > self.period:
40
+ self.fn()
41
+ self.t1 = time.time()
42
+
43
+
44
+ class Timer:
45
+ def __init__(self):
46
+ self.start()
47
+
48
+ def start(self):
49
+ self.start_at = time.time()
50
+
51
+ def stop(self):
52
+ self.end_at = time.time()
53
+ return self.elapsed()
54
+
55
+ def elapsed(self):
56
+ return self.end_at - self.start_at
@@ -0,0 +1,86 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2024
10
+ #
11
+
12
+ import socket
13
+
14
+ from sciveo.common.tools.logger import *
15
+ from sciveo.common.tools.timers import Timer
16
+
17
+
18
+ class NetworkTools:
19
+ def __init__(self, **kwargs):
20
+ self.default_arguments = {
21
+ "timeout": 0.1,
22
+ "localhost": False,
23
+ }
24
+
25
+ self.arguments = {}
26
+ for k, v in self.default_arguments.items():
27
+ self.arguments[k] = kwargs.get(k, v)
28
+
29
+ self.net_classes = ["192.168.", "10."]
30
+ for i in range(16, 32):
31
+ self.net_classes.append(f"172.{i}.")
32
+
33
+ def get_local_nets(self):
34
+ list_local_ips = []
35
+ try:
36
+ import netifaces
37
+ interfaces = netifaces.interfaces()
38
+ for interface in interfaces:
39
+ addrs = netifaces.ifaddresses(interface)
40
+ if netifaces.AF_INET in addrs:
41
+ ip = addrs[netifaces.AF_INET][0]['addr']
42
+ for net_class in self.net_classes:
43
+ if ip.startswith(net_class):
44
+ list_local_ips.append(ip)
45
+ except Exception as e:
46
+ warning(type(self).__name__, "netifaces not installed")
47
+ return list_local_ips
48
+
49
+ def generate_ip_list(self, base_ip):
50
+ octets = base_ip.split('.')
51
+ network_prefix = '.'.join(octets[:3])
52
+ return [f'{network_prefix}.{i}' for i in range(1, 255)]
53
+
54
+ def scan_port(self, port=22):
55
+ t = Timer()
56
+ result = []
57
+ list_local_ips = self.get_local_nets()
58
+ debug(type(self).__name__, "scan_port", "list_local_ips", list_local_ips)
59
+ for local_ip in list_local_ips:
60
+ list_ip = self.generate_ip_list(local_ip)
61
+ result += self.scan_port_hosts(list_ip, port)
62
+ if self.arguments["localhost"]:
63
+ result += self.scan_port_hosts(["127.0.0.1"], port)
64
+ debug(type(self).__name__, "scan_port elapsed time", t.stop(), "result", result)
65
+ return result
66
+
67
+ def scan_port_hosts(self, list_ip, port=22):
68
+ list_hosts = []
69
+ timeout = self.arguments["timeout"]
70
+ for ip in list_ip:
71
+ try:
72
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
73
+ sock.settimeout(timeout)
74
+ result = sock.connect_ex((ip, port))
75
+ if result == 0:
76
+ list_hosts.append(ip)
77
+ # debug(type(self).__name__, "scan_ports", ip, port, result)
78
+ except socket.error:
79
+ pass
80
+ return list_hosts
81
+
82
+
83
+ if __name__ == "__main__":
84
+ net = NetworkTools(timeout=0.01, localhost=True)
85
+ list_hosts = net.scan_port(port=22)
86
+ print(list_hosts)
@@ -1,3 +1,14 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2024
10
+ #
11
+
1
12
  import os
2
13
  import time
3
14
 
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = '0.0.49'
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.0.48
3
+ Version: 0.0.49
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
+ Provides-Extra: net
7
+ Provides-Extra: all
6
8
 
7
9
  # SCIVEO - ML/Scientific Experiments Management Client
8
10
 
@@ -21,6 +21,7 @@ sciveo/common/tools/formating.py
21
21
  sciveo/common/tools/hardware.py
22
22
  sciveo/common/tools/logger.py
23
23
  sciveo/common/tools/synchronized.py
24
+ sciveo/common/tools/timers.py
24
25
  sciveo/content/__init__.py
25
26
  sciveo/content/dataset.py
26
27
  sciveo/content/experiment.py
@@ -28,6 +29,7 @@ sciveo/content/project.py
28
29
  sciveo/content/runner.py
29
30
  sciveo/monitoring/__init__.py
30
31
  sciveo/monitoring/monitor.py
32
+ sciveo/monitoring/network.py
31
33
  sciveo/monitoring/start.py
32
34
  test/test_configuration.py
33
35
  test/test_monitoring.py
@@ -0,0 +1,12 @@
1
+ numpy>=0.0.0
2
+ requests>=0.0.0
3
+
4
+ [all]
5
+ psutil>=0.0.0
6
+ netifaces>=0.0.0
7
+
8
+ [mon]
9
+ psutil>=0.0.0
10
+
11
+ [net]
12
+ netifaces>=0.0.0
@@ -1,3 +1,14 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2023
10
+ #
11
+
1
12
  from setuptools import setup, find_packages
2
13
  from sciveo.version import __version__
3
14
 
@@ -14,6 +25,13 @@ setup(
14
25
  extras_require={
15
26
  'mon': [
16
27
  'psutil>=0.0.0',
28
+ ],
29
+ 'net': [
30
+ 'netifaces>=0.0.0',
31
+ ],
32
+ 'all': [
33
+ 'psutil>=0.0.0',
34
+ 'netifaces>=0.0.0',
17
35
  ]
18
36
  },
19
37
  )
@@ -1,2 +0,0 @@
1
-
2
- __version__ = '0.0.48'
@@ -1,5 +0,0 @@
1
- numpy>=0.0.0
2
- requests>=0.0.0
3
-
4
- [mon]
5
- psutil>=0.0.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes