DoubleReset now counts (and returns) the number of resets within the specified time (default 5 seconds)
This commit is contained in:
@@ -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
|
|
||||||
|
|
||||||
|
|
||||||
@@ -11,9 +11,12 @@ def DoubleReset(Time=5,File="doublereset.txt"):
|
|||||||
a=open(File)
|
a=open(File)
|
||||||
Check=a.read().strip()
|
Check=a.read().strip()
|
||||||
a.close()
|
a.close()
|
||||||
if Check == '1':
|
a=open(File,"w")
|
||||||
|
a.write(str(int(Check)+1))
|
||||||
|
a.close()
|
||||||
|
sleep(Time)
|
||||||
os.remove(File)
|
os.remove(File)
|
||||||
return True
|
return int(Check)+1
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
a=open(File,"w")
|
a=open(File,"w")
|
||||||
|
|||||||
Reference in New Issue
Block a user