summaryrefslogtreecommitdiffstats
path: root/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py')
-rw-r--r--meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py
new file mode 100644
index 0000000..f4f83d3
--- /dev/null
+++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+#
+# Copyright 2014-present Facebook. All Rights Reserved.
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+#
+
+
+import json
+import os
+import re
+
+# Handler for sensors resource endpoint
+def get_sensors():
+ result = []
+ data = os.popen('sensors').read()
+ data = re.sub(r'\(.+?\)', '', data)
+ for edata in data.split('\n\n'):
+ adata = edata.split('\n', 1)
+ sresult = {}
+ if (len(adata) < 2):
+ break;
+ sresult['name'] = adata[0]
+ for sdata in adata[1].split('\n'):
+ tdata = sdata.split(':')
+ if (len(tdata) < 2):
+ continue
+ sresult[tdata[0].strip()] = tdata[1].strip()
+ result.append(sresult)
+
+ fresult = {
+ "Information": result,
+ "Actions": [],
+ "Resources": [],
+ }
+
+ return fresult
OpenPOWER on IntegriCloud