def update(): if app.consumerValidated: if datetime.datetime.now() < app.updateAt: return "Update already scheduled" app.updatesStarted = True gdc = gcontacts.GoogleDataContacts() updateCount = gdc.updateAll() # Tell the diary how many contacts we updated url = "{0}/diary".format(app.lockerInfo["lockerUrl"]) urllib2.urlopen( url, urllib.urlencode([ ("message", "Updated {0} contacts in Google Contacts".format(updateCount)) ])) # Schedule a new update at = time.mktime(datetime.datetime.now().timetuple() ) + 720 # Just doing 10m updates for nwo app.updateAt = datetime.datetime.fromtimestamp(at) me = lockerfs.loadMeData() url = "{0}/at?at={1}&id={2}&cb=/update".format( app.lockerInfo["lockerUrl"], at, me["id"]) urllib2.urlopen(url) return "Updated" else: return redirect(app.meInfo["uri"] + "setupAuth")
def runService(info): secrets = lockerfs.loadJsonFile("secrets.json") app.lockerInfo = info app.consumerValidated = "consumerKey" in secrets and "consumerSecret" in secrets app.puller = None app.updateAt = datetime.datetime.now() app.updatesStarted = False app.meInfo = lockerfs.loadMeData() #app.debug = True app.run(port=app.lockerInfo["port"], use_reloader=False)
def runService(info): secrets = lockerfs.loadJsonFile("secrets.json"); app.lockerInfo = info app.consumerValidated = "consumerKey" in secrets and "consumerSecret" in secrets app.puller = None app.updateAt = datetime.datetime.now() app.updatesStarted = False app.meInfo = lockerfs.loadMeData() #app.debug = True app.run(port=app.lockerInfo["port"], use_reloader=False)
def testCredentials(username, password): me = lockerfs.loadMeData() gd_client = gdata.contacts.service.ContactsService() gd_client.email = username gd_client.password = password gd_client.source = 'locker-0.1' try: gd_client.ProgrammaticLogin() return True except Exception: return False
def index(): if app.started: return json.dumps({ "/info": "User info", "/blogs": "List of users blogs", "/posts": "List of users posts", "/comments": "Comments on users posts", "/pingbacks": "Pingbacks to users blogs", "/trackbacks": "Trackbacks to users blogs", "/update": "update to refresh info" }) else: return redirect(lockerfs.loadMeData()["uri"] + "setupAuth")
def index(): if app.started: return json.dumps({ "/info" : "User info", "/blogs" : "List of users blogs", "/posts" : "List of users posts", "/comments" : "Comments on users posts", "/pingbacks" : "Pingbacks to users blogs", "/trackbacks" : "Trackbacks to users blogs", "/update" : "update to refresh info" }) else: return redirect(lockerfs.loadMeData()["uri"] + "setupAuth")
def update(): if app.consumerValidated: if datetime.datetime.now() < app.updateAt: return "Update already scheduled" app.updatesStarted = True gdc = gcontacts.GoogleDataContacts() gdc.updateAll() at = time.mktime(datetime.datetime.now().timetuple()) + 720 # Just doing 10m updates for nwo app.updateAt = datetime.datetime.fromtimestamp(at) me = lockerfs.loadMeData() url = "{0}at?at={1}&id={2}&cb=/update".format(app.lockerInfo["lockerUrl"], at, me["id"]) urllib2.urlopen(url) return "Updated" else: return redirect(url_for("setupAuth"))
def update(): if app.consumerValidated: if datetime.datetime.now() < app.updateAt: return "Update already scheduled" app.updatesStarted = True gdc = gcontacts.GoogleDataContacts() gdc.updateAll() at = time.mktime(datetime.datetime.now().timetuple() ) + 720 # Just doing 10m updates for nwo app.updateAt = datetime.datetime.fromtimestamp(at) me = lockerfs.loadMeData() url = "{0}at?at={1}&id={2}&cb=/update".format( app.lockerInfo["lockerUrl"], at, me["id"]) urllib2.urlopen(url) return "Updated" else: return redirect(url_for("setupAuth"))
def update(): if app.consumerValidated: if datetime.datetime.now() < app.updateAt: return "Update already scheduled" app.updatesStarted = True gdc = gcontacts.GoogleDataContacts() updateCount = gdc.updateAll() # Tell the diary how many contacts we updated url = "{0}/diary".format(app.lockerInfo["lockerUrl"]) urllib2.urlopen(url, urllib.urlencode([("message", "Updated {0} contacts in Google Contacts".format(updateCount))])) # Schedule a new update at = time.mktime(datetime.datetime.now().timetuple()) + 720 # Just doing 10m updates for nwo app.updateAt = datetime.datetime.fromtimestamp(at) me = lockerfs.loadMeData() url = "{0}/at?at={1}&id={2}&cb=/update".format(app.lockerInfo["lockerUrl"], at, me["id"]) urllib2.urlopen(url) return "Updated" else: return redirect(app.meInfo["uri"] + "setupAuth")