def main(): """ Main entry point """ # Create logs directory if not present Path('logs').mkdir(parents=True, exist_ok=True) # Start logger app_name = __file__.split('.')[0] logger.start_logger(app_name) module_logger = logging.getLogger( '{app_name}.controller'.format(app_name=app_name)) module_logger.info('<<<<< Starting >>>>>') # command line to execute: # cat user_inputs.txt | python controller.py read_obj = ReadInputs(module_logger) # read patterns read_obj.read_patterns() # read and process paths result = read_obj.process_paths() for res in result: module_logger.info(res) print(res) module_logger.info('<<<<< Done >>>>>')
def main(): # Start logger app_name = __file__.split('.')[0] logger.start_logger(app_name) module_logger = logging.getLogger('{app_name}.controller'.format(app_name=app_name)) module_logger.info('<<<<< Starting >>>>>') # get command line args cmd_line_args = cmd_line_parse() if cmd_line_args.airlines: obj = GetAirlines(module_logger) obj.run() if cmd_line_args.airports: obj = AirportImporter(module_logger) obj.run() if cmd_line_args.flights: icao_codes = cmd_line_args.flights.split(',') obj = FlightInfo(module_logger, icao_codes) obj.run() module_logger.info('<<<<< Done >>>>>')
def create_app(is_main=False): """ Main asynchronous program. """ start_logger() log = logging.getLogger(__name__) parser = configargparse.ArgParser( default_config_files=["~/.virgin-monitor"]) parser.add("-c", "--my-config", is_config_file=True, help="config file path") parser.add("-p", "--db-path", env_var="DB_PATH", default="~/virgin-monitor.sqlite", help="database file path") parser.add("-i", "--interval", env_var="POLL_INTERVAL", default=10, help="poll interval (seconds)", type=int) parser.add("-u", "--url", env_var="URL", default=ENDPOINT_URL, help="Endpoint URL") if is_main: argv = sys.argv[1:] else: # Run with adev or something argv = sys.argv[2:] args = parser.parse_args(argv) db_path = os.path.expanduser(args.db_path) http = aiohttp.ClientSession() app = web.Application() app.update( # pylint: disable=no-member args=args, http=http, sql3_connect=lambda: aiosqlite.connect(db_path, isolation_level=None), log=log) app.on_startup.append(start_monitor) app.on_cleanup.append(cleanup) # Web routes app.add_routes([web.static('/js', "web/js")]) app.add_routes([web.static('/css', "web/css")]) app.router.add_get('/', render_index) app.router.add_get('/data', render_data) return app
def main(): # Start logger app_name = __file__.split('.')[0] logger.start_logger(app_name) module_logger = logging.getLogger('{app_name}.controller'.format(app_name=app_name)) module_logger.info('===== Starting =====') # start the game holdings_loop()
def start_logger(app_name, calling_function): """ Create logging directory along with starting module logger :param calling_function Name of calling function - used for log file name """ # Create logs directory if not present Path('logs').mkdir(parents=True, exist_ok=True) # Start logger logger.start_logger(app_name) module_logger = logging.getLogger('{app_name}.{calling_function}'.\ format(app_name=app_name, calling_function=calling_function)) return module_logger
def main(): # Start logger app_name = __file__.split('.')[0] logger.start_logger(app_name) module_logger = logging.getLogger('{app_name}.controller'.format(app_name=app_name)) module_logger.info('===== Starting =====') # db name db_name = 'debit.db' # db_name = ':memory:' # start the trading debit_loop(db_name, module_logger) module_logger.info('===== Done =====')
def main(): # Start logger app_name = __file__.split('.')[0] logger.start_logger(app_name) module_logger = logging.getLogger( '{app_name}.controller'.format(app_name=app_name)) module_logger.info('<<<<< Starting >>>>>') # get command line args cmd_line_args = cmd_line_parse() # remove leading and trailing spaces from each input city argument tmp_city_list = cmd_line_args.cities.split(',') city_list = [x.strip(' ') for x in tmp_city_list] # get valid categories valid_categories = set() for cat in categories: valid_categories.add(cat['id']) category_list = None if cmd_line_args.categories: input_categories = set(cmd_line_args.categories.split(',')) tmp_category_list = list( valid_categories.intersection(input_categories)) category_list = [x.strip(' ') for x in tmp_category_list] # display input cities and categories msg = 'Cities: {0}'.format(','.join(city_list)) module_logger.info(msg) if category_list: msg = 'Categories: {0}'.format(','.join(category_list)) else: msg = 'Categories: All' module_logger.info(msg) event_obj = GetEvent(city_list, category_list, module_logger) event_obj.run() module_logger.info('<<<<< Done >>>>>')
import os from logger import start_logger from databasehandler import start_dbhandler TOKEN = os.environ.get('BOT_TOKEN', None) PORT = int(os.environ.get("PORT", "8443")) HEROKU_APP_NAME = os.environ.get('HEROKU_APP_NAME', None) PASS_HASH = os.environ.get('PASS_HASH', None) # only enable pooling for testing on local machine, Heroku will only work on webhook method POOLING = os.environ.get('POOLING', False) OPEN_CHANNEL_USERNAME = os.environ.get('OPEN_CHANNEL_USERNAME', None) # Database connection urls USER_DB = os.environ.get('USER_DB', None) AUDIO_DB = os.environ.get('AUDIO_DB', None) # start the logger LOGGER = start_logger(user_db=USER_DB) DBHANDLER = start_dbhandler(audio_db=AUDIO_DB)
import os dir_src = os.path.dirname(os.path.abspath(__file__)) print dir_src dir_main = os.path.split(dir_src)[0] print dir_main dir_log = os.path.join(dir_main, 'logs') from optics import * try: os.makedirs(dir_log) except OSError as e: pass import logger logger.start_logger(os.path.join(dir_log, 'work.log'))