def check_validations(self): """ Checks for validations """ for validation, message in self.validations(): if not validation: exit_with_error(message)
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()
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")
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()
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()
def __getitem__(self, key): if key in self: return dict.__getitem__(self, key) else: exit_with_error("No recognized database Engine")
def __getitem__(self, key): if key in self: return dict.__getitem__(self, key) else: exit_with_error("[%s] Subcommand not valid" % (key))