update gitignore + test logdir

This commit is contained in:
Samuele Locatelli
2023-11-22 16:03:16 +01:00
parent 3e3fdc22e9
commit 9ee4754789
5 changed files with 38 additions and 0 deletions
+2
View File
@@ -330,3 +330,5 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
# esclusioni gestione IOB-WIN-PYTHON
IOB-WIN-PSER/logs/logfile.txt*
View File
+4
View File
@@ -131,6 +131,10 @@ try:
confPath = os.path.join(BASE_PATH, IOB_CONF)
config.read(confPath)
config.sections()
# fix cartella log...
logDirOk=os.path.exists(confPath)
if(not logDirOk):
os.makedirs(os.path.dirname(confPath), exist_ok=True)
LOGFILE = config.get('log','LOGFILE')
+32
View File
@@ -0,0 +1,32 @@
import win32api
print " Running on WINDOWS\n"
import os
#---------------------------------------------------------------
# meccanismo di file lock per evitare multiple instances
# The function will try to lock the file specified , if it success, return True, else return False.
# The nice thing is that the lock will be dropped when the program terminates.
# >>>Use :
# if not lockFile(".lock.pod"):
# sys.exit(0)
def lockFile ( lockfile ) :
try:
fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY )
except:
logga("Errore nel file WIN.PY per FD")
try:
# Request exclusive (EX) non-blocking (NB) advisory lock.
#fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB )
print " Dummy Method! Completa Lockfile\n"
except IOError:
return False
return True
try:
if not lockFile ( ".lockfile" ) :
print '\n noi non siamo soli ...\n'
logga ( "LOCK: Piu istanze aperte")
sys.exit ( 0 )
except:
logga("if not lockfile NON RIUSCITO in file WIN.PY")
sys.exit(1)
Binary file not shown.