]>
Commit | Line | Data |
---|---|---|
405d20bc MT |
1 | From 810fe43289f5b003cbf80ebb1d9a79f52a767cdb Mon Sep 17 00:00:00 2001 |
2 | From: Michael Tremer <michael.tremer@ipfire.org> | |
3 | Date: Mon, 15 Dec 2014 22:48:26 +0100 | |
4 | Subject: [PATCH 3/3] Revert vendor/model for ARM to old behaviour | |
5 | ||
6 | --- | |
7 | src/fireinfo/system.py | 33 +++++++++++++++++++++++++++++---- | |
8 | 1 file changed, 29 insertions(+), 4 deletions(-) | |
9 | ||
10 | diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py | |
11 | index 195832e9f7eb..ce33837af747 100644 | |
12 | --- a/src/fireinfo/system.py | |
13 | +++ b/src/fireinfo/system.py | |
14 | @@ -304,6 +304,27 @@ class System(object): | |
15 | """ | |
16 | return read_from_file("/sys/class/dmi/id/bios_vendor") | |
17 | ||
18 | + def vendor_model_tuple(self): | |
19 | + try: | |
20 | + s = self.__cpuinfo["Hardware"] | |
21 | + except KeyError: | |
22 | + return (None, None) | |
23 | + | |
24 | + if s.startswith("ARM-Versatile"): | |
25 | + return ("ARM", s) | |
26 | + | |
27 | + try: | |
28 | + v, m = s.split(" ", 1) | |
29 | + except ValueError: | |
30 | + if s.startswith("BCM"): | |
31 | + v = "Broadcom" | |
32 | + m = s | |
33 | + else: | |
34 | + v = None | |
35 | + m = s | |
36 | + | |
37 | + return v, m | |
38 | + | |
39 | @property | |
40 | def vendor(self): | |
41 | """ | |
42 | @@ -316,10 +337,10 @@ class System(object): | |
43 | break | |
44 | ||
45 | if ret is None: | |
46 | - try: | |
47 | - return self.__cpuinfo["Hardware"] | |
48 | - except KeyError: | |
49 | - pass | |
50 | + if os.path.exists("/proc/device-tree"): | |
51 | + ret = self.__cpuinfo.get("Hardware", None) | |
52 | + else: | |
53 | + ret, m = self.vendor_model_tuple() | |
54 | ||
55 | return ret | |
56 | ||
57 | @@ -340,6 +361,10 @@ class System(object): | |
58 | # replace the NULL byte with which the DT string ends | |
59 | ret = ret.replace(u"\u0000", "") | |
60 | ||
61 | + # Fall back to read /proc/cpuinfo | |
62 | + if not ret: | |
63 | + v, ret = self.vendor_model_tuple() | |
64 | + | |
65 | return ret | |
66 | ||
67 | @property | |
68 | -- | |
69 | 1.9.3 | |
70 |