示例#1
0
                                   ['help', 'catchup', 'verbose'])
    except getopt.error, msg:
        print >> sys.stderr, 'Error: %s\n' % msg
        print >> sys.stderr, __usage__.strip()
        return 1
    # process options
    catchup = False
    verbose = 0
    for o, a in opts:
        if o == '-h' or o == '--help':
            print __usage__.strip()
            return 0
        elif o == '-c' or o == '--catchup':
            catchup = True
        elif o == '-v' or o == '--verbose':
            verbose += 1
    # check arguments
    if len(args) != 2:
        print >> sys.stderr, "Error: 2 arguments required"
        print >> sys.stderr, __usage__.strip()
        return 2
    logger = ApplicationLogger(verbose)
    return ToService(DataStore.params(args[0]), DataStore.status(args[0]),
                     DataStore.calib_store(args[0]),
                     args[1]).Upload(catchup=catchup,
                                     ignore_last_update=not catchup)


if __name__ == "__main__":
    sys.exit(main())
示例#2
0
     return 1
 # check arguments
 if len(args) != 0:
     print >>sys.stderr, 'Error: no arguments allowed\n'
     print >>sys.stderr, __usage__.strip()
     return 2
 # process options
 verbose = 0
 for o, a in opts:
     if o in ('-h', '--help'):
         print __usage__.strip()
         return 0
     elif o in ('-v', '--verbose'):
         verbose += 1
 # do it!
 logger = ApplicationLogger(verbose)
 ws = WeatherStation.weather_station()
 fixed_block = ws.get_fixed_block()
 if not fixed_block:
     print "No valid data block found"
     return 3
 # loop
 ptr = ws.data_start
 total_count = 0
 bad_count = 0
 while True:
     if total_count % 1000 == 0:
         active = ws.current_pos()
     while True:
         ptr += 0x20
         if ptr >= 0x10000:
示例#3
0
        return 1
    # process options
    logfile = None
    verbose = 0
    for o, a in opts:
        if o in ('-h', '--help'):
            print __doc__.split('\n\n')[0]
            print usage
            return 0
        elif o in ('-l', '--log'):
            logfile = a
        elif o in ('-v', '--verbose'):
            verbose += 1
    # check arguments
    if len(args) != 1:
        print >> sys.stderr, 'Error: 1 argument required\n'
        print >> sys.stderr, usage
        return 2
    logger = ApplicationLogger(verbose, logfile)
    return LiveLog(args[0])


if __name__ == "__main__":
    logger = logging.getLogger('pywws')
    try:
        sys.exit(main())
    except KeyboardInterrupt:
        pass
    except Exception, e:
        logger.exception(str(e))
示例#4
0
     return 1
 # check arguments
 if len(args) != 0:
     print >> sys.stderr, 'Error: no arguments allowed\n'
     print >> sys.stderr, __usage__.strip()
     return 2
 # process options
 verbose = 0
 for o, a in opts:
     if o in ('-h', '--help'):
         print __usage__.strip()
         return 0
     elif o in ('-v', '--verbose'):
         verbose += 1
 # do it!
 logger = ApplicationLogger(verbose)
 ws = WeatherStation.weather_station()
 fixed_block = ws.get_fixed_block()
 if not fixed_block:
     print "No valid data block found"
     return 3
 # loop
 ptr = ws.data_start
 total_count = 0
 bad_count = 0
 while True:
     if total_count % 1000 == 0:
         active = ws.current_pos()
     while True:
         ptr += 0x20
         if ptr >= 0x10000:
示例#5
0
        argv = sys.argv
    try:
        opts, args = getopt.getopt(argv[1:], "h", ['help'])
    except getopt.error, msg:
        print >>sys.stderr, 'Error: %s\n' % msg
        print >>sys.stderr, __usage__.strip()
        return 1
    # process options
    for o, a in opts:
        if o == '-h' or o == '--help':
            print __usage__.strip()
            return 0
    # check arguments
    if len(args) != 4:
        print >>sys.stderr, 'Error: 4 arguments required\n'
        print >>sys.stderr, __usage__.strip()
        return 2
    logger = ApplicationLogger(2)
    params = DataStore.params(args[0])
    status = DataStore.status(args[0])
    Localisation.SetApplicationLanguage(params)
    return GraphPlotter(
        params, status,
        DataStore.calib_store(args[0]), DataStore.hourly_store(args[0]),
        DataStore.daily_store(args[0]), DataStore.monthly_store(args[0]),
        args[1]
        ).DoPlot(GraphFileReader(args[2]), args[3])

if __name__ == "__main__":
    sys.exit(main())
示例#6
0
        print >>sys.stderr, 'Error: %s\n' % msg
        print >>sys.stderr, __usage__.strip()
        return 1
    # process options
    logfile = None
    verbose = 0
    for o, a in opts:
        if o in ('-h', '--help'):
            print __usage__.strip()
            return 0
        elif o in ('-l', '--log'):
            logfile = a
        elif o in ('-v', '--verbose'):
            verbose += 1
    # check arguments
    if len(args) != 1:
        print >>sys.stderr, 'Error: 1 argument required\n'
        print >>sys.stderr, __usage__.strip()
        return 2
    logger = ApplicationLogger(verbose, logfile)
    return LiveLog(args[0])

if __name__ == "__main__":
    logger = logging.getLogger('pywws')
    try:
        sys.exit(main())
    except KeyboardInterrupt:
        pass
    except Exception, e:
        logger.exception(str(e))
示例#7
0
    # process options
    pid_file = '/run/lock/pywws.pid'
    verbose = 0
    for o, a in opts:
        if o in ('-h', '--help'):
            print __doc__.split('\n\n')[0]
            print usage
            return 0
        elif o in ('-p', '--pid'):
            pid_file = a
        elif o in ('-v', '--verbose'):
            verbose += 1
    # check arguments
    if len(args) != 3:
        print >> sys.stderr, 'Error: 3 arguments required\n'
        print >> sys.stderr, usage
        return 2
    logger = ApplicationLogger(verbose, args[1])
    runner = Runner(args[0], args[2], map(lambda x: x.stream, logger.handlers),
                    pid_file)
    try:
        runner.do_action()
    except Exception, ex:
        logger.exception(ex)
        return 3
    return 0


if __name__ == "__main__":
    sys.exit(main())
示例#8
0
     return 1
 # check arguments
 if len(args) != 0:
     print >> sys.stderr, "Error: no arguments allowed\n"
     print >> sys.stderr, __usage__.strip()
     return 2
 # process options
 verbose = 0
 for o, a in opts:
     if o in ("-h", "--help"):
         print __usage__.strip()
         return 0
     elif o in ("-v", "--verbose"):
         verbose += 1
 # do it!
 logger = ApplicationLogger(verbose)
 ws = WeatherStation.weather_station()
 fixed_block = ws.get_fixed_block()
 if not fixed_block:
     print "No valid data block found"
     return 3
 # loop
 ptr = ws.data_start
 total_count = 0
 bad_count = 0
 while True:
     if total_count % 1000 == 0:
         active = ws.current_pos()
     while True:
         ptr += 0x20
         if ptr >= 0x10000:
示例#9
0
        print >>sys.stderr, __usage__.strip()
        return 1
    # process options
    pid_file = '/run/lock/pywws.pid'
    verbose = 0
    for o, a in opts:
        if o in ('-h', '--help'):
            print __usage__.strip()
            return 0
        elif o in ('-p', '--pid'):
            pid_file = a
        elif o in ('-v', '--verbose'):
            verbose += 1
    # check arguments
    if len(args) != 3:
        print >>sys.stderr, 'Error: 3 arguments required\n'
        print >>sys.stderr, __usage__.strip()
        return 2
    logger = ApplicationLogger(verbose, args[1])
    runner = Runner(
        args[0], args[2], map(lambda x: x.stream, logger.handlers), pid_file)
    try:
        runner.do_action()
    except Exception, ex:
        logger.exception(ex)
        return 3
    return 0

if __name__ == "__main__":
    sys.exit(main())