[devtools] Firefox need write access to $HOME stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 15 Oct 2010 17:00:09 +0200
branchstable
changeset 6514 f328ec853e18
parent 6512 1f8b902f3143
child 6516 6b2e1e8d3a22
[devtools] Firefox need write access to $HOME Check that you have write acces to the user home before launching Firefox. Firefox need to write stuff in the home directory of the user and will silency crash when unable to do it. We add an assertion with an explicite message to improve crash report in such situation.
devtools/qunit.py
--- a/devtools/qunit.py	Fri Oct 15 16:20:27 2010 +0200
+++ b/devtools/qunit.py	Fri Oct 15 17:00:09 2010 +0200
@@ -11,6 +11,7 @@
 from logilab.common.testlib import unittest_main, with_tempdir, InnerTest
 
 import os
+from os.path import expanduser
 import cubicweb
 from cubicweb.view import StartupView
 from cubicweb.web.controller import Controller
@@ -53,15 +54,19 @@
         stdout = TemporaryFile()
         stderr = TemporaryFile()
         try:
-          check_call(['firefox', '-no-remote', '-CreateProfile',
-                      '%s %s' % (self._profile_name, self._tmp_dir)],
-                                stdout=stdout, stderr=stderr)
+            home = expanduser('~')
+            user = os.getlogin()
+            assert os.access(home, os.W_OK), \
+                   'No write access to your home directory, Firefox will crash.'\
+                   ' Are you sure "%s" is a valid home  for user "%s"' % (home, user)
+            check_call(['firefox', '-no-remote', '-CreateProfile',
+                        '%s %s' % (self._profile_name, self._tmp_dir)],
+                                  stdout=stdout, stderr=stderr)
         except CalledProcessError, cpe:
             stdout.seek(0)
             stderr.seek(0)
             raise VerboseCalledProcessError(cpe.returncode, cpe.cmd, stdout.read(), stderr.read())
 
-
     def start(self, url):
         self.stop()
         fnull = open(os.devnull, 'w')