How to use the pywws.storage.pywws_context function in pywws

To help you get started, we’ve selected a few pywws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jim-easterbrook / pywws / src / pywws / totwitter.py View on Github external
import argparse
    import inspect
    if argv is None:
        argv = sys.argv
    docstring = inspect.getdoc(sys.modules[__name__]).split('\n\n')
    parser = argparse.ArgumentParser(
        description=docstring[0], epilog=docstring[1])
    parser.add_argument('-r', '--register', action='store_true',
                        help='authorise pywws to post to your account')
    parser.add_argument('-v', '--verbose', action='count',
                        help='increase amount of reassuring messages')
    parser.add_argument('data_dir', help='root directory of the weather data')
    parser.add_argument('file', nargs='*', help='file to be uploaded')
    args = parser.parse_args(argv[1:])
    pywws.logger.setup_handler(args.verbose or 0)
    with pywws.storage.pywws_context(args.data_dir) as context:
        if args.register:
            twitter_auth(context.params)
            context.flush()
            return 0
        uploader = ToTwitter(context)
        for file in args.file:
            uploader.upload_file(file)
        uploader.stop()
    return 0
github jim-easterbrook / pywws / src / pywws / logdata.py View on Github external
print(__usage__.strip())
            return 0
        elif o in ('-c', '--clear'):
            clear = True
        elif o in ('-s', '--sync'):
            sync = int(a)
        elif o in ('-v', '--verbose'):
            verbose += 1
    # check arguments
    if len(args) != 1:
        print('Error: 1 argument required\n', file=sys.stderr)
        print(__usage__.strip(), file=sys.stderr)
        return 2
    pywws.logger.setup_handler(verbose)
    root_dir = args[0]
    with pywws.storage.pywws_context(root_dir) as context:
        DataLogger(context).log_data(sync=sync, clear=clear)
github jim-easterbrook / pywws / src / pywws / hourly.py View on Github external
def hourly(data_dir):
    with pywws.storage.pywws_context(data_dir) as context:
        # localise application
        pywws.localisation.set_application_language(context.params)
        # get weather station data
        pywws.logdata.DataLogger(context).log_data()
        # do the processing
        pywws.process.process_data(context)
        # do tasks
        pywws.regulartasks.RegularTasks(context).do_tasks()
    return 0