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)