def main(log_location, start_time): # Set up our logging here log_file_name = log_location + "CiscoBuild.log" # Set loggers for specific areas of the module logger1 = my_logger('CiscoBuild.main', log_file_name) logger2 = my_logger('CiscoBuild.build_config', log_file_name) logger3 = my_logger('CiscoBuild.regex_create', log_file_name) logger4 = my_logger('CiscoBuild.multiple_replace', log_file_name) # Production stuff input_file = arguments.input_file device_template = arguments.device_template # testing stuff # input_file = '3650_input.csv' # device_template = './input_Templates/3650-config-template.txt' # Check to see if input files exist try: open(input_file) logger1.debug('input_file was found... {}'.format(input_file)) except Exception as err: logger1.info('Check the input file and path. It does not appear to exist... {}'.format(input_file)) logger1.exception(err) sys.exit(1) try: open(device_template) logger1.debug('device template was found... {}'.format(device_template)) except Exception as err: logger1.info('Check the device template file and path. It does not appear to exist... {}'.format(device_template)) logger1.exception(err) sys.exit(1) # Read in inpput data file with open(input_file, encoding='utf-8-sig') as csv_inputf: # build a dict for current device reader = csv.reader(csv_inputf, skipinitialspace=True) header = next(reader) device_dict = [dict(zip(header, map(str, row))) for row in reader] logger1.debug(device_dict) build_config(device_template, device_dict, logger2, logger3, logger4) logger1.info('--- {} seconds ---'.format(time.time() - start_time)) sys.exit(0)
parser.add_argument("-p", "--port", help="change server listen port", default="5000") parser.add_argument("-r", "--record", help="save vehicle data to db", action='store_true') parser.add_argument("-m", "--mail", help="set the email address") parser.add_argument("-P", "--password", help="set the password") parser.add_argument("--remote-disable", help="disable remote control") parser.add_argument("-b", "--base-path", help="base path for web app",default="/") parser.parse_args() return parser if __name__ == "__main__": if sys.version_info < (3, 6): raise RuntimeError("This application requires Python 3.6+") parser = parse_args() args = parser.parse_args() my_logger(handler_level=args.debug) logger.info("server start") if args.config: web.app.myp = MyPSACC.load_config(name=args.config.name) else: web.app.myp = MyPSACC.load_config() atexit.register(web.app.myp.save_config) if args.record: web.app.myp.set_record(True) try: web.app.myp.manager._refresh_token() except OAuthError: if args.mail and args.password: client_email = args.mail client_password = args.password else:
def main(log_location): # Set up our logging here log_file_name = log_location + 'FileCompare.log' # Set loggers for specific areas of the module logger1 = my_logger('FileCompare.main', log_file_name) logger2 = my_logger('FileCompare.gui_thread', log_file_name) logger3 = my_logger('FileCompare.main_thread', log_file_name) logger4 = my_logger('FileCompare.multiple_replace', log_file_name) """ Get the path to the users Documents folder Assumes that this is a Windows 10 machine and the user has a Documents folder. """ default_path = "" try: userprofile = os.environ.get('USERPROFILE') # This should work for windows OS logger1.debug(userprofile) default_path = userprofile + "\\" + "Documents" logger1.debug(default_path) except: userprofile = str(Path.home()) # This should work for MAC and probably Linux default_path = userprofile + "/" + "Documents" logger1.debug(default_path) # GUI Things global main_window main_window = tkinter.Tk() main_window.title('File Compare') site_name_text = Label(main_window, text="Site Name/Code") site_name_text.grid(row=1, column=0, sticky=W) site_name_entry = Entry(main_window) site_name_entry.grid(row=1, column=1, sticky=W) site_name_entry.insert(END, 'BOP') file1_text = Label(main_window, text="select file1") file1_text.grid(row=2, column=0, sticky=W) file2_text = Label(main_window, text="select file2") file2_text.grid(row=3, column=0, sticky=W) file1_entry = Entry(main_window, width=30) # width=30 file1_entry.grid(row=2, column=1, sticky=W) open_file = Button(main_window, command=lambda: file_entry(file1_entry), padx=1, text="Select File1") open_file.grid(row=2, column=2, sticky=W) file2_entry = Entry(main_window, width=30) # width=30 file2_entry.grid(row=3, column=1, sticky=W) open_file = Button(main_window, command=lambda: file_entry(file2_entry), padx=1, text="Select File2") open_file.grid(row=3, column=2, sticky=W) output_location_text = Label(main_window, text="Select the output path") output_location_text.grid(row=4, column=0, sticky=W) output_location_entry = Entry(main_window, width=30) # width=40 was used originally output_location_entry.grid(row=4, column=1, sticky=W) output_location_entry.insert(END, default_path) open_file = Button(main_window, command=lambda: outpath(output_location_entry), padx=1, text="Select Output Path") open_file.grid(row=4, column=2, sticky=W) # Let's Go! attempt = Button(text="OK", command=lambda: gui_thread(file1_entry, file2_entry, site_name_entry, output_location_entry, logger2, logger3)) attempt.grid(row=10, column=0, sticky=W) exit = Button(text="Close", command=close) exit.grid(row=10, column=1, sticky=W) """ Playing with Menu ideas. This may get ripped out in the end but wanted to give it a try for now. """ # Menu Construction menubar = Menu(main_window) filemenu = Menu(menubar, tearoff=0) # filemenu.add_command(label="New", command=new) # New would be a function similar to a button # filemenu.add_command(label="Open") # filemenu.add_command(label="Save As..") filemenu.add_command(label="Close", command=close) menubar.add_cascade(label="File", menu=filemenu) main_window.config(menu=menubar) # Edit Menu # editmenu = Menu(menubar, tearoff=0) # editmenu.add_command(label='Edit', command=edit) # menubar.add_cascade(label="Edit", menu=editmenu) # Help Menu helpmenu = Menu(menubar, tearoff=0) helpmenu.add_command(label="Help Docs", command=help_docs) helpmenu.add_command(label="About", command=about) menubar.add_cascade(label="Help", menu=helpmenu) # Main Starter required for Windows machines main_window.mainloop()