summaryrefslogtreecommitdiff
diff options
authorrod.smith <rod.smith@canonical.com>2014-07-16 14:28:38 -0400
committerrod.smith <rod.smith@canonical.com>2014-07-16 14:28:38 -0400
commit8e2d02c097a0b880d79c656c4370850998c0b65b (patch)
tree4c9a2af3436d131d53938a4893bb5fa0733aed2b
parent3ce73e9cd0df844f4c87abdc14de231e5fa92b15 (diff)
Rewrite in response to comments
-rwxr-xr-xbin/get_make_and_model29
-rw-r--r--jobs/miscellanea.txt.in3
2 files changed, 19 insertions, 13 deletions
diff --git a/bin/get_make_and_model b/bin/get_make_and_model
index 331198a..0a7b855 100755
--- a/bin/get_make_and_model
+++ b/bin/get_make_and_model
@@ -1,18 +1,25 @@
#!/usr/bin/env python3
-import sys
-from subprocess import call
+import os.path
+def PrintFileContents(Heading, Filename):
+ if os.path.isfile(Filename):
+ File = open(Filename, 'r')
+ RawContents = File.read()
+ StrippedContents = RawContents.rstrip('\n')
+ print(Heading + ": " + StrippedContents)
+ File.close()
+ return 1
+ else:
+ print("Unable to determine " + Heading)
+ return 0
def main():
-
- print ("Manufacturer: ", end="", flush=True)
- call(["dmidecode", "-s", "system-manufacturer"])
- print ("Model: ", end="", flush=True)
- call(["dmidecode", "-s", "system-product-name"])
- print ("Version: ", end="", flush=True)
- call(["dmidecode", "-s", "system-version"])
- return 0
+ Success = PrintFileContents('Manufacturer', '/sys/class/dmi/id/sys_vendor')
+ Success = Success & PrintFileContents('Model', '/sys/class/dmi/id/product_name')
+ Success = Success & PrintFileContents('Version', '/sys/class/dmi/id/product_version')
+ return (not Success)
if __name__ == "__main__":
- sys.exit(main())
+ raise SystemExit(main())
+
diff --git a/jobs/miscellanea.txt.in b/jobs/miscellanea.txt.in
index b7fe8c4..02394c1 100644
--- a/jobs/miscellanea.txt.in
+++ b/jobs/miscellanea.txt.in
@@ -178,7 +178,6 @@ plugin: shell
estimated_duration: 0.1
id: miscellanea/get_make_and_model
user: root
-command: make_model
+command: get_make_and_model
_description: Retrieve the computer's make and model for easier access than digging through the dmidecode output.
_summary: Retrieve the computer's make and model
-requires: package.name == "dmidecode"