Exemplo n.º 1
0
class Entry(metaclass=Singleton):
    _app = None

    def __init__(self):
        super().__init__()
        self.parser = argparse.ArgumentParser(description='Run Spider')
        self.args = self.build_parser()

    def build_parser(self):
        self.parser.add_argument('--spider_type',
                                 dest='spider_type',
                                 required=False,
                                 help='spider type',
                                 default='default')
        self.parser.add_argument('--task_name',
                                 dest='task_name',
                                 required=False,
                                 help='task name',
                                 default='default')
        self.parser.add_argument('--params',
                                 dest='params',
                                 required=False,
                                 help='params',
                                 default=None)
        return self.parser.parse_args()

    def run(self):
        try:
            self._app = Application().init(self.args.spider_type,
                                           self.args.task_name)
            self.parser_params()
            Application().get('browser').generate_browser(
                Application().get('engine'))
        except Exception as e:
            # 异常关闭浏览器
            if self._app is not None:
                self._app.get('browser').close()
            print('into exception')
            print(e)

    def parser_params(self):
        params = self.args.params
        global_manage = self._app.get('global')
        if params is not None and params is not "":
            items = params.split(";")
            for item in items:
                arr = item.split("=")
                global_manage.set(arr[0], arr[1])
Exemplo n.º 2
0
    def __init__(self, app_node_name):
        self.app_node_name = app_node_name

        self.data = {}

        from application import Application
        self.app = Application.get()

        self.init()
Exemplo n.º 3
0
    def __init__(self, app_node_name):
        self.app_node_name = app_node_name

        self.data = {}

        from application import Application
        self.app = Application.get()

        self.init()
Exemplo n.º 4
0
    def __init__(my, app_node_name):
        my.app_node_name = app_node_name

        my.data = {}

        from application import Application
        my.app = Application.get()

        my.init()
Exemplo n.º 5
0
    def __init__(self):
        self.xml = None
        self.doc = None
        self.root = None

        from tactic_client_lib import TacticServerStub
        self.server = TacticServerStub.get()

        # TODO: pull this out of here!!!
        self.util = TacticNodeUtil()
        self.app = Application.get()
Exemplo n.º 6
0
    def __init__(my):
        my.xml = None
        my.doc = None
        my.root = None

        from tactic_client_lib import TacticServerStub
        my.server = TacticServerStub.get()

        # TODO: pull this out of here!!!
        my.util = TacticNodeUtil()
        my.app = Application.get()
Exemplo n.º 7
0
    def __init__(my):
        my.xml = None
        my.doc = None
        my.root = None

        from tactic_client_lib import TacticServerStub
        my.server = TacticServerStub.get()

        # TODO: pull this out of here!!!
        my.util = TacticNodeUtil()
        my.app = Application.get()
Exemplo n.º 8
0
    def __init__(self):
        self.xml = None
        self.doc = None
        self.root = None

        from tactic_client_lib import TacticServerStub
        self.server = TacticServerStub.get()

        # TODO: pull this out of here!!!
        self.util = TacticNodeUtil()
        self.app = Application.get()
Exemplo n.º 9
0
 def __init__(self):
     # TODO: pull this out of here!!!
     self.util = TacticNodeUtil()
     self.app = Application.get()
Exemplo n.º 10
0
 def __init__(my):
     # TODO: pull this out of here!!!
     my.util = TacticNodeUtil()
     my.app = Application.get()
Exemplo n.º 11
0
class MidonetApi(object):

    def __init__(self, base_uri, username, password, project_id=None):
        self.base_uri = base_uri
        self.project_id = project_id
        self.app = None
        self.auth = auth_lib.Auth(base_uri + '/login', username, password,
                                  project_id)

    def get_routers(self, query):
        self._ensure_application()
        return self.app.get_routers(query)

    def get_bridges(self, query):
        self._ensure_application()
        return self.app.get_bridges(query)

    def get_port_groups(self, query):
        self._ensure_application()
        return self.app.get_port_groups(query)

    def get_chains(self, query):
        self._ensure_application()
        return self.app.get_chains(query)

    def get_chain(self, id_):
        self._ensure_application()
        return self.app.get_chain(id_)

    def get_tunnel_zones(self, query=None):
        self._ensure_application()
        return self.app.get_tunnel_zones(query)

    def get_hosts(self, query=None):
        self._ensure_application()
        return self.app.get_hosts(query)

    def get_host(self, id_):
        self._ensure_application()
        return self.app.get_host(id_)

    def get_ad_route(self, id_):
        self._ensure_application()
        return self.app.get_ad_route(id_)

    def get_bgp(self, id_):
        self._ensure_application()
        return self.app.get_bgp(id_)

    def get_bridge(self, id_):
        self._ensure_application()
        return self.app.get_bridge(id_)

    def get_port_group(self, id_):
        self._ensure_application()
        return self.app.get_port_group(id_)

    def get_port(self, id_):
        self._ensure_application()
        return self.app.get_port(id_)

    def get_route(self, id_):
        self._ensure_application()
        return self.app.get_route(id_)

    def get_router(self, id_):
        self._ensure_application()
        return self.app.get_router(id_)

    def get_rule(self, id_):
        self._ensure_application()
        return self.app.get_rule(id_)

    def add_router(self):
        self._ensure_application()
        return self.app.add_router()

    def add_bridge(self):
        self._ensure_application()
        return self.app.add_bridge()

    def add_port_group(self):
        self._ensure_application()
        return self.app.add_port_group()

    def add_chain(self):
        self._ensure_application()
        return self.app.add_chain()

    def add_gre_tunnel_zone(self):
        self._ensure_application()
        return self.app.add_gre_tunnel_zone()

    def add_capwap_tunnel_zone(self):
        self._ensure_application()
        return self.app.add_capwap_tunnel_zone()

    def _ensure_application(self):
        if (self.app == None):
            self.app = Application(None, {'uri': self.base_uri}, self.auth)
            self.app.get()
Exemplo n.º 12
0
def app_inspect(name, namespace):
    app = Application(name, namespace=namespace)
    services = app.get()
    util.print_app_output(services)
Exemplo n.º 13
0
def open_home_page(app):
    app = Application()
    app.get("http://automationpractice.com/index.php")
Exemplo n.º 14
0
 def __init__(self):
     # TODO: pull this out of here!!!
     self.util = TacticNodeUtil()
     self.app = Application.get()
Exemplo n.º 15
0
class MidonetApi(object):

    def __init__(self, midonet_uri='http://localhost:8080/midonet-api/',
                 web_resource=None, logger=None):

        self.midonet_uri = midonet_uri
        self.web_resource = web_resource
        self.app = None

    def get_routers(self, query):
        self._ensure_application()
        return self.app.get_routers(query)

    def get_bridges(self, query):
        self._ensure_application()
        return self.app.get_bridges(query)

    def get_port_groups(self, query):
        self._ensure_application()
        return self.app.get_port_groups(query)

    def get_chains(self, query):
        self._ensure_application()
        return self.app.get_chains(query)

    def get_chain(self, tenant_id, id_):
        self._ensure_application()
        return self.app.get_chain(tenant_id, id_)

    def get_tunnel_zones(self, query={}):
        self._ensure_application()
        return self.app.get_tunnel_zones(query)

    def get_hosts(self, query={}):
        self._ensure_application()
        return self.app.get_hosts(query)

    def get_host(self, id_):
        self._ensure_application()
        return self.app.get_host(id_)

    def get_ad_route(self, id_):
        self._ensure_application()
        return self.app.get_ad_route(id_)

    def get_bgp(self, id_):
        self._ensure_application()
        return self.app.get_bgp(id_)

    def get_bridge(self, id_):
        self._ensure_application()
        return self.app.get_bridge(id_)

    def get_chain(self, id_):
        self._ensure_application()
        return self.app.get_chain(id_)

    def get_host(self, id_):
        self._ensure_application()
        return self.app.get_host(id_)

    def get_port_group(self, id_):
        self._ensure_application()
        return self.app.get_port_group(id_)

    def get_port(self, id_):
        self._ensure_application()
        return self.app.get_port(id_)

    def get_route(self, id_):
        self._ensure_application()
        return self.app.get_route(id_)

    def get_router(self, id_):
        self._ensure_application()
        return self.app.get_router(id_)

    def get_rule(self, id_):
        self._ensure_application()
        return self.app.get_rule(id_)

    def add_router(self):
        self._ensure_application()
        return self.app.add_router()

    def add_bridge(self):
        self._ensure_application()
        return self.app.add_bridge()

    def add_port_group(self):
        self._ensure_application()
        return self.app.add_port_group()

    def add_chain(self):
        self._ensure_application()
        return self.app.add_chain()

    def add_gre_tunnel_zone(self):
        self._ensure_application()
        return self.app.add_gre_tunnel_zone()

    def add_capwap_tunnel_zone(self):
        self._ensure_application()
        return self.app.add_capwap_tunnel_zone()

    def _ensure_application(self):
        if (self.app == None):
            self.app = Application(self.web_resource, None,
                                   {'uri': self.midonet_uri})
            self.app.get()
Exemplo n.º 16
0
 def __init__(my):
     # TODO: pull this out of here!!!
     my.util = TacticNodeUtil()
     my.app = Application.get()
Exemplo n.º 17
0
def app_inspect(name, namespace):
    app = Application(name, namespace=namespace)
    services = app.get()
    util.print_app_output(services)