nano-wait 0.0.1__py3-none-any.whl
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.
Potentially problematic release.
This version of nano-wait might be problematic. Click here for more details.
nano_wait/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .nano_wait import *
|
nano_wait/nano_wait.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import pywifi
|
|
2
|
+
import psutil
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
class NanoWait:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.wifi = pywifi.PyWiFi()
|
|
8
|
+
self.interface = self.wifi.interfaces()[0]
|
|
9
|
+
|
|
10
|
+
def get_wifi_signal(self, ssid):
|
|
11
|
+
try:
|
|
12
|
+
self.interface.scan()
|
|
13
|
+
time.sleep(2) # Wait for WiFi scan
|
|
14
|
+
scan_results = self.interface.scan_results()
|
|
15
|
+
|
|
16
|
+
signal_strength = -100 # Default value for poor signal
|
|
17
|
+
|
|
18
|
+
for network in scan_results:
|
|
19
|
+
if network.ssid == ssid:
|
|
20
|
+
signal_strength = network.signal
|
|
21
|
+
break
|
|
22
|
+
else:
|
|
23
|
+
raise ValueError(f"WiFi network '{ssid}' not found.")
|
|
24
|
+
|
|
25
|
+
# Convert signal strength to a scale of 0 to 10
|
|
26
|
+
wifi_score = max(0, min(10, (signal_strength + 100) / 10))
|
|
27
|
+
return wifi_score
|
|
28
|
+
|
|
29
|
+
except Exception as e:
|
|
30
|
+
print(f"Error getting WiFi signal: {e}")
|
|
31
|
+
return 0
|
|
32
|
+
|
|
33
|
+
def get_pc_score(self):
|
|
34
|
+
try:
|
|
35
|
+
cpu_usage = psutil.cpu_percent(interval=1)
|
|
36
|
+
memory_usage = psutil.virtual_memory().percent
|
|
37
|
+
|
|
38
|
+
# Convert CPU and memory usage to a scale of 0 to 10
|
|
39
|
+
cpu_score = max(0, min(10, 10 - cpu_usage / 10))
|
|
40
|
+
memory_score = max(0, min(10, 10 - memory_usage / 10))
|
|
41
|
+
|
|
42
|
+
# Average score of CPU and memory
|
|
43
|
+
pc_score = (cpu_score + memory_score) / 2
|
|
44
|
+
return pc_score
|
|
45
|
+
|
|
46
|
+
except Exception as e:
|
|
47
|
+
print(f"Error getting PC score: {e}")
|
|
48
|
+
return 0
|
|
49
|
+
|
|
50
|
+
def wait_wifi(self, speed, ssid):
|
|
51
|
+
try:
|
|
52
|
+
pc_score = self.get_pc_score()
|
|
53
|
+
wifi_score = self.get_wifi_signal(ssid)
|
|
54
|
+
|
|
55
|
+
# Combined risk score
|
|
56
|
+
risk_score = (pc_score + wifi_score) / 2
|
|
57
|
+
|
|
58
|
+
# Calculate wait time based on speed and risk score
|
|
59
|
+
wait_time = max(1, (10 - risk_score) / speed)
|
|
60
|
+
return wait_time
|
|
61
|
+
|
|
62
|
+
except Exception as e:
|
|
63
|
+
print(f"Error in wait_wifi: {e}")
|
|
64
|
+
return 1
|
|
65
|
+
|
|
66
|
+
def wait_n_wifi(self, speed):
|
|
67
|
+
try:
|
|
68
|
+
pc_score = self.get_pc_score()
|
|
69
|
+
|
|
70
|
+
# Calculate wait time based on speed and risk score
|
|
71
|
+
wait_time = max(1, (10 - pc_score) / speed)
|
|
72
|
+
return wait_time
|
|
73
|
+
|
|
74
|
+
except Exception as e:
|
|
75
|
+
print(f"Error in wait_n_wifi: {e}")
|
|
76
|
+
return 1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Luiz Filipe Seabra de marco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: nano_wait
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Waiting Time Calculation for Automations Based on WiFi and PC Processing
|
|
5
|
+
Author: Luiz Filipe Seabra de Marco
|
|
6
|
+
Author-email: luizfilipeseabra@icloud.com
|
|
7
|
+
License: MIT License
|
|
8
|
+
Keywords: automation automação wifi wait
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: psutil
|
|
12
|
+
Requires-Dist: pywifi
|
|
13
|
+
|
|
14
|
+
# NanoWait
|
|
15
|
+
|
|
16
|
+
**NanoWait** é uma biblioteca Python para automação de tarefas com ajuste dinâmico do tempo de espera com base na qualidade da conexão WiFi e no desempenho do computador. É ideal para situações onde o tempo de espera deve ser ajustado de acordo com a condição da rede e do sistema para garantir que as operações de automação sejam executadas suavemente.
|
|
17
|
+
|
|
18
|
+
**Requisitos**
|
|
19
|
+
Antes de usar o NanoWait, você deve instalar as seguintes bibliotecas:
|
|
20
|
+
|
|
21
|
+
pywifi: Para verificar a qualidade do sinal WiFi.
|
|
22
|
+
psutil: Para monitorar o desempenho do sistema.
|
|
23
|
+
pyautogui: Para realizar ações de automação no computador.
|
|
24
|
+
|
|
25
|
+
**Principais Funções**
|
|
26
|
+
wait_wifi: Ela deve ser passada junto com speed e ssid. Ela calcula o tempo de espera considerando o Wifi e o processamento do PC.
|
|
27
|
+
wait_n_wifi: Ela deve ser passada junto com speed. Ela calcula o tempo de espera considerando o processamento do PC no momento.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
nano_wait/__init__.py,sha256=I5jtVftNdesvR689O2eOz3CeTAtFs8ZP5GJhn7RrQvA,24
|
|
2
|
+
nano_wait/nano_wait.py,sha256=k1ENwE77qY687iAdMGIVZYlrDpV_ErNpXeOIX7JdWH0,2431
|
|
3
|
+
nano_wait-0.0.1.dist-info/LICENSE,sha256=h77N3ma56KwtT-tI-UQ8LntVneq5t506SCJXmdTx5-Y,1105
|
|
4
|
+
nano_wait-0.0.1.dist-info/METADATA,sha256=qLpeN5Nssu2zlpV8unKwBnDfQRxPDwunSNnPbZvh7Gg,1381
|
|
5
|
+
nano_wait-0.0.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
6
|
+
nano_wait-0.0.1.dist-info/top_level.txt,sha256=dSiF3Wc3ZEB1pzcp_ubHZeb0OE7n1nPMntkL48uz6aI,10
|
|
7
|
+
nano_wait-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nano_wait
|