equal
deleted
inserted
replaced
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 import os, os.path as osp |
18 import os, os.path as osp |
|
19 import time |
19 import errno |
20 import errno |
20 import shutil |
21 import shutil |
21 from queue import Queue, Empty |
22 from queue import Queue, Empty |
22 from tempfile import mkdtemp, TemporaryDirectory |
23 from tempfile import mkdtemp, TemporaryDirectory |
23 from subprocess import Popen, PIPE, STDOUT |
24 from subprocess import Popen, PIPE, STDOUT |
77 cmd = self.firefox_cmd + ['-silent', '--profile', self._profile_dir, |
78 cmd = self.firefox_cmd + ['-silent', '--profile', self._profile_dir, |
78 '-url', self._url] |
79 '-url', self._url] |
79 with open(self.log_file, 'wb') as fout: |
80 with open(self.log_file, 'wb') as fout: |
80 self._process = Popen(cmd, stdout=fout, stderr=STDOUT) |
81 self._process = Popen(cmd, stdout=fout, stderr=STDOUT) |
81 |
82 |
|
83 # check that the process has correctly started |
|
84 time.sleep(1) |
|
85 if self._process.poll() is not None: |
|
86 with open(self.log_file, 'r') as f: |
|
87 log = f.read() |
|
88 |
|
89 raise Exception("Error: failed to start firefox subprocess using the command " |
|
90 "'%s' with the return code '%s' and the output:\n\n%s" % |
|
91 (' '.join(cmd), self._process.poll(), log)) |
|
92 |
82 def stop(self): |
93 def stop(self): |
83 if self._process is not None: |
94 if self._process is not None and self._process.poll() is None: |
84 assert self._process.returncode is None, self._process.returncode |
95 assert self._process.returncode is None, self._process.returncode |
85 self._process.terminate() |
96 self._process.terminate() |
86 self._process.wait() |
97 self._process.wait() |
87 self._process = None |
98 self._process = None |
88 |
99 |