mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-02-13 19:52:11 +00:00
19 lines
No EOL
566 B
Python
19 lines
No EOL
566 B
Python
import os
|
|
|
|
class Locker:
|
|
def createlock(self, lockfile, date=0):
|
|
try:
|
|
if os.path.exists(lockfile):
|
|
f = open(lockfile, "r+")
|
|
return f.read()
|
|
else:
|
|
f = open(lockfile, "w")
|
|
f.write(date)
|
|
except BaseException as e:
|
|
raise("Can't create or read the lock file: {0}".format(e))
|
|
|
|
def unlock(self, lockfile):
|
|
try:
|
|
os.remove(lockfile)
|
|
except BaseException as e:
|
|
raise ("Can't delete the lock file: {0}".format(e)) |