Beispiel #1
0
def execute(command):
    if command == "quit()":
        print "\nOMC has been Shutdown\n"
        sys.exit(1)
    else:
        result = omc.sendExpression(command)
        answer = OMParser.check_for_values(result)
        OMParser.result = {}
        return answer
Beispiel #2
0
def execute(command):
    if command == "quit()":
        print "\nOMC has been Shutdown\n"
        sys.exit(1)
    else:
        result = omc.sendExpression(command)
        answer = OMParser.check_for_values(result)
        OMParser.result = {}
        return answer
Beispiel #3
0
def run():
    omc_running = True
    while omc_running:
        command = raw_input("\n>>")
        if command == "quit()":
            print "\nOMC has been Shutdown\n"
            omc_running = False
            sys.exit(1)
        else:
            result = omc.sendExpression(command)
            answer = OMParser.check_for_values(result)
            OMParser.result = {}
            print answer
Beispiel #4
0
def run():
    omc_running = True
    while omc_running:
        command = raw_input("\n>>")
        if command == "quit()":
            print "\nOMC has been Shutdown\n"
            omc_running = False
            sys.exit(1)
        else:
            result = omc.sendExpression(command)
            answer = OMParser.check_for_values(result)
            OMParser.result = {}
            print answer
Beispiel #5
0
    def execute(self, command):
        if self.echo:
            print command
        curdir = os.path.abspath(os.path.curdir)
        os.chdir(self.build_path)
        if command == "quit()":
            self.omc.sendExpression("quit()")
            print "\nOMC has been Shutdown\n"
            os.chdir(curdir)
            sys.exit(1)
        else:
            result = self.omc.sendExpression(command)
            error = self.omc.sendExpression('getErrorString()').strip()[1:-1]
            try:
                if self.re_simulate.match(command):
                    answer = OMParser.check_for_values(result)
                    OMParser.result = {}
                    if type(answer) is dict and answer != {}:
                        result = answer
                        messages = get(result, 'SimulationResults.messages')
                        print "messages: ", messages
                        if self.re_error.match(messages):
                            raise Exception(messages)
                elif type(result) is bool:
                    if not (result):
                        raise Exception("command: %s returned false" % command)
                elif type(result) is str:
                    if self.re_error.match(result):
                        raise Exception(result)

                if self.re_error.match(error):
                    raise Exception(error)

            finally:
                os.chdir(curdir)

            return result
Beispiel #6
0
  def execute(self,command):
    if self.echo:
      print command
    curdir = os.path.abspath(os.path.curdir)
    os.chdir(self.build_path)
    if command == "quit()":
      self.omc.sendExpression("quit()")
      print "\nOMC has been Shutdown\n"
      os.chdir(curdir)
      sys.exit(1)
    else:
      result = self.omc.sendExpression(command)
      error = self.omc.sendExpression('getErrorString()').strip()[1:-1]
      try:
        if self.re_simulate.match(command):
          answer = OMParser.check_for_values(result)
          OMParser.result = {}
          if type(answer) is dict and answer != {}:
            result = answer
            messages = get(result,'SimulationResults.messages')
            print "messages: ", messages
            if self.re_error.match(messages):
              raise Exception(messages)
        elif type(result) is bool:
          if not (result):
            raise Exception("command: %s returned false" % command)
        elif type(result) is str:
          if self.re_error.match(result):
            raise Exception(result)

        if self.re_error.match(error):
          raise Exception(error)

      finally:
        os.chdir(curdir)

      return result