Example #1
0
    def setUpClass(cls):  # pragma: no cover
        # Set clean HOME environment as OOO.org might scan it...
        cls._marker = object()
        cls.old_home = os.environ.get('HOME', cls._marker)
        cls.homedir = tempfile.mkdtemp()
        os.environ['HOME'] = cls.homedir

        # Don't start oooctl if it runs already...
        cls.ooo_running = False
        cls.oooctl_path = 'oooctl'

        if check_port('localhost', 2002):
            cls.ooo_running = True
            return

        # Start oooctl...
        cls.oooctl_path = 'oooctl'
        exe = sys.executable
        cls.oooctl_path = ulif.openoffice.oooctl.__file__
        cls.oooctl_path = os.path.splitext(cls.oooctl_path)[0] + '.py'
        cls.oooctl_path = '%s %s' % (exe, cls.oooctl_path)
        os.system(cls.oooctl_path + ' --stdout=/tmp/oooctl.log start')
        ts = time.time()
        while not check_port('localhost', 2002):
            time.sleep(0.5)
            if time.time() - ts > 3:
                break
            pass
        return
Example #2
0
    def setUpClass(cls):                                # pragma: no cover
        # Set clean HOME environment as OOO.org might scan it...
        cls._marker = object()
        cls.old_home = os.environ.get('HOME', cls._marker)
        cls.homedir = tempfile.mkdtemp()
        os.environ['HOME'] = cls.homedir

        # Don't start oooctl if it runs already...
        cls.ooo_running = False
        cls.oooctl_path = 'oooctl'

        if check_port('localhost', 2002):
            cls.ooo_running = True
            return

        # Start oooctl...
        cls.oooctl_path = 'oooctl'
        exe = sys.executable
        cls.oooctl_path = ulif.openoffice.oooctl.__file__
        cls.oooctl_path = os.path.splitext(cls.oooctl_path)[0] + '.py'
        cls.oooctl_path = '%s %s' % (exe, cls.oooctl_path)
        os.system(cls.oooctl_path + ' --stdout=/tmp/oooctl.log start')
        ts = time.time()
        while not check_port('localhost', 2002):
            time.sleep(0.5)
            if time.time() - ts > 3:
                break
            pass
        return
Example #3
0
 def stop_server():
     cmd = "%s %s.py stop" % (sys.executable, script_path)
     # It would be nice, to work w/o shell here.
     proc = subprocess.Popen(cmd, shell=True)
     proc.wait()
     ts = time.time()
     nap = 0.1
     while check_port('localhost', 2002):
         time.sleep(nap)
         nap = nap * 2
         if time.time() - ts > 3:
             break
Example #4
0
 def stop_server():
     cmd = "%s %s.py stop" % (sys.executable, script_path)
     # It would be nice, to work w/o shell here.
     proc = subprocess.Popen(cmd, shell=True)
     proc.wait()
     ts = time.time()
     nap = 0.1
     while check_port('localhost', 2002):
         time.sleep(nap)
         nap = nap * 2
         if time.time() - ts > 3:
             break
Example #5
0
def lo_server(request, home, tmpdir_sess, envpath_no_venv):
    """Start a libre office server (scope: session).

    session-scoped test fixture. Sets new $HOME.
    """
    if check_port("localhost", 2002):
        return
    script_path = os.path.splitext(oooctl.__file__)[0]
    log_path = tmpdir_sess.join("loctl.log")
    cmd = "%s %s.py --stdout=%s start" % (
        sys.executable, script_path, log_path)
    # It would be nice, to work w/o shell here.
    proc = subprocess.Popen(cmd, shell=True)
    proc.wait()
    ts = time.time()
    nap = 0.1
    while not check_port('localhost', 2002):
        time.sleep(nap)
        nap = nap * 2
        if time.time() - ts > 3:
            break

    def stop_server():
        cmd = "%s %s.py stop" % (sys.executable, script_path)
        # It would be nice, to work w/o shell here.
        proc = subprocess.Popen(cmd, shell=True)
        proc.wait()
        ts = time.time()
        nap = 0.1
        while check_port('localhost', 2002):
            time.sleep(nap)
            nap = nap * 2
            if time.time() - ts > 3:
                break

    request.addfinalizer(stop_server)
    return proc
Example #6
0
def lo_server(request, home, tmpdir_sess, envpath_no_venv):
    """Start a libre office server (scope: session).

    session-scoped test fixture. Sets new $HOME.
    """
    if check_port("localhost", 2002):
        return
    script_path = os.path.splitext(oooctl.__file__)[0]
    log_path = tmpdir_sess.join("loctl.log")
    cmd = "%s %s.py --stdout=%s start" % (sys.executable, script_path,
                                          log_path)
    # It would be nice, to work w/o shell here.
    proc = subprocess.Popen(cmd, shell=True)
    proc.wait()
    ts = time.time()
    nap = 0.1
    while not check_port('localhost', 2002):
        time.sleep(nap)
        nap = nap * 2
        if time.time() - ts > 3:
            break

    def stop_server():
        cmd = "%s %s.py stop" % (sys.executable, script_path)
        # It would be nice, to work w/o shell here.
        proc = subprocess.Popen(cmd, shell=True)
        proc.wait()
        ts = time.time()
        nap = 0.1
        while check_port('localhost', 2002):
            time.sleep(nap)
            nap = nap * 2
            if time.time() - ts > 3:
                break

    request.addfinalizer(stop_server)
    return proc
Example #7
0
    def tearDownClass(cls):  # pragma: no cover
        # Only shut down oooctl if it were not running already...
        if cls.ooo_running is not True:
            os.system(cls.oooctl_path + ' stop')
            ts = time.time()
            while check_port('localhost', 2002):
                time.sleep(0.5)
                if time.time() - ts > 3:
                    break
                pass

        # Clean up dirs...
        shutil.rmtree(cls.homedir)

        # Set HOME to old state...
        if cls.old_home is cls._marker:
            del os.environ['HOME']
        else:
            os.environ['HOME'] = cls.old_home
        return
Example #8
0
    def tearDownClass(cls):                             # pragma: no cover
        # Only shut down oooctl if it were not running already...
        if cls.ooo_running is not True:
            os.system(cls.oooctl_path + ' stop')
            ts = time.time()
            while check_port('localhost', 2002):
                time.sleep(0.5)
                if time.time() - ts > 3:
                    break
                pass

        # Clean up dirs...
        shutil.rmtree(cls.homedir)

        # Set HOME to old state...
        if cls.old_home is cls._marker:
            del os.environ['HOME']
        else:
            os.environ['HOME'] = cls.old_home
        return