Commit 8c7c9fc6 authored by Markus's avatar Markus

multiuser notification, distingush between devices and users

- now multiple notifications for coming/ going are getting created
- if device count changes no longer user notifications are getting created
parent d4d738a0
......@@ -79,7 +79,7 @@ if __name__ == '__main__':
}
#compare saved and fetched value
if not (cached_data_dict['device_count'] == device_count ) :
if args.show_user == True and (cached_data_dict['device_count'] != device_count ) :
count_changed=True
......@@ -97,11 +97,11 @@ if __name__ == '__main__':
if user_diff_fetched.__len__() > 0 :
count_changed = True
user_new = user_diff_fetched[0]
user_new_list = user_diff_fetched
if user_diff_saved.__len__() > 0 :
count_changed = True
user_left = user_diff_saved[0]
user_left_list = user_diff_saved
### save to cachefile ####
......@@ -115,18 +115,24 @@ if __name__ == '__main__':
print ("HackHro Users: ",users.__len__())
else :
print ("HackHro Devcies: ",device_count)
try:
user_left
user_left_list
except NameError:
pass
else:
print ("User left: ",user_left)
print(user_left_list)
print ("Users left: ",end="")
for user in user_left_list :
print (user['name']+" " ,end="")
try:
user_new
user_new_list
except NameError :
pass
else :
print ("User New: ",user_new)
print ("Users new: ",end="")
for user in user_new_list :
print (user['name']+" ",end="")
##notification
......@@ -136,32 +142,35 @@ if __name__ == '__main__':
notif = bus.get_object(item, path)
notify = dbus.Interface(notif, interface)
notification_string = ""
if args.show_user == False :
title = "HackSpace Users Changed"
try:
user_left
user_left_list
except NameError:
pass
else:
icon = os.path.join(CACHE_PICTURE_FOLDER,str(user_left['id'])+".jpg")
notification_string = "the user "+str(user_left['name'])+" left."
#print ("User left: ",user_left)
for user in user_left_list :
icon = os.path.join(CACHE_PICTURE_FOLDER,str(user['id'])+".jpg")
notification_string = "the user "+str(user['name'])+" left."
#create notification
notify.Notify(app_name, 0, icon, title, notification_string, array, hint, time)
try:
user_new
user_new_list
except NameError :
pass
else :
icon = os.path.join(CACHE_PICTURE_FOLDER,str(user_new['id'])+".jpg")
print(icon)
notification_string = "the user "+str(user_new['name'])+" just came in."
for user in user_new_list :
icon = os.path.join(CACHE_PICTURE_FOLDER,str(user['id'])+".jpg")
notification_string = "the user "+str(user['name'])+" just came in."
#create notification
notify.Notify(app_name, 0, icon, title, notification_string, array, hint, time)
else :
title = "HackSpace Devices Changed"
notification_string = str(device_count)
#create notification
notify.Notify(app_name, 0, icon, title, notification_string, array, hint, time)
#create notification
notify.Notify(app_name, 0, icon, title, notification_string, array, hint, time)
count_changed = False
if not args.daemonize == True :
......
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