コード例 #1
0
    def __init__(self, manager, info, name=''):
        self._manager = manager

        # Store info that defines the kernel
        self._originalInfo = KernelInfo(info)

        # Make a copy for the current version. This copy is re-created on
        # each restart
        self._info = ssdf.copy(self._originalInfo)

        # Store name (or should the name be defined in the info struct)
        self._name = name

        # Create context for the connection to the kernel and IDE's
        # This context is persistent (it stays as long as this KernelBroker
        # instance is alive).
        self._context = yoton.Context()
        self._kernelCon = None
        self._ctrl_broker = None

        # Create yoton-based timer
        self._timer = yoton.Timer(0.2, oneshot=False)
        self._timer.bind(self.mainLoopIter)

        # Kernel process and connection (these are replaced on restarting)
        self._reset()

        # For restarting after terminating
        self._pending_restart = None
コード例 #2
0
ファイル: kernelbroker.py プロジェクト: BrenBarn/pyzo
 def __init__(self, manager, info, name=''):
     self._manager = manager
     
     # Store info that defines the kernel
     self._originalInfo = KernelInfo(info)
     
     # Make a copy for the current version. This copy is re-created on
     # each restart
     self._info = ssdf.copy(self._originalInfo)
     
     # Store name (or should the name be defined in the info struct)
     self._name = name
     
     # Create context for the connection to the kernel and IDE's
     # This context is persistent (it stays as long as this KernelBroker
     # instance is alive).
     self._context = yoton.Context()
     self._kernelCon = None
     self._ctrl_broker = None
     
     # Create yoton-based timer
     self._timer = yoton.Timer(0.2, oneshot=False)
     self._timer.bind(self.mainLoopIter)
     
     # Kernel process and connection (these are replaced on restarting)
     self._reset()
     
     # For restarting after terminating
     self._pending_restart = None
コード例 #3
0
def finishKernelInfo(info, scriptFile=None):
    """ finishKernelInfo(info, scriptFile=None)
    
    Get a copy of the kernel info struct, with the scriptFile
    and the projectPath set.
    
    """

    # Set executable to default if it is empty
    # Note that we do this on the original struct object.
    if not info.exe:
        info.exe = '[default]'

    # Make a copy, we do not want to change the original
    info = ssdf.copy(info)

    # Set scriptFile (if '', the kernel will run in interactive mode)
    if scriptFile:
        info.scriptFile = scriptFile
    else:
        info.scriptFile = ''

    #If the file browser is active, and has the check box
    #'add path to Python path' set, set the PROJECTPATH variable
    fileBrowser = iep.toolManager.getTool('iepfilebrowser')
    projectManager = iep.toolManager.getTool('iepprojectmanager')
    info.projectPath = ''
    if fileBrowser:
        info.projectPath = fileBrowser.getAddToPythonPath()
    if projectManager and not info.projectPath:
        # Only process project manager tool if file browser did not set a path.
        info.projectPath = projectManager.getAddToPythonPath()

    return info
コード例 #4
0
ファイル: shell.py プロジェクト: guanzd88/iep
def finishKernelInfo(info, scriptFile=None):
    """ finishKernelInfo(info, scriptFile=None)
    
    Get a copy of the kernel info struct, with the scriptFile
    and the projectPath set.
    
    """ 

    # Set executable to default if it is empty
    # Note that we do this on the original struct object.
    if not info.exe:
        info.exe = '[default]'
    
    # Make a copy, we do not want to change the original
    info = ssdf.copy(info)
    
    # Set scriptFile (if '', the kernel will run in interactive mode)
    if scriptFile:
        info.scriptFile = scriptFile
    else:
        info.scriptFile = ''
    
    #If the file browser is active, and has the check box
    #'add path to Python path' set, set the PROJECTPATH variable
    fileBrowser = iep.toolManager.getTool('iepfilebrowser')
    projectManager = iep.toolManager.getTool('iepprojectmanager')
    info.projectPath = ''
    if fileBrowser:
        info.projectPath = fileBrowser.getAddToPythonPath()
    if projectManager and not info.projectPath:
        # Only process project manager tool if file browser did not set a path.
        info.projectPath = projectManager.getAddToPythonPath()
    
    return info
コード例 #5
0
    def _commandRestart(self, msg):
        # Almost the same as terminate, but now we have a pending action
        self._pending_restart = True

        # Recreate the info struct
        self._info = ssdf.copy(self._originalInfo)
        # Update the info struct
        new_info = ssdf.loads(msg.split('RESTART', 1)[1])
        for key in new_info:
            self._info[key] = new_info[key]

        # Restart now, wait, or initiate termination procedure?
        if self._process is None:
            self.startKernel()
        elif self.isTerminating():
            pass  # Already terminating
        else:
            self.terminate('for restart')
コード例 #6
0
ファイル: kernelbroker.py プロジェクト: BrenBarn/pyzo
 def _commandRestart(self, msg):
     # Almost the same as terminate, but now we have a pending action
     self._pending_restart = True
     
     # Recreate the info struct
     self._info = ssdf.copy(self._originalInfo)
     # Update the info struct
     new_info = ssdf.loads(msg.split('RESTART',1)[1])
     for key in new_info:
         self._info[key] = new_info[key]
     
     # Restart now, wait, or initiate termination procedure?
     if self._process is None:
         self.startKernel()
     elif self.isTerminating():
         pass # Already terminating
     else:
         self.terminate('for restart')