def dotell_body(str, loc, toks,changed_only=False): model = toks[1] if model == '.': model = defaultmodel context = [x for x in toks[2:-6] if x != '/'] componentid = toks[-5] evidence_type = toks[-3] newval = toks[-1] print "Tell %s/%s/%s, %s:%s" % (model, context, componentid, evidence_type, newval) try: if model!=defaultmodel: global Personis import Personis as pmdns um = pmdns.Access(model=model, user=user, password=password) if changed_only: comp = um.ask(context=context, view=[componentid], resolver='default')[0] if comp.value == newval: return True # don't actually need to do the tell um.tell(context=context, componentid=componentid, evidence=Personis_base.Evidence(evidence_type=evidence_type, value=newval)) else: if changed_only: comp = currentum.ask(context=context, view=[componentid], resolver='default')[0] if comp.value == newval: return True # don't actually need to do the tell currentum.tell(context=context, componentid=componentid, evidence=Personis_base.Evidence(evidence_type=evidence_type, value=newval)) except: print 'tell failed' raise ParseException, (str, loc, "tell failed",0) return True
def list_subs(self, context=None, componentid=None): self.curcontext = self._getcontextdir(context) try: subs,subs_shelf_fd = Personis_base.shelf_open(self.curcontext+"/.subscriptions", "r") except: raise ValueError, 'no subs db when listing subs for component "%s" in context "%s" '%(componentid,self.curcontext) if not subs.has_key(componentid): raise ValueError, 'no subs for component "%s" in context "%s" not found'%(componentid,self.curcontext) subdict = subs[componentid] if subs != None: Personis_base.shelf_close(subs, subs_shelf_fd) return subdict
def docomponent(str, loc, toks): global attrs, keyvals, paths, curcontext, themodel, Debug if curcontext == "": print "No context defined for component", toks[1] print "docomponent::", toks[1] sys.stdout.flush() print " \tattrs::", attrs required = ['type', 'description', 'value_type'] for x in required: if x not in attrs[0]: print "one or more of the required keyvals", required, "not found for ", toks[ 1] print attrs[0] return if not Debug: cobj = Personis_base.Component(Identifier=toks[1], component_type=attrs[0]['type'], value_type=attrs[0]['value_type'], value_list=attrs[0].get('value'), resolver=attrs[0].get('resolver'), Description=attrs[0]['description']) try: res = themodel.mkcomponent(context=curcontext, componentobj=cobj) except: print "mkcomponent failed" if res != None: print res print """cobj = Personis_base.Component(Identifier="%s", component_type="%s", value_type="%s", value_list="%s", resolver="%s", Description="%s") """ % (toks[1], attrs[0]['type'], attrs[0]['value_type'], attrs[0].get('value'), attrs[0].get('resolver'), attrs[0]['description']) if 'rule' in attrs[0]: if type(attrs[0]['rule']) != type([]): rules = [attrs[0]['rule']] for rule in rules: if not Debug: themodel.subscribe(context=curcontext, view=[toks[1]], subscription=dict(user="******", password="******", statement=rule)) print "\tsub::", curcontext, [toks[1]], dict(user="******", password="******", statement=rule) print "+++ component created " if len(attrs) > 1: # see if there is some evidence for e in attrs[1:]: print "\tevidence::", e dotells(e, toks[1]) # del attrs[0] attrs = [] keyvals = {} paths = []
def dotells(ev, compid): global themodel, curcontext evattrs = [ "flags", "evidence_type", "source", "owner", "value", "comment", "time", "useby" ] if not all([a in evattrs for a in ev]): print "**** evidence attributes %s must be one of %s" % (ev.keys(), ` evattrs `) return if "flags" in ev: if type(ev['flags']) != type([]): print "**** evidence flags %s must be a list" % (ev['flags']) return if not Debug: evobj = Personis_base.Evidence(evidence_type="explicit") for k, v in ev.items(): evobj.__dict__[k] = v themodel.tell(context=curcontext, componentid=compid, evidence=evobj) print """ evobj = Personis_base.Evidence(ev) themodel.tell(context=%s, componentid=%s, evidence=%s) """ % (curcontext, compid, evobj.__dict__) else: print """ evobj = Personis_base.Evidence(ev) themodel.tell(context=%s, componentid=%s, evidence=%s) """ % (curcontext, compid, ev)
def do_mkmodel(self, line): """mkmodel model_name [model_directory] makes a new empty model uses username, password specified in login cmd""" global umname, modeldir, username, userpassword if not loggedin(self.username, self.userpassword, 'mkmodel'): return line = line.split() if self.accesstype == "base": if len(line) != 2: print "usage: mkmodel model_name model_directory" return self.umname = line[0] modeldir = line[1] print "making model '%s' in directory '%s' with username '%s' and password '%s'" % ( self.umname, modeldir, self.username, self.userpassword) try: Personis_base.MkModel(model=self.umname, modeldir=modeldir, user=self.username, password=self.userpassword) except Exception, e: print "mkmodel failed: ", e return print "model made" print "to access the model, use the command 'model %s %s'" % ( self.umname, modeldir)
def getresolvers(self): '''Return a list of the available resolver names''' if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "getresolvers", {'modelname':self.modelname,\ 'authType':self.authType, 'auth':self.auth})
def docontext(str, loc, toks): global attrs, paths, curcontext, themodel, Debug, keyvals print "docontext::", toks print " \tpaths::", paths print " \tattrs::", attrs if len(paths) != 1: print "too many paths", paths raise ParseException, "too many paths " + ` paths ` curcontext = paths[0] print "\tcurcontext::", curcontext, curcontext.split('/') if 'description' not in attrs[0]: print "*** description required for ", curcontext raise ParseException, "description required for " + ` curcontext ` if not Debug: cobj = Personis_base.Context(Identifier=curcontext.split('/')[-1], Description=attrs[0]['description']) print "\tPersonis_base.Context(Identifier='%s', Description='%s')" % ( curcontext.split('/')[-1], attrs[0]['description']) print "\t", curcontext.split('/')[:-1] if not Debug: if themodel.mkcontext(curcontext.split('/')[:-1], cobj): print "+++ context created ok" else: print "+++ context creation failed" keyvals = {} del attrs[0] paths = []
def delcontext(self, context=[]): if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "delcontext", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context})
def ask(self, context=[], view=None, resolver=None, showcontexts=None): """ arguments: (see Personis_base for details) context is a list giving the path of context identifiers view is either: an identifier of a view in the context specified a list of component identifiers or full path lists None indicating that the values of all components in the context be returned resolver specifies a resolver, default is the builtin resolver returns a list of component objects """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) reslist = jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "ask", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'view':view,\ 'resolver':resolver,\ 'showcontexts':showcontexts}) complist = [] if showcontexts: cobjlist, contexts, theviews, thesubs = reslist for c in cobjlist: comp = Personis_base.Component(**c) if c["evidencelist"]: comp.evidencelist = [ Personis_base.Evidence(**e) for e in c["evidencelist"] ] complist.append(comp) reslist = [complist, contexts, theviews, thesubs] else: for c in reslist: comp = Personis_base.Component(**c) if c["evidencelist"]: comp.evidencelist = [ Personis_base.Evidence(**e) for e in c["evidencelist"] ] complist.append(comp) reslist = complist return reslist
def listapps(self): """ returns array of registered app names """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "listapps", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth})
def checksubs(self, context, componentid): subs,subs_shelf_fd = Personis_base.shelf_open(self.curcontext+"/.subscriptions", "r") #print ">>>subs in context '%s': %s" % (self.curcontext, subs.keys()) #print "checking subs for '%s'"%(componentid) if subs.has_key(componentid): subdict = subs[componentid] for subname,sub in subdict.items(): if sub == {}: continue Subscription.dosub(sub, self)
def listrequests(self): """ returns array of apps requesting authorisation """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "listrequests", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth})
def delete_sub(self, context=None, componentid=None, subname=None): self.curcontext = self._getcontextdir(context) if type(componentid) == type(u''): componentid = str(componentid) try: subs,subs_shelf_fd = Personis_base.shelf_open(self.curcontext+"/.subscriptions", "w") except: raise ValueError, 'no subs db when deleting sub %s for component "%s" in context "%s" not found'%(subname, componentid,self.curcontext) if not subs.has_key(componentid): raise ValueError, 'sub %s for component "%s" in context "%s" not found'%(subname, componentid,self.curcontext) subdict = subs[componentid] try: del subdict[subname] except: raise ValueError, 'cannot delete subname "%s" for component "%s" in context "%s" '%(subname,componentid,self.curcontext) subs[componentid] = subdict if subs != None: Personis_base.shelf_close(subs, subs_shelf_fd) return None
def mkmodel(model=None, mfile=None, modeldir=None, user=None, password=None): Personis_base.MkModel(model=model, modeldir=modeldir, user=user, password=password) auth = user + ":" + password um = Personis_a.Access(model=model, modeldir=modeldir, authType="user", auth=auth) mkmodel_um(um, get_modeldef(mfile))
def deleteapp(self, app=None): """ deletes an app """ if app == None: raise ValueError, "deleteapp: app is None" if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "deleteapp", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'app':app})
def import_model(self, context=[], partial_model=None): """ arguments: context is the context to import into partial_model is a json encoded string containing the partial model """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "import_model", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'partial_model':partial_model})
def list_subs(self, context=[], componentid=None): """ arguments: context is a list giving the path of context identifiers componentid designates the component with subscriptions attached """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "list_subs", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'componentid':componentid})
def doview(str, loc, toks): global paths, curcontext, themodel, Debug if curcontext == "": print "No context defined for view", toks[1] raise ParseException, "No context defined for view " + ` toks[1] ` if paths == []: print "No paths defined for view", toks[1] raise ParseException, "No paths defined for view " + ` toks[1] ` print "doview::", toks[1] print "\t paths::", paths if not Debug: vobj = Personis_base.View(Identifier=toks[1], component_list=paths) themodel.mkview(curcontext, vobj) paths = []
def getcontext(self, context=[], getsize=False): """ Get context information arguments: context - a list giving the path to the required context getsize - True if the size in bytes of the context subtree is required """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "getcontext", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'getsize':getsize})
def getpermission(self, context=None, componentid=None, app=None): """ gets permissions for a context (if componentid is None) or a component returns a tuple (ask,tell) """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "getpermission", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context': context,\ 'componentid': componentid,\ 'app': app})
def delete_sub(self, context=[], componentid=None, subname=None): """ arguments: context is a list giving the path of context identifiers componentid designates the component subscribed to subname is the subscription name """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "delete_sub", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'componentid':componentid,\ 'subname':subname})
def checksub(modeldir, m): sub = m['subscription'] try: um = pmdns.Access(modeldir=modeldir, model=sub['modelname'], user=sub['user'], password=sub['password']) except: print "Access failed", sub return print "Access OK", sub try: Subscription.dosub(sub, um) except: print "dosub failed" return print "dosub ok"
def mkcontext(self, context=[], contextobj=None): """ Make a new context in a given context arguments: context - a list giving the path to the required context contextobj - a Context object """ if contextobj == None: raise ValueError, "mkcontext: contextobj is None" if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "mkcontext", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'contextobj':contextobj.__dict__})
def do_tell(self, line): """tell component_name will prompt for component value etc""" global um, umname, context, username if not loggedin(self.username, self.userpassword, 'tell'): return if not nomodel(self.umname, line): return line = line.split() if len(line) != 1: print "usage: tell component" return compname = line[0] val = raw_input("Value? ") print "Evidence type:" for et in Personis_base.EvidenceTypes: print Personis_base.EvidenceTypes.index(et), et etindex = raw_input("Index? [0]") if etindex == '': etindex = 0 else: etindex = int(etindex) if (etindex < 0) or (etindex > len(Personis_base.EvidenceTypes) - 1): print "Index out of range" return etype = Personis_base.EvidenceTypes[etindex] source = self.username flags = [] while True: flag = raw_input("Evidence flag? (CR for none)") if flag == '': break flags.append(flag) print "Tell value=%s, type=%s, flags=%s, source=%s, context=%s, component=%s " % ( val, etype, flags, source, self.context, compname) ok = raw_input("Ok?[N] ") if ok != 'Y': return ev = Personis_base.Evidence(source=source, evidence_type=etype, flags=flags, value=val) try: um.tell(context=self.context, componentid=compname, evidence=ev) except ValueError, e: print "tell failed: %s" % (e)
def set_goals(self, context=[], componentid=None, goals=None): """ arguments: context is a list giving the path of context identifiers componentid designates the component with subscriptions attached goals is a list of paths to components that are: goals for this componentid if it is not of type goal components that contribute to this componentid if it is of type goal """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "set_goals", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'componentid':componentid,\ 'goals':goals})
def setpermission(self, context=None, componentid=None, app=None, permissions={}): """ sets ask/tell permission for a context (if componentid is None) or a component """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "setpermission", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context': context,\ 'componentid': componentid,\ 'app': app,\ 'permissions': permissions})
def delview(self, context=[], viewid=None): """ Delete an existing view in a given context arguments: context - a list giving the path to the required context viewid - the id for the view returns: None on success """ if viewid == None: raise ValueError, "delview: viewid is None" if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "delview", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'viewid':viewid})
def do_mkcomponent(self, line): """mkcomponent component_name make a new component""" global um, context, attrs if not loggedin(self.username, self.userpassword, 'mkcomponent'): return if not nomodel(self.umname, line): return line = line.split() if len(line) != 1: print "usage: mkcomponent compname" return contxt = self.context comp = line[0] compdesc = raw_input("Component description? ") print "Component type:" for ct in Personis_base.ComponentTypes: print Personis_base.ComponentTypes.index(ct), ct ctindex = int(raw_input("Index? ")) if (ctindex < 0) or (ctindex > len(Personis_base.ComponentTypes) - 1): print "Index out of range" return comptype = Personis_base.ComponentTypes[ctindex] print "Value type:" for ct in Personis_base.ValueTypes: print Personis_base.ValueTypes.index(ct), ct ctindex = int(raw_input("Index? ")) if (ctindex < 0) or (ctindex > len(Personis_base.ValueTypes) - 1): print "Index out of range" return valtype = Personis_base.ValueTypes[ctindex] print "Creating new component '%s', type '%s', description '%s', value type '%s'" % ( comp, comptype, compdesc, valtype) ok = raw_input("Ok?[N] ") if ok != 'Y': return cobj = Personis_base.Component(Identifier=comp, component_type=comptype, Description=compdesc, value_type=valtype) res = um.mkcomponent(context=contxt, componentobj=cobj)
def mkview(self, context=[], viewobj=None): """ Make a new view in a given context arguments: context - a list giving the path to the required context viewobj - a View object returns: None on success a string error message on error """ if viewobj == None: raise ValueError, "mkview: viewobj is None" if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "mkview", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'viewobj':viewobj.__dict__})
def subscribe(self, context=[], view=None, subscription=None): """ arguments: context is a list giving the path of context identifiers view is either: an identifier of a view in the context specified a list of component identifiers or full path lists None indicating that the values of all components in the context be returned subscription is a Subscription object """ if self.authType == 'app': self.auth = self.app + ":" + Personis_base.generate_app_signature( self.app, self.key) return jsoncall.do_call(self.modelserver, self.modelport, self.ca_certs_file, "subscribe", {'modelname':self.modelname,\ 'authType':self.authType,\ 'auth':self.auth,\ 'context':context,\ 'view':view,\ 'subscription':subscription})
um = Personis_base.Access(model="Alice", modeldir='Tests/Models', authType='user', auth='alice:secret') print "List the registered apps (should be none):" apps = um.listapps() print apps print "Try and set permissions on a context for an unregistered app:" try: um.setpermission(context=["Personal"], app="MyHealth", permissions={'ask':True, 'tell':False}) except Exception as e: print "setpermission failed with exception : %s\n" % (e) print "Register an app" try: key = Personis_base.generate_app_key("MyHealth") fingerprint = Personis_base.generate_app_fingerprint(key) Personis_base.AppRequestAuth(model='Alice', modeldir='Tests/Models', app='MyHealth', key=key.publickey().exportKey(), description="My Health Manager") except Exception as e: print "App auth request failed with exception : %s\n" % (e) requests = um.listrequests() print requests fingerprint2 = requests['MyHealth']['fingerprint'] if fingerprint2 != fingerprint: print "Fingerprints don't match!" else: print "Fingerprints match" appdetails = um.registerapp(app="MyHealth", desc="My Health Manager", fingerprint=fingerprint) print "Registered ok: ", appdetails print "List the registered apps (should be one):"
def subscribe(self, context=[], view=None, subscription=None): """ arguments: context is a list giving the path of context identifiers view is either: an identifier of a view in the context specified a list of component identifiers or full path lists None indicating that the values of all components in the context be returned subscription is a dictionary containing owner, password and subscription statement string """ subscription['modelname'] = self.modelname print "subscription>>> %s %s %s" % (`context`, `view`, `subscription`) cronsub = subscription["statement"].strip().startswith("[") token = "%s:%f" % (self.user, time.time()) for elt in ("user", "password", "statement"): if elt not in subscription: raise ValueError, '"%s" key missing from subscription dict' % (elt) if len(subscription.items()) != 4: raise ValueError, 'unknown attribute in subscription %s'%(subscription) #print "token:", token self.curcontext = self._getcontextdir(context) contextinfo = self.getcontext(context) try: comps,comps_shelf_fd = Personis_base.shelf_open(self.curcontext+"/.components", "r") except: print "can't open ",self.curcontext+"/.components" comps = None try: views,views_shelf_fd = Personis_base.shelf_open(self.curcontext+"/.views", "r") except: views = None try: subs,subs_shelf_fd = Personis_base.shelf_open(self.curcontext+"/.subscriptions", "w") except: subs = None cidlist = [] cobjlist = [] if type(view) is StringType: if views != None: if not views.has_key(view): raise ValueError, '"%s" view not found'%(view) cidlist = views[view].component_list else: raise ValueError, '"%s" view not found'%(view) elif type(view) is ListType: cidlist = view elif view == None: if comps != None: cidlist = comps.keys() else: raise TypeError, 'view "%s" has unknown type'%(`view`) for cid in cidlist: if type(cid) == type(u''): cid = str(cid) if type(cid) is StringType: if comps != None: if comps.has_key(cid): # add sub dict to subs for cid ###### if subs.has_key(cid): newsub = subs[cid] else: newsub = {} newsub[token] = subscription subs[cid] = newsub if cronsub: cronserver.cronq.put(dict(op="put",context=context, comp=cid, subscription=subscription)) else: raise ValueError, 'component "%s" not in view "%s" (%s)'%(cid,view,cidlist) else: raise ValueError, 'component "%s" not found'%(cid) elif type(cid) is ListType: vcontext = self._getcontextdir(cid[:-1]) try: vcomps,vcomps_shelf_fd = Personis_base.shelf_open(vcontext+"/.components", "r") except: raise ValueError, 'context "%s" not in view "%s"'%(cid[-1],`view`) if vcomps.has_key(cid[-1]): # add sub dict to subs for cid[-1] ######### if not subs.has_key(cid[-1]): newsub = {} else: newsub = subs[cid[-1]] newsub[token] = subscription subs[cid[-1]] = newsub if cronsub: cronserver.cronq.put(dict(op="put",context=context, comp=cid, subscription=subscription)) else: raise ValueError, 'component "%s" not in view "%s"'%(cid[-1],`view`) Personis_base.shelf_close(vcomps, vcomps_shelf_fd) if comps != None: Personis_base.shelf_close(comps, comps_shelf_fd) if views != None: Personis_base.shelf_close(views, views_shelf_fd) if subs != None: Personis_base.shelf_close(subs, subs_shelf_fd) return token
def printAskContext( info ): (cobjlist, contexts, theviews, thesubs) = info printcomplist(cobjlist, printev = "yes") print "Contexts: %s" % str(contexts) print "Views: %s" % str(theviews) print "Subscriptions: %s" % str(thesubs) print "===================================================================" print "Simple example showing how permissions work" print "===================================================================" um = Personis_base.Access(model="Alice", modeldir='Tests/Models', authType='user', auth='alice:secret') print "Register an app" try: key = Personis_base.generate_app_key("MyHealth") fingerprint = Personis_base.generate_app_fingerprint(key) Personis_base.AppRequestAuth(model='Alice', modeldir='Tests/Models', app='MyHealth', key=key.publickey().exportKey(), description="My Health Manager") except Exception as e: print "App auth request failed with exception : %s\n" % (e) requests = um.listrequests() print requests fingerprint2 = requests['MyHealth']['fingerprint'] if fingerprint2 != fingerprint: print "Fingerprints don't match!" else: print "Fingerprints match" appdetails = um.registerapp(app="MyHealth", desc="My Health Manager", fingerprint=fingerprint) print "Registered ok: ", appdetails