Ejemplo n.º 1
0
 def tearDown(self):
   """Restart the openoffice in cases that the openoffice is stopped"""
   if not openoffice.status():
     openoffice.acquire()
     openoffice.restart()
     openoffice.release()
   if self.monitor.is_alive():
     self.monitor.terminate()
Ejemplo n.º 2
0
 def tearDown(self):
   """Restart the openoffice in cases that the openoffice is stopped"""
   if not openoffice.status():
     openoffice.acquire()
     openoffice.restart()
     openoffice.release()
   if self.monitor.is_alive():
     self.monitor.terminate()
Ejemplo n.º 3
0
 def testStopOpenOffice(self):
   """Test if the openoffice stop by the monitor"""
   openoffice.acquire()
   try:
     monitor_timeout = self._createMonitor(1)
     monitor_timeout.start()
     sleep(2)
     self.assertEquals(openoffice.status(), False)
     openoffice.restart()
     self.assertTrue(openoffice.status())
   finally:
     monitor_timeout.terminate()
     openoffice.release()
Ejemplo n.º 4
0
  def _callUnoConverter(self, *feature_list, **kw):
    """ """
    if not openoffice.status():
      openoffice.start()
    command_list = self._getCommand(*feature_list, **kw)
    stdout, stderr = self._subprocess(command_list)
    if not stdout and len(re.findall("\w*Exception|\w*Error", stderr)) >= 1:
      logger.debug(stderr)
      self.document.restoreOriginal()
      openoffice.restart()
      kw['document_url'] = self.document.getUrl()
      command = self._getCommand(*feature_list, **kw)
      stdout, stderr = self._subprocess(command)
      if stderr != "":
          raise Exception(stderr)

    return stdout, stderr
Ejemplo n.º 5
0
  def _callUnoConverter(self, *feature_list, **kw):
    """ """
    if not openoffice.status():
      openoffice.start()
    command_list = self._getCommand(*feature_list, **kw)
    stdout, stderr = self._subprocess(command_list)
    if not stdout and stderr:
      first_error = stderr
      logger.error(stderr)
      self.document.restoreOriginal()
      openoffice.restart()
      kw['document_url'] = self.document.getUrl()
      command = self._getCommand(*feature_list, **kw)
      stdout, stderr = self._subprocess(command)
      if not stdout and stderr:
        second_error = "\nerror of the second run: " + stderr
        logger.error(second_error)
        raise Exception(first_error + second_error)

    return stdout, stderr
Ejemplo n.º 6
0
 def testStopOpenOfficeTwice(self):
   """Test the cases that is necessary start the monitors twice"""
   openoffice.acquire()
   try:
     monitor_timeout = self._createMonitor(1)
     monitor_timeout.start()
     sleep(2)
     self.assertEquals(openoffice.status(), False)
     monitor_timeout.terminate()
     openoffice.restart()
     self.assertTrue(openoffice.status())
     monitor_timeout = self._createMonitor(1)
     monitor_timeout.start()
     sleep(2)
     self.assertEquals(openoffice.status(), False)
     monitor_timeout.terminate()
     sleep(1)
     self.assertEquals(monitor_timeout.is_alive(), False)
   finally:
     monitor_timeout.terminate()
     openoffice.release()