def main(): parser = argparse.ArgumentParser() parser.add_argument('--host', default='0.0.0.0') parser.add_argument('--port', default='39999', type=int) parser.add_argument('--live', action='store_true', help='Autoupdate the server with code changes') parser.add_argument('--debug', action='store_true', help='Print tracebacks on errors') options = parser.parse_args() bottle.debug(options.debug) app.start(host=options.host, port=options.port, reloader=options.live)
def main(): parser = argparse.ArgumentParser( description="query and visualization api tool for nidm results, workflow, and experiments") parser.add_argument("--ttl", help="List of comma separated ttl files to parse.", type=str) try: args = parser.parse_args() except: parser.print_help() sys.exit(0) #TODO: We will have logic here to serve API vs do some other functions, right now just serve API start()
def start_server(): # some prelimenary setup app.FULLNAME = os.path.normpath(os.path.abspath(__file__)) app.NAME = os.path.basename(app.FULLNAME) app.PROG_DIR = os.path.dirname(app.FULLNAME) app.DATA_DIR = app.PROG_DIR app.ARGS = sys.argv[1:] app.CREATEPID = False print "SofaSpud has started" app.start() sys.exit()
def start_server(): # some prelimenary setup app.FULLNAME = os.path.normpath(os.path.abspath(__file__)) app.NAME = os.path.basename(app.FULLNAME) app.PROG_DIR = os.path.dirname(app.FULLNAME) app.DATA_DIR = app.PROG_DIR app.ARGS = sys.argv[1:] app.CREATEPID = False print "SofaSpud has started" app.start() sys.exit();
def main(): # start mesh network mesh.start() # register pipes mesh.net_add_pipe('update', pipe_update) mesh.net_add_pipe('startapp', pipe_startapp) mesh.net_add_pipe('stopapp', pipe_stopapp) mesh.net_add_pipe('reset', pipe_reset) # execute application try: app.start() except Exception, e: log.warning('APP: ' + str(e))
def test_start(self): """test start function""" MOCKSESSION = UnifiedAlchemyMagicMock() with mock.patch("app.db.session", MOCKSESSION): with mock.patch("flask.render_template", mock_render): response = start() self.assertEqual(response, "Successfully rendered index.html")
def add_contact(): os.system("clear") # create temporary dictionary to store user details user_details = {} # get contact details user_details["first_name"] = input("First name: ").lower() user_details["surname"] = input("Surname: ").lower() user_details["email"] = input("Email: ").lower() user_details["phone_number"] = input("Phone number: ") user_details["address"] = input("Address: ").lower() # write details to file with open(utils.CONTACTS_DATABASE, "a+") as f: os.system("clear") # convert dictionary to JSON f.write(json.dumps(user_details) + "\n") # close file f.close() # inform user of success print(f"\n\n{utils.Colors.GREEN}Contact added successfully!{utils.Colors.END}\n\n") time.sleep(1.5) # return to main menu os.system("clear") return app.start()
def pipe_update(data): log.info('MAIN: Update requested') # check if the received file is valid try: compile(data, '<string>', 'exec') except: log.error('UPDATE: Application is invalid') app.start() return # stop mesh network try: mesh.stop() except Exception, e: log.warning('MESH: ' + str(e))
def main(): parser = argparse.ArgumentParser( description= "query and visualization api tool for nidm results, workflow, and experiments" ) parser.add_argument("--ttl", help="List of comma separated ttl files to parse.", type=str) try: args = parser.parse_args() except: parser.print_help() sys.exit(0) #TODO: We will have logic here to serve API vs do some other functions, right now just serve API start()
def main(): opts = get_config() logger.info("Preparing for data retrieval") data_download = DataDownload(opts.tempdir) data_download.add_download( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv", "covid19_confirmed.csv") data_download.add_download( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv", "covid19_deaths.csv") data_download.add_download( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv", "covid19_recovered.csv") data_download.add_download( "https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2019_TotalPopulationBySex.csv", "total_population_data.csv") data_file_paths = data_download.download_all() data = {} for file_path in data_file_paths: if file_path.endswith('covid19_confirmed.csv'): data['infected'] = file_path elif file_path.endswith('covid19_deaths.csv'): data['dead'] = file_path elif file_path.endswith('covid19_recovered.csv'): data['recovered'] = file_path elif file_path.endswith('total_population_data.csv'): data['population'] = file_path logger.info('Parsing COVID-19 data') data_parser = coviddata.COVIDDataParser(data['infected'], data['recovered'], data['dead']) covid_data = data_parser.parse() logger.info('Parsing population data') population_data = populationdata.PopulationDataParser( data['population']).parse() population_data.add_country_aliases('United States of America', 'US', 'USA') population_data.add_country_aliases('Dem. People\'s Republic of Korea', 'North Korea', 'Korea, North') population_data.add_country_aliases('Republic of Korea', 'South Korea', 'Korea, South') app.set_data(covid_data, population_data) app.create() server = app.start() options = { 'bind': '%s:%s' % (opts.listen, opts.port), 'workers': opts.workers } StandaloneApplication(server, options).run()
def init(): try: db_connection.test_connection() db_connection.create_tables() except Exception as e: logger.error(e) raise e logger.info("Application initialized") return application.start()
def _post_fork(server=None, w=None): _config_logging() start()
def entrenamiento_service(): start(token) result = "Envio de imagen: OK" print(result) return jsonify(result)
from app import db, start print("Importing db...") db.create_all(app=start()) print("Created database!")
def main(): app.start()
def main(): # start app app.start()
def main(): selected_packages = ask_user() start(selected_packages)
import app app.start(debug=True)
#newname from app import (start, App) app = App() @app.route('/') def route_index(): return app.response.send('Hello, World!') start(app, __name__)
'tap': lambda dev, observer, env, attr: tap(dev, attr['x'], attr['y']), 'longclick': lambda dev, observer, env, attr: longclick(dev, attr['x'], attr['y']), 'back': lambda dev, observer, env, attr: back(dev), 'enter': lambda dev, observer, env, attr: enter(dev), 'home': lambda dev, observer, env, attr: home(dev), 'swipe': lambda dev, observer, env, attr: swipe(dev, attr['x1'], attr['y1'], attr[ 'x2'], attr['y2']), # app 'start': lambda dev, observer, env, attr: app.start(dev, attr['name']), 'stop': lambda dev, observer, env, attr: app.stop(dev, attr['name']), 'clear': lambda dev, observer, env, attr: app.clear(dev, attr['name']), 'waitact': lambda dev, observer, env, attr: app.waitact(dev, attr['name']), 'wait': lambda dev, observer, env, attr: wait(dev, attr['time']), 'waitfor': lambda dev, observer, env, attr: waitfor(dev, attr['method'], attr[ 'value'], observer, env), 'waitready': lambda dev, observer, env, attr: waitready(dev, observer), 'waitidle': lambda dev, observer, env, attr: waitidle(dev),
def test_init(self, mock_print): with patch('app.game.game.input', side_effect=('y', 'y', 'y', 'y', 'y')): start()
from app import start if __name__ == '__main__': start()
# logging from logging import getLogger, DEBUG, WARNING log_initializer.setFmt() log_initializer.setRootLevel(WARNING) logger = getLogger(__name__) logger.setLevel(DEBUG) app.logger.setLevel(DEBUG) if __name__ == '__main__': # IO queue update_queue = multiprocessing.Queue() response_queue = multiprocessing.Queue() # Start server app.start(update_queue, response_queue) # Main process try: while True: # Wait for browser inputs data = update_queue.get() if 'range' in data: val = data['range'] logger.info('Range input event ({})'.format(val)) message = 'Response: Range is changed ({})'.format(val) elif 'button' in data: logger.info('Button event') message = 'Response: Button clicked' else:
#Testing tello # TelloDrone = unidrone.drone(droneType=2) # TelloDrone.takeOff() # TelloDrone.Forward(20) # TelloDrone.Rollright(10) # TelloDrone.Land() # Testing codrone # codrone = unidrone.drone(droneType=1) # codrone.takeOff(5) # codrone.Forward(50) # codrone.Rollright(30) # codrone.Land() file_name = 'command.txt' tellodrone = unidrone.Tello() startdrone = app.start(file_name) tellodrone.__init__() tellodrone.send_command() tellodrone.add_response() tellodrone._receive_thread() app.start(file_name) # if droneT == 'TelloDrone': # Tello=drone(droneType=2) # yaw_direction = "cw" # # Put Tello into command mode # send("command", 3) # # Send the takeoff command # send("takeoff", 5)
import app if __name__ == '__main__': app.start()
def list_contacts(): os.system("clear") print("\nList contacts by\n") print("1. First name (Ascending)") print("2. First name (Descending)") print("3. Surname (Ascending)") print("4. Surname (Descending)\n") print("0. Return\n") # all the possible options a user can take available_options = {"0", "1", "2", "3", "4"} # get user input user_input = input(utils.user_input_str) # validate user input if user_input not in available_options: return utils.invalid_input(list_contacts) # convert user input into an integer user_input = int(user_input) # user wants to go back if user_input == 0: return app.start() os.system("clear") # temporary dictionary that stores all the # contacts contained in the text file users_dictionary = {} # open contacts text file (database) with open(utils.CONTACTS_DATABASE, "r") as f: # read first line in the database and store its content in a variable user_details = f.readline() # loop through all users stored in the file while user_details: # convert current user string into a dictionary user = json.loads(user_details) # append user to users dictionary if user_input == 1 or user_input == 2: users_dictionary[ f"{user['first_name']}_{user['surname']}"] = user # append user to users dictionary if user_input == 3 or user_input == 4: users_dictionary[ f"{user['surname']}_{user['first_name']}"] = user # get the next user user_details = f.readline() # close file after operation f.close() # sort contacts in ascending order if user_input == 1 or user_input == 3: for user in sorted(users_dictionary, reverse=False): utils.print_contact_details(users_dictionary[user]) # sort contacts in descending order if user_input == 2 or user_input == 4: for user in sorted(users_dictionary, reverse=True): utils.print_contact_details(users_dictionary[user]) # print number of existing contacts print(f"\nCONTACTS: {utils.number_of_entries(users_dictionary)}") # call to action utils.press_enter()
def test_if_init_works(self, mock_input, mock_print, mock_sleep): start()
#! /usr/bin/env python # -*- coding: utf-8 -*- # # RegexMate: A Visual Regular Expression Test/Evaluation tool # # @author: Sreejith K <*****@*****.**> # Created on 29th June 2013 # # Licensed under MIT license. Refer COPYING for more info. import app if __name__ == '__main__': app.start()
def search_contact(): os.system("clear") print("\nSearch contact by\n") print("1. First name") print("2. Email address\n") print("0. Return\n") # all the possible options a user can take available_options = {"0", "1", "2"} # get user input user_input = input(utils.user_input_str).lower() # validate user input if user_input not in available_options: return utils.invalid_input(search_contact) # convert user input into an integer user_input = int(user_input) # user wants to go back if user_input == 0: return app.start() # user wants to search by first name if user_input == 1: os.system("clear") print("\nEnter contact's first name\n") print("0. Return\n") search_query = "first_name" user_input = input(utils.user_input_str) # user wants to go back if user_input == "0": return search_contact() # user wants to search by email address if user_input == 2: os.system("clear") print("\nEnter contact's email\n") print("0. Return\n") search_query = "email" user_input = input(utils.user_input_str) # user wants to go back if user_input == "0": return search_contact() # search user in database with open(utils.CONTACTS_DATABASE, "r") as f: os.system("clear") # read first line in the database and store its content in a variable user_details = f.readline() # loop through all users while user_details: # convert current user data into a dictionary user = json.loads(user_details) # check if user matches search query if user_input == user[search_query]: utils.print_contact_details(user) # get the next user user_details = f.readline() # close file f.close() # call to action utils.press_enter()
def handle(event, context): return app.start(app.getConfig())
def pipe_startapp(data): log.info('MAIN: Application start requested') app.start()
def press_enter(): input(f"\n{Colors.GREEN}Press ENTER to return... {Colors.END}") os.system("clear") return app.start()
from app import start app = start() if __name__ == '__main__': app.run(host="0.0.0.0", debug=True)
def test_app_start_log(caplog): start() assert "Starting" in caplog.text