Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
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())
Beispiel #4
0
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())
Beispiel #5
0
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()
Beispiel #7
0
 def setUp(self):
     db.setup()