예제 #1
0
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")
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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
예제 #5
0
파일: gcontacts.py 프로젝트: adamf/Locker
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
예제 #6
0
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")
예제 #7
0
파일: webservice.py 프로젝트: BrettQ/Locker
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")
예제 #8
0
파일: webservice.py 프로젝트: adamf/Locker
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"))
예제 #9
0
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"))
예제 #10
0
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")