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 option_changed(self, option, value): """Option has changed""" setattr(self, to_text_string(option), value) if not self.is_internal_shell: settings = self.get_view_settings() communicate(self._get_sock(), 'set_remote_view_settings()', settings=[settings])
def get_value(self, name): value = monitor_get_global(self._get_sock(), name) if value is None: if communicate(self._get_sock(), '%s is not None' % name): import pickle msg = to_text_string(_("Object <b>%s</b> is not picklable") % name) raise pickle.PicklingError(msg) return value
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 refresh_table(self): """Refresh variable table""" if self.is_visible and self.isVisible(): if self.is_internal_shell: # Internal shell wsfilter = self.get_internal_shell_filter('editable') self.editor.set_filter(wsfilter) interpreter = self.shellwidget.interpreter if interpreter is not None: self.editor.set_data(interpreter.namespace) self.editor.adjust_columns() elif self.shellwidget.is_running(): # import time; print >>STDOUT, time.ctime(time.time()), "Refreshing namespace browser" sock = self._get_sock() if sock is None: return try: communicate(sock, "refresh()") except socket.error: # Process was terminated before calling this method pass
def send_to_process(self, text): if not isinstance(text, basestring): text = unicode(text) if self.install_qt_inputhook and not self.is_ipython_shell: # For now, the Spyder's input hook does not work with IPython: # with IPython v0.10 or non-Windows platforms, this is not a # problem. However, with IPython v0.11 on Windows, this will be # fixed by patching IPython to force it to use our inputhook. 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 not self.is_ipython_shell and text.startswith(('%', '!')): text = 'evalsc(r"%s")\n' % text if not text.endswith('\n'): text += '\n' self.process.write(locale_codec.fromUnicode(text)) 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 is_series(self, name): """Return True if variable is a Series""" return communicate(self._get_sock(), "isinstance(globals()['%s'], Series)" % name)
def ask_monitor(self, command): sock = self.externalshell.monitor_socket if sock is None: return return communicate(sock, command, pickle_try=True)
def get_array_shape(self, name): """Return array's shape""" return communicate(self._get_sock(), "%s.shape" % name)
def is_array(self, name): """Return True if variable is a NumPy array""" return communicate(self._get_sock(), 'is_array("%s")' % name)
def is_data_frame(self, name): """Return True if variable is a data_frame""" return communicate(self._get_sock(), "isinstance(globals()['%s'], DataFrame)" % name)
def keyboard_interrupt(self): if self.introspection_socket is not None: communicate(self.introspection_socket, "thread.interrupt_main()")
def is_tablelist(self, name): """Return True if variable is a PeakMap""" return communicate(self._get_sock(), "isinstance(globals()['%s'], list) " "and all(isinstance(li, emzed.core.data_types.Table)" " for li in globals()['%s'])" % (name, name))
def toggle_auto_refresh(self, state): """Toggle auto refresh state""" self.autorefresh = state if not self.setup_in_progress and not self.is_internal_shell: communicate(self._get_sock(), "set_monitor_auto_refresh(%r)" % state)
def is_table(self, name): """Return True if variable is a PeakMap""" return communicate(self._get_sock(), "isinstance(globals()['%s'], emzed.core.data_types.Table)" % name)
def is_tablelist(self, name): """Return True if variable is a PeakMap""" return communicate( self._get_sock(), "isinstance(globals()['%s'], list) " "and all(isinstance(li, emzed.core.data_types.Table)" " for li in globals()['%s'])" % (name, name))
def is_table(self, name): """Return True if variable is a PeakMap""" return communicate( self._get_sock(), "isinstance(globals()['%s'], emzed.core.data_types.Table)" % name)
def is_dict(self, name): """Return True if variable is a dictionary""" return communicate(self._get_sock(), 'isinstance(%s, dict)' % name)
def is_list(self, name): """Return True if variable is a list or a tuple""" return communicate(self.shellwidget.monitor_socket, "isinstance(globals()['%s'], (tuple, list))" % name, pickle_try=True)
def keyboard_interrupt(self): communicate(self.monitor_socket, "thread.interrupt_main()")
def is_dict(self, name): """Return True if variable is a dictionary""" return communicate(self.shellwidget.monitor_socket, "isinstance(globals()['%s'], dict)" % name, pickle_try=True)
def get_len(self, name): """Return sequence length""" return communicate(self.shellwidget.monitor_socket, "len(globals()['%s'])" % name, pickle_try=True)
def is_list(self, name): """Return True if variable is a list or a tuple""" return communicate(self._get_sock(), 'isinstance(%s, (tuple, list))' % name)
def get_array_ndim(self, name): """Return array's ndim""" return communicate(self.shellwidget.monitor_socket, "globals()['%s'].ndim" % name, pickle_try=True)
def get_len(self, name): """Return sequence length""" return communicate(self._get_sock(), "len(%s)" % name)
def is_table(self, name): """Return True if variable is a PeakMap""" return communicate(self._get_sock(), "isinstance(globals()['%s'], (libms.DataStructures.Table))" % name)
def is_image(self, name): """Return True if variable is a PIL.Image image""" return communicate(self._get_sock(), 'is_image("%s")' % name)
def is_tablelist(self, name): """Return True if variable is a PeakMap""" return communicate(self._get_sock(), "isinstance(globals()['%s'], list) "\ "and all(isinstance(li, libms.DataStructures.Table)"\ " for li in globals()['%s'])" %(name, name))
def is_time_series(self, name): """Return True if variable is a data_frame""" return communicate(self._get_sock(), "isinstance(globals()['%s'], TimeSeries)" % name)
def get_array_ndim(self, name): """Return array's ndim""" return communicate(self._get_sock(), "%s.ndim" % name)
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])