Example #1
0
 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
Example #2
0
 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])
Example #3
0
 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
Example #4
0
 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
Example #5
0
 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                
Example #6
0
    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()
Example #7
0
 def is_series(self, name):
     """Return True if variable is a Series"""
     return communicate(self._get_sock(),
                        "isinstance(globals()['%s'], Series)" % name)
Example #8
0
 def ask_monitor(self, command):
     sock = self.externalshell.monitor_socket
     if sock is None:
         return
     return communicate(sock, command, pickle_try=True)
Example #9
0
 def get_array_shape(self, name):
     """Return array's shape"""
     return communicate(self._get_sock(), "%s.shape" % name)
Example #10
0
 def is_array(self, name):
     """Return True if variable is a NumPy array"""
     return communicate(self._get_sock(), 'is_array("%s")' % name)
Example #11
0
 def is_data_frame(self, name):
     """Return True if variable is a data_frame"""
     return communicate(self._get_sock(),
          "isinstance(globals()['%s'], DataFrame)" % name)
Example #12
0
 def keyboard_interrupt(self):
     if self.introspection_socket is not None:
         communicate(self.introspection_socket, "thread.interrupt_main()")
Example #13
0
 def ask_monitor(self, command):
     sock = self.externalshell.monitor_socket
     if sock is None:
         return
     return communicate(sock, command, pickle_try=True)
Example #14
0
 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))
Example #15
0
 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)
Example #16
0
 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)
Example #17
0
 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))
Example #18
0
 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)
Example #19
0
 def is_series(self, name):
     """Return True if variable is a Series"""
     return communicate(self._get_sock(),
          "isinstance(globals()['%s'], Series)" % name)
Example #20
0
 def is_dict(self, name):
     """Return True if variable is a dictionary"""
     return communicate(self._get_sock(), 'isinstance(%s, dict)' % name)
Example #21
0
 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)
Example #22
0
 def keyboard_interrupt(self):
     communicate(self.monitor_socket, "thread.interrupt_main()")
Example #23
0
 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)
Example #24
0
 def get_len(self, name):
     """Return sequence length"""
     return communicate(self.shellwidget.monitor_socket,
                        "len(globals()['%s'])" % name,
                        pickle_try=True)
Example #25
0
 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)
Example #26
0
 def get_array_ndim(self, name):
     """Return array's ndim"""
     return communicate(self.shellwidget.monitor_socket,
                        "globals()['%s'].ndim" % name,
                        pickle_try=True)
Example #27
0
 def get_len(self, name):
     """Return sequence length"""
     return communicate(self._get_sock(), "len(%s)" % name)
Example #28
0
 def is_table(self, name):
     """Return True if variable is a PeakMap"""
     return communicate(self._get_sock(),
          "isinstance(globals()['%s'], (libms.DataStructures.Table))" % name)
Example #29
0
 def is_image(self, name):
     """Return True if variable is a PIL.Image image"""
     return communicate(self._get_sock(), 'is_image("%s")' % name)
Example #30
0
 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))
Example #31
0
 def is_time_series(self, name):
     """Return True if variable is a data_frame"""
     return communicate(self._get_sock(),
          "isinstance(globals()['%s'], TimeSeries)" % name)   
Example #32
0
 def keyboard_interrupt(self):
     communicate(self.monitor_socket, "thread.interrupt_main()")
Example #33
0
 def get_array_ndim(self, name):
     """Return array's ndim"""
     return communicate(self._get_sock(), "%s.ndim" % name)
Example #34
0
 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])