asfjghdszdvcxvcxi dsai saljcxzv fds;oj vcxzo vcxzoi xz

master
daz 2013-11-23 20:55:55 +01:00
parent b92f36bbb2
commit a9dc8ee50a
1 changed files with 15 additions and 7 deletions

View File

@ -11,6 +11,11 @@ import json
INTERVAL = 15
LABEL_TEMPLATE = """\
{users}
unknown:{unknown}\
"""
class HelloPython(plasmascript.Applet):
def init(self):
@ -31,7 +36,6 @@ class HelloPython(plasmascript.Applet):
self.layout.addItem(self.at_list)
self.layout.addItem(hs_button)
self.applet.setLayout(self.layout)
self.update_list()
self.connect_to_engine()
self.resize(125, 125)
@ -41,8 +45,10 @@ class HelloPython(plasmascript.Applet):
api_content = urlopen("https://at.hackerspace.pl/api").read()
except (URLError, HTTPError):
pass # TODO:
users = json.loads(api_content)["users"]
return (x["login"] for x in users)
json_dict = json.loads(api_content)
users = json_dict["users"]
unknown = json_dict["unknown"]
return (x["login"] for x in users), unknown
def connect_to_engine(self):
self.timeEngine = self.dataEngine("time")
@ -50,7 +56,9 @@ class HelloPython(plasmascript.Applet):
self, INTERVAL*6000, Plasma.AlignToMinute)
def update_list(self):
self.at_list.setText("\n".join(self.get_user_list()))
users, unknown = self.get_user_list()
users = "\n".join(users)
self.at_list.setText(LABEL_TEMPLATE.format(users=users, unknown=unknown))
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
def dataUpdated(self, sourceName, data):