def history(): try: if request.method == "POST": if (request.form['action'] == "export"): log = plumb.Export(request.form['column'], request.form['value'], False) return (render_history(log)) elif (request.form['action'] == "archive"): plumb.Archive(False) return (render_history("AIM system archived.")) elif (request.form['action'] == "remove"): plumb.DeleteSnapshot(request.form['remove_snapshot'], False) log = "snapshot {0} has been removed from archive.".format( request.form['remove_snapshot']) return (render_history(log)) else: return (render_history("")) except Exception as e: return (render_history(e)) return (render_history(""))
def main(argv): verbose = False test = "" aim = "" initialize = False notes = "" look = False update = False allo = False export = "" save = False try: opts, args = getopt.getopt(argv, "se:ailun:hvt:", ["help", "verbose", "test=", "notes=", "look", "update", "initialize", "allocation", "export=", "save"]) except getopt.GetoptError as err: print(err) usage() sys.exit(2) for o, a in opts: if o in ("-v", "--verbose"): verbose = True elif o in ("-a", "--allocation"): allo = True elif o in ("-t", "--test"): test = a elif o in ("-h", "--help"): usage() exit() elif o in ("-n", "--notes"): notes = a elif o in ("-e", "--export"): export = a elif o in ("-i", "--initialize"): initialize = True elif o in ("-l", "--look"): look = True elif o in ("-s", "--save"): save = True elif o in ("-u", "--update"): update = True else: assert False, "unhandled option" defaults, types = plumb.GetDefaults(False) if defaults['folder name'] is None: print ("\tWarning, the folder name is missing, please correct") exit() if defaults['test root'] is None: print ("\tWarning, the test root path is not set, please correct") exit() if (test > ""): testResult = plumb.TestAIM(test, verbose) print (testResult['output']) exit() if (notes > ""): notesResult, initialize_day = plumb.GetAIMNotes(notes, verbose) print (notesResult) if initialize_day: print("AIM system was initialized today") exit() if (initialize): nowResult, log = plumb.CreateAIM(verbose) print (nowResult, log) exit() if (look): lookResult, lookHTML, lookDB = plumb.Look(verbose) pprint.pprint(lookResult) pprint.pprint(lookHTML) pprint.pprint(lookDB) exit() if (update): postResult = plumb.Post(verbose) if (postResult): print ("updated.") else: print ("failed.") exit() if (allo): allocation_list, trending_list, life_list = plumb.AllocationTrends(verbose) pprint.pprint(allocation_list) pprint.pprint(trending_list) pprint.pprint(life_list) exit() if (export > ""): exportResult = plumb.Export(export, "", verbose) print (exportResult) exit() if (save): saveResult = plumb.Archive(verbose) if (saveResult): print ("updated.") else: print ("failed.") exit() usage()
def main(argv): verbose = False test = False printyear = "" export = "" save = False archive = False delete = "" try: opts, args = getopt.getopt(argv, "d:ase:p:hvt", [ "help", "verbose", "test", "notes=", "look", "update", "print=", "initialize", "allocation", "export=", "save", "archive", "delete=" ]) except getopt.GetoptError as err: print(err) usage() sys.exit(2) for o, a in opts: if o in ("-v", "--verbose"): verbose = True elif o in ("-t", "--test"): test = True elif o in ("-a", "--archive"): archive = True elif o in ("-h", "--help"): usage() exit() elif o in ("-e", "--export"): export = a elif o in ("-d", "--delete"): delete = a elif o in ("-s", "--save"): save = True elif o in ("-p", "--print"): if (a[0] == '-'): if ("verbose" in a): verbose = True printyear = str(datetime.datetime.now().year) else: printyear = a.lower() else: assert False, "unhandled option" defaults, types = plumb.GetDefaults(False) if defaults['folder name'] is None: print("\tWarning, the folder name is missing, please correct") exit() if defaults['test root'] is None: print("\tWarning, the test root path is not set, please correct") exit() if (test): testResult = plumb.TestHistory(False, verbose) print(testResult) exit() if (printyear > ""): printResult = plumb.PrintAIM(printyear, verbose) if (printResult > ""): pprint.pprint(printResult) else: print("failed.") exit() if (export > ""): exportResult = plumb.Export(export, "", verbose) print(exportResult) exit() if (delete > ""): deleteResult = plumb.DeleteSnapshot(delete, verbose) if (deleteResult): print("deleted.") else: print("failed.") exit() if (save): saveResult = plumb.Archive(verbose) if (saveResult): print("updated.") else: print("failed.") exit() if (archive): archiveResult = plumb.PrintSummary(verbose) if (archiveResult > ""): pprint.pprint(archiveResult) else: print("failed.") exit() usage()