Exemplo n.º 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
Exemplo n.º 2
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])
Exemplo n.º 3
0
 def mglobals(self):
     """Return current globals -- handles Pdb frames"""
     if self.pdb_frame is not None:
         return self.pdb_frame.f_globals
     else:
         if self._mglobals is None:
             from __main__ import __dict__ as glbs
             self._mglobals = glbs
         else:
             glbs = self._mglobals
         if self.ipython_kernel is None and '__ipythonkernel__' in glbs:
             self.ipython_kernel = glbs['__ipythonkernel__']
             argv = ['--existing'] +\
                    ['--%s=%d' % (name, port) for name, port
                     in self.ipython_kernel.ports.items()]
             opts = ' '.join(argv)
             communicate(self.n_request,
                         dict(command="ipython_kernel", data=opts))
         if self.ipython_shell is None and '__ipythonshell__' in glbs:
             # IPython >=v0.11
             self.ipython_shell = glbs['__ipythonshell__']
             if not hasattr(self.ipython_shell, 'user_ns'):
                 # IPython v0.10
                 self.ipython_shell = self.ipython_shell.IP
             self.ipython_shell.modcompletion = moduleCompletion
             glbs = self.ipython_shell.user_ns
         self._mglobals = glbs
         return glbs
Exemplo n.º 4
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
Exemplo n.º 5
0
    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 == 'Qt4Agg' 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()
Exemplo n.º 6
0
    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 == 'Qt4Agg' 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()
Exemplo n.º 7
0
 def update_remote_view(self):
     """
     Return remote view of globals()
     """
     settings = self.remote_view_settings
     if settings:
         ns = self.get_current_namespace()
         more_excluded_names = ["In", "Out"] if self.ipython_shell else None
         remote_view = make_remote_view(ns, settings, more_excluded_names)
         communicate(self.n_request, dict(command="remote_view", data=remote_view))
Exemplo n.º 8
0
 def update_remote_view(self):
     """
     Return remote view of globals()
     """
     settings = self.remote_view_settings
     if settings:
         ns = self.get_current_namespace()
         more_excluded_names = ['In', 'Out'] if self.ipython_shell else None
         remote_view = make_remote_view(ns, settings, more_excluded_names)
         communicate(self.n_request,
                     dict(command="remote_view", data=remote_view))
Exemplo n.º 9
0
 def neted_getmodel():
   """
   Get the raw SBML representing the model currently
   displayed in the viewer
   """
   # return monitor.layout('~::empty::~')
   return communicate(monitor.n_request,
                      dict(command="layout", data=('~::empty::~')))
Exemplo n.º 10
0
 def neted_getmodel():
     """
 Get the raw SBML representing the model currently
 displayed in the viewer
 """
     # return monitor.layout('~::empty::~')
     return communicate(monitor.n_request,
                        dict(command="layout", data=('~::empty::~')))
Exemplo n.º 11
0
      def neted_setmodel(sbml):
        """
        Opens the SBML model with the layout tool.

        :param sbml: raw XML string containing the model
        """
        # return monitor.layout(sbml)
        return communicate(monitor.n_request,
                           dict(command="layout", data=(sbml)))
Exemplo n.º 12
0
        def neted_setmodel(sbml):
            """
        Opens the SBML model with the layout tool.

        :param sbml: raw XML string containing the model
        """
            # return monitor.layout(sbml)
            return communicate(monitor.n_request,
                               dict(command="layout", data=(sbml)))
Exemplo n.º 13
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
Exemplo n.º 14
0
    def mglobals(self):
        """Return current globals -- handles Pdb frames"""
        if self.pdb_frame is not None:
            return self.pdb_frame.f_globals
        else:
            if self._mglobals is None:
                from __main__ import __dict__ as glbs

                self._mglobals = glbs
            else:
                glbs = self._mglobals
            if self.ipykernel is None and "__ipythonkernel__" in glbs:
                self.ipykernel = glbs["__ipythonkernel__"]
                communicate(self.n_request, dict(command="ipykernel", data=self.ipykernel.connection_file))
            if self.ipython_shell is None and "__ipythonshell__" in glbs:
                # IPython kernel
                self.ipython_shell = glbs["__ipythonshell__"]
                glbs = self.ipython_shell.user_ns
                self.ip = self.ipython_shell.get_ipython()
            self._mglobals = glbs
            return glbs
Exemplo n.º 15
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
Exemplo n.º 16
0
 def mglobals(self):
     """Return current globals -- handles Pdb frames"""
     if self.pdb_frame is not None:
         return self.pdb_frame.f_globals
     else:
         if self._mglobals is None:
             from __main__ import __dict__ as glbs
             self._mglobals = glbs
         else:
             glbs = self._mglobals
         if self.ipykernel is None and '__ipythonkernel__' in glbs:
             self.ipykernel = glbs['__ipythonkernel__']
             communicate(self.n_request,
                         dict(command="ipykernel",
                              data=self.ipykernel.connection_file))
         if self.ipython_shell is None and '__ipythonshell__' in glbs:
             # IPython kernel
             self.ipython_shell = glbs['__ipythonshell__']
             glbs = self.ipython_shell.user_ns
             self.ip = self.ipython_shell.get_ipython()
         self._mglobals = glbs
         return glbs
Exemplo n.º 17
0
    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.install_qt_inputhook 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 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()
Exemplo n.º 18
0
    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.install_qt_inputhook 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 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()
Exemplo n.º 19
0
def monitor_del_global(sock, name):
    """Del global variable *name*"""
    return communicate(sock, '__del_global__("%s")' % name)
Exemplo n.º 20
0
 def keyboard_interrupt(self):
     if self.introspection_socket is not None:
         communicate(self.introspection_socket, "thread.interrupt_main()")
Exemplo n.º 21
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])
Exemplo n.º 22
0
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))
Exemplo n.º 23
0
 def keyboard_interrupt(self):
     if self.introspection_socket is not None:
         communicate(self.introspection_socket, "thread.interrupt_main()")
Exemplo n.º 24
0
 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)))
Exemplo n.º 25
0
 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)))
Exemplo n.º 26
0
def monitor_load_globals(sock, filename, ext):
    """Load globals() from file"""
    return communicate(sock, "__load_globals__()", settings=[filename, ext])
Exemplo n.º 27
0
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))
Exemplo n.º 28
0
 def refresh(self):
     """Refresh variable explorer in ExternalPythonShell"""
     communicate(self.n_request, dict(command="refresh"))
Exemplo n.º 29
0
def monitor_del_global(sock, name):
    """Del global variable *name*"""
    return communicate(sock, '__del_global__("%s")' % name)
Exemplo n.º 30
0
def monitor_set_global(sock, name, value):
    """Set global variable *name* value to *value*"""
    return communicate(sock, '__set_global__("%s")' % name, settings=[value])
Exemplo n.º 31
0
def monitor_get_global(sock, name):
    """Get global variable *name* value"""
    return communicate(sock, '__get_global__("%s")' % name)
Exemplo n.º 32
0
def monitor_set_global(sock, name, value):
    """Set global variable *name* value to *value*"""
    return communicate(sock, '__set_global__("%s")' % name, settings=[value])
Exemplo n.º 33
0
 def notify_open_file(self, fname, lineno=1):
     """Open file in Spyder's editor"""
     communicate(self.n_request,
                 dict(command="open_file", data=(fname, lineno)))
Exemplo n.º 34
0
def monitor_get_global(sock, name):
    """Get global variable *name* value"""
    return communicate(sock, '__get_global__("%s")' % name)
Exemplo n.º 35
0
 def refresh(self):
     """Refresh variable explorer in ExternalPythonShell"""
     communicate(self.n_request, dict(command="refresh"))
Exemplo n.º 36
0
def monitor_save_globals(sock, settings, filename):
    """Save globals() to file"""
    return communicate(sock, "__save_globals__()", settings=[settings, filename])
Exemplo n.º 37
0
def monitor_save_globals(sock, settings, filename):
    """Save globals() to file"""
    return communicate(sock,
                       '__save_globals__()',
                       settings=[settings, filename])
Exemplo n.º 38
0
def monitor_load_globals(sock, filename, ext):
    """Load globals() from file"""
    return communicate(sock, '__load_globals__()', settings=[filename, ext])
Exemplo n.º 39
0
 def notify_open_file(self, fname, lineno=1):
     """Open file in Spyder's editor"""
     communicate(self.n_request, dict(command="open_file", data=(fname, lineno)))