def main(args): if args.month and args.week: print("Month and Week cannot be specified together.") exit(1) query = create_query(args.city, args.year, args.month, args.week) db.setup() with db.cursor() as cursor: get_data(cursor, query)
def main(): """ Iterate over all cities in ./cities, scrape and save their data to the database """ # the catch-all enterprise loop db.setup() for module in env.supported_cities().values(): try: scrape_city(module) except Exception as e: print("Failed to scrape '%s': %s" % (module.geodata.city.name, e)) print(traceback.format_exc())
def main(): log_path = os.path.join(env.APP_ROOT, "log", env.ENV + ".log") log_handler = RotatingFileHandler(log_path, maxBytes=1000000, backupCount=1) formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s ") log_handler.setFormatter(formatter) app.logger.addHandler(log_handler) app.logger.addHandler(logging.StreamHandler()) if not env.is_development(): app.logger.setLevel(logging.INFO) log_handler.setLevel(logging.INFO) db.setup() app.run(**env.SERVER_CONF._asdict())
def setUp(self): db.setup()