示例#1
0
def run_plugins():
    logging.debug('run_plugins')
    best_location = location.get_matching_config(config)
    logging.info('Best location: ' + best_location['name'])
    plugins_folder = os.path.expanduser(config.dynstatus['plugins_path'])
    logging.debug('Plugins path: ' + plugins_folder)
    sys.path.append(plugins_folder)
    for plugin in config.dynstatus['plugins']:
        try:
            plugin = __import__(plugin)
            plugin.run(best_location)
        except:
            pass
示例#2
0
def run_plugins():
    logging.debug('run_plugins')
    best_location = location.get_matching_config(config)
    best_location = add_global_settings(best_location)
    plugins_folder = os.path.expanduser(config.dynstatus['plugins_path'])
    logging.debug('Plugins path: ' + plugins_folder)
    sys.path.append(plugins_folder)
    for plugin in config.dynstatus['plugins']:
        try:
            plugin = __import__(plugin)
            plugin.run(best_location)
        except:
            pass
示例#3
0
def run_plugins():
    logging.debug("run_plugins")
    best_location = location.get_matching_config(config)
    best_location = add_global_settings(best_location)
    plugins_folder = os.path.expanduser(config.dynstatus["plugins_path"])
    logging.debug("Plugins path: " + plugins_folder)
    sys.path.append(plugins_folder)
    for plugin in config.dynstatus["plugins"]:
        try:
            plugin = __import__(plugin)
            plugin.run(best_location)
        except:
            pass
示例#4
0
def print_help():
    parser.print_help()


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Dynstatus tries to pinpoint your location based on your network configuration (WLAN, IP, ...) and enables you to run code to react to changes.')
    parser.add_argument('-d','--daemon',action="store_true",dest="daemon",help='Dynstatus will fork to background and detect your location and run your plugins periodically. The interval is configured in the config.py of dynstatus.',required=False,default=False)
    parser.add_argument('-g','--get', help='Dynstatus can give you status information without running the plugins. You can ask for every location setting of your config.py.',default='ssid',required=False)
    args = parser.parse_args()

    logging.basicConfig(format='%(asctime)s: (%(levelname)s) %(message)s', datefmt='%d.%m.%Y %H:%M:%S', level=logging.DEBUG)
    logging.debug('=============================================')
    logging.debug('dynstatus v0.1')
    logging.debug('Developed by Max Rosin <*****@*****.**>')
    logging.debug('=============================================')
    setup_configuration()

    # argparse
    if len(sys.argv) <= 1:
        run_plugins()
    elif args.daemon:
        run_daemon()
    elif args.get:
        best_location = location.get_matching_config(config)
        if args.get in best_location:
            print(best_location[args.get])
        else:
            print('Unknown value.')
    else:
        print_help()
示例#5
0
    args = parser.parse_args()

    loglevel = 'INFO'
    if args.verbose:
        loglevel = 'DEBUG'

    logging.basicConfig(format='%(asctime)s (%(levelname)s) %(message)s',
                        datefmt='%H:%M:%S',
                        level=loglevel)
    #logging.basicConfig(filename='log.txt', level=loglevel)
    logging.debug('=' * 45)
    logging.debug('dynstatus v0.1')
    logging.debug('Developed by Max Rosin <*****@*****.**>')
    logging.debug('=' * 45)
    setup_configuration()

    # argparse
    if not (args.daemon or args.get):
        run_plugins()
    elif args.daemon:
        run_daemon()
    elif args.get:
        best_location = location.get_matching_config(config)
        if args.get in best_location:
            logging.debug('{}: {}'.format(args.get, best_location[args.get]))
            print(best_location[args.get])
        else:
            logging.error('Unknown value: {}'.format(args.get))
    else:
        print_help()