def startup(args=sys.argv): import optparse options = optparse.OptionParser() options.add_option("-p", "--plugin", dest="selected_plugins", action="append", help="include this plugin") options.add_option("-U", "--username", dest="username", help="use this IM username") options.add_option("-P", "--password", dest="password", help="use this password") options.add_option("-I", "--improto", dest="improto", help="use this IM protocol [see documentation for a list]") options.add_option("-c", "--config-dir", dest="configdir", help="client configuration directory", default=yobot_interfaces.get_yobot_homedir()) options.add_option("--use-proxy", dest="use_proxy", action="store_true", help="use env proxy settings", default=False) options.add_option("--agent-address", dest="agent_addrinfo", help="agent server:port") options, args = options.parse_args(args) #set our configuration directory yobot_interfaces.component_registry.register_component("yobot-config-dir", options.configdir) if options.selected_plugins: #generate dict: name_object = {} for plugin in yobot_interfaces.component_registry.get_plugins(): name_object[plugin.plugin_name] = plugin for p in options.selected_plugins: plugin_object = name_object.get(p) if not plugin_object: log_warn("couldn't find plugin", p) continue yobot_interfaces.component_registry.activate_plugin(plugin_object) tmp = options.agent_addrinfo if tmp: tmp = tmp.rsplit(":", 1) address = tmp[0] if len(tmp) >= 2: port = int(tmp[1]) else: #no address specified on the command line address, port = None, None debuglog.init("Client", title_color="green") yobotproto.yobot_proto_setlogger("Client") ui = UIClient() ui.run(address, port)
def __init__(self, username=None, password=None, improto=None): """Set the service""" #set up the client configuration: self.config = yobot_interfaces.component_registry.get_component("client-config") if not self.config: import client_config import os.path self.config = client_config.ClientConfig( os.path.join(yobot_interfaces.get_yobot_homedir(),"client.conf"),autocreate=True) yobot_interfaces.component_registry.register_component("client-config", self.config) self.config.save() self.svc = YobotClientService(self, reactor) self.plugins = set() self.joined_rooms = defaultdict(lambda: []) yobot_interfaces.component_registry.register_component("client-operations", self) yobot_interfaces.component_registry.register_component("joined-rooms", self.joined_rooms) self.connector = None