larigira-dbmanage is multipleDB-ready
This commit is contained in:
parent
d9d0af994c
commit
257e3e45cd
1 changed files with 8 additions and 5 deletions
|
@ -8,19 +8,19 @@ from .config import get_conf
|
||||||
|
|
||||||
|
|
||||||
def main_list(args):
|
def main_list(args):
|
||||||
m = EventModel(args.file)
|
m = EventModel(args.file, args.additional_dir)
|
||||||
for alarm, action in m.get_all_alarms_expanded():
|
for alarm, action in m.get_all_alarms_expanded():
|
||||||
json.dump(dict(alarm=alarm, action=action), sys.stdout, indent=4)
|
json.dump(dict(alarm=alarm, action=action), sys.stdout, indent=4)
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
|
||||||
|
|
||||||
def main_getaction(args):
|
def main_getaction(args):
|
||||||
m = EventModel(args.file)
|
m = EventModel(args.file, args.additional_dir)
|
||||||
json.dump(m.get_action_by_id(int(args.actionid)), sys.stdout, indent=4)
|
json.dump(m.get_action_by_id(args.actionid), sys.stdout, indent=4)
|
||||||
|
|
||||||
|
|
||||||
def main_add(args):
|
def main_add(args):
|
||||||
m = EventModel(args.file)
|
m = EventModel(args.file, args.additional_dir)
|
||||||
m.add_event(
|
m.add_event(
|
||||||
dict(kind="frequency", interval=args.interval, start=1),
|
dict(kind="frequency", interval=args.interval, start=1),
|
||||||
[dict(kind="mpd", howmany=1)],
|
[dict(kind="mpd", howmany=1)],
|
||||||
|
@ -29,11 +29,14 @@ def main_add(args):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
conf = get_conf()
|
conf = get_conf()
|
||||||
p = argparse.ArgumentParser()
|
p = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
p.set_defaults(func=None)
|
p.set_defaults(func=None)
|
||||||
p.add_argument(
|
p.add_argument(
|
||||||
"-f", "--file", help="Filepath for DB", required=False, default=conf["DB_URI"]
|
"-f", "--file", help="Filepath for DB", required=False, default=conf["DB_URI"]
|
||||||
)
|
)
|
||||||
|
p.add_argument(
|
||||||
|
"-d", "--additional-dir", help="Filepath for extra DBs", required=False, default=conf["DB_ADDITIONAL_DIR"]
|
||||||
|
)
|
||||||
sub = p.add_subparsers()
|
sub = p.add_subparsers()
|
||||||
sub_list = sub.add_parser("list")
|
sub_list = sub.add_parser("list")
|
||||||
sub_list.set_defaults(func=main_list)
|
sub_list.set_defaults(func=main_list)
|
||||||
|
|
Loading…
Reference in a new issue