def getKernelList(self): # Get info of each kernel as an ssdf struct infos = [] for kernel in self._kernels: info = kernel._info info = ssdf.loads(info.tostring()) info.name = kernel._name infos.append(info) # Done return infos
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")
def __init__(self, info=None): super().__init__() # ----- Fixed parameters that define a shell ----- # scriptFile is used to define the mode. If given, we run in # script-mode. Otherwise we run in interactive mode. # The name of this shell config. Can be used to name the kernel self.name = "Python" # The executable. This can be '/usr/bin/python3.1' or # 'c:/program files/python2.6/python.exe', etc. self.exe = "" # The GUI toolkit to embed the event loop of. # Instantiate with a value that is settable self.gui = "Auto" # The Python path. Paths should be separated by newlines. # '$PYTHONPATH' is replaced by environment variable by broker self.pythonPath = "" # The path of the current project, the kernel will prepend this # to the sys.path. The broker could prepend to PYTHONPATH, but # in this way it is more explicit (kernel can tell the user that # the project path was prepended). self.projectPath = "" # The full filename of the script to run. # If given, the kernel should run in script-mode. # The kernel will check whether this file exists, and will # revert to interactive mode if it doesn't. self.scriptFile = "" # Interactive-mode only: # The initial directory. Only used for interactive-mode; in # script-mode the initial directory is the dir of the script. self.startDir = "" # The Startup script (only used for interactive-mode). # - Empty string means run nothing, # - Single line means file name # - multiple lines means source code. # - '$PYTHONSTARTUP' uses the code in that file. Broker replaces this. self.startupScript = "" # Additional command line arguments, set by the kernel self.argv = "" # Additional environment variables self.environ = "" # Load info from ssdf struct. Make sure they are all strings if info: # Get struct if isinstance(info, dict): s = info elif isinstance(info, str): s = ssdf.loads(info) else: raise ValueError( "Kernel info should be a string or ssdf struct, not %s" % str(type(info))) # Inject values for key in s: val = s[key] if not val: val = "" self[key] = val
def __init__(self, info=None): super().__init__() # ----- Fixed parameters that define a shell ----- # scriptFile is used to define the mode. If given, we run in # script-mode. Otherwise we run in interactive mode. # The name of this shell config. Can be used to name the kernel self.name = "Python" # The executable. This can be '/usr/bin/python3.1' or # 'c:/program files/python2.6/python.exe', etc. self.exe = "" # The GUI toolkit to embed the event loop of. # Instantiate with a value that is settable self.gui = "Auto" # The Python path. Paths should be separated by newlines. # '$PYTHONPATH' is replaced by environment variable by broker self.pythonPath = "" # The path of the current project, the kernel will prepend this # to the sys.path. The broker could prepend to PYTHONPATH, but # in this way it is more explicit (kernel can tell the user that # the project path was prepended). self.projectPath = "" # The full filename of the script to run. # If given, the kernel should run in script-mode. # The kernel will check whether this file exists, and will # revert to interactive mode if it doesn't. self.scriptFile = "" # Interactive-mode only: # The initial directory. Only used for interactive-mode; in # script-mode the initial directory is the dir of the script. self.startDir = "" # The Startup script (only used for interactive-mode). # - Empty string means run nothing, # - Single line means file name # - multiple lines means source code. # - '$PYTHONSTARTUP' uses the code in that file. Broker replaces this. self.startupScript = "" # Additional command line arguments, set by the kernel self.argv = "" # Additional environment variables self.environ = "" # Load info from ssdf struct. Make sure they are all strings if info: # Get struct if isinstance(info, dict): s = info elif isinstance(info, str): s = ssdf.loads(info) else: raise ValueError("Kernel info should be a string or ssdf struct, not %s" % str(type(info))) # Inject values for key in s: val = s[key] if not val: val = "" self[key] = val