~ubuntu-branches/ubuntu/precise/landscape-client/precise

« back to all changes in this revision

Viewing changes to landscape/manager/hardwareinfo.py

  • Committer: Package Import Robot
  • Author(s): Andreas Hasenack
  • Date: 2012-03-19 09:33:34 UTC
  • mto: This revision was merged to the branch mainline in revision 41.
  • Revision ID: package-import@ubuntu.com-20120319093334-oxjttz163vvfgq8s
Tags: upstream-12.04
ImportĀ upstreamĀ versionĀ 12.04

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
 
3
from twisted.internet.utils import getProcessOutput
 
4
 
 
5
from landscape.manager.plugin import ManagerPlugin
 
6
 
 
7
 
 
8
class HardwareInfo(ManagerPlugin):
 
9
    """A plugin to retrieve hardware information."""
 
10
 
 
11
    message_type = "hardware-info"
 
12
    run_interval = 60 * 60 * 24
 
13
    run_immediately = True
 
14
    command = "/usr/bin/lshw"
 
15
 
 
16
    def run(self):
 
17
        self.call_on_accepted(self.message_type, self.send_message)
 
18
        return self.registry.broker.call_if_accepted(
 
19
                self.message_type, self.send_message)
 
20
 
 
21
    def send_message(self):
 
22
        result = getProcessOutput(
 
23
            self.command, args=["-xml", "-quiet"], env=os.environ, path=None)
 
24
        return result.addCallback(self._got_output)
 
25
 
 
26
    def _got_output(self, output):
 
27
        message = {"type": self.message_type, "data": output}
 
28
        return self.registry.broker.send_message(message)