示例#1
0
文件: command.py 项目: aparo/crawley
    def check_validations(self):
        """
            Checks for validations
        """

        for validation, message in self.validations():
            if not validation:
                exit_with_error(message)
示例#2
0
文件: command.py 项目: cmcc/crawley
    def check_validations(self):
        """
            Checks for validations
        """

        for validation, message in self.validations():
            if not validation:
                exit_with_error(message)
示例#3
0
def run_cmd(args):
    """
        Runs a crawley's command
    """

    if len(args) <= 1:
        exit_with_error("Subcommand not specified")

    cmd_name = args[1]
    cmd_args = args[2:]

    cmd = commands[cmd_name](cmd_args)
    cmd.checked_execute()
示例#4
0
文件: command.py 项目: aparo/crawley
    def _check_project_type(self):
        """
            Check for the project's type [code based project
            or dsl templates based project]
        """

        if check_for_file(self.settings, "config.ini") and check_for_file(self.settings, "template.crw"):
            self.project_type = TemplateProject()

        elif import_user_module("models", exit=False) is not None:
            self.project_type = CodeProject()

        else:
            exit_with_error("Unrecognized crawley project")
示例#5
0
    def execute(self):

        try:
            import IPython
        except ImportError:
            exit_with_error("Please install the ipython console")

        url = self.args[0]
        crawler = BaseCrawler()

        response = crawler._get_data(url)
        html = XPathExtractor().get_object(response)

        shell = IPython.Shell.IPShellEmbed(argv=[], user_ns={ 'response' : response })
        shell()
示例#6
0
文件: shell.py 项目: wgfi110/crawley
    def execute(self):

        try:
            import IPython
        except ImportError:
            exit_with_error("Please install the ipython console")

        url = self.args[0]
        crawler = BaseCrawler()

        response = crawler._get_response(url)
        html = XPathExtractor().get_object(response)

        shell = IPython.Shell.IPShellEmbed(argv=[],
                                           user_ns={'response': response})
        shell()
示例#7
0
    def __getitem__(self, key):

        if key in self:
            return dict.__getitem__(self, key)
        else:
            exit_with_error("No recognized database Engine")
示例#8
0
文件: __init__.py 项目: 4iji/crawley
    def __getitem__(self, key):

        if key in self:
            return dict.__getitem__(self, key)
        else:
            exit_with_error("[%s] Subcommand not valid" % (key))
示例#9
0
    def __getitem__(self, key):

        if key in self:
            return dict.__getitem__(self, key)
        else:
            exit_with_error("No recognized database Engine")
示例#10
0
    def __getitem__(self, key):

        if key in self:
            return dict.__getitem__(self, key)
        else:
            exit_with_error("[%s] Subcommand not valid" % (key))