def execute(self, create_API_object=False):
   """
   :param bool createAPIObject: True if the runner should create the API object
   :returns str: error from execution
   Executes as a string if there is no filepath. Otherwise,
   executes from the filepath.
   """
   if create_API_object:
     error = self._createAPIObject()
     if error is not None:
       return error
   executer = ProgramExecuter(self._program_filename,
       self._program, self._table.getNamespace())
   if not self._user_directory is None:
     sys.path.append(self._user_directory)
   # Check syntax here because there may be an uncorrected
   # syntax error in a column
   msg = executer.execute()
   # Update the table columns
   namespace = executer.getNamespace()
   if API_OBJECT in namespace:
     api_object = namespace[API_OBJECT]
     api_object.updateColumnFromColumnVariables()
     api_object.controller.endProgram(
         details="After updateColumnFromColumnVariables")
   return msg
Exemple #2
0
 def execute(self, create_API_object=False):
     """
 :param bool createAPIObject: True if the runner should create the API object
 :returns str: error from execution
 Executes as a string if there is no filepath. Otherwise,
 executes from the filepath.
 """
     if create_API_object:
         error = self._createAPIObject()
         if error is not None:
             return error
     executer = ProgramExecuter(self._program_filename, self._program,
                                self._table.getNamespace())
     if not self._user_directory is None:
         sys.path.append(self._user_directory)
     # Check syntax here because there may be an uncorrected
     # syntax error in a column
     msg = executer.execute()
     # Update the table columns
     namespace = executer.getNamespace()
     if API_OBJECT in namespace:
         api_object = namespace[API_OBJECT]
         api_object.updateColumnFromColumnVariables()
         api_object.controller.endProgram(
             details="After updateColumnFromColumnVariables")
     return msg
  def _createAPIObject(self):  
    """
    Creates the API object needed for the runtime.
    Note that the APIFormulas object is created in the program
    to avoid circular imports.
    :return str error: error from execution
    """
    namespace = self._table.getNamespace()
    namespace['_table'] = self._table
    program = """
from scisheets.core import api as api
%s = api.APIFormulas(_table, is_logging=True, debug=%s)
""" % (API_OBJECT, self.debug)
    executer = ProgramExecuter("ProgramRunner._createAPIObject", program, 
        namespace)
    result = executer.execute()
    namespace[API_OBJECT] = executer.getNamespace()[API_OBJECT]
    return result
Exemple #4
0
    def _createAPIObject(self):
        """
    Creates the API object needed for the runtime.
    Note that the APIFormulas object is created in the program
    to avoid circular imports.
    :return str error: error from execution
    """
        namespace = self._table.getNamespace()
        namespace['_table'] = self._table
        program = """
from scisheets.core import api as api
%s = api.APIFormulas(_table, is_logging=True, debug=%s)
""" % (API_OBJECT, self.debug)
        executer = ProgramExecuter("ProgramRunner._createAPIObject", program,
                                   namespace)
        result = executer.execute()
        try:
            namespace[API_OBJECT] = executer.getNamespace()[API_OBJECT]
        except Exception as e:
            import pdb
            pdb.set_trace()
            pass
        return result