modulitiz-micro 2.26.0__py311-none-any.whl → 2.27.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.
Files changed (102) hide show
  1. modulitiz_micro/ModuloBase64.py +61 -61
  2. modulitiz_micro/ModuloColorText.py +35 -35
  3. modulitiz_micro/ModuloDate.py +295 -295
  4. modulitiz_micro/ModuloFunzioni.py +58 -58
  5. modulitiz_micro/ModuloListe.py +150 -150
  6. modulitiz_micro/ModuloMeteo.py +72 -72
  7. modulitiz_micro/ModuloNumeri.py +130 -130
  8. modulitiz_micro/ModuloPyinstaller.py +29 -29
  9. modulitiz_micro/ModuloSeriale.py +61 -61
  10. modulitiz_micro/ModuloStatistiche.py +31 -31
  11. modulitiz_micro/ModuloStringhe.py +180 -180
  12. modulitiz_micro/ModuloTarghe.py +46 -46
  13. modulitiz_micro/android/ModuloAndroid.py +18 -18
  14. modulitiz_micro/android/ModuloAndroidAdb.py +48 -48
  15. modulitiz_micro/android/ModuloAndroidSim.py +130 -130
  16. modulitiz_micro/android/beans/SmsBean.py +12 -12
  17. modulitiz_micro/android/enums/AndroidSmsTypeEnum.py +17 -17
  18. modulitiz_micro/database/AbstractDatabaseService.py +13 -13
  19. modulitiz_micro/database/AbstractSql.py +49 -49
  20. modulitiz_micro/database/ModuloSqlOracle.py +19 -19
  21. modulitiz_micro/database/ModuloSqlServer.py +50 -50
  22. modulitiz_micro/database/eccezioni/EccezioneDbNoData.py +6 -6
  23. modulitiz_micro/database/mysql/AbstractBasicMysql.py +114 -114
  24. modulitiz_micro/database/mysql/ModuloMysql.py +151 -151
  25. modulitiz_micro/database/mysql/MysqlCommonConverter.py +47 -47
  26. modulitiz_micro/database/mysql/eccezioni/EccezioneMysqlOffline.py +6 -6
  27. modulitiz_micro/database/sqlite/AbstractBasicSQLite.py +114 -114
  28. modulitiz_micro/database/sqlite/ModuloSQLite.py +82 -82
  29. modulitiz_micro/eccezioni/EccezioneBase.py +7 -7
  30. modulitiz_micro/eccezioni/EccezioneCtrlC.py +7 -7
  31. modulitiz_micro/eccezioni/EccezioneRuntime.py +7 -7
  32. modulitiz_micro/eccezioni/EccezioneScheduler.py +7 -7
  33. modulitiz_micro/eccezioni/EccezioneSoNonSupportato.py +7 -7
  34. modulitiz_micro/eccezioni/http/EccezioneHttp.py +8 -8
  35. modulitiz_micro/eccezioni/http/EccezioneHttp404.py +7 -7
  36. modulitiz_micro/eccezioni/http/EccezioneHttpGeneric.py +7 -7
  37. modulitiz_micro/files/ModuloFiles.py +173 -173
  38. modulitiz_micro/files/ModuloLogging.py +69 -69
  39. modulitiz_micro/files/ModuloZip.py +42 -42
  40. modulitiz_micro/files/cache/CacheBean.py +5 -5
  41. modulitiz_micro/files/cache/CacheRam.py +29 -29
  42. modulitiz_micro/files/cache/DatabaseCache.py +91 -91
  43. modulitiz_micro/files/cache/decorators/cacheRam.py +26 -26
  44. modulitiz_micro/files/git/ModuloGit.py +15 -15
  45. modulitiz_micro/gestionedom/GestioneDom.py +44 -44
  46. modulitiz_micro/init/AbstractBasicInit.py +27 -27
  47. modulitiz_micro/init/AbstractInit.py +11 -11
  48. modulitiz_micro/keylogger/EccezioneKeyLogger.py +7 -7
  49. modulitiz_micro/keylogger/ModuloKeylogger.py +73 -73
  50. modulitiz_micro/multithreading/ModuloThread.py +26 -26
  51. modulitiz_micro/multithreading/ModuloThreadLogger.py +8 -8
  52. modulitiz_micro/multithreading/ModuloThreadWithCallbackError.py +25 -25
  53. modulitiz_micro/nlp/ModuloNlp.py +36 -36
  54. modulitiz_micro/nlp/ModuloNlpDateAndTime.py +59 -59
  55. modulitiz_micro/rete/ModuloNetworking.py +64 -64
  56. modulitiz_micro/rete/ModuloOpenVpn.py +15 -15
  57. modulitiz_micro/rete/email/EmailBean.py +5 -0
  58. modulitiz_micro/rete/{ModuloEmail.py → email/ModuloEmail.py} +90 -69
  59. modulitiz_micro/rete/http/ModuloHttp.py +114 -114
  60. modulitiz_micro/rete/http/ModuloHttpConnectionSafe.py +91 -91
  61. modulitiz_micro/rete/http/ModuloHttpUtils.py +66 -66
  62. modulitiz_micro/rete/http/beans/HttpResponseBean.py +5 -5
  63. modulitiz_micro/rete/http/decorators/catchAndRaiseHttpExceptions.py +22 -22
  64. modulitiz_micro/rete/ntp/AbstractModuloNtp.py +73 -73
  65. modulitiz_micro/rete/ntp/ModuloNtpIt.py +8 -8
  66. modulitiz_micro/rete/socketserver/AbstractBasicGetSocketServer.py +35 -35
  67. modulitiz_micro/rete/socketserver/AbstractSocketServer.py +267 -267
  68. modulitiz_micro/rete/ssl/ModuloSsl.py +56 -56
  69. modulitiz_micro/sistema/EnvVarsEnum.py +9 -9
  70. modulitiz_micro/sistema/ModuloEnvVars.py +34 -34
  71. modulitiz_micro/sistema/ModuloSystem.py +298 -298
  72. modulitiz_micro/sistema/ModuloSystemPipe.py +67 -67
  73. modulitiz_micro/social/telegram/ModuloTelegram.py +52 -52
  74. modulitiz_micro/social/telegram/ModuloTelegramSimple.py +26 -26
  75. modulitiz_micro/util/beans/conf/AbstractBasicConfBean.py +11 -11
  76. modulitiz_micro/util/beans/conf/AbstractConfBean.py +16 -16
  77. modulitiz_micro/util/beans/fileconf/AbstractBasicFileConfBean.py +11 -11
  78. modulitiz_micro/util/beans/fileconf/AbstractFileConfBean.py +13 -13
  79. modulitiz_micro/util/beans/globalvar/AbstractBasicGlobalVarBean.py +15 -15
  80. modulitiz_micro/util/beans/globalvar/AbstractGlobalVarBean.py +34 -34
  81. modulitiz_micro/util/decorators/noAwait.py +23 -23
  82. modulitiz_micro/util/pip/AbstractModuloPip.py +41 -41
  83. modulitiz_micro/util/pip/ModuloPip.py +49 -49
  84. modulitiz_micro/util/scheduler/AbstractScheduler.py +32 -32
  85. modulitiz_micro/util/spooler/AbstractSpooler.py +14 -14
  86. modulitiz_micro/util/spooler/Spooler.py +18 -18
  87. modulitiz_micro/util/spooler/beans/QueueBean.py +8 -8
  88. modulitiz_micro/util/spooler/decorators/spooler.py +49 -49
  89. modulitiz_micro/util/spooler/eccezioni/EccezioneSpooler.py +7 -7
  90. modulitiz_micro/util/spooler/eccezioni/EccezioneSpoolerFull.py +7 -7
  91. modulitiz_micro/util/unittesting/AbstractOverrideTestUtil.py +18 -18
  92. modulitiz_micro/util/unittesting/AbstractTestUtil.py +11 -11
  93. modulitiz_micro/util/unittesting/ModuloRunUnitTest.py +25 -25
  94. modulitiz_micro/util/wheel/ModuloBuildWheel.py +118 -118
  95. modulitiz_micro/util/wheel/ModuloToml.py +40 -40
  96. modulitiz_micro/util/wheel/ModuloWheel.py +12 -12
  97. {modulitiz_micro-2.26.0.dist-info → modulitiz_micro-2.27.0.dist-info}/LICENSE +20 -20
  98. {modulitiz_micro-2.26.0.dist-info → modulitiz_micro-2.27.0.dist-info}/METADATA +63 -63
  99. modulitiz_micro-2.27.0.dist-info/RECORD +101 -0
  100. modulitiz_micro-2.26.0.dist-info/RECORD +0 -100
  101. {modulitiz_micro-2.26.0.dist-info → modulitiz_micro-2.27.0.dist-info}/WHEEL +0 -0
  102. {modulitiz_micro-2.26.0.dist-info → modulitiz_micro-2.27.0.dist-info}/top_level.txt +0 -0
@@ -1,91 +1,91 @@
1
- from modulitiz_micro.ModuloStringhe import ModuloStringhe
2
- from modulitiz_micro.database.sqlite.ModuloSQLite import AbstractSqlite
3
-
4
-
5
- class DatabaseCache(AbstractSqlite):
6
-
7
- # costruttore
8
- def __init__(self,*args,**kwargs):
9
- super().__init__(*args,**kwargs)
10
-
11
- # metodi
12
- def schema(self):
13
- sql="""
14
- CREATE TABLE tb_cache(
15
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
16
- type TEXT NOT NULL,
17
- key TEXT NULL,
18
- valore TEXT NOT NULL,
19
- data_insert TIMESTAMP NOT NULL
20
- );
21
- CREATE UNIQUE INDEX IX_tb_cache__type_key ON tb_cache(type,key);
22
-
23
- """
24
-
25
- return sql
26
-
27
- def insertBasicTables(self):
28
- return
29
-
30
-
31
- #############################################################################################################################
32
- def select_cache_valore_by_entries(self,tipo,chiave):
33
- results=self.select_cache_by_entries(tipo, chiave)
34
- if results is None:
35
- return
36
- return results[0]['valore']
37
-
38
- def select_cache_by_entries(self,tipo,chiave):
39
- with self.__query_cache_by_entries(tipo, chiave,False) as cursoreDb:
40
- results=cursoreDb.fetchall()
41
- if len(results)==0:
42
- return
43
- return results
44
-
45
- def count_cache_by_entries(self,tipo,chiave)->int:
46
- cursoreDb=self.__query_cache_by_entries(tipo, chiave,True)
47
- return self.count(cursoreDb)
48
-
49
- def __query_cache_by_entries(self,tipo,chiave,isCount):
50
- add_chiave=ModuloStringhe.isEmpty(chiave) is False
51
- sql="SELECT "+("COUNT(*) AS conta" if isCount is True else "*")+"""
52
- FROM tb_cache
53
- WHERE type=:tipo
54
- """+("AND key=:chiave" if add_chiave is True else "")+"""
55
- ;
56
- """
57
- params={'tipo':tipo}
58
- if add_chiave is True:
59
- params['chiave']=chiave
60
-
61
- cursoreDb=self.initCursore()
62
- cursoreDb.execute(sql,params)
63
- return cursoreDb
64
-
65
- def insert_cache(self,tipo,chiave,valore):
66
- sql="""
67
- INSERT INTO tb_cache(
68
- type,key,valore,data_insert
69
- ) VALUES (
70
- :tipo,:chiave,:valore,"""+self.DATE_TIME_NOW+"""
71
- );
72
- """
73
- cursoreDb=self.initCursore()
74
- cursoreDb.execute(sql,{
75
- 'tipo':tipo,'chiave':chiave,'valore':valore
76
- })
77
- return cursoreDb
78
-
79
- def update_cache_valore(self,tipo,chiave,valore):
80
- sql="""
81
- UPDATE tb_cache
82
- SET valore=:valore,data_insert="""+self.DATE_TIME_NOW+"""
83
- WHERE type=:tipo AND key=:chiave
84
- ;
85
- """
86
- cursoreDb=self.initCursore()
87
- cursoreDb.execute(sql,{
88
- 'valore':valore,'tipo':tipo,'chiave':chiave
89
- })
90
- return cursoreDb
91
-
1
+ from modulitiz_micro.ModuloStringhe import ModuloStringhe
2
+ from modulitiz_micro.database.sqlite.ModuloSQLite import AbstractSqlite
3
+
4
+
5
+ class DatabaseCache(AbstractSqlite):
6
+
7
+ # costruttore
8
+ def __init__(self,*args,**kwargs):
9
+ super().__init__(*args,**kwargs)
10
+
11
+ # metodi
12
+ def schema(self):
13
+ sql="""
14
+ CREATE TABLE tb_cache(
15
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
16
+ type TEXT NOT NULL,
17
+ key TEXT NULL,
18
+ valore TEXT NOT NULL,
19
+ data_insert TIMESTAMP NOT NULL
20
+ );
21
+ CREATE UNIQUE INDEX IX_tb_cache__type_key ON tb_cache(type,key);
22
+
23
+ """
24
+
25
+ return sql
26
+
27
+ def insertBasicTables(self):
28
+ return
29
+
30
+
31
+ #############################################################################################################################
32
+ def select_cache_valore_by_entries(self,tipo,chiave):
33
+ results=self.select_cache_by_entries(tipo, chiave)
34
+ if results is None:
35
+ return
36
+ return results[0]['valore']
37
+
38
+ def select_cache_by_entries(self,tipo,chiave):
39
+ with self.__query_cache_by_entries(tipo, chiave,False) as cursoreDb:
40
+ results=cursoreDb.fetchall()
41
+ if len(results)==0:
42
+ return
43
+ return results
44
+
45
+ def count_cache_by_entries(self,tipo,chiave)->int:
46
+ cursoreDb=self.__query_cache_by_entries(tipo, chiave,True)
47
+ return self.count(cursoreDb)
48
+
49
+ def __query_cache_by_entries(self,tipo,chiave,isCount):
50
+ add_chiave=ModuloStringhe.isEmpty(chiave) is False
51
+ sql="SELECT "+("COUNT(*) AS conta" if isCount is True else "*")+"""
52
+ FROM tb_cache
53
+ WHERE type=:tipo
54
+ """+("AND key=:chiave" if add_chiave is True else "")+"""
55
+ ;
56
+ """
57
+ params={'tipo':tipo}
58
+ if add_chiave is True:
59
+ params['chiave']=chiave
60
+
61
+ cursoreDb=self.initCursore()
62
+ cursoreDb.execute(sql,params)
63
+ return cursoreDb
64
+
65
+ def insert_cache(self,tipo,chiave,valore):
66
+ sql="""
67
+ INSERT INTO tb_cache(
68
+ type,key,valore,data_insert
69
+ ) VALUES (
70
+ :tipo,:chiave,:valore,"""+self.DATE_TIME_NOW+"""
71
+ );
72
+ """
73
+ cursoreDb=self.initCursore()
74
+ cursoreDb.execute(sql,{
75
+ 'tipo':tipo,'chiave':chiave,'valore':valore
76
+ })
77
+ return cursoreDb
78
+
79
+ def update_cache_valore(self,tipo,chiave,valore):
80
+ sql="""
81
+ UPDATE tb_cache
82
+ SET valore=:valore,data_insert="""+self.DATE_TIME_NOW+"""
83
+ WHERE type=:tipo AND key=:chiave
84
+ ;
85
+ """
86
+ cursoreDb=self.initCursore()
87
+ cursoreDb.execute(sql,{
88
+ 'valore':valore,'tipo':tipo,'chiave':chiave
89
+ })
90
+ return cursoreDb
91
+
@@ -1,26 +1,26 @@
1
- from functools import wraps
2
-
3
- from cachetools import TTLCache
4
- from cachetools import cached
5
-
6
- from modulitiz_micro.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
+ from functools import wraps
2
+
3
+ from cachetools import TTLCache
4
+ from cachetools import cached
5
+
6
+ from modulitiz_micro.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,15 +1,15 @@
1
- import git
2
-
3
-
4
- class ModuloGit(object):
5
- def __init__(self, repoPath:str):
6
- self.inner=git.Repo(repoPath)
7
-
8
- def getWorkingCopyRevision(self)->str:
9
- return self.inner.head.object.hexsha
10
-
11
- def getRemoteRevision(self)->str:
12
- return self.inner.remotes[0].fetch()[0].ref.object.hexsha
13
-
14
- def update(self)->str:
15
- return self.inner.remotes[0].pull()[0].ref.object.hexsha
1
+ import git
2
+
3
+
4
+ class ModuloGit(object):
5
+ def __init__(self, repoPath:str):
6
+ self.inner=git.Repo(repoPath)
7
+
8
+ def getWorkingCopyRevision(self)->str:
9
+ return self.inner.head.object.hexsha
10
+
11
+ def getRemoteRevision(self)->str:
12
+ return self.inner.remotes[0].fetch()[0].ref.object.hexsha
13
+
14
+ def update(self)->str:
15
+ return self.inner.remotes[0].pull()[0].ref.object.hexsha
@@ -1,44 +1,44 @@
1
- from bs4 import BeautifulSoup
2
-
3
- from modulitiz_micro.ModuloStringhe import ModuloStringhe
4
- from modulitiz_micro.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
+ from bs4 import BeautifulSoup
2
+
3
+ from modulitiz_micro.ModuloStringhe import ModuloStringhe
4
+ from modulitiz_micro.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,27 +1,27 @@
1
- from abc import ABC
2
- from abc import abstractmethod
3
-
4
- from modulitiz_micro.init.AbstractInit import AbstractInit
5
-
6
-
7
- class AbstractBasicInit(AbstractInit,ABC):
8
- @classmethod
9
- @abstractmethod
10
- def getCartellaBase(cls)->str:
11
- """
12
- Ricavo la cartella dell'archivio del progetto attuale.
13
- """
14
-
15
- @classmethod
16
- @abstractmethod
17
- def getProjectRoot(cls,nome: str) -> str:
18
- """
19
- Restituisce il percorso assoluto di un progetto.
20
- """
21
-
22
- @classmethod
23
- @abstractmethod
24
- def getProjectsRoot(cls) -> str:
25
- """
26
- Restituisce il percorso assoluto dei progetti.
27
- """
1
+ from abc import ABC
2
+ from abc import abstractmethod
3
+
4
+ from modulitiz_micro.init.AbstractInit import AbstractInit
5
+
6
+
7
+ class AbstractBasicInit(AbstractInit,ABC):
8
+ @classmethod
9
+ @abstractmethod
10
+ def getCartellaBase(cls)->str:
11
+ """
12
+ Ricavo la cartella dell'archivio del progetto attuale.
13
+ """
14
+
15
+ @classmethod
16
+ @abstractmethod
17
+ def getProjectRoot(cls,nome: str) -> str:
18
+ """
19
+ Restituisce il percorso assoluto di un progetto.
20
+ """
21
+
22
+ @classmethod
23
+ @abstractmethod
24
+ def getProjectsRoot(cls) -> str:
25
+ """
26
+ Restituisce il percorso assoluto dei progetti.
27
+ """
@@ -1,11 +1,11 @@
1
- from abc import ABC
2
- from abc import abstractmethod
3
-
4
-
5
- class AbstractInit(ABC):
6
- @staticmethod
7
- @abstractmethod
8
- def getCartellaScriptCorrente(cls)->str:
9
- """
10
- Come recuperare la cartella dello script corrente.
11
- """
1
+ from abc import ABC
2
+ from abc import abstractmethod
3
+
4
+
5
+ class AbstractInit(ABC):
6
+ @staticmethod
7
+ @abstractmethod
8
+ def getCartellaScriptCorrente(cls)->str:
9
+ """
10
+ Come recuperare la cartella dello script corrente.
11
+ """
@@ -1,7 +1,7 @@
1
- from modulitiz_micro.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
+ from modulitiz_micro.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 modulitiz_micro.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
+ import threading
2
+ import time
3
+ from typing import Callable
4
+
5
+ from modulitiz_micro.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,26 +1,26 @@
1
- import threading
2
-
3
- from modulitiz_micro.files.ModuloLogging import ModuloLogging
4
- from modulitiz_micro.multithreading.ModuloThreadLogger import ModuloThreadLogger
5
- from modulitiz_micro.multithreading.ModuloThreadWithCallbackError import ModuloThreadWithCallbackError
6
-
7
-
8
- class ModuloThread(object):
9
- @staticmethod
10
- def startDaemon(logger:ModuloLogging,funzione,args:tuple)->ModuloThreadLogger:
11
- d=ModuloThreadLogger(logger,name='th__'+funzione.__name__,target=funzione,args=args,daemon=True)
12
- d.start()
13
- return d
14
- @staticmethod
15
- def startDaemonWithCallbackError(callbackError,funzione,args:tuple)->ModuloThreadWithCallbackError:
16
- d=ModuloThreadWithCallbackError(callbackError,name='th__'+funzione.__name__,target=funzione,args=args,daemon=True)
17
- d.start()
18
- return d
19
-
20
- @staticmethod
21
- def numeroThreadsAttivi()->int:
22
- """
23
- Non e' incluso il main, ovviamente.
24
- Se usi pydev debugger devi sottrarre altri 2 o 3 threads
25
- """
26
- return threading.active_count()-1
1
+ import threading
2
+
3
+ from modulitiz_micro.files.ModuloLogging import ModuloLogging
4
+ from modulitiz_micro.multithreading.ModuloThreadLogger import ModuloThreadLogger
5
+ from modulitiz_micro.multithreading.ModuloThreadWithCallbackError import ModuloThreadWithCallbackError
6
+
7
+
8
+ class ModuloThread(object):
9
+ @staticmethod
10
+ def startDaemon(logger:ModuloLogging,funzione,args:tuple)->ModuloThreadLogger:
11
+ d=ModuloThreadLogger(logger,name='th__'+funzione.__name__,target=funzione,args=args,daemon=True)
12
+ d.start()
13
+ return d
14
+ @staticmethod
15
+ def startDaemonWithCallbackError(callbackError,funzione,args:tuple)->ModuloThreadWithCallbackError:
16
+ d=ModuloThreadWithCallbackError(callbackError,name='th__'+funzione.__name__,target=funzione,args=args,daemon=True)
17
+ d.start()
18
+ return d
19
+
20
+ @staticmethod
21
+ def numeroThreadsAttivi()->int:
22
+ """
23
+ Non e' incluso il main, ovviamente.
24
+ Se usi pydev debugger devi sottrarre altri 2 o 3 threads
25
+ """
26
+ return threading.active_count()-1
@@ -1,8 +1,8 @@
1
- from modulitiz_micro.files.ModuloLogging import ModuloLogging
2
- from modulitiz_micro.multithreading.ModuloThreadWithCallbackError import ModuloThreadWithCallbackError
3
-
4
-
5
- class ModuloThreadLogger(ModuloThreadWithCallbackError):
6
-
7
- def __init__(self,logger:ModuloLogging,**kwargs):
8
- super().__init__(lambda ex:logger.exception('Eccezione nel thread:'),**kwargs)
1
+ from modulitiz_micro.files.ModuloLogging import ModuloLogging
2
+ from modulitiz_micro.multithreading.ModuloThreadWithCallbackError import ModuloThreadWithCallbackError
3
+
4
+
5
+ class ModuloThreadLogger(ModuloThreadWithCallbackError):
6
+
7
+ def __init__(self,logger:ModuloLogging,**kwargs):
8
+ super().__init__(lambda ex:logger.exception('Eccezione nel thread:'),**kwargs)