def print_source(self, side, args, line): '''Print(if can) source of method or function or class''' obj = get_value_in_context(args.arg, side, self.shell) try: source = side.get_source(obj) if is_remote(obj) else get_source(obj) except (TypeError, IOError) as exc: print_err(exc, debug=debug) return display_html(highlight_python_source(source), raw=True)
def print_source(self, side, args, line): '''Print(if can) source of method or function or class''' obj = get_value_in_context(args.arg, side, self.shell) try: source = side.get_source(obj) if is_remote(obj) else get_source( obj) except (TypeError, IOError) as exc: print_err(exc, debug=debug) return display_html(highlight_python_source(source), raw=True)
def deco_body(self, other, line, cell=None): args = parse_argstring(getattr(other, self.name), line) try: side = self.get_scrapy_side(other, args) if cell is None: return self.func(other, side, args, line) return self.func(other, side, args, line, cell) except Exception as exc: print_err(exc, debug=debug)
def scrapy_embed(self, arg): try: args = parse_argstring(self.scrapy_embed, arg) url = get_url_from_ipython(args.url, self.shell) spidercls = self._parse_spidercls(args.spidercls, url) crawler = scrapy_embedding(spidercls) scrapy_shell = IPythonNotebookShell(self.shell, crawler) scrapy_shell.start(url=url) side = LocalScrapy(self.shell, crawler) # FIXME: request and response vars push later so they are not printed as loaded self.add_new_scrapy_side(side) return side except Exception as exc: print_err(exc, debug=debug)
def scrapy_attach(self, arg): try: args = parse_argstring(self.scrapy_attach, arg) host, port = args.host, args.port assert 1 <= port <= 65536 try: conn = get_rpyc_connection(host, port, debug) except socket.gaierror: print_err("Wrong host: " + host) return except socket.error: print_err("Connection failure") return side = RemoteScrapy(self.shell, conn) self.add_new_scrapy_side(side) return side except Exception as exc: print_err(exc, debug=debug)
def visualize_scrapy(self): print_err('Not implemented yet')
def visualize_scrapy(self): print_err("Not implemented yet")