Esempio n. 1
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
Esempio n. 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
Esempio n. 3
0
 def _runProgram(self, program_name, program, exc_lineno):
     """
 Executes the program.
 :param str program_name:
 :param str program:
 :param int exc_lineno: line number of exception (0 if None)
 :return str: message from syntax checking and program execution
 """
     executer = ProgramExecuter(program_name, program, self.namespace)
     msg = executer.execute()
     if msg is None:
         msg = executer.execute()
         if exc_lineno == 0:
             self.assertIsNone(msg)
         else:
             self.assertTrue(str(exc_lineno) in msg)
     return msg
 def _runProgram(self, program_name, program, exc_lineno):
   """
   Executes the program.
   :param str program_name:
   :param str program:
   :param int exc_lineno: line number of exception (0 if None)
   :return str: message from syntax checking and program execution
   """
   executer = ProgramExecuter(program_name, program,
       self.namespace)
   msg = executer.execute()
   if msg is None:
     msg = executer.execute()
     if exc_lineno == 0:
       self.assertIsNone(msg)
     else:
       self.assertTrue(str(exc_lineno) in msg)
   return msg
Esempio n. 5
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()
    namespace[API_OBJECT] = executer.getNamespace()[API_OBJECT]
    return result
Esempio n. 6
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