def set_config(self, line): util.set_config(line, self.config, C, log) cmd, tail = util.parse_cmdline2(line, self.config, log) if cmd == 'log-level': log.set_log_level(self.config['log-level'].value) if cmd == 'wav-prefix': self.transport.set_wav_prefix(tail)
def init(preserve_output=False): with daemon.DaemonContext( stdout=sys.stdout if preserve_output else None, stderr=sys.stderr if preserve_output else None, stdin=sys.stdin if preserve_output else None, signal_map={ signal.SIGTERM: shutdown, signal.SIGTSTP: shutdown, }, pidfile=lockfile.FileLock('/var/run/gcal-mm-status.pid')): set_log_level(LogLevel.DEBUG) log('Hello world!') shutdown(signal.SIGTERM, None)
def looper(self, args): except_count = 0 history_file = '.hpirhist' exit_val = EXIT_OK d = None try: log.set_log_level(args.log) read_history_file(history_file) d = dispatcher.Dispatcher(args) d.start_transport() while not d.is_done(): try: d.read_and_exec() except_count = 0 except: except_count += 1 log.i('') # Ensure the following error message starts on a new line. log.e('{} : {}'.format(sys.argv[0], sys.exc_info()[1])) if d.is_trace_on_error(): print traceback.format_exc() if (except_count >= 2) or d.is_exit_on_error(): exit_val = EXIT_ERR d.force_done() write_history_file(history_file) except: exit_val = EXIT_ERR print traceback.format_exc() finally: if d: d.stop_transport() return exit_val
def load(): global ARGS, CFG parser = ArgumentParser( prog='telex', conflict_handler='resolve', description='Handle historic teletypes.', epilog='More infos at https://github.com/fablab-wue/piTelex.git', allow_abbrev=True) gi = parser.add_argument_group("Interfaces") gi.add_argument("-G", "--RPiTW39", dest="RPiTTY", default=False, action="store_true", help="GPIO (pigpio) on RPi with TW39 teletype") gi.add_argument("-C", "--RPiCtrl", dest="RPiCtrl", default=False, action="store_true", help="GPIO (pigpio) on RPi with button controls and LEDs") gi.add_argument( "-X", "--terminal", dest="terminal", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="Serial terminal in 8-bit ASCII") gi.add_argument( "-Y", "--tty", dest="CH340", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-serial-adapter (CH340-chip) with teletype (without dialing)") gi.add_argument( "-W", "--ttyTW39", dest="CH340_TW39", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-serial-adapter (CH340-chip) with TW39 teletype (pulse dial)") gi.add_argument( "-M", "--ttyTWM", dest="CH340_TWM", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-serial-adapter (CH340-chip) with TWM teletype (keypad dial)") gi.add_argument( "-V", "--ttyV10", dest="CH340_V10", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-serial-adapter (CH340-chip) with V.10 teletype (FS200, FS220)" ) gi.add_argument("-E", "--audioED1000", dest="ED1000", default=False, action="store_true", help="USB-sound-card with ED1000 teletype") gi.add_argument("--noscreen", dest="screen", default=True, action="store_false", help="No screen in/out") gg = parser.add_argument_group("Gateways") gg.add_argument("-I", "--iTelex", dest="itelex", default=-1, const=0, nargs='?', metavar='PORT', type=int, help="i-Telex client and server (if PORT>0)") gg.add_argument("-N", "--news", dest="news", default='', metavar="PATH", help="News from file") gg.add_argument("-T", "--twitter", dest="twitter", default='', nargs='?', metavar='CONSUMER_KEY:CONSUMER_SECRET:API_KEY:API_SECRET', help="Twitter client") gg.add_argument("-C", "--IRC", dest="irc", default='', metavar="CHANNEL", help="IRC client") gg.add_argument("-R", "--REST", dest="rest", default='', metavar="TEMPLATE", help="REST client") gt = parser.add_argument_group("Tools / Toys") gt.add_argument("-Z", "--eliza", dest="eliza", default=False, action="store_true", help="Eliza chat bot") gt.add_argument("-A", "--archive", dest="archive", default=False, action="store_true", help="Archive module") gt.add_argument("-S", "--shellcmd", dest="shellcmd", default=False, action="store_true", help="Execute shell command of ESC sequ.") gd = parser.add_argument_group("Debug") gd.add_argument("-L", "--log", dest="log", default='', metavar="FILE", help="Log to file") gd.add_argument("-d", "--debug", dest="debug", default=0, metavar='LEVEL', type=int, help="Debug level") parser.add_argument("-c", "--config", dest="cnf_file", default='telex.json', metavar="FILE", help="Load config file (telex.json)") parser.add_argument( "-k", "--id", "--KG", dest="wru_id", default='', metavar="ID", help= "Set the ID of the telex device. Leave empty to use the hardware ID") parser.add_argument( "--id-fallback", dest="wru_fallback", default=False, action="store_true", help= "Enable software ID fallback mode: If printer isn't starting up on command, enable software ID" ) parser.add_argument( "--errorlog-path", dest="errorlog_path", default=False, action="store_true", help= "Path of error log; relative paths are referred to where this program is being executed" ) #parser.add_argument("-m", "--mode", # dest="mode", default='', metavar="MODE", # help="Set the mode of the Telex Device. e.g. TW39, TWM, V.10") parser.add_argument("-q", "--quiet", dest="verbose", default=True, action="store_false", help="don't print status messages to stdout") parser.add_argument( "-s", "--save", dest="save", default=False, action="store_true", help="Save command line args to config file (telex.json)") ARGS = parser.parse_args() try: with open(ARGS.cnf_file.strip(), 'r') as fp: CFG = json.load(fp) except FileNotFoundError: l.warning( "Configuration file '{}' not found. Using CLI params only.".format( ARGS.cnf_file.strip())) CFG = {} except json.JSONDecodeError as e: l.warning( "Configuration file '{}' error '{}' in line {} column {}".format( ARGS.cnf_file.strip(), e.msg, e.lineno, e.colno)) exit() except Exception as e: l.warning("Configuration file '{}' damaged: ".format( ARGS.cnf_file.strip())) raise if not CFG.get('devices', None): CFG['devices'] = {} devices = CFG['devices'] if ARGS.screen and 'screen' not in devices: devices['screen'] = { 'type': 'screen', 'enable': True, 'show_BuZi': True, 'show_capital': False, 'show_ctrl': True, 'show_info': False } if ARGS.terminal: devices['terminal'] = { 'type': 'terminal', 'enable': True, 'portname': ARGS.terminal.strip(), 'baudrate': 300, 'bytesize': 8, 'stopbits': 1, 'parity': 'N', 'loc_echo': True, } if ARGS.CH340: devices['CH340'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340.strip(), 'mode': '', 'baudrate': 50, 'loopback': True } if ARGS.CH340_TW39: devices['CH340_TW39'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340_TW39.strip(), 'mode': 'TW39', 'baudrate': 50, 'loopback': True } if ARGS.CH340_TWM: devices['CH340_TWM'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340_TWM.strip(), 'mode': 'TWM', 'baudrate': 50, 'loopback': True } if ARGS.CH340_V10: devices['CH340_V10'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340_V10.strip(), 'mode': 'V10', 'baudrate': 50, 'loopback': False } if ARGS.RPiTTY: devices['RPiTTY'] = { 'type': 'RPiTTY', 'enable': True, 'pin_txd': 17, 'pin_rxd': 27, 'inv_rxd': False, 'pin_relay': 22, 'inv_relay': False, 'pin_online': 0, 'pin_dir': 0, 'pin_number_switch': 6, 'baudrate': 50, 'coding': 0, 'loopback': True, 'observe_rxd': True, } if ARGS.RPiCtrl: devices['RPiCtrl'] = { 'type': 'RPiCtrl', 'enable': True, 'pin_switch_num': 0, 'pin_button_1T': 0, 'pin_button_AT': 0, 'pin_button_ST': 0, 'pin_button_LT': 0, 'pin_button_U1': 0, 'pin_button_U2': 0, 'pin_button_U3': 0, 'pin_button_U4': 0, 'pin_LED_A': 0, 'pin_LED_WB': 0, 'pin_LED_WB_A': 9, 'pin_LED_status_R': 23, 'pin_LED_status_G': 24, } if ARGS.ED1000: devices['ED1000'] = { 'type': 'ED1000', 'enable': True, 'send_f0': 500, 'send_f1': 700, 'recv_f0': 2250, 'recv_f1': 3150, 'recv_squelch': 100, 'baudrate': 50, 'devindex': None, 'zcarrier': False, 'unres_threshold': 100, } if ARGS.itelex >= 0: devices['i-Telex'] = { 'type': 'i-Telex', 'enable': True, 'port': ARGS.itelex, 'tns-dynip-number': 0, 'tns-pin': 12345 } if ARGS.news: devices['news'] = { 'type': 'news', 'enable': True, 'newspath': ARGS.news.strip() } if ARGS.twitter: import os twit_creds = ARGS.twitter.split(":") os.environ['consumer_key'] = ARGS.consumer_key os.environ['consumer_secret'] = ARGS.consumer_secret devices['twitter'] = { 'type': 'twitter', 'enable': True, 'consumer_key': twit_creds[0], 'consumer_secret': twit_creds[1], 'access_token_key': twit_creds[2], 'access_token_secret': twit_creds[3], 'track': ARGS.track, 'follow': ARGS.follow, 'languages': ARGS.languages, 'url': ARGS.url, 'host': ARGS.host, 'port': ARGS.port } if ARGS.irc: devices['IRC'] = { 'type': 'IRC', 'enable': True, 'channel': ARGS.irc.strip() } if ARGS.rest: devices['REST'] = { 'type': 'REST', 'enable': True, 'template': ARGS.rest.strip() } if ARGS.eliza: devices['eliza'] = {'type': 'eliza', 'enable': True} if ARGS.archive: devices['archive'] = { 'type': 'archive', 'enable': True, 'path': 'archive' } if ARGS.shellcmd: devices['shellcmd'] = { 'type': 'shellcmd', 'enable': True, 'LUT': { 'X': 'xxx' } } if ARGS.log: devices['log'] = { 'type': 'log', 'enable': True, 'filename': ARGS.log.strip() } CFG['verbose'] = ARGS.verbose wru_id = ARGS.wru_id.strip().upper() if wru_id: CFG['wru_id'] = wru_id wru_fallback = ARGS.wru_fallback if wru_fallback: CFG['wru_fallback'] = ARGS.wru_fallback errorlog_path = ARGS.errorlog_path if errorlog_path: CFG['errorlog_path'] = ARGS.errorlog_path #mode = ARGS.mode.strip() #if mode: # CFG['mode'] = mode if ARGS.debug: CFG['debug'] = ARGS.debug log.set_log_level(CFG.get('debug', 0)) if ARGS.save: with open(ARGS.cnf_file, 'w') as fp: json.dump(CFG, fp, indent=2)
from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtWidgets import QTableView, QApplication, QAction, QMessageBox, QMainWindow, QWidget, QDialog from PyQt5.QtWidgets import QFileDialog, QTableWidgetItem, QHeaderView from Pyqt_CANMatrixSignalsSWFSTool import Ui_MainWindow import sys import Function_getSWFS_DBC_RW import Function_SWFSGenerator from Function_SWFSGenerator import SWFS_SignalInfo # import pandas as pd import log __Author__ = "By: Xueming" __Copyright__ = "Copyright (c) 2019 Xueming." __Version__ = "Version 1.0" logger = log.setup_logger() log.set_log_level(logger, 2) #2:debug logger.info('Start') class MainWindow(QMainWindow, Ui_MainWindow): """ Class documentation goes here. """ def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(MainWindow, self).__init__(parent)
log.info('[CORS] Allowing requests from: %s', args.cors_allow) ensure_dir(args.cookie_dir) log_dir = os.path.dirname(args.log) ensure_dir(log_dir) add_file_handler(args.log) try: with open(args.account_file, "r") as f: TwitterSession.accounts = json.loads(f.read()) except: pass if args.debug is True: set_log_level('debug') else: set_log_level('info') async def shut_down(app): log.info("Closing %d guest sessions", len(TwitterSession.guest_sessions)) for session in TwitterSession.guest_sessions: await session.close() async def clean_up(app): global DB log.info("Closing database connection") DB.close() shutdown_logging()
def main(): # Get current folder current_folder = os.getcwd() step_number = 0 # Get console argument parser = OptionParser() parser.add_option( "-f", "--file", dest="filename", help="The AADL file containing the model description (mandatory)", metavar="FILE") parser.add_option("-s", "--system", dest="system", help="The system to be generated (optional)") parser.add_option("-o", "--output", dest="out_dir", metavar="DIR", help="Output directory (optional)") parser.add_option("-x", "--xml", dest="delete_xml_folder", default=True, action="store_false", help="keep the XML model (optional)") parser.add_option("-l", "--log", dest="log_level", metavar="LEVEL", help="Log level. Valid values: [INFO, WARNING, ERROR]") (options, args) = parser.parse_args() if not options.filename: print("Please provide an AADL file to process.") sys.exit(-1) if not options.out_dir: global_filepath.output_dir = current_folder else: global_filepath.output_dir = os.path.realpath( os.path.join(current_folder, options.out_dir)) # Step 1: Run the prototype changer print_header("Starting procedure") if options.log_level: level = str(options.log_level).upper() if not log.is_valid_log_level(level): print( "Invalid log level {}. Used default INFO. See --help for more information." .format(level)) else: log.set_log_level(level) print("Log level: {}".format(level)) aadl_file_complete_path = os.path.join(current_folder, options.filename) aadl_file_directory = os.path.dirname(aadl_file_complete_path) aadl_file_name = os.path.basename(aadl_file_complete_path) step_number += 1 print("{}. Environment initialization".format(step_number)) clean_up_aadl_modfile(aadl_file_directory, True) replace_prototypes(aadl_file_name, aadl_file_directory) step_number += 1 print("{}. Prototype changed".format(step_number)) # Step 2: Collecting all files # Leggo il contenuto della cartella che contiene il system che mi è stato passato con anche il suo file, # a questo punto leggo tutti i with e per ogni file presente mi cerco se è da usare oppure no file_package_mapping = {} file_property_set_mapping = {} find_package = re.compile('\s*package\s*(.+)') find_with = re.compile('\s*with\s*(\w+\s*,?\s*)+\s*;') find_property_set = re.compile('\s*property\s*set\s*(\w+)\s*is') for path, subdirs, files in os.walk(aadl_file_directory): for name in files: # Skip per i file di sistema if name[0] == ".": continue curr_file_path = os.path.realpath(os.path.join(path, name)) (package, imported, property_sets) = get_usage_packages(curr_file_path, find_package, find_property_set, find_with) tmp_package = {'file': curr_file_path, 'imported': imported} if len(package) > 0: if package not in file_package_mapping: file_package_mapping[package] = tmp_package # Se ho il _mod nel file, sovrascrivo il vecchio valore elif "_mod.aadl" in name: file_package_mapping[package] = tmp_package for p_set in property_sets: if p_set not in file_property_set_mapping: file_property_set_mapping[p_set] = tmp_package step_number += 1 print("{}. Files collected and analyzed".format(step_number)) (system_package, system_imported, _) = get_usage_packages(aadl_file_complete_path, find_package, find_property_set, find_with) packages_to_import = [p for p in system_imported] tmp_desc = file_package_mapping[system_package] files_to_import = [tmp_desc['file']] # Importo via via che trovo i vari file che contengono i package usati while len(packages_to_import) > 0: next_package = packages_to_import.pop() if next_package in file_package_mapping: tmp_desc = file_package_mapping[next_package] import_from_desc(tmp_desc, files_to_import, packages_to_import) if next_package in file_property_set_mapping: tmp_desc = file_property_set_mapping[next_package] import_from_desc(tmp_desc, files_to_import, packages_to_import) step_number += 1 print("{}. The following files will be used in the process:".format( step_number)) for f in files_to_import: print("\t + " + f) # Step 3: Ocarina """ ocarina -aadlv2 -g ever_xml [-r system_name] files """ xml_model_folder = os.path.join(global_filepath.output_dir, "generated_xml_model") if os.path.exists(xml_model_folder): shutil.rmtree(xml_model_folder) os.makedirs(xml_model_folder) ocarina_parameters = ["ocarina", "-aadlv2", "-g", "ever_xml"] # Compose paramters if options.system: ocarina_parameters.append("-r") ocarina_parameters.append(options.system) ocarina_parameters.extend(files_to_import) p = Popen(ocarina_parameters, cwd=xml_model_folder, stdout=PIPE, stderr=PIPE) output, err = p.communicate() # rc = p.returncode step_number += 1 if "Fine Ever XML" in output.decode(): print("{}. Ocarina backend ever_xml ended correctly.".format( step_number)) else: print("{}. Error in Ocarina backend ever_xml".format(step_number)) print("\nOcarina errors:\n") print(err.decode()) print("\nOcarina output:\n") print(output.decode()) sys.exit(0) # Step 4: Code Generation # Set the global_filepath parameters global_filepath.xml_folder_path = xml_model_folder global_filepath.aadl_model_dir = aadl_file_directory for path, _, files in os.walk(xml_model_folder): for name in files: # curr_file_path = os.path.realpath(os.path.join(path, name)) (curr_file_name, curr_file_ext) = os.path.splitext(os.path.basename(name)) if curr_file_ext.replace(".", "") == "xml": global_filepath.xml_filename = name startGeneration() step_number += 1 print("{}. Code generation ended correctly.".format(step_number)) # Step 4: Clean-up step_number += 1 print("{}. Cleaning up:".format(step_number)) if options.delete_xml_folder: if os.path.exists(xml_model_folder): try: shutil.rmtree(xml_model_folder) print( "\t+ Removed XML model folder {}".format(xml_model_folder)) except: print("\t+ Unable to remove XML model folder {}".format( xml_model_folder)) pass else: print("\t+ XML model folder available at {}".format(xml_model_folder)) clean_up_aadl_modfile(aadl_file_directory, should_print=True) print_header("End procedure")
def load(): global ARGS, CFG parser = ArgumentParser( prog='telex', conflict_handler='resolve', description='Handle historic teletypes.', epilog='More infos at https://github.com/fablab-wue/piTelex.git', allow_abbrev=True) gi = parser.add_argument_group("Interfaces") gi.add_argument("-G", "--RPiTW39", dest="RPiTTY", default=False, action="store_true", help="GPIO (pigpio) on RPi with TW39 teletype") gi.add_argument( "-Y", "--tty", dest="CH340", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-Serial-Adapter (CH340-chip) with teletype (without dialing)") gi.add_argument( "-W", "--ttyTW39", dest="CH340_TW39", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-Serial-Adapter (CH340-chip) with TW39 teletype (pulse dial)") gi.add_argument( "-M", "--ttyTWM", dest="CH340_TWM", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-Serial-Adapter (CH340-chip) with TWM teletype (keypad dial)") gi.add_argument( "-V", "--ttyV10", dest="CH340_V10", default='', metavar="TTY", # '/dev/serial0' '/dev/ttyUSB0' help="USB-Serial-Adapter (CH340-chip) with V.10 teletype (FS200, FS220)" ) gi.add_argument("-E", "--audioED1000", dest="ED1000", default=False, action="store_true", help="USB-Sound-Card with ED1000 teletype") gi.add_argument("--noscreen", dest="screen", default=True, action="store_false", help="No Screen in/out") gg = parser.add_argument_group("Gateways") gg.add_argument("-I", "--iTelex", dest="itelex", default=-1, const=0, nargs='?', metavar='PORT', type=int, help="i-Telex Client and Server (if PORT>0)") #gg.add_argument("-T", "--telnet", # dest="telnet", default=0, metavar='PORT', type=int, # help="Terminal Socket Server at Port Number") gg.add_argument("-N", "--news", dest="news", default='', metavar="PATH", help="News from File") gg.add_argument("-C", "--IRC", dest="irc", default='', metavar="CHANNEL", help="IRC Client") gg.add_argument("-R", "--REST", dest="rest", default='', metavar="TEMPLATE", help="REST Client") gg.add_argument("-Z", "--eliza", dest="eliza", default=False, action="store_true", help="Eliza chat bot") gd = parser.add_argument_group("Debug") gd.add_argument("-L", "--log", dest="log", default='', metavar="FILE", help="Log to File") gd.add_argument("-d", "--debug", dest="debug", default=2, metavar='LEVEL', type=int, help="Debug level") parser.add_argument("-c", "--config", dest="cnf", default='txConfig.json', metavar="FILE", help="Load Config File (JSON)") parser.add_argument( "-k", "--id", "--KG", dest="wru_id", default='', metavar="ID", help= "Set the ID of the Telex Device. Leave empty to use the Hardware ID") #parser.add_argument("-m", "--mode", # dest="mode", default='', metavar="MODE", # help="Set the mode of the Telex Device. e.g. TW39, TWM, V.10") parser.add_argument("-q", "--quiet", dest="verbose", default=True, action="store_false", help="don't print status messages to stdout") parser.add_argument( "-s", "--save", dest="save", default=False, action="store_true", help="Save command line args to config file (txConfig.json)") ARGS = parser.parse_args() try: with open(ARGS.cnf, 'r') as fp: CFG = json.load(fp) except: CFG = {} if not CFG.get('devices', None): CFG['devices'] = {} devices = CFG['devices'] if ARGS.screen: devices['screen'] = {'type': 'screen', 'enable': True} if ARGS.CH340: devices['CH340'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340.strip(), 'mode': '', 'baudrate': 50, 'loopback': True } if ARGS.CH340_TW39: devices['CH340_TW39'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340_TW39.strip(), 'mode': 'TW39', 'baudrate': 50, 'loopback': True } if ARGS.CH340_TWM: devices['CH340_TWM'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340_TWM.strip(), 'mode': 'TWM', 'baudrate': 50, 'loopback': True } if ARGS.CH340_V10: devices['CH340_V10'] = { 'type': 'CH340TTY', 'enable': True, 'portname': ARGS.CH340_V10.strip(), 'mode': 'V10', 'baudrate': 50, 'loopback': False } if ARGS.RPiTTY: devices['RPiTTY'] = { 'type': 'RPiTTY', 'enable': True, 'pin_txd': 17, 'pin_rxd': 27, 'pin_fsg_ns': 6, 'pin_rel': 22, 'pin_oin': 10, 'pin_opt': 9, 'pin_dir': 11, 'pin_sta': 23, 'baudrate': 50, 'inv_rxd': False, 'uscoding': False, 'loopback': True, } if ARGS.ED1000: devices['ED1000'] = { 'type': 'ED1000', 'enable': True, 'send_f0': 500, 'send_f1': 700, 'recv_f0': 2250, 'recv_f1': 3150, 'baudrate': 50, 'devindex': None, 'zcarrier': False, } #if ARGS.telnet: # devices['telnet'] = {'type': 'telnet', 'enable': True, 'port': ARGS.telnet} if ARGS.itelex >= 0: devices['i-Telex'] = { 'type': 'i-Telex', 'enable': True, 'port': ARGS.itelex } if ARGS.news: devices['news'] = { 'type': 'news', 'enable': True, 'newspath': ARGS.news.strip() } if ARGS.irc: devices['IRC'] = { 'type': 'IRC', 'enable': True, 'channel': ARGS.irc.strip() } if ARGS.rest: devices['REST'] = { 'type': 'REST', 'enable': True, 'template': ARGS.rest.strip() } if ARGS.eliza: devices['eliza'] = {'type': 'eliza', 'enable': True} if ARGS.log: devices['log'] = { 'type': 'log', 'enable': True, 'filename': ARGS.log.strip() } CFG['verbose'] = ARGS.verbose wru_id = ARGS.wru_id.strip().upper() if wru_id: CFG['wru_id'] = wru_id #mode = ARGS.mode.strip() #if mode: # CFG['mode'] = mode CFG['debug'] = ARGS.debug log.set_log_level(ARGS.debug) if ARGS.save: with open(ARGS.cnf, 'w') as fp: json.dump(CFG, fp, indent=2)
#!/usr/bin/env python import constants.log_level import log import sys from main import main if not sys.version_info.major == 3 or (sys.version_info.major == 3 and sys.version_info.minor < 7): print('This software requires Python 3 from the version 3.6 or above.') # Still in the initial phase... log.set_log_level(constants.log_level.LogLevel.DEBUG) main()