modulitiz-micro 2.41.0__py311-none-any.whl → 2.42.0__py311-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.
- modulitiz_micro/ModuloMeteo.py +72 -72
- modulitiz_micro/ModuloSeriale.py +70 -70
- modulitiz_micro/ModuloTarghe.py +47 -46
- modulitiz_micro/database/AbstractDatabaseService.py +13 -13
- modulitiz_micro/database/AbstractSql.py +69 -69
- modulitiz_micro/database/ModuloSqlOracle.py +19 -19
- modulitiz_micro/database/ModuloSqlServer.py +43 -43
- modulitiz_micro/database/eccezioni/EccezioneDbNoData.py +6 -6
- modulitiz_micro/database/mysql/AbstractBasicMysql.py +114 -114
- modulitiz_micro/database/mysql/ModuloMysql.py +163 -163
- modulitiz_micro/database/mysql/MysqlCommonConverter.py +47 -47
- modulitiz_micro/database/mysql/eccezioni/EccezioneMysqlOffline.py +6 -6
- modulitiz_micro/database/sqlite/AbstractBasicSQLite.py +114 -114
- modulitiz_micro/database/sqlite/ModuloSQLite.py +82 -82
- modulitiz_micro/eccezioni/EccezioneCtrlC.py +7 -7
- modulitiz_micro/eccezioni/EccezioneScheduler.py +7 -7
- modulitiz_micro/eccezioni/http/EccezioneHttp.py +8 -8
- modulitiz_micro/eccezioni/http/EccezioneHttp404.py +7 -7
- modulitiz_micro/eccezioni/http/EccezioneHttpGeneric.py +7 -7
- modulitiz_micro/files/cache/DatabaseCache.py +91 -91
- modulitiz_micro/files/cache/decorators/cacheRam.py +26 -26
- modulitiz_micro/files/git/ModuloGit.py +28 -28
- modulitiz_micro/files/git/decorators/catchAndRaiseGitExceptions.py +19 -19
- modulitiz_micro/files/git/exceptions/EccezioneGit.py +7 -7
- modulitiz_micro/gestionedom/GestioneDom.py +44 -44
- modulitiz_micro/iot/ModuleIotDevice.py +4 -4
- modulitiz_micro/keylogger/EccezioneKeyLogger.py +7 -7
- modulitiz_micro/keylogger/ModuloKeylogger.py +73 -73
- modulitiz_micro/rete/ModuloNetworking.py +72 -72
- modulitiz_micro/rete/ModuloOpenVpn.py +15 -15
- modulitiz_micro/rete/email/EmailBean.py +5 -5
- modulitiz_micro/rete/email/ModuloEmail.py +90 -90
- modulitiz_micro/rete/http/ModuloHttp.py +119 -119
- modulitiz_micro/rete/http/ModuloHttpConnectionSafe.py +91 -91
- modulitiz_micro/rete/http/ModuloHttpUtils.py +69 -69
- modulitiz_micro/rete/http/beans/HttpResponseBean.py +5 -5
- modulitiz_micro/rete/http/decorators/catchAndRaiseHttpExceptions.py +22 -22
- modulitiz_micro/rete/ntp/AbstractModuloNtp.py +73 -73
- modulitiz_micro/rete/ntp/ModuloNtpIt.py +8 -8
- modulitiz_micro/rete/socketserver/AbstractBasicGetSocketServer.py +35 -35
- modulitiz_micro/rete/socketserver/AbstractSocketServer.py +267 -267
- modulitiz_micro/rete/ssl/ModuloSsl.py +56 -56
- modulitiz_micro/sistema/ModuloEnvVars.py +34 -34
- modulitiz_micro/sistema/ModuloSystemPipe.py +67 -67
- modulitiz_micro/social/telegram/AbstractModuloTelegram.py +53 -53
- modulitiz_micro/social/telegram/ModuloTelegramSimple.py +26 -26
- modulitiz_micro/util/beans/globalvar/AbstractBasicGlobalVarBean.py +15 -15
- modulitiz_micro/util/scheduler/ModuleScheduler.py +26 -26
- {modulitiz_micro-2.41.0.dist-info → modulitiz_micro-2.42.0.dist-info}/METADATA +58 -66
- modulitiz_micro-2.42.0.dist-info/RECORD +56 -0
- {modulitiz_micro-2.41.0.dist-info → modulitiz_micro-2.42.0.dist-info}/WHEEL +1 -1
- {modulitiz_micro-2.41.0.dist-info → modulitiz_micro-2.42.0.dist-info/licenses}/LICENSE +21 -21
- modulitiz_micro/ModuleEnum.py +0 -8
- modulitiz_micro/ModuloBase64.py +0 -61
- modulitiz_micro/ModuloColorText.py +0 -35
- modulitiz_micro/ModuloDate.py +0 -327
- modulitiz_micro/ModuloFunzioni.py +0 -71
- modulitiz_micro/ModuloListe.py +0 -150
- modulitiz_micro/ModuloNumeri.py +0 -127
- modulitiz_micro/ModuloPyinstaller.py +0 -29
- modulitiz_micro/ModuloStatistiche.py +0 -31
- modulitiz_micro/ModuloStringhe.py +0 -180
- modulitiz_micro/android/ModuloAndroid.py +0 -18
- modulitiz_micro/android/ModuloAndroidAdb.py +0 -48
- modulitiz_micro/android/ModuloAndroidSim.py +0 -130
- modulitiz_micro/android/beans/SmsBean.py +0 -12
- modulitiz_micro/android/enums/AndroidSmsTypeEnum.py +0 -17
- modulitiz_micro/eccezioni/EccezioneBase.py +0 -7
- modulitiz_micro/eccezioni/EccezioneRuntime.py +0 -7
- modulitiz_micro/eccezioni/EccezioneSoNonSupportato.py +0 -7
- modulitiz_micro/files/ModuloFiles.py +0 -173
- modulitiz_micro/files/ModuloLogging.py +0 -69
- modulitiz_micro/files/ModuloZip.py +0 -42
- modulitiz_micro/files/cache/CacheBean.py +0 -5
- modulitiz_micro/files/cache/CacheRam.py +0 -29
- modulitiz_micro/init/AbstractBasicInit.py +0 -27
- modulitiz_micro/init/AbstractInit.py +0 -11
- modulitiz_micro/multithread/ModuloThread.py +0 -26
- modulitiz_micro/multithread/ModuloThreadLogger.py +0 -8
- modulitiz_micro/multithread/ModuloThreadWithCallbackError.py +0 -25
- modulitiz_micro/nlp/ModuloNlp.py +0 -36
- modulitiz_micro/nlp/ModuloNlpDateAndTime.py +0 -59
- modulitiz_micro/sistema/EnvVarsEnum.py +0 -9
- modulitiz_micro/sistema/ModuloSystem.py +0 -298
- modulitiz_micro/util/beans/conf/AbstractBasicConfBean.py +0 -11
- modulitiz_micro/util/beans/conf/AbstractConfBean.py +0 -16
- modulitiz_micro/util/beans/fileconf/AbstractBasicFileConfBean.py +0 -11
- modulitiz_micro/util/beans/fileconf/AbstractFileConfBean.py +0 -13
- modulitiz_micro/util/beans/globalvar/AbstractGlobalVarBean.py +0 -34
- modulitiz_micro/util/decorators/noAwait.py +0 -23
- modulitiz_micro/util/pip/AbstractModuloPip.py +0 -41
- modulitiz_micro/util/pip/ModuloPip.py +0 -49
- modulitiz_micro/util/spooler/AbstractSpooler.py +0 -14
- modulitiz_micro/util/spooler/Spooler.py +0 -18
- modulitiz_micro/util/spooler/beans/QueueBean.py +0 -8
- modulitiz_micro/util/spooler/decorators/spooler.py +0 -49
- modulitiz_micro/util/spooler/eccezioni/EccezioneSpooler.py +0 -7
- modulitiz_micro/util/spooler/eccezioni/EccezioneSpoolerFull.py +0 -7
- modulitiz_micro/util/unittesting/AbstractOverrideTestUtil.py +0 -31
- modulitiz_micro/util/unittesting/AbstractTestUtil.py +0 -11
- modulitiz_micro/util/unittesting/ModuloRunUnitTest.py +0 -25
- modulitiz_micro/util/wheel/ModuloBuildWheel.py +0 -118
- modulitiz_micro/util/wheel/ModuloCheckTestNamingConvention.py +0 -89
- modulitiz_micro/util/wheel/ModuloToml.py +0 -40
- modulitiz_micro/util/wheel/ModuloWheel.py +0 -12
- modulitiz_micro-2.41.0.dist-info/RECORD +0 -109
- {modulitiz_micro-2.41.0.dist-info → modulitiz_micro-2.42.0.dist-info}/top_level.txt +0 -0
@@ -1,26 +1,26 @@
|
|
1
|
-
from functools import wraps
|
2
|
-
|
3
|
-
from cachetools import TTLCache
|
4
|
-
from cachetools import cached
|
5
|
-
|
6
|
-
from
|
7
|
-
|
8
|
-
|
9
|
-
def cacheRam(minsBeforeExpiry: int|float|None):
|
10
|
-
"""
|
11
|
-
Usare questo decorator per mettere in cache delle informazioni.
|
12
|
-
Alla base usa una libreria di terze parti.
|
13
|
-
:param minsBeforeExpiry: se null mantiene i dati in memoria per 1 giorno
|
14
|
-
"""
|
15
|
-
|
16
|
-
__secsBeforeExpiry=24*3600 if minsBeforeExpiry is None else ModuloNumeri.decimalNumbersTruncate(minsBeforeExpiry*60,2)
|
17
|
-
__cache=cached(TTLCache(20,__secsBeforeExpiry))
|
18
|
-
|
19
|
-
def decorator(funzione):
|
20
|
-
__funzione=__cache(funzione)
|
21
|
-
|
22
|
-
@wraps(funzione)
|
23
|
-
def wrapped(*args,**kwargs):
|
24
|
-
return __funzione(*args,**kwargs)
|
25
|
-
return wrapped
|
26
|
-
return decorator
|
1
|
+
from functools import wraps
|
2
|
+
|
3
|
+
from cachetools import TTLCache
|
4
|
+
from cachetools import cached
|
5
|
+
|
6
|
+
from modulitiz_nano.ModuloNumeri import ModuloNumeri
|
7
|
+
|
8
|
+
|
9
|
+
def cacheRam(minsBeforeExpiry: int|float|None):
|
10
|
+
"""
|
11
|
+
Usare questo decorator per mettere in cache delle informazioni.
|
12
|
+
Alla base usa una libreria di terze parti.
|
13
|
+
:param minsBeforeExpiry: se null mantiene i dati in memoria per 1 giorno
|
14
|
+
"""
|
15
|
+
|
16
|
+
__secsBeforeExpiry=24*3600 if minsBeforeExpiry is None else ModuloNumeri.decimalNumbersTruncate(minsBeforeExpiry*60,2)
|
17
|
+
__cache=cached(TTLCache(20,__secsBeforeExpiry))
|
18
|
+
|
19
|
+
def decorator(funzione):
|
20
|
+
__funzione=__cache(funzione)
|
21
|
+
|
22
|
+
@wraps(funzione)
|
23
|
+
def wrapped(*args,**kwargs):
|
24
|
+
return __funzione(*args,**kwargs)
|
25
|
+
return wrapped
|
26
|
+
return decorator
|
@@ -1,28 +1,28 @@
|
|
1
|
-
import git
|
2
|
-
|
3
|
-
from modulitiz_micro.files.git.decorators.catchAndRaiseGitExceptions import catchAndRaiseGitExceptions
|
4
|
-
|
5
|
-
|
6
|
-
class ModuloGit(object):
|
7
|
-
def __init__(self, repoPath:str):
|
8
|
-
self.inner=git.Repo(repoPath)
|
9
|
-
|
10
|
-
@catchAndRaiseGitExceptions
|
11
|
-
def getWorkingCopyRevision(self)->str:
|
12
|
-
return self.inner.head.object.hexsha
|
13
|
-
|
14
|
-
@catchAndRaiseGitExceptions
|
15
|
-
def getRemoteRevision(self)->str:
|
16
|
-
return self.inner.remotes[0].fetch()[0].ref.object.hexsha
|
17
|
-
|
18
|
-
@catchAndRaiseGitExceptions
|
19
|
-
def addFile(self,filenamePath:str):
|
20
|
-
self.inner.index.add(filenamePath)
|
21
|
-
|
22
|
-
@catchAndRaiseGitExceptions
|
23
|
-
def removeFile(self,filenamePath:str):
|
24
|
-
self.inner.index.remove(filenamePath,working_tree=True)
|
25
|
-
|
26
|
-
@catchAndRaiseGitExceptions
|
27
|
-
def update(self)->str:
|
28
|
-
return self.inner.remotes[0].pull()[0].ref.object.hexsha
|
1
|
+
import git
|
2
|
+
|
3
|
+
from modulitiz_micro.files.git.decorators.catchAndRaiseGitExceptions import catchAndRaiseGitExceptions
|
4
|
+
|
5
|
+
|
6
|
+
class ModuloGit(object):
|
7
|
+
def __init__(self, repoPath:str):
|
8
|
+
self.inner=git.Repo(repoPath)
|
9
|
+
|
10
|
+
@catchAndRaiseGitExceptions
|
11
|
+
def getWorkingCopyRevision(self)->str:
|
12
|
+
return self.inner.head.object.hexsha
|
13
|
+
|
14
|
+
@catchAndRaiseGitExceptions
|
15
|
+
def getRemoteRevision(self)->str:
|
16
|
+
return self.inner.remotes[0].fetch()[0].ref.object.hexsha
|
17
|
+
|
18
|
+
@catchAndRaiseGitExceptions
|
19
|
+
def addFile(self,filenamePath:str):
|
20
|
+
self.inner.index.add(filenamePath)
|
21
|
+
|
22
|
+
@catchAndRaiseGitExceptions
|
23
|
+
def removeFile(self,filenamePath:str):
|
24
|
+
self.inner.index.remove(filenamePath,working_tree=True)
|
25
|
+
|
26
|
+
@catchAndRaiseGitExceptions
|
27
|
+
def update(self)->str:
|
28
|
+
return self.inner.remotes[0].pull()[0].ref.object.hexsha
|
@@ -1,19 +1,19 @@
|
|
1
|
-
from functools import wraps
|
2
|
-
|
3
|
-
from git import GitCommandError
|
4
|
-
|
5
|
-
from modulitiz_micro.files.git.exceptions.EccezioneGit import EccezioneGit
|
6
|
-
|
7
|
-
|
8
|
-
def catchAndRaiseGitExceptions(funzione):
|
9
|
-
"""
|
10
|
-
Cattura tutte le eccezioni git di vario tipo e rilancia un'eccezione custom
|
11
|
-
"""
|
12
|
-
|
13
|
-
@wraps(funzione)
|
14
|
-
def wrapped(*args,**kwargs):
|
15
|
-
try:
|
16
|
-
return funzione(*args,**kwargs)
|
17
|
-
except (GitCommandError,) as ex:
|
18
|
-
raise EccezioneGit() from ex
|
19
|
-
return wrapped
|
1
|
+
from functools import wraps
|
2
|
+
|
3
|
+
from git import GitCommandError
|
4
|
+
|
5
|
+
from modulitiz_micro.files.git.exceptions.EccezioneGit import EccezioneGit
|
6
|
+
|
7
|
+
|
8
|
+
def catchAndRaiseGitExceptions(funzione):
|
9
|
+
"""
|
10
|
+
Cattura tutte le eccezioni git di vario tipo e rilancia un'eccezione custom
|
11
|
+
"""
|
12
|
+
|
13
|
+
@wraps(funzione)
|
14
|
+
def wrapped(*args,**kwargs):
|
15
|
+
try:
|
16
|
+
return funzione(*args,**kwargs)
|
17
|
+
except (GitCommandError,) as ex:
|
18
|
+
raise EccezioneGit() from ex
|
19
|
+
return wrapped
|
@@ -1,7 +1,7 @@
|
|
1
|
-
from
|
2
|
-
|
3
|
-
|
4
|
-
class EccezioneGit(EccezioneBase):
|
5
|
-
|
6
|
-
def __init__(self,*args,**kwargs):
|
7
|
-
super().__init__(*args,**kwargs)
|
1
|
+
from modulitiz_nano.eccezioni.EccezioneBase import EccezioneBase
|
2
|
+
|
3
|
+
|
4
|
+
class EccezioneGit(EccezioneBase):
|
5
|
+
|
6
|
+
def __init__(self,*args,**kwargs):
|
7
|
+
super().__init__(*args,**kwargs)
|
@@ -1,44 +1,44 @@
|
|
1
|
-
from bs4 import BeautifulSoup
|
2
|
-
|
3
|
-
from
|
4
|
-
from
|
5
|
-
|
6
|
-
|
7
|
-
class GestioneDom(object):
|
8
|
-
def __init__(self, percorsoNomefile: str | None, htmlString:str):
|
9
|
-
if percorsoNomefile is not None:
|
10
|
-
self.percorsoNomefile=percorsoNomefile
|
11
|
-
htmlString=ModuloFiles.readFileText(percorsoNomefile, True)
|
12
|
-
self.htmlString=htmlString
|
13
|
-
self.dom=self.__createObj()
|
14
|
-
|
15
|
-
@staticmethod
|
16
|
-
def innerHTML(tag):
|
17
|
-
"""
|
18
|
-
dato in input un tag html della classe BeautifulSoup, restituisce il codice html all'interno di questo tag
|
19
|
-
"""
|
20
|
-
return "".join([str(x) for x in tag.contents])
|
21
|
-
|
22
|
-
def selector(self,cssSelector:str):
|
23
|
-
"""
|
24
|
-
estrae tutti gli elementi che corrispondono al css selector
|
25
|
-
"""
|
26
|
-
elementi=self.dom.select(cssSelector)
|
27
|
-
return elementi
|
28
|
-
|
29
|
-
@staticmethod
|
30
|
-
def getAttributeValue(tag, nomeAttr:str):
|
31
|
-
oldValue=tag.attrs[nomeAttr]
|
32
|
-
return oldValue
|
33
|
-
@staticmethod
|
34
|
-
def setAttributeValue(tag, nomeAttr:str, value):
|
35
|
-
tag.attrs[nomeAttr]=value
|
36
|
-
return tag
|
37
|
-
|
38
|
-
def save(self):
|
39
|
-
htmlOut=str(self.dom).encode(ModuloStringhe.CODIFICA_UTF8)
|
40
|
-
with ModuloFiles.open(self.percorsoNomefile, "wb") as file:
|
41
|
-
file.write(htmlOut)
|
42
|
-
|
43
|
-
def __createObj(self)->BeautifulSoup:
|
44
|
-
return BeautifulSoup(self.htmlString, features="html.parser")
|
1
|
+
from bs4 import BeautifulSoup
|
2
|
+
|
3
|
+
from modulitiz_nano.ModuloStringhe import ModuloStringhe
|
4
|
+
from modulitiz_nano.files.ModuloFiles import ModuloFiles
|
5
|
+
|
6
|
+
|
7
|
+
class GestioneDom(object):
|
8
|
+
def __init__(self, percorsoNomefile: str | None, htmlString:str):
|
9
|
+
if percorsoNomefile is not None:
|
10
|
+
self.percorsoNomefile=percorsoNomefile
|
11
|
+
htmlString=ModuloFiles.readFileText(percorsoNomefile, True)
|
12
|
+
self.htmlString=htmlString
|
13
|
+
self.dom=self.__createObj()
|
14
|
+
|
15
|
+
@staticmethod
|
16
|
+
def innerHTML(tag):
|
17
|
+
"""
|
18
|
+
dato in input un tag html della classe BeautifulSoup, restituisce il codice html all'interno di questo tag
|
19
|
+
"""
|
20
|
+
return "".join([str(x) for x in tag.contents])
|
21
|
+
|
22
|
+
def selector(self,cssSelector:str):
|
23
|
+
"""
|
24
|
+
estrae tutti gli elementi che corrispondono al css selector
|
25
|
+
"""
|
26
|
+
elementi=self.dom.select(cssSelector)
|
27
|
+
return elementi
|
28
|
+
|
29
|
+
@staticmethod
|
30
|
+
def getAttributeValue(tag, nomeAttr:str):
|
31
|
+
oldValue=tag.attrs[nomeAttr]
|
32
|
+
return oldValue
|
33
|
+
@staticmethod
|
34
|
+
def setAttributeValue(tag, nomeAttr:str, value):
|
35
|
+
tag.attrs[nomeAttr]=value
|
36
|
+
return tag
|
37
|
+
|
38
|
+
def save(self):
|
39
|
+
htmlOut=str(self.dom).encode(ModuloStringhe.CODIFICA_UTF8)
|
40
|
+
with ModuloFiles.open(self.percorsoNomefile, "wb") as file:
|
41
|
+
file.write(htmlOut)
|
42
|
+
|
43
|
+
def __createObj(self)->BeautifulSoup:
|
44
|
+
return BeautifulSoup(self.htmlString, features="html.parser")
|
@@ -1,8 +1,8 @@
|
|
1
|
-
from
|
2
|
-
from
|
3
|
-
from
|
1
|
+
from modulitiz_nano.ModuloNumeri import ModuloNumeri
|
2
|
+
from modulitiz_nano.ModuloStringhe import ModuloStringhe
|
3
|
+
from modulitiz_nano.eccezioni.EccezioneRuntime import EccezioneRuntime
|
4
4
|
from modulitiz_micro.eccezioni.http.EccezioneHttp import EccezioneHttp
|
5
|
-
from
|
5
|
+
from modulitiz_nano.files.ModuloLogging import ModuloLogging
|
6
6
|
from modulitiz_micro.iot.beans.IotDeviceBean import IotDeviceBean
|
7
7
|
from modulitiz_micro.iot.enums.IotOSEnum import IotOSEnum
|
8
8
|
from modulitiz_micro.iot.espurna.ModuleEspurna import ModuleEspurna
|
@@ -1,7 +1,7 @@
|
|
1
|
-
from
|
2
|
-
|
3
|
-
|
4
|
-
class EccezioneKeyLogger(EccezioneBase):
|
5
|
-
|
6
|
-
def __init__(self):
|
7
|
-
super().__init__("Ricevuto comando da tastiera di chiusura programma")
|
1
|
+
from modulitiz_nano.eccezioni.EccezioneBase import EccezioneBase
|
2
|
+
|
3
|
+
|
4
|
+
class EccezioneKeyLogger(EccezioneBase):
|
5
|
+
|
6
|
+
def __init__(self):
|
7
|
+
super().__init__("Ricevuto comando da tastiera di chiusura programma")
|
@@ -1,73 +1,73 @@
|
|
1
|
-
import threading
|
2
|
-
import time
|
3
|
-
from typing import Callable
|
4
|
-
|
5
|
-
from
|
6
|
-
|
7
|
-
if ModuloSystem.isWindows():
|
8
|
-
from pynput.keyboard import Key, Listener
|
9
|
-
|
10
|
-
|
11
|
-
class ModuloKeylogger(object):
|
12
|
-
IS_AVAILABLE=ModuloSystem.isWindows()
|
13
|
-
EXIT_KEY=None
|
14
|
-
EXIT_KEY_2=None
|
15
|
-
if IS_AVAILABLE:
|
16
|
-
EXIT_KEY=Key.pause
|
17
|
-
EXIT_KEY_2=Key.menu
|
18
|
-
|
19
|
-
__lastKeyPressed=None
|
20
|
-
__numKeyPressed=0
|
21
|
-
__callbackOnKeyPress=None
|
22
|
-
|
23
|
-
@staticmethod
|
24
|
-
def getTasto(key):
|
25
|
-
try:
|
26
|
-
tasto=key.char
|
27
|
-
except AttributeError:
|
28
|
-
tasto=key
|
29
|
-
if tasto is None:
|
30
|
-
return str(key.vk)
|
31
|
-
return str(tasto).replace("Key.","")
|
32
|
-
|
33
|
-
@classmethod
|
34
|
-
def start(cls,callbackOnKeyPress:Callable,runNewProcess:bool):
|
35
|
-
"""
|
36
|
-
Se la liberia non e' disponibile non verra' caricata, ad esempio se usi la cli
|
37
|
-
"""
|
38
|
-
# controllo se e' disponibile
|
39
|
-
if not cls.IS_AVAILABLE:
|
40
|
-
return
|
41
|
-
# lancio gli handler
|
42
|
-
cls.__callbackOnKeyPress=callbackOnKeyPress
|
43
|
-
if runNewProcess is True:
|
44
|
-
processo=threading.Thread(target=cls.__tStartListening,args=(cls.__onKeyPressHandler,cls.__onKeyReleaseHandler),daemon=True)
|
45
|
-
processo.start()
|
46
|
-
return
|
47
|
-
cls.__startListening(cls.__onKeyPressHandler,cls.__onKeyReleaseHandler)
|
48
|
-
|
49
|
-
@staticmethod
|
50
|
-
def __startListening(onKeyPressHandler,onKeyReleaseHandler):
|
51
|
-
with Listener(on_press=onKeyPressHandler,on_release=onKeyReleaseHandler) as listener:
|
52
|
-
listener.join()
|
53
|
-
@classmethod
|
54
|
-
def __tStartListening(cls,onKeyPressHandler,onKeyReleaseHandler):
|
55
|
-
cls.__startListening(onKeyPressHandler,onKeyReleaseHandler)
|
56
|
-
while True:
|
57
|
-
time.sleep(1)
|
58
|
-
|
59
|
-
#
|
60
|
-
#key handlers
|
61
|
-
#
|
62
|
-
@classmethod
|
63
|
-
def __onKeyPressHandler(cls,key):
|
64
|
-
if cls.__lastKeyPressed==key:
|
65
|
-
return
|
66
|
-
cls.__callbackOnKeyPress(key,cls.__numKeyPressed)
|
67
|
-
|
68
|
-
cls.__lastKeyPressed=key
|
69
|
-
cls.__numKeyPressed+=1
|
70
|
-
@classmethod
|
71
|
-
def __onKeyReleaseHandler(cls,key):
|
72
|
-
cls.__lastKeyPressed=None
|
73
|
-
cls.__numKeyPressed-=1
|
1
|
+
import threading
|
2
|
+
import time
|
3
|
+
from typing import Callable
|
4
|
+
|
5
|
+
from modulitiz_nano.sistema.ModuloSystem import ModuloSystem
|
6
|
+
|
7
|
+
if ModuloSystem.isWindows():
|
8
|
+
from pynput.keyboard import Key, Listener
|
9
|
+
|
10
|
+
|
11
|
+
class ModuloKeylogger(object):
|
12
|
+
IS_AVAILABLE=ModuloSystem.isWindows()
|
13
|
+
EXIT_KEY=None
|
14
|
+
EXIT_KEY_2=None
|
15
|
+
if IS_AVAILABLE:
|
16
|
+
EXIT_KEY=Key.pause
|
17
|
+
EXIT_KEY_2=Key.menu
|
18
|
+
|
19
|
+
__lastKeyPressed=None
|
20
|
+
__numKeyPressed=0
|
21
|
+
__callbackOnKeyPress=None
|
22
|
+
|
23
|
+
@staticmethod
|
24
|
+
def getTasto(key):
|
25
|
+
try:
|
26
|
+
tasto=key.char
|
27
|
+
except AttributeError:
|
28
|
+
tasto=key
|
29
|
+
if tasto is None:
|
30
|
+
return str(key.vk)
|
31
|
+
return str(tasto).replace("Key.","")
|
32
|
+
|
33
|
+
@classmethod
|
34
|
+
def start(cls,callbackOnKeyPress:Callable,runNewProcess:bool):
|
35
|
+
"""
|
36
|
+
Se la liberia non e' disponibile non verra' caricata, ad esempio se usi la cli
|
37
|
+
"""
|
38
|
+
# controllo se e' disponibile
|
39
|
+
if not cls.IS_AVAILABLE:
|
40
|
+
return
|
41
|
+
# lancio gli handler
|
42
|
+
cls.__callbackOnKeyPress=callbackOnKeyPress
|
43
|
+
if runNewProcess is True:
|
44
|
+
processo=threading.Thread(target=cls.__tStartListening,args=(cls.__onKeyPressHandler,cls.__onKeyReleaseHandler),daemon=True)
|
45
|
+
processo.start()
|
46
|
+
return
|
47
|
+
cls.__startListening(cls.__onKeyPressHandler,cls.__onKeyReleaseHandler)
|
48
|
+
|
49
|
+
@staticmethod
|
50
|
+
def __startListening(onKeyPressHandler,onKeyReleaseHandler):
|
51
|
+
with Listener(on_press=onKeyPressHandler,on_release=onKeyReleaseHandler) as listener:
|
52
|
+
listener.join()
|
53
|
+
@classmethod
|
54
|
+
def __tStartListening(cls,onKeyPressHandler,onKeyReleaseHandler):
|
55
|
+
cls.__startListening(onKeyPressHandler,onKeyReleaseHandler)
|
56
|
+
while True:
|
57
|
+
time.sleep(1)
|
58
|
+
|
59
|
+
#
|
60
|
+
#key handlers
|
61
|
+
#
|
62
|
+
@classmethod
|
63
|
+
def __onKeyPressHandler(cls,key):
|
64
|
+
if cls.__lastKeyPressed==key:
|
65
|
+
return
|
66
|
+
cls.__callbackOnKeyPress(key,cls.__numKeyPressed)
|
67
|
+
|
68
|
+
cls.__lastKeyPressed=key
|
69
|
+
cls.__numKeyPressed+=1
|
70
|
+
@classmethod
|
71
|
+
def __onKeyReleaseHandler(cls,key):
|
72
|
+
cls.__lastKeyPressed=None
|
73
|
+
cls.__numKeyPressed-=1
|
@@ -1,72 +1,72 @@
|
|
1
|
-
import os
|
2
|
-
import re
|
3
|
-
import socket
|
4
|
-
from contextlib import closing
|
5
|
-
from uuid import getnode
|
6
|
-
|
7
|
-
from _socket import gaierror
|
8
|
-
|
9
|
-
from
|
10
|
-
from
|
11
|
-
from
|
12
|
-
from
|
13
|
-
|
14
|
-
|
15
|
-
class ModuloNetworking(object):
|
16
|
-
@staticmethod
|
17
|
-
def getMacAddress()->str:
|
18
|
-
mac=("%012X" % getnode())
|
19
|
-
return mac
|
20
|
-
|
21
|
-
@staticmethod
|
22
|
-
def getLocalIp()->str|None:
|
23
|
-
"""
|
24
|
-
Returns private local IP address.
|
25
|
-
"""
|
26
|
-
sockObj = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
27
|
-
sockObj.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
28
|
-
try:
|
29
|
-
# doesn't even have to be reachable
|
30
|
-
sockObj.connect(('255.255.255.255', 1))
|
31
|
-
indirizzoIp = sockObj.getsockname()[0]
|
32
|
-
except gaierror:
|
33
|
-
indirizzoIp = None
|
34
|
-
finally:
|
35
|
-
sockObj.close()
|
36
|
-
return indirizzoIp
|
37
|
-
|
38
|
-
@staticmethod
|
39
|
-
def isHttpPortOpen(host:str|None,port:int)->bool:
|
40
|
-
# controllo host
|
41
|
-
if host is None:
|
42
|
-
host="127.0.0.1"
|
43
|
-
# controllo porta
|
44
|
-
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
45
|
-
if sock.connect_ex((host, port)) == 0:
|
46
|
-
return True
|
47
|
-
return False
|
48
|
-
|
49
|
-
@staticmethod
|
50
|
-
def checkPing(ipAddress:str)->bool:
|
51
|
-
# build command
|
52
|
-
cmd="ping "
|
53
|
-
regexPercPacketsLost=r"(\d{1,3})\% "
|
54
|
-
if ModuloSystem.isWindows():
|
55
|
-
cmd+="-n"
|
56
|
-
regexPercPacketsLost=r"\("+regexPercPacketsLost
|
57
|
-
elif os.name=='posix':
|
58
|
-
cmd+="-c"
|
59
|
-
regexPercPacketsLost=r", "+regexPercPacketsLost
|
60
|
-
else:
|
61
|
-
raise EccezioneRuntime("Tipologia del sistema operativo non riconosciuta: "+os.name)
|
62
|
-
cmd+=" 1 "+ipAddress
|
63
|
-
# execute command
|
64
|
-
outputComando=ModuloStringhe.normalizzaEol(ModuloSystem.systemCallReturnOutput(cmd,None))
|
65
|
-
rows=outputComando.split("\n")
|
66
|
-
rows=ModuloListe.eliminaElementiVuoti(rows)
|
67
|
-
for row in rows:
|
68
|
-
if ModuloStringhe.contains(row, "%"):
|
69
|
-
regexOutput=re.search(regexPercPacketsLost,row)
|
70
|
-
if regexOutput is not None:
|
71
|
-
return int(regexOutput.group(1).strip())==0
|
72
|
-
return False
|
1
|
+
import os
|
2
|
+
import re
|
3
|
+
import socket
|
4
|
+
from contextlib import closing
|
5
|
+
from uuid import getnode
|
6
|
+
|
7
|
+
from _socket import gaierror
|
8
|
+
|
9
|
+
from modulitiz_nano.ModuloListe import ModuloListe
|
10
|
+
from modulitiz_nano.ModuloStringhe import ModuloStringhe
|
11
|
+
from modulitiz_nano.eccezioni.EccezioneRuntime import EccezioneRuntime
|
12
|
+
from modulitiz_nano.sistema.ModuloSystem import ModuloSystem
|
13
|
+
|
14
|
+
|
15
|
+
class ModuloNetworking(object):
|
16
|
+
@staticmethod
|
17
|
+
def getMacAddress()->str:
|
18
|
+
mac=("%012X" % getnode())
|
19
|
+
return mac
|
20
|
+
|
21
|
+
@staticmethod
|
22
|
+
def getLocalIp()->str|None:
|
23
|
+
"""
|
24
|
+
Returns private local IP address.
|
25
|
+
"""
|
26
|
+
sockObj = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
27
|
+
sockObj.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
28
|
+
try:
|
29
|
+
# doesn't even have to be reachable
|
30
|
+
sockObj.connect(('255.255.255.255', 1))
|
31
|
+
indirizzoIp = sockObj.getsockname()[0]
|
32
|
+
except gaierror:
|
33
|
+
indirizzoIp = None
|
34
|
+
finally:
|
35
|
+
sockObj.close()
|
36
|
+
return indirizzoIp
|
37
|
+
|
38
|
+
@staticmethod
|
39
|
+
def isHttpPortOpen(host:str|None,port:int)->bool:
|
40
|
+
# controllo host
|
41
|
+
if host is None:
|
42
|
+
host="127.0.0.1"
|
43
|
+
# controllo porta
|
44
|
+
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
45
|
+
if sock.connect_ex((host, port)) == 0:
|
46
|
+
return True
|
47
|
+
return False
|
48
|
+
|
49
|
+
@staticmethod
|
50
|
+
def checkPing(ipAddress:str)->bool:
|
51
|
+
# build command
|
52
|
+
cmd="ping "
|
53
|
+
regexPercPacketsLost=r"(\d{1,3})\% "
|
54
|
+
if ModuloSystem.isWindows():
|
55
|
+
cmd+="-n"
|
56
|
+
regexPercPacketsLost=r"\("+regexPercPacketsLost
|
57
|
+
elif os.name=='posix':
|
58
|
+
cmd+="-W 5 -c"
|
59
|
+
regexPercPacketsLost=r", "+regexPercPacketsLost
|
60
|
+
else:
|
61
|
+
raise EccezioneRuntime("Tipologia del sistema operativo non riconosciuta: "+os.name)
|
62
|
+
cmd+=" 1 "+ipAddress
|
63
|
+
# execute command
|
64
|
+
outputComando=ModuloStringhe.normalizzaEol(ModuloSystem.systemCallReturnOutput(cmd,None))
|
65
|
+
rows=outputComando.split("\n")
|
66
|
+
rows=ModuloListe.eliminaElementiVuoti(rows)
|
67
|
+
for row in rows:
|
68
|
+
if ModuloStringhe.contains(row, "%"):
|
69
|
+
regexOutput=re.search(regexPercPacketsLost,row)
|
70
|
+
if regexOutput is not None:
|
71
|
+
return int(regexOutput.group(1).strip())==0
|
72
|
+
return False
|
@@ -1,15 +1,15 @@
|
|
1
|
-
from
|
2
|
-
|
3
|
-
|
4
|
-
class ModuloOpenVpn(object):
|
5
|
-
def __init__(self,percorsoOpenVpn:str):
|
6
|
-
self.__percorsoOpenVpn=percorsoOpenVpn
|
7
|
-
|
8
|
-
def startVpn(self,isOpenVpnAlreadyRunning:bool,filenameOvpn:str):
|
9
|
-
"""
|
10
|
-
Send a command to start vpn to a new or already running instance of the GUI.
|
11
|
-
https://community.openvpn.net/openvpn/wiki/OpenVPN-GUI-New#gui-help
|
12
|
-
"""
|
13
|
-
subCmd="--command connect" if isOpenVpnAlreadyRunning else "--connect"
|
14
|
-
cmd=r'start "" "{}" {} {}.ovpn'.format(self.__percorsoOpenVpn,subCmd,filenameOvpn)
|
15
|
-
ModuloSystem.systemCallWaitAndClose(cmd,False)
|
1
|
+
from modulitiz_nano.sistema.ModuloSystem import ModuloSystem
|
2
|
+
|
3
|
+
|
4
|
+
class ModuloOpenVpn(object):
|
5
|
+
def __init__(self,percorsoOpenVpn:str):
|
6
|
+
self.__percorsoOpenVpn=percorsoOpenVpn
|
7
|
+
|
8
|
+
def startVpn(self,isOpenVpnAlreadyRunning:bool,filenameOvpn:str):
|
9
|
+
"""
|
10
|
+
Send a command to start vpn to a new or already running instance of the GUI.
|
11
|
+
https://community.openvpn.net/openvpn/wiki/OpenVPN-GUI-New#gui-help
|
12
|
+
"""
|
13
|
+
subCmd="--command connect" if isOpenVpnAlreadyRunning else "--connect"
|
14
|
+
cmd=r'start "" "{}" {} {}.ovpn'.format(self.__percorsoOpenVpn,subCmd,filenameOvpn)
|
15
|
+
ModuloSystem.systemCallWaitAndClose(cmd,False)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class EmailBean(object):
|
2
|
-
def __init__(self,diz:dict):
|
3
|
-
self.destinatario:str=diz['destinatario']
|
4
|
-
self.user:str=diz['user']
|
5
|
-
self.password:str=diz['password']
|
1
|
+
class EmailBean(object):
|
2
|
+
def __init__(self,diz:dict):
|
3
|
+
self.destinatario:str=diz['destinatario']
|
4
|
+
self.user:str=diz['user']
|
5
|
+
self.password:str=diz['password']
|