def set_autorefresh_timeout(self, interval): if self.introspection_socket is not None: try: communicate(self.introspection_socket, "set_monitor_timeout(%d)" % interval) except socket.error: pass
def set_introspection_socket(self, introspection_socket): self.introspection_socket = introspection_socket if self.namespacebrowser is not None: settings = self.namespacebrowser.get_view_settings() communicate(introspection_socket, 'set_remote_view_settings()', settings=[settings])
def update_remote_view(self): """ Return remote view of globals() """ settings = self.remote_view_settings if settings: ns = self.get_current_namespace() remote_view = make_remote_view(ns, settings) communicate(self.n_request, dict(command="remote_view", data=remote_view))
def ask_monitor(self, command, settings=[]): sock = self.externalshell.introspection_socket if sock is None: return try: return communicate(sock, command, settings=settings) except socket.error: # Process was just closed pass except MemoryError: # Happens when monitor is not ready on slow machines pass
def send_to_process(self, text): if not self.is_running(): return if not is_text_string(text): text = to_text_string(text) if self.mpl_backend == 0 and os.name == 'nt' and \ self.introspection_socket is not None: communicate(self.introspection_socket, "toggle_inputhook_flag(True)") # # Socket-based alternative (see input hook in sitecustomize.py): # while self.local_server.hasPendingConnections(): # self.local_server.nextPendingConnection().write('go!') if any([text == cmd for cmd in ['%ls', '%pwd', '%scientific']]) or \ any([text.startswith(cmd) for cmd in ['%cd ', '%clear ']]): text = 'evalsc(r"%s")\n' % text if not text.endswith('\n'): text += '\n' self.process.write(to_binary_string(text, 'utf8')) self.process.waitForBytesWritten(-1) # Eventually write prompt faster (when hitting Enter continuously) # -- necessary/working on Windows only: if os.name == 'nt': self.write_error()
def keyboard_interrupt(self): if self.introspection_socket is not None: communicate(self.introspection_socket, "thread.interrupt_main()")
def monitor_copy_global(sock, orig_name, new_name): """Copy global variable *orig_name* to *new_name*""" return communicate(sock, '__copy_global__("%s", "%s")' \ % (orig_name, new_name))
def monitor_del_global(sock, name): """Del global variable *name*""" return communicate(sock, '__del_global__("%s")' % name)
def monitor_set_global(sock, name, value): """Set global variable *name* value to *value*""" return communicate(sock, '__set_global__("%s")' % name, settings=[value])
def monitor_get_global(sock, name): """Get global variable *name* value""" return communicate(sock, '__get_global__("%s")' % name)
def monitor_load_globals(sock, filename, ext): """Load globals() from file""" return communicate(sock, '__load_globals__()', settings=[filename, ext])
def monitor_save_globals(sock, settings, filename): """Save globals() to file""" return communicate(sock, '__save_globals__()', settings=[settings, filename])
def notify_open_file(self, fname, lineno=1): """Open file in TRex's editor""" communicate(self.n_request, dict(command="open_file", data=(fname, lineno)))
def notify_pdb_step(self, fname, lineno): """Notify the ExternalPythonShell regarding pdb current frame""" communicate(self.n_request, dict(command="pdb_step", data=(fname, lineno)))
def refresh(self): """Refresh variable explorer in ExternalPythonShell""" communicate(self.n_request, dict(command="refresh"))