示例#1
0
def main():
    parser = ParserWithConfig(CONFIG_PATH)
    parser.add_default_option(
        "-a", "--address",
        help="address to listen on",
        dest="host"
        )
    parser.add_default_option("-p", "--port",
        help="port to listen on",
        dest="port",
        type="int"
        )
    parser.add_default_option("-P", "--password",
        help="Network password",
        dest='password'
        )

    # Debug Options
    parser.add_option('-v', '--verbose',
        dest='verbose',
        default=0,
        action='count',
        )
    parser.add_option("-d", "--debug",
        help="Print raw growl packets",
        dest='debug',
        action="store_true",
        default=False
        )
    parser.add_option("-q", "--quiet",
        help="Quiet mode",
        dest='debug',
        action="store_false"
        )

    (options, args) = parser.parse_args()
    options.verbose = logging.WARNING - options.verbose * 10

    try:
        import setproctitle
        setproctitle.setproctitle('regrowl-server')
    except ImportError:
        pass

    logging.basicConfig(level=options.verbose,
        format="%(name)-25s %(levelname)s:%(message)s")

    server = GNTPServer(options, parser.config)
    server.run()
示例#2
0
def main():
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "-c",
        "--config",
        help="Config File",
        default=os.path.expanduser('~/.regrowl'),
    )

    args, _ = parser.parse_known_args()
    config = ReloadableConfig()
    config.read(args.config)

    # Redefine our parser so that -h works with the entire
    # list of options
    parser = argparse.ArgumentParser(parents=[parser])
    parser.add_argument("-a",
                        "--address",
                        help="address to listen on",
                        dest="host",
                        default=config.get('regrowl.server', 'host',
                                           DEFAULTS['host']))

    parser.add_argument("-p",
                        "--port",
                        help="port to listen on",
                        dest="port",
                        type=int,
                        default=config.getint('regrowl.server', 'port',
                                              DEFAULTS['port']))

    parser.add_argument("-P",
                        "--password",
                        help="Network password",
                        dest='password',
                        default=config.get('regrowl.server', 'password',
                                           DEFAULTS['password']))

    # Debug Options
    parser.add_argument(
        '-v',
        '--verbose',
        dest='verbose',
        default=0,
        action='count',
    )

    parser.add_argument(
        "-r",
        "--reload",
        help="Auto reload config and bridges (Useful for development)",
        dest='reload',
        action="store_true",
        default=False,
    )

    parser.add_argument(
        "-t",
        "--test",
        help="Simple built-in test client (Useful for development)",
        choices=TEST_OPTIONS)

    options = parser.parse_args()
    options.verbose = logging.WARNING - options.verbose * 10

    if options.test:
        return test_client(config, options)

    try:
        import setproctitle
        setproctitle.setproctitle('regrowl-server')
    except ImportError:
        pass

    logging.basicConfig(level=options.verbose,
                        format="%(levelname)-7s %(name)-25s %(message)s")

    try:
        from raven.conf import setup_logging
        from raven.handlers.logging import SentryHandler
        setup_logging(
            SentryHandler(config.get('regrowl.server', 'sentry_dsn'),
                          level=logging.ERROR))
        logger.info('Enabled sentry')
    except (ImportError, ValueError):
        logger.warning('Error loading Sentry')

    server = GNTPServer(options, config)
    server.run()
示例#3
0
文件: cli.py 项目: kfdm/gntp-regrowl
def main():
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "-c", "--config",
        help="Config File",
        default=os.path.expanduser('~/.regrowl'),
    )

    args, _ = parser.parse_known_args()
    config = ReloadableConfig()
    config.read(args.config)

    # Redefine our parser so that -h works with the entire
    # list of options
    parser = argparse.ArgumentParser(parents=[parser])
    parser.add_argument(
        "-a",
        "--address",
        help="address to listen on",
        dest="host",
        default=config.get('regrowl.server', 'host', DEFAULTS['host'])
    )

    parser.add_argument(
        "-p",
        "--port",
        help="port to listen on",
        dest="port",
        type=int,
        default=config.getint('regrowl.server', 'port', DEFAULTS['port'])
    )

    parser.add_argument(
        "-P",
        "--password",
        help="Network password",
        dest='password',
        default=config.get('regrowl.server', 'password', DEFAULTS['password'])
    )

    # Debug Options
    parser.add_argument(
        '-v',
        '--verbose',
        dest='verbose',
        default=0,
        action='count',
    )

    parser.add_argument(
        "-r",
        "--reload",
        help="Auto reload config and bridges (Useful for development)",
        dest='reload',
        action="store_true",
        default=False,
    )

    parser.add_argument(
        "-t",
        "--test",
        help="Simple built-in test client (Useful for development)",
        choices=TEST_OPTIONS
    )

    options = parser.parse_args()
    options.verbose = logging.WARNING - options.verbose * 10

    if options.test:
        return test_client(config, options)

    try:
        import setproctitle
        setproctitle.setproctitle('regrowl-server')
    except ImportError:
        pass

    logging.basicConfig(
        level=options.verbose,
        format="%(asctime)s %(levelname)-7s %(name)-25s %(message)s"
    )

    try:
        from raven.conf import setup_logging
        from raven.handlers.logging import SentryHandler
        setup_logging(
            SentryHandler(config.get('regrowl.server', 'sentry_dsn'), level=logging.ERROR)
        )
        logger.info('Enabled sentry')
    except (ImportError, ValueError):
        logger.warning('Error loading Sentry')

    server = GNTPServer(options, config)
    server.run()
示例#4
0
def main():
    conf_parser = ParserWithConfig(config=CONFIG_PATH, add_help=False)
    conf_parser.add_argument(
        '-c', '--config',
        help='path to a regrowl configuration file',
        dest='config_path'
        )
    
    (options, remaining_args) = conf_parser.parse_known_args()
    if options.config_path is not None:
        conf_parser.config.read(options.config_path)
    else:
        options.config_path = CONFIG_PATH

    parser = ParserWithConfig(
        config=options.config_path, 
        parents=[conf_parser]
        )

    parser.add_default_option(
        '-a', '--address',
        help='address to listen on',
        dest='host',
        section='regrowl.server'
        )
    parser.add_default_option(
        '-p', '--port',
        help='port to listen on',
        dest='port',
        type=int,
        section='regrowl.server'
        )
    parser.add_default_option(
        '-P', '--password',
        help='Network password',
        dest='password',
        section='regrowl.server'
        )

    # Debug Options
    parser.add_argument(
        '-v', '--verbose',
        dest='verbose',
        default=0,
        action='count',
        )
    parser.add_argument(
        '-d', '--debug',
        help='Print raw growl packets',
        dest='debug',
        action='store_true',
        default=False
        )
    parser.add_argument(
        '-q', '--quiet',
        help='Quiet mode',
        dest='debug',
        action='store_false'
        )

    (options, args) = parser.parse_known_args(remaining_args)
    options.verbose = logging.WARNING - options.verbose * 10
    if options.debug:
        options.verbose = logging.DEBUG

    try:
        import setproctitle
        setproctitle.setproctitle('regrowl-server')
    except ImportError:
        pass

    logging.basicConfig(level=options.verbose,
        format="%(name)-25s %(levelname)s:%(message)s")

    server = GNTPServer(options, parser.config)
    server.run()
示例#5
0
def main():
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "-c", "--config",
        help="Config File",
        default=os.path.expanduser('~/.regrowl'),
    )

    args, _ = parser.parse_known_args()
    config = ReloadableConfig(DEFAULTS)
    config.read(args.config)

    # Redefine our parser so that -h works with the entire
    # list of options
    parser = argparse.ArgumentParser(parents=[parser])
    parser.add_argument(
        "-a",
        "--address",
        help="address to listen on",
        dest="host",
        default=config.get('regrowl.server', 'host')
    )

    parser.add_argument(
        "-p",
        "--port",
        help="port to listen on",
        dest="port",
        type=int,
        default=config.getint('regrowl.server', 'port')
    )

    parser.add_argument(
        "-P",
        "--password",
        help="Network password",
        dest='password',
        default=config.get('regrowl.server', 'password')
    )

    # Debug Options
    parser.add_argument(
        '-v',
        '--verbose',
        dest='verbose',
        default=0,
        action='count',
    )

    parser.add_argument(
        "-r",
        "--reload",
        help="Auto reload config and bridges (Useful for development)",
        dest='reload',
        action="store_true",
        default=False,
    )

    options = parser.parse_args()
    options.verbose = logging.WARNING - options.verbose * 10

    try:
        import setproctitle
        setproctitle.setproctitle('regrowl-server')
    except ImportError:
        pass

    logging.basicConfig(
        level=options.verbose,
        format="%(name)-25s %(levelname)s:%(message)s"
    )

    server = GNTPServer(options, config)
    server.run()