def setUp(self): app_dir = os.path.dirname(__file__, ) rel_path = 'supplychainpy/data2.csv' abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path)) self.db_rs, app.config['DATABASE'] = tempfile.mkstemp() app.config['TESTING'] = True self.app = app.test_client() with app.app_context(): load_db(file=abs_file_path)
def main(): parser = argparse.ArgumentParser(description='Supplychainpy commandline interface a') parser.add_argument(dest='filenames', metavar='filename', nargs='?') parser.add_argument('-l', '--lau', dest='launch', action='store_true', help='launch supplychainpy reporting') parser.add_argument('-p', dest='process', action='store_true', help='process file and perform analysis/') parser.add_argument('-o', dest='outfile', action='store', help='output file') parser.add_argument('-v', dest='verbose', action='store_true', help='verbose mode') parser.add_argument('-db', dest='database', action='store', help='database engine uri e.g. ') parser.add_argument('-loc', dest='location', action='store', help='database path e.g. ') args = parser.parse_args() if args.verbose: print('filenames = {}'.format(args.filenames)) print('launch reports = {}'.format(args.launch)) print('process file = {}'.format(args.process)) print('database location = {}'.format(args.location)) if args.launch and args.process and args.filenames is not None and args.location is None: print(1) launch_load_report(args.filenames) elif args.launch and args.process and args.filenames is not None and args.location is not None: print(2) launch_load_report(args.filenames, args.location) elif args.launch and args.location is not None: print(3) launch_report(location=args.location) elif args.process and args.location is not None and args.filenames is not None: print(4) load_db(file=args.filenames, location=args.location) if args.filenames is None and False == args.process and False == args.launch and args.outfile is None: filename = input('path to "CSV" or "text" file... ') sys.stdout.flush()
def setUp(self): self.__dude = ChatBot() self.__SALUTATION_RESPONSES = ["hi", "hello", "how's tricks?"] app = Flask(__name__, instance_relative_config=True) PWD = os.path.abspath(os.curdir) i_c = IntegrationConfig i_c.SQLALCHEMY_DATABASE_URI ='sqlite:///{}/reporting.db'.format(PWD) app.config.from_object(i_c) app.config['DATABASE'] = PWD app.config['TESTING'] = True self.app = app.test_client() app_settings = { 'file': ABS_FILE_PATH['COMPLETE_CSV_SM'], 'currency': 'USD', 'database_path': PWD, } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) with app.app_context(): db.init_app(app) db.create_all() load_db(file=ABS_FILE_PATH['COMPLETE_CSV_SM'],location=PWD)
def main(): parser = argparse.ArgumentParser( description='Supplychainpy commandline interface a') parser.add_argument(dest='filenames', metavar='filename', nargs='?') parser.add_argument( '-l', '--launch', dest='launch', action='store_true', help='Launches supplychainpy reporting gui for setting \ port and launching the default browser.') parser.add_argument( '-lx', '--launch-console', dest='launch_console', action='store_true', help='Launches supplychainpy reporting in the default browser, \ without gui interface. Uses default port (5000) unless another port \ is specified. ') parser.add_argument( '-a', '--analyse', dest='analyse_file', action='store_true', help='Processes the file supplied as the first argument \ and performs analysis') parser.add_argument('-o', dest='outfile', action='store', help='output file') parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help='verbose mode') parser.add_argument('-db', dest='database', action='store', help='database engine uri e.g. ') parser.add_argument( '-cur', dest='currency', action='store', help='Sets the currency for the analysis. The currency should \ match the currency of the raw data. IMPORTANT: Currency \ conversion does not occur by setting this flag. The default \ currency is US Dollars (USD). ', default='USD') parser.add_argument('--host', dest='host', action='store', help='Sets the host for the server \ (defaults 127.0.0.1) ', default='127.0.0.1') parser.add_argument('--debug', dest='debug', action='store_true', help='Runs in debug mode (default : debug.INFO)') parser.add_argument('-loc', dest='location', action='store', help='database path e.g. ') parser.add_argument('-u', dest='user', action='store', help='user name ') parser.add_argument('-p', '--port', dest='port', action='store', help='port to use for local server e.g. 8080 \ (default: 5000)', default='5000') parser.add_argument('-c', dest='chat', action='store_true', help='chat to dash from the command line') args = parser.parse_args() if args.verbose: print('filenames = {}'.format(args.filenames)) print('launch reports = {}'.format(args.launch)) print('process file = {}'.format(args.analyse_file)) print('database location = {}'.format(args.location)) if args.debug: logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') if args.launch and args.analyse_file is None and args.filenames is not None and args.location: # -l -loc print(1) if args.currency is not None: currency = args.currency else: currency = 'USD' app_settings = deserialise_config(ABS_FILE_PATH_APPLICATION_CONFIG) app_settings['database_path'] = args.location app_settings['file'] = args.filenames app_settings['currency'] = currency serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) #d = _Orchestrate() #d.copy_file() #db_present = d.check_for_db() #if db_present: # create_management_db() launch_load_report(args.filenames, args.location) elif args.launch and args.analyse_file and args.filenames is not None and args.location is not None: # -a -loc -l print(2) if args.currency is not None: currency = args.currency else: currency = 'USD' app_settings = deserialise_config(ABS_FILE_PATH_APPLICATION_CONFIG) app_settings['database_path'] = args.location app_settings['file'] = args.filenames app_settings['currency'] = currency serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) #d = _Orchestrate() #d.copy_file() #db_present = d.check_for_db() #if db_present: # create_management_db() launch_load_report(args.filenames, args.location) elif args.launch and args.location is not None and args.host: # -l -loc --host print(3) app_settings = deserialise_config(ABS_FILE_PATH_APPLICATION_CONFIG) app_settings['database_path'] = args.location app_settings['port'] = args.port serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) launch_report(location=args.location, host=args.host, port=args.port) elif args.launch and args.analyse_file and args.filenames and args.location: # -a -l -loc print(4) if args.currency is not None: currency = args.currency else: currency = 'USD' app_settings = deserialise_config(ABS_FILE_PATH_APPLICATION_CONFIG) app_settings['database_path'] = args.location app_settings['file'] = args.filenames app_settings['currency'] = currency serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) #d = _Orchestrate() #d.copy_file() #db_present = d.check_for_db() #if db_present: # create_management_db() launch_load_report(args.filenames, args.location) launch_report(location=args.location, host=args.host, port=args.port) elif args.analyse_file and args.location is not None and args.filenames is not None and args.launch_console is None: # -a load_db(file=args.filenames, location=args.location) elif args.analyse_file and args.location and args.filenames and args.launch_console and args.port: # -a -loc --lx -p try: print(5) app_settings = { 'database_path': args.location, 'file': args.filenames, 'currency': args.currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) #d = _Orchestrate() #d.copy_file() #db_present = d.check_for_db() #if db_present: # create_management_db() load_db(file=args.filenames, location=args.location) launch_report_server(location=args.location, port=args.port, host=args.host) except OSError as e: print(e) elif args.location and args.launch_console and args.port and args.host: # -loc -lx -p --host try: print(6) app_settings = { 'database_path': args.location, 'host': args.host, 'currency': args.currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) launch_report_server(location=args.location, port=args.port, host=args.host) except OSError as e: print(e) elif args.analyse_file and args.location is not None and args.filenames is not None and args.launch_console is None and args.host: # -a -loc -lx --host print(7) app_settings = { 'database_path': args.location, 'host': args.host, 'currency': args.currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) launch_report_server(location=args.location, port=args.port, host=args.host) elif args.chat: msg = input("Enter message for Dash: ") while msg != 'q': dash = ChatBot() response = dash.chat_machine(message=msg) for i in response: print('Dash> ', i) msg = input("> ")
def main(): parser = argparse.ArgumentParser(description='Supplychainpy commandline interface a') parser.add_argument(dest='filenames', metavar='filename', nargs='?') parser.add_argument('-l', '--launch', dest='launch', action='store_true', help='Launches supplychainpy reporting gui for setting port and launching the default browser.') parser.add_argument('-lx', '--launch-console', dest='launch_console', action='store_true', help='Launches supplychainpy reporting in the default browser, without gui interface. Uses default port (5000) unless another port is specified. ') parser.add_argument('-a', '--analyse', dest='analyse_file', action='store_true', help='Processes the file supplied as the first argument and performs analysis') parser.add_argument('-o', dest='outfile', action='store', help='output file') parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help='verbose mode') parser.add_argument('-db', dest='database', action='store', help='database engine uri e.g. ') parser.add_argument('-cur', dest='currency', action='store', help='Sets the currency for the analysis. The currency should match the currency of the ' 'raw data. IMPORTANT: Currency conversion does not occur by setting this flag. ' 'The default currency is US Dollars (USD). ', default='USD') parser.add_argument('--host', dest='host', action='store', help='Sets the host for the server (defaults 127.0.0.1) ', default='127.0.0.1') parser.add_argument('-loc', dest='location', action='store', help='database path e.g. ') parser.add_argument('-u', dest='user', action='store', help='user name ') parser.add_argument('-p', '--port', dest='port', action='store', help='port to use for local server e.g. 8080 (default: 5000)', default='5000') args = parser.parse_args() if args.verbose: print('filenames = {}'.format(args.filenames)) print('launch reports = {}'.format(args.launch)) print('process file = {}'.format(args.analyse_file)) print('database location = {}'.format(args.location)) if args.launch and args.analyse_file and args.filenames is not None and args.location is None: print(1) launch_load_report(args.filenames) elif args.launch and args.analyse_file and args.filenames is not None and args.location is not None: print(2) if args.currency is not None: currency= args.currency else: currency = 'USD' app_settings = { 'database_path': args.location, 'file': args.filenames, 'currency': currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) #d = _Orchestrate() #d.copy_file() #db_present = d.check_for_db() #if db_present: # create_management_db() launch_load_report(args.filenames, args.location) elif args.launch and args.location is not None and args.host: print(3) app_settings = { 'database_path': args.location, 'host': args.host, 'currency': args.currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) launch_report(location=args.location, host=args.host, port=args.port) elif args.analyse_file and args.location is not None and args.filenames is not None and args.launch_console is None: print(4) load_db(file=args.filenames, location=args.location) elif args.analyse_file and args.location and args.filenames and args.launch_console and args.port: print(5) app_settings = { 'database_path': args.location, 'file': args.filenames, 'currency': args.currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) #d = _Orchestrate() #d.copy_file() #db_present = d.check_for_db() #if db_present: # create_management_db() load_db(file=args.filenames, location=args.location) launch_report_server(location=args.location,port=args.port, host=args.host) elif args.location and args.launch_console and args.port and args.host: print(6) app_settings = { 'database_path': args.location, 'host': args.host, 'currency': args.currency } serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG) launch_report_server(location=args.location,port=args.port, host=args.host)