Exemplo n.º 1
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()
Exemplo 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()
Exemplo n.º 3
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()
Exemplo n.º 4
0
 def testMonitorWithHugeMemoryLimit(self):
   """Test the monitor with limit of 400Mb to the OpenOffice process"""
   try:
     self.monitor = MonitorMemory(openoffice, 1, 400)
     self.monitor.start()
     sleep(6)
     self.assertTrue(openoffice.status())
   finally:
     self.monitor.terminate()
Exemplo n.º 5
0
 def testMonitorWithHugeMemoryLimit(self):
   """Test the monitor with limit of 400Mb to the OpenOffice process"""
   try:
     self.monitor = MonitorMemory(openoffice, 1, 400)
     self.monitor.start()
     sleep(6)
     self.assertTrue(openoffice.status())
   finally:
     self.monitor.terminate()
Exemplo n.º 6
0
 def testGetMemoryUsage(self):
   """Test memory usage"""
   self.monitor = MonitorMemory(openoffice, 2, 400)
   openoffice.stop()
   memory_usage_int = self.monitor.get_memory_usage()
   self.assertEquals(memory_usage_int, 0)
   if not openoffice.status():
     openoffice.start()
   memory_usage_int = self.monitor.get_memory_usage()
   self.assertEquals(type(memory_usage_int), IntType)
Exemplo n.º 7
0
 def testMonitorWithLittleMemoryLimit(self):
   """Test the monitor with limit of 10Mb. In This case the openoffice will be
   stopped"""
   try:
     self.monitor = MonitorMemory(openoffice, 2, 10)
     self.monitor.start()
     sleep(self.interval)
     self.assertEquals(openoffice.status(), False)
   finally:
     self.monitor.terminate()
Exemplo n.º 8
0
 def testGetMemoryUsage(self):
   """Test memory usage"""
   self.monitor = MonitorMemory(openoffice, 2, 400)
   openoffice.stop()
   memory_usage_int = self.monitor.get_memory_usage()
   self.assertEquals(memory_usage_int, 0)
   if not openoffice.status():
     openoffice.start()
   memory_usage_int = self.monitor.get_memory_usage()
   self.assertEquals(type(memory_usage_int), IntType)
Exemplo n.º 9
0
 def testMonitorWithLittleMemoryLimit(self):
   """Test the monitor with limit of 10Mb. In This case the openoffice will be
   stopped"""
   try:
     self.monitor = MonitorMemory(openoffice, 2, 10)
     self.monitor.start()
     sleep(self.interval)
     self.assertEquals(openoffice.status(), False)
   finally:
     self.monitor.terminate()
Exemplo n.º 10
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()
Exemplo n.º 11
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
Exemplo n.º 12
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
Exemplo n.º 13
0
 def setUp(self):
   if not openoffice.status():
     openoffice.start()
Exemplo n.º 14
0
 def setUp(self):
   if not openoffice.status():
     openoffice.start()