~ubuntu-branches/ubuntu/lucid/checkbox/lucid-proposed

« back to all changes in this revision

Viewing changes to plugins/backend_info.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Manrique
  • Date: 2011-06-22 14:18:08 UTC
  • Revision ID: james.westby@ubuntu.com-20110622141808-7deahjrkz2hpthw6
Tags: 0.9.2
New upstream release (LP: #567568):
* Added referer when sending submissions to Launchpad (LP: #550973)
* Added suggests to checkbox package in debian/control file (LP: #352740)
* Fixed udev_resource script to be more resilient (LP: #556824)
* Fixed cdimage_resource script to read casper.log (LP: #558728)
* Fixed reporting all resources found for a job (LP: #560948)
* Fixed stalling when using kdesudo to start backend (LP: #557443)
* Fixed starting the appropriate default browser on UNR (LP: #563050)
* Fixed opening the report with the gconf preferred browser (LP: #562580)
* Fixed suspend_test to use relative time for wakealarm (LP: #349768)
* Fixed backend not getting terminated upon closing (LP: #553328)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#
19
19
import os
20
20
import shutil
21
 
import signal
22
21
 
23
22
from subprocess import call, PIPE
24
23
from tempfile import mkdtemp
44
43
        # Backend should run as early as possible
45
44
        self._manager.reactor.call_on("gather", self.gather, -100)
46
45
 
47
 
    def get_root_command(self, command):
 
46
    def get_command(self, *args):
 
47
        command = [self.command, "--path=%s" % os.environ["PATH"]]
 
48
 
 
49
        return command + list(args)
 
50
 
 
51
    def get_root_command(self, *args):
48
52
        uid = os.getuid()
49
53
        if uid == 0:
50
54
            prefix = []
59
63
                    stdout=PIPE, stderr=PIPE) == 0 and \
60
64
                call(["pgrep", "-x", "-u", str(uid), "gnome-panel|gconfd-2"],
61
65
                    stdout=PIPE, stderr=PIPE) == 0:
62
 
            prefix = ["gksu", "-k", "--"]
 
66
            prefix = ["gksu", "--"]
63
67
        else:
64
 
            prefix = ["sudo", "-E"]
65
 
 
66
 
        # Append PATH
67
 
        prefix.append("PATH=%s" % os.environ["PATH"])
68
 
 
69
 
        # Extend command
70
 
        prefix.extend(command)
71
 
 
72
 
        return prefix
 
68
            prefix = ["sudo"]
 
69
 
 
70
        return prefix + self.get_command(*args)
73
71
 
74
72
    def gather(self):
75
73
        self.directory = mkdtemp(prefix="checkbox")
82
80
            self.parent_reader = FifoReader(child_output)
83
81
 
84
82
        else:
85
 
            command = [self.command, child_input, child_output]
86
 
            root_command = self.get_root_command(command)
 
83
            root_command = self.get_root_command(child_input, child_output)
87
84
            os.execvp(root_command[0], root_command)
88
85
            # Should never get here
89
86
 
95
92
                self._manager.reactor.fire("message-result", *result)
96
93
 
97
94
    def stop(self):
98
 
        os.kill(self.pid, signal.SIGHUP)
 
95
        self.parent_writer.close()
 
96
        self.parent_reader.close()
 
97
        shutil.rmtree(self.directory)
 
98
 
99
99
        os.waitpid(self.pid, 0)
100
100
 
101
 
        shutil.rmtree(self.directory)
102
 
 
103
101
 
104
102
factory = BackendInfo