Commit 970af23c authored by Markus's avatar Markus

fixed the "user has no avatar" problem now using the default avatar

parent 54a63610
......@@ -13,6 +13,7 @@ import itertools
USER_HOME = os.path.expanduser("~")
CACHE_FOLDER = os.path.join(str(USER_HOME),".cache/hack_count")
CACHE_PICTURE_FOLDER = os.path.join(str(USER_HOME),".cache/hack_count/pics")
DEFAULT_CACHE_PICTURE = os.path.join(str(USER_HOME),".cache/hack_count/pics/default.png")
CACHE_FILE = "hack_count.json"
CACHE_PATH = os.path.join(str(CACHE_FOLDER),str(CACHE_FILE))
count_changed=True
......@@ -75,10 +76,18 @@ if __name__ == '__main__':
if not os.path.exists(CACHE_PICTURE_FOLDER) :
os.makedirs(CACHE_PICTURE_FOLDER)
if not os.path.isfile(DEFAULT_CACHE_PICTURE):
urllib.request.urlretrieve("http://hack-hro.de/avatar/default.png",DEFAULT_CACHE_PICTURE)
for user in users :
user_image_path = os.path.join(CACHE_PICTURE_FOLDER,str(user['id'])+".jpg")
if not os.path.isfile(user_image_path) :
urllib.request.urlretrieve("http://hack-hro.de"+user['avatar'],user_image_path)
try :
user['avatar']
except :
pass
else :
urllib.request.urlretrieve("http://hack-hro.de"+user['avatar'],user_image_path)
####fetch cached vals
......@@ -167,6 +176,8 @@ if __name__ == '__main__':
else:
for user in user_left_list :
icon = os.path.join(CACHE_PICTURE_FOLDER,str(user['id'])+".jpg")
if not os.path.isfile(icon):
icon = os.path.join(CACHE_PICTURE_FOLDER,"default.png")
notification_string = "the user "+str(user['name'])+" left."
#create notification
notify.Notify(app_name, 0, icon, title, notification_string, array, hint, time)
......@@ -177,6 +188,9 @@ if __name__ == '__main__':
else :
for user in user_new_list :
icon = os.path.join(CACHE_PICTURE_FOLDER,str(user['id'])+".jpg")
if not os.path.isfile(icon):
icon = os.path.join(CACHE_PICTURE_FOLDER,"default.png")
notification_string = "the user "+str(user['name'])+" just came in."
#create notification
notify.Notify(app_name, 0, icon, title, notification_string, array, hint, time)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment