DoubleReset now counts (and returns) the number of resets within the specified time (default 5 seconds)

This commit is contained in:
2022-05-26 00:38:46 +02:00
parent f2e4bbf681
commit 4a5c844510
2 changed files with 6 additions and 24 deletions

View File

@@ -1,21 +0,0 @@
from time import sleep
import os
def DoubleReset(Time=5,File="doublereset.txt"):
try:
a=open(File)
Check=a.read().strip()
a.close()
if Check == '1':
os.remove(File)
return True
except OSError:
pass
a=open(File,"w")
a.write("1")
a.close()
sleep(Time)
os.remove(File)
return False

View File

@@ -11,9 +11,12 @@ def DoubleReset(Time=5,File="doublereset.txt"):
a=open(File)
Check=a.read().strip()
a.close()
if Check == '1':
os.remove(File)
return True
a=open(File,"w")
a.write(str(int(Check)+1))
a.close()
sleep(Time)
os.remove(File)
return int(Check)+1
except OSError:
pass
a=open(File,"w")