当前位置: 首页>>代码示例>>Python>>正文


Python log.startLogging函数代码示例

本文整理汇总了Python中twisted.python.log.startLogging函数的典型用法代码示例。如果您正苦于以下问题:Python startLogging函数的具体用法?Python startLogging怎么用?Python startLogging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了startLogging函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: agent_main

def agent_main(collector):
    to_file(sys.stdout)
    startLogging(sys.stdout)
    return react(
        run_agent, [
            environ.get(
                "FLOCKER_CONFIGURATION_PATH",
                "/etc/flocker",
            ).decode("ascii"),
            environ.get(
                "CATALOG_FIREHOSE_PROTOCOL",
                DEFAULT_FIREHOSE_PROTOCOL,
            ).decode("ascii"),
            environ.get(
                "CATALOG_FIREHOSE_HOSTNAME",
                DEFAULT_FIREHOSE_HOSTNAME,
            ).decode("ascii"),
            int(
                environ.get(
                    "CATALOG_FIREHOSE_PORT",
                    unicode(DEFAULT_FIREHOSE_PORT).encode("ascii"),
                ).decode("ascii")
            ),
            # Base64 encoded
            environ["CATALOG_FIREHOSE_SECRET"].decode("ascii"),
            collector,
        ],
    )
开发者ID:ClusterHQ,项目名称:volume-hub-catalog-agents,代码行数:28,代码来源:agentlib.py

示例2: main

def main():
    
    import optparse

    parser = optparse.OptionParser(usage='Insert usage string here')
    parser.add_option('-m', '--mqttbroker', dest='mqttBroker', default=None, type='string',
                       help='Specify the MQTT broker to run on')
    parser.add_option('-x', '--xmppserver', dest='xmppServer', default=None, type='string',
                       help='Specify the XMPP pubsub server to run on')
    parser.add_option('-i', '--gatewayid', dest='gatewayId', default=None, type='string',
                       help='Specify the ID of the gateway on the MQTT and XMPP networks')
    parser.add_option('-t', '--registrationtopic', dest='registrationTopic', default=None,
                       type='string', help='Specify the MQTT topic that the gateway will listen for registration messages on')
    parser.add_option('-j', '--gatewayjid', dest='gatewayJid', default=None, type='string',
                       help='Specify the JID used to publish and subscribe to XMPP messages')
    parser.add_option('-p', '--gatewaypassword', dest='gatewayPassword', default=None, type='string',
                       help='Specify the password used to connect using the specified JID')
    
    (options, args) = parser.parse_args()
    
    # CHECK THIS AT SOME POINT
    gateway = GatewayService(options.gatewayId, options.registrationTopic, options.xmppServer, 
                             options.gatewayJid, options.gatewayPassword, options.mqttBroker)
    import sys
    log.startLogging(sys.stdout)
    
    reactor.run()
开发者ID:adamvr,项目名称:MQTT-to-XMPP-Gateway,代码行数:27,代码来源:Gateway.py

示例3: main

def main():
    from optparse import OptionParser
    parser = OptionParser(usage="usage: %prog [options] channels")

    # IRC connection options
    parser.add_option("-s", "--server",
                      action="store", dest="server",
                      default="irc.freenode.net",
                      help="IRC server to connect to")
    parser.add_option("-p", "--port",
                      action="store", type="int", dest="port", default=None,
                      help="IRC server to connect to")
    parser.add_option("--ssl",
                      action="store_true", dest="ssl", default=False,
                      help="use SSL")
    parser.add_option("--password",
                      action="store", dest="password", default=None,
                      help="server password")
    parser.add_option("-n", "--nick",
                      action="store", dest="nick", default="karmabot",
                      help="nickname to use")
    # Bot options
    parser.add_option("-v", "--verbose",
                      action="store_true", dest="verbose", default=False,
                      help="enable verbose output")
    parser.add_option("-d", "--data",
                      action="store", dest="filename", default="karma.json",
                      help="karma data file name")
    parser.add_option("-t", "--trust",
                      action="append", dest="trusted", default=[],
                      help="trusted hostmasks")
    parser.add_option("-f", "--facets",
                      action="append", dest="facets", default=[],
                      help="additional facets to load")

    (options, channels) = parser.parse_args()

    if not channels:
        parser.error("You must supply some channels to join.")
    else:
        log.msg("Channels to join: %s" % channels)

    if options.verbose:
        log.startLogging(sys.stdout)

    if not options.port:
        options.port = 6667 if not options.ssl else 9999
    
    # FIXME: this needs to be replaced with a real facet manager
    for facet_path in options.facets:
        execfile(facet_path, globals())

    factory = KarmaBotFactory(options.filename, options.nick,
                              channels, options.trusted, options.password)
    if not options.ssl:
        reactor.connectTCP(options.server, options.port, factory)
    else:
        reactor.connectSSL(options.server, options.port,
                           factory, ssl.ClientContextFactory())
    reactor.run()
开发者ID:drd,项目名称:karmabot,代码行数:60,代码来源:karmabot.py

示例4: main

def main():
    users = {'testadmin': 'x'}

    log.startLogging(sys.stderr)

    MockSSH.runServer(
        commands, prompt="hostname>", interface='127.0.0.1', port=9999, **users)
开发者ID:ncouture,项目名称:MockSSH,代码行数:7,代码来源:mock_cisco.py

示例5: main

def main(argv):
    options = parse_options(argv[1:])
    if options.log:
        log.startLogging(sys.stdout)
    factory = FtpServerFactory(options.root_path, options.port)
    factory.makeListener()
    twisted.internet.reactor.run()
开发者ID:Aaron1011,项目名称:oh-mainline,代码行数:7,代码来源:twisted-ftpserver.py

示例6: start_logging

def start_logging(out=_stdout, level='info'):
    """
    Start logging to the file-like object in ``out``. By default, this
    is stdout.
    """
    global _loggers, _observer, _log_level, _started_logging

    if level not in log_levels:
        raise RuntimeError(
            "Invalid log level '{0}'; valid are: {1}".format(
                level, ', '.join(log_levels)
            )
        )

    if _started_logging:
        return

    _started_logging = True

    _log_level = level
    set_global_log_level(_log_level)

    if out:
        _observer = _LogObserver(out)

    if _NEW_LOGGER:
        _observers = []
        if _observer:
            _observers.append(_observer)
        globalLogBeginner.beginLoggingTo(_observers)
    else:
        assert out, "out needs to be given a value if using Twisteds before 15.2"
        from twisted.python import log
        log.startLogging(out)
开发者ID:Blockshare,项目名称:Django-LandingPage-Template,代码行数:34,代码来源:tx.py

示例7: __init__

    def __init__(self, save_dir=".", 
                       listen_port=6881, 
                       enable_DHT=False,
                       remote_debugging=False):
        """
        @param remote_degugging enables telnet login via port 9999 with a
            username and password of 'admin'
        """
        log.startLogging(sys.stdout) # Start logging to stdout
        self.save_dir = save_dir
        self.listen_port = listen_port
        self.enable_DHT = enable_DHT
        self.tasks = {}
        self.btServer = BTServerFactories(self.listen_port)
        reactor.listenTCP(self.listen_port, self.btServer)
        if enable_DHT:
            log.msg("Turning DHT on.")
            self.dht = DHTProtocol()
            reactor.listenUDP(self.listen_port, self.dht)

        if remote_debugging:
            log.msg("Turning remote debugging on. You may login via telnet " +\
                "on port 9999 username & password are 'admin'")
            import twisted.manhole.telnet
            dbg = twisted.manhole.telnet.ShellFactory()
            dbg.username = "admin"
            dbg.password = "admin"
            dbg.namespace['app'] = self 
            reactor.listenTCP(9999, dbg)
开发者ID:jakesyl,项目名称:AutonomoTorrent,代码行数:29,代码来源:BTApp.py

示例8: __init__

    def __init__(self, port, debug):
        if debug:
            log.startLogging(sys.stdout)

        self.server = WampServerFactory("ws://localhost:"+ str(port), debug)
        self.server.protocol = LogeeProtocol
        listenWS(self.server)
开发者ID:codename-heroes,项目名称:pervastered-interface,代码行数:7,代码来源:websocket_server.py

示例9: init_logging

def init_logging(logdir, logname):
    if DEBUG_LEVEL > 0:
        log.startLogging(sys.stdout)
    if not os.path.exists(logdir):
        os.makedirs(logdir)
    logfile = get_path(os.path.join(logdir, logname))
    log.startLogging(DailyLogFile.fromFullPath(logfile))
开发者ID:hosle,项目名称:tapas,代码行数:7,代码来源:util.py

示例10: main

def main():
    log.startLogging(sys.stderr)

    conf_file = os.path.join(
        xdg.BaseDirectory.save_config_path('socialsound'),
        'config.ini')
    config = ConfigObj(conf_file)

    username = config['Pandora']['username']
    password = config['Pandora']['password']

    proxy = config.get('Proxy', {})
    proxy_host = proxy.get('host', None)
    proxy_port = proxy.get('port', None)
    proxy = {}
    if proxy_host: proxy['proxy_host'] = proxy_host
    if proxy_port: proxy['proxy_port'] = proxy_port

    # Start websocket listener
    factory = PandoraFactory("ws://localhost:9000", debug=False,
                             username=username, password=password, **proxy)
    factory.protocol = PandoraProtocol
    listenWS(factory)

    # Start the MPD client factory.
    factory.player = PlayerFactory()
    reactor.connectTCP(MPD_HOST, MPD_PORT, factory.player)

    reactor.run()
开发者ID:cellofellow,项目名称:socialsound,代码行数:29,代码来源:socialsound.py

示例11: run

    def run(self, host, port, logFile=None):
        """
        Run a minimal twisted.web server on the specified C{port}, bound to the
        interface specified by C{host} and logging to C{logFile}.

        This function will run the default reactor for your platform and so
        will block the main thread of your application.  It should be the last
        thing your klein application does.

        @param host: The hostname or IP address to bind the listening socket
            to.  "0.0.0.0" will allow you to listen on all interfaces, and
            "127.0.0.1" will allow you to listen on just the loopback interface.
        @type host: str

        @param port: The TCP port to accept HTTP requests on.
        @type port: int

        @param logFile: The file object to log to, by default C{sys.stdout}
        @type logFile: file object
        """
        if logFile is None:
            logFile = sys.stdout

        log.startLogging(logFile)
        reactor.listenTCP(port, Site(self.resource()), interface=host)
        reactor.run()
开发者ID:Arttii,项目名称:deps,代码行数:26,代码来源:app.py

示例12: run

def run():
    args = PARSER.parse_args()

    # Unpack values. Each should be a list of one item (hence the
    # comma. Yay list unpacking)
    private_key, = args.private_key
    public_key, = args.public_key
    webserver_address, = args.webserver_address
    webserver_user, = args.webserver_user
    webserver_password, = args.webserver_password
    port = int(args.port)

    log.startLogging(sys.stderr)
    log.startLogging(open('gitssh.log', 'w'))

    components.registerAdapter(GitSession, GitConchUser, ISession)

    # Set up authorization
    GitServer.meta = GitMeta(webserver_address,
                             webserver_user, webserver_password)
    GitServer.portal = Portal(GitRealm(GitServer.meta))
    GitServer.portal.registerChecker(TeamPasswordChecker(GitServer.meta))

    # Instantiate a server
    server = GitServer(os.path.abspath(private_key),
                       os.path.abspath(public_key))

    # Start listening
    reactor.listenTCP(port, server)
    reactor.run()
开发者ID:michaelwisely,项目名称:gitserv,代码行数:30,代码来源:main.py

示例13: main

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--config", type=str, help="config file")
    parser.add_argument("-V", "--version", action="store_true", default=False)
    args = parser.parse_args()

    if args.version:
        print __version__
        exit(0)

    cp = SafeConfigParser()
    cp.read(args.config)
    # initialize logging
    log.startLogging(sys.stdout)

    # create factory protocol and application
    bot_cnf = {
        "nickname": cp.get("main", "nickname_bot"),
        "nickname_user": cp.get("main", "nickname_user"),
        "channels": cp.get("main", "channels").split(" "),
        "filename": cp.get("main", "logfile"),
        "filename_raw": cp.get("main", "logfile_raw"),
    }

    f = BotFactory(**bot_cnf)
    reactor.connectTCP(cp.get("server", "host"), cp.getint("server", "port"), f)
    reactor.run()
开发者ID:yaccz,项目名称:redirbot,代码行数:27,代码来源:__init__.py

示例14: main

def main():
	import argparse
	import sys

	def serverEndpoint(x):
		return endpoints.serverFromString(reactor, x)

	def listenFailed(reason):
		log.err(reason)
		reactor.stop()

	def serverListening(_):
		log.msg("NBD Server running")

	log.startLogging(sys.stderr)

	parser = argparse.ArgumentParser(description='NBD Server')
	parser.add_argument('--listen',
		help='Endpoint address to listen on',
		type=serverEndpoint,
		default='tcp:10809:interface=127.0.0.1')
	parser.add_argument('--readonly',
		help='Make the export read-only',
		action='store_true')
	parser.add_argument('filename',
		help='File to serve')
	args = parser.parse_args()

	bdev = FileBlockDevice(args.filename, args.readonly)
	f = NBDServerFactory({os.path.basename(args.filename): bdev})
	d = args.listen.listen(f)
	d.addErrback(listenFailed)
	d.addCallback(serverListening)
	reactor.run()
开发者ID:therealmik,项目名称:avctproxy,代码行数:34,代码来源:nbdserver.py

示例15: run_server

def run_server(fd=None, port=None, procs=None, verbose=False):
    if args.verbose:
        log.startLogging(stdout)
        environ['SOLEDAD_LOG_TO_STDOUT'] = '1'

    config = get_config()
    path = config["blobs_path"]
    if not port:
        port = int(config["blobs_port"])

    root = Resource()
    root.putChild('blobs', BlobsResource("filesystem", path))
    factory = Site(root)

    if fd is None:
        # Create a new listening port and several other
        # processes to help out.
        if procs is None:
            procs = cpu_count()
        log.msg('A total of %d processes will listen on port %d.' % (procs, port))
        port = reactor.listenTCP(port, factory)
        for i in range(procs - 1):
            reactor.spawnProcess(
                None, executable, [executable, __file__, str(port.fileno())],
                childFDs={0: 0, 1: 1, 2: 2, port.fileno(): port.fileno()},
                env=environ)
    else:
        # Another process created the port, just start listening on it.
        log.msg('Adopting file descriptor %d...' % fd)
        port = reactor.adoptStreamPort(fd, AF_INET, factory)

    reactor.run()
开发者ID:leapcode,项目名称:soledad-perf,代码行数:32,代码来源:blobs-server.py


注:本文中的twisted.python.log.startLogging函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。