summaryrefslogtreecommitdiffstats
path: root/py3status/modules
diff options
context:
space:
mode:
authorTimm Szigat <timm@szigat.de>2015-02-02 23:57:54 +0100
committerTimm Szigat <timm@szigat.de>2015-02-02 23:57:54 +0100
commit11997293f350f52a4b2c9ec18113be9af59a8a82 (patch)
treecd607e381c26643e465d8bd34beebc90436da708 /py3status/modules
parentb8c154127083406349a126d6692d67e1757ef35a (diff)
module spaceapi QA
Diffstat (limited to 'py3status/modules')
-rw-r--r--py3status/modules/spaceapi.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/py3status/modules/spaceapi.py b/py3status/modules/spaceapi.py
index 6f9dcd9..8703fc9 100644
--- a/py3status/modules/spaceapi.py
+++ b/py3status/modules/spaceapi.py
@@ -7,35 +7,34 @@ Author: @timmszigat
License: WTFPL http://www.wtfpl.net/txt/copying/
"""
-from time import time
+import codecs
import datetime
import json
+from time import time
import urllib.request
-import codecs
class Py3status:
"""
Configuration Parameters:
- - cache_timeout: Set timeout between calls in seconds
- - url: URL to SpaceAPI json file of your space
- - open_text: text if space is open, strftime parmeters will be translated
- - open_color: color if space is open
- - closed_text: text if space is closed, strftime parameters will be translated
- - closed_color: color if space is closed
+ - cache_timeout: Set timeout between calls in seconds
+ - closed_color: color if space is closed
+ - closed_text: text if space is closed, strftime parameters will be translated
+ - open_color: color if space is open
+ - open_text: text if space is open, strftime parmeters will be translated
+ - url: URL to SpaceAPI json file of your space
"""
# available configuration parameters
cache_timeout = 60
- url = 'http://status.chaospott.de/status.json'
- open_text = 'open since %H:%M'
- open_color = None
- closed_text = 'closed since %H:%M'
closed_color = None
+ closed_text = 'closed since %H:%M'
+ open_color = None
+ open_text = 'open since %H:%M'
+ url = 'http://status.chaospott.de/status.json'
def check(self, i3s_output_list, i3s_config):
response = {
- 'name': 'spaceapi',
'cached_until': time() + self.cache_timeout
}
@@ -47,14 +46,12 @@ class Py3status:
if not self.closed_color:
self.closed_color = ''
-
# grab json file
json_file=urllib.request.urlopen(self.url)
reader = codecs.getreader("utf-8")
data = json.load(reader(json_file))
json_file.close()
-
if(data['state']['open'] == True):
response['full_text'] = self.open_text
response['short_text'] = '%H:%M'
@@ -74,7 +71,6 @@ class Py3status:
except:
response['full_text'] = '';
-
return response
if __name__ == "__main__":