return ret
class UUIDmanager:
- def __init__(self, target):
+ def __init__(self, target, inc):
self.target = target
+ self.inc = inc
def lock(self):
# go through the list of not locked uuid files and stop on the first successfully locked
return True
def unlockfailed(self):
- # unlock target as usual and increase its counter by 10
+ # unlock target as usual and increase its counter by self.inc
if not self.unlock():
logging.warn("Unlock failed: %s", self.target)
uuid = UUID_PREFIX + self.target
- UUIDlist.set_cnt(uuid, UUIDlist.get_cnt(uuid)+10)
+ UUIDlist.set_cnt(uuid, UUIDlist.get_cnt(uuid) + self.inc)
def parse_arguments():
parser = argparse.ArgumentParser(description="Manager of locks on UUID files")
group.add_argument("-f", "--unlockfailed",
action="store_true", default=False, dest="unlockfailed",
- help="Unlock a device and increment counter by 10")
+ help="Unlock a device and increment counter by INC")
+
+ parser.add_argument("--inc", type=int,
+ action="store", default=10, dest="inc",
+ help="Set INC value (default: 10)")
parser.add_argument("-L", "--log",
action="store", dest="loglevel",
raise ValueError('Invalid log level: %s' % args.loglevel)
logging.basicConfig(format='%(asctime)s %(message)s',level=numeric_level)
logging.debug("Begin")
- uuid_man = UUIDmanager(args.target)
+ uuid_man = UUIDmanager(args.target, args.inc)
if args.lock:
if not uuid_man.lock():
logging.warn("File locking unsuccessful!")