Commit dc5dd511 authored by Markus's avatar Markus

added option for printing/notify

parent a01d8cfa
......@@ -2,18 +2,31 @@
import urllib
import json
import pynotify
import getopt
import sys
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Process stuff')
parser.add_argument("-n","--notify",action="store_true",help="Create a notification using\
libnotify",default=False)
parser.add_argument("-p","--printing",action="store_true",help="Create a notification using\
libnotify",default=True)
args= parser.parse_args()
##fetch usercount
var=urllib.urlopen("http://hack-hro.de/api/users")
device_count=json.loads(var.read().decode())['deviceCount']
if not pynotify.init("HackHro"):
sys.exit(1)
n = pynotify.Notification("DeviceCount", str(device_count)+" Devices")
if not n.show():
print ("Failed to send notification")
sys.exit(1)
if args.notify:
if not pynotify.init("HackHro"):
sys.exit(1)
#create notification
n = pynotify.Notification("DeviceCount", str(device_count)+" Devices")
if not n.show():
print ("Failed to send notification")
sys.exit(1)
if args.printing:
print "HackHro Users: ",device_count
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