コード例 #1
0
ファイル: proxy.py プロジェクト: WMCAlliance/WebAuth
    def __init__(self, downstream_factory, downstream):
        self.downstream_factory = downstream_factory
        self.upstream_factory = downstream_factory.upstream_factory_class()
        self.downstream = downstream
        self.upstream = None

        self.buff_type = self.downstream_factory.buff_type

        self.logger = logging.getLogger(
            "%s{%s}" % (self.__class__.__name__, self.downstream.username))
        self.logger.setLevel(self.log_level)

        self.register_handlers()

        # Set up offline profile
        profile = Profile()
        profile.login_offline(self.downstream.username)

        # Set up client factory
        self.upstream_factory.bridge = self
        self.upstream_factory.buff_type = self.buff_type
        self.upstream_factory.profile = profile

        # Connect!
        self.upstream_factory.connect(self.downstream_factory.connect_host,
                                      self.downstream_factory.connect_port,
                                      "login",
                                      self.downstream.protocol_version)
コード例 #2
0
ファイル: proxy.py プロジェクト: CodeMyAss/quarry
    def __init__(self, downstream_factory, downstream):
        self.downstream_factory  = downstream_factory
        self.upstream_factory    = downstream_factory.upstream_factory_class()
        self.downstream = downstream
        self.upstream   = None

        self.buff_type = self.downstream_factory.buff_type

        self.logger = logging.getLogger("%s{%s}" % (
            self.__class__.__name__,
            self.downstream.username))
        self.logger.setLevel(self.log_level)

        self.register_handlers()

        # Set up offline profile
        profile = Profile()
        profile.login_offline(self.downstream.username)

        # Set up client factory
        self.upstream_factory.bridge = self
        self.upstream_factory.buff_type = self.buff_type
        self.upstream_factory.profile = profile

        # Connect!
        self.upstream_factory.connect(
            self.downstream_factory.connect_host,
            self.downstream_factory.connect_port,
            "login",
            self.downstream.protocol_version)
コード例 #3
0
def main():
    # Parse options
    import optparse
    parser = optparse.OptionParser(usage="usage: %prog host port")
    (options, args) = parser.parse_args()

    if len(args) != 2:
        return parser.print_usage()

    host, port = args

    # Create profile
    profile = Profile()
    profile.login_offline("quarry")

    # Create factory
    factory = PingFactory()
    factory.profile = profile

    factory.connect(host, int(port), "status")
    factory.run()
コード例 #4
0
ファイル: start.py プロジェクト: Ameliorate/DevotedBot
def main():
    if os.path.isfile(CONFIG_FILE):
        CONFIG.read(CONFIG_FILE)
    else:
        generate_config_file(CONFIG_FILE, CONFIG)

    profile = Profile()
    if not CONFIG['auth'].getboolean('auth'):
        profile.login_offline(CONFIG['auth']['username'])
        factory.profile = profile
    else:
        def login_ok(data):
            factory.connect(CONFIG['server']['ip'], int(CONFIG['server']['port']))

        def login_failed(err):
            print('login failed:', err.value)
            factory.stop()
            sys.exit(1)

        factory.profile = profile
        deferred = profile.login(CONFIG['auth']['username'], CONFIG['auth']['password'])
        deferred.addCallbacks(login_ok, login_failed)
        factory.run()