Exemple #1
0
    def updateLocations(self):
        logging.info("Updating locations")

        if self.update_state['locations']['syncedThrough'] is None:
            # special case for the initial fetch to backfill old entries
            min_time, max_time = self._fetchLocationBatch()
            if min_time is None:
                logging.info("No locations found on first fetch, maybe history is disabled?")
                return
            self.update_state['locations']['syncedThrough'] = max_time
            while min_time is not None:
                min_time, max_time = self._fetchLocationBatch(
                        min_time-(1000*60*60*24*30),
                        min_time-1
                        )

        min_time, max_time = self._fetchLocationBatch(
                self.update_state['locations']['syncedThrough']+1,
                self.update_state['locations']['syncedThrough']+(1000*60*60*24*30))
        while max_time is not None:
            self.update_state['locations']['syncedThrough'] = max_time
            min_time, max_time = self._fetchLocationBatch(
                self.update_state['locations']['syncedThrough']+1,
                self.update_state['locations']['syncedThrough']+(1000*60*60*24*30))

        lockerfs.saveJsonFile("locations.json", self.locations)
        lockerfs.saveJsonFile("updateState.json", self.update_state)
Exemple #2
0
    def updateLocations(self):
        logging.info("Updating locations")

        if self.update_state['locations']['syncedThrough'] is None:
            # special case for the initial fetch to backfill old entries
            min_time, max_time = self._fetchLocationBatch()
            if min_time is None:
                logging.info(
                    "No locations found on first fetch, maybe history is disabled?"
                )
                return
            self.update_state['locations']['syncedThrough'] = max_time
            while min_time is not None:
                min_time, max_time = self._fetchLocationBatch(
                    min_time - (1000 * 60 * 60 * 24 * 30), min_time - 1)

        min_time, max_time = self._fetchLocationBatch(
            self.update_state['locations']['syncedThrough'] + 1,
            self.update_state['locations']['syncedThrough'] +
            (1000 * 60 * 60 * 24 * 30))
        while max_time is not None:
            self.update_state['locations']['syncedThrough'] = max_time
            min_time, max_time = self._fetchLocationBatch(
                self.update_state['locations']['syncedThrough'] + 1,
                self.update_state['locations']['syncedThrough'] +
                (1000 * 60 * 60 * 24 * 30))

        lockerfs.saveJsonFile("locations.json", self.locations)
        lockerfs.saveJsonFile("updateState.json", self.update_state)
Exemple #3
0
def saveAuth():
    secrets = lockerfs.loadJsonFile("secrets.json")
    secrets["username"] = request.args["username"]
    secrets["password"] = request.args["password"]
    secrets["server"] = request.args["server"]
    app.consumerValidated = True
    lockerfs.saveJsonFile("secrets.json", secrets)
    return redirect(url_for("mainIndex"))
Exemple #4
0
def saveAuth():
    logging.info("Saving auth")
    secrets = lockerfs.loadJsonFile("secrets.json")
    secrets["jid"] = request.form["jid"]
    secrets["password"] = request.form["password"]
    start(secrets)
    lockerfs.saveJsonFile("secrets.json", secrets)
    return json.dumps("started")
Exemple #5
0
def saveAuth():
    secrets = lockerfs.loadJsonFile("secrets.json")
    secrets["username"] = request.form["username"]
    secrets["password"] = request.form["password"]
    secrets["server"] = request.form["server"]
    app.consumerValidated = True
    lockerfs.saveJsonFile("secrets.json", secrets)
    return "<html>Looks good! You can:<br><ul><li><a href='update'>Get new messages</a></li></ul>"
Exemple #6
0
def saveAuth():    
    secrets = lockerfs.loadJsonFile("secrets.json");
    secrets["username"] = request.form["username"]
    secrets["password"] = request.form["password"]
    secrets["server"] = request.form["server"]
    app.consumerValidated = True
    lockerfs.saveJsonFile("secrets.json", secrets)
    return "<html>Looks good! You can:<br><ul><li><a href='update'>Get new messages</a></li></ul>"
Exemple #7
0
def saveAuth():
    secrets = lockerfs.loadJsonFile("secrets.json");
    secrets["username"] = request.args["username"]
    secrets["password"] = request.args["password"]
    secrets["server"] = request.args["server"]
    app.consumerValidated = True
    lockerfs.saveJsonFile("secrets.json", secrets)
    return redirect(url_for("mainIndex"))
Exemple #8
0
def saveAuth():
    if not gcontacts.testCredentials(request.args["consumerKey"], request.args["consumerSecret"]):
        return redirect(url_for("setupAuth"))
    secrets = lockerfs.loadJsonFile("secrets.json");
    secrets["consumerKey"] = request.args["consumerKey"]
    secrets["consumerSecret"] = request.args["consumerSecret"]
    lockerfs.saveJsonFile("secrets.json", secrets)
    app.consumerValidated = True
    return redirect(url_for("mainIndex"))
Exemple #9
0
def saveAuth():
    if not gcontacts.testCredentials(request.args["consumerKey"], request.args["consumerSecret"]):
        return redirect(app.meInfo["uri"] + "setupAuth")
    secrets = lockerfs.loadJsonFile("secrets.json");
    secrets["consumerKey"] = request.args["consumerKey"]
    secrets["consumerSecret"] = request.args["consumerSecret"]
    lockerfs.saveJsonFile("secrets.json", secrets)
    app.consumerValidated = True
    return redirect(app.meInfo["uri"] + "/")
Exemple #10
0
def saveAuth():
    if not gcontacts.testCredentials(request.args["consumerKey"], request.args["consumerSecret"]):
        return redirect(url_for("setupAuth"))
    secrets = lockerfs.loadJsonFile("secrets.json");
    secrets["consumerKey"] = request.args["consumerKey"]
    secrets["consumerSecret"] = request.args["consumerSecret"]
    lockerfs.saveJsonFile("secrets.json", secrets)
    app.consumerValidated = True
    return redirect(url_for("mainIndex"))
Exemple #11
0
 def update(self):
     logging.info("Updating %s" % name)
     old_value = self.__dict__.get(name, None) or lockerfs.loadJsonFile(name + ".json") or default
     new_value = fun(self)
     self.__dict__[name] = new_value
     if event_type:
         for item in new_value:
             if item not in old_value:
                 push_event(self.core_info["lockerUrl"], self.me_info["id"], event_type, item)
     lockerfs.saveJsonFile(name + ".json", new_value)
Exemple #12
0
def saveAuth():
    if not gcontacts.testCredentials(request.args["consumerKey"],
                                     request.args["consumerSecret"]):
        return redirect(app.meInfo["uri"] + "setupAuth")
    secrets = lockerfs.loadJsonFile("secrets.json")
    secrets["consumerKey"] = request.args["consumerKey"]
    secrets["consumerSecret"] = request.args["consumerSecret"]
    lockerfs.saveJsonFile("secrets.json", secrets)
    app.consumerValidated = True
    return redirect(app.meInfo["uri"] + "/")
Exemple #13
0
def saveAuth():
    logging.info("Saving auth")
    secrets = lockerfs.loadJsonFile("secrets.json")
    secrets["url"] = request.form["url"]
    secrets["user"] = request.form["user"]
    secrets["password"] = request.form["password"]
    secrets["server_type"] = "wordpress" # !!! other types are awaiting testing
    start(secrets)
    lockerfs.saveJsonFile("secrets.json", secrets)
    return json.dumps("started")
Exemple #14
0
def saveAuth():
    logging.info("Saving auth")
    secrets = lockerfs.loadJsonFile("secrets.json")
    secrets["url"] = request.form["url"]
    secrets["user"] = request.form["user"]
    secrets["password"] = request.form["password"]
    secrets[
        "server_type"] = "wordpress"  # !!! other types are awaiting testing
    start(secrets)
    lockerfs.saveJsonFile("secrets.json", secrets)
    return json.dumps("started")
Exemple #15
0
 def write_feed_to_file(self):
     self.jsonFile = open('contacts.json', 'w')
     query = gdata.contacts.service.ContactsQuery()
     #query.updated_min = self.lastUpdate.isoformat()
     query.max_results = 3000
     feed = self.gd_client.GetContactsFeed(query.ToUri())
     if len(feed.entry) <= 0:
         return
     for i, entry in enumerate(feed.entry):
         self.write_entry_to_file(i, entry)
     self.jsonFile.close()
     self.lastUpdate = datetime.now()
     lockerfs.saveJsonFile("status.json", {"lastUpdate":time.mktime(self.lastUpdate.timetuple())})
Exemple #16
0
 def write_feed_to_file(self):
     self.jsonFile = open('contacts.json', 'w')
     query = gdata.contacts.service.ContactsQuery()
     #query.updated_min = self.lastUpdate.isoformat()
     query.max_results = 3000
     feed = self.gd_client.GetContactsFeed(query.ToUri())
     if len(feed.entry) <= 0:
         return
     for i, entry in enumerate(feed.entry):
         self.write_entry_to_file(i, entry)
     self.jsonFile.close()
     self.lastUpdate = datetime.now()
     lockerfs.saveJsonFile("status.json", {"lastUpdate":time.mktime(self.lastUpdate.timetuple())})
     return len(feed.entry)
Exemple #17
0
 def write_feed_to_file(self):
     
     # get all contacts and write overwrite the current.json file
     current = open('current.json', 'w')
     allQuery = gdata.contacts.service.ContactsQuery()
     allQuery.max_results = 3000
     self.write_query_to_file(allQuery, current, False)
     current.close()
     
     # get only updates since the last time and append to the all.json file
     allFile = open('all.json', 'a')
     updatesQuery = gdata.contacts.service.ContactsQuery()
     updatesQuery['updated-min'] = self.lastUpdate.isoformat()
     updatesQuery['showdeleted'] = 'true'
     updatesQuery['sortorder'] = 'ascending'
     updatesQuery.orderby = 'lastmodified'
     updatesQuery.max_results = 3000
     self.lastUpdate = datetime.utcnow()
     numUpdated = self.write_query_to_file(updatesQuery, allFile, True)
     allFile.close()
     
     lockerfs.saveJsonFile("status.json", {"lastUpdate":time.mktime(self.lastUpdate.timetuple())})
     return numUpdated
Exemple #18
0
def saveAuth():
    logging.info("Saving auth")
    app.secrets["client_id"] = request.form["client_id"]
    app.secrets["client_secret"] = request.form["client_secret"]
    lockerfs.saveJsonFile("secrets.json", app.secrets)
    return get_credentials()
Exemple #19
0
def saveAuth():
    logging.info("Saving auth")
    app.secrets["client_id"] = request.form["client_id"]
    app.secrets["client_secret"] = request.form["client_secret"]
    lockerfs.saveJsonFile("secrets.json", app.secrets)
    return get_credentials()