Exemple #1
0
def allMessages():
    box = request.args.get('box', '')
    start = int(request.args['start'])
    end = int(request.args['end'])
    attachmentTypes = request.args.get('attachmentTypes')
    if attachmentTypes is not None:
        try:
            #            attachmentTypes = json.loads(attachmentTypes)
            attachmentTypes = attachmentTypes.split(',')
        except:
            pass
    hasAttachment = request.args.get('hasAttachment')
    if hasAttachment is not None or attachmentTypes is not None:
        hasAttachment = str(hasAttachment).lower()
        hasAttachment = (hasAttachment == 'true' or hasAttachment == '1'
                         or attachmentTypes is not None)
    secrets = lockerfs.loadJsonFile("secrets.json")
    username = secrets['username']
    boxPath = username + '/' + box
    messages = []

    for i in range(start, end):
        message = lockerfs.loadJsonFile(boxPath + '/' + str(i))
        if filter(message, hasAttachment, attachmentTypes):
            messages.append(message)

    return json.dumps(messages)
Exemple #2
0
def allMessages():
    box = request.args.get('box', '')
    start = int(request.args['start'])
    end = int(request.args['end'])
    attachmentTypes = request.args.get('attachmentTypes')
    if attachmentTypes is not None:
        try:
#            attachmentTypes = json.loads(attachmentTypes)
            attachmentTypes = attachmentTypes.split(',')
        except:
            pass
    hasAttachment = request.args.get('hasAttachment')
    if hasAttachment is not None or attachmentTypes is not None:
        hasAttachment = str(hasAttachment).lower()
        hasAttachment = (hasAttachment == 'true' or hasAttachment == '1' or attachmentTypes is not None)
    secrets = lockerfs.loadJsonFile("secrets.json");
    username = secrets['username']
    boxPath = username + '/' + box
    messages = []
    
    for i in range(start, end):
        message = lockerfs.loadJsonFile(boxPath + '/' + str(i))
        if filter(message, hasAttachment, attachmentTypes):
            messages.append(message)
    
    return json.dumps(messages)
Exemple #3
0
    def __init__(self, core_info, credentials):
        self.core_info = core_info
        self.me_info = lockerfs.loadJsonFile("me.json")

        http = credentials.authorize(httplib2.Http())
        self._service = apiclient.discovery.build("latitude", "v1", http=http)

        self.locations = lockerfs.loadJsonFile("locations.json")
        self.update_state = lockerfs.loadJsonFile("updateState.json")
        self.update_state.setdefault('locations', {}).setdefault('syncedThrough', None)
Exemple #4
0
    def __init__(self, core_info, credentials):
        self.core_info = core_info
        self.me_info = lockerfs.loadJsonFile("me.json")

        http = credentials.authorize(httplib2.Http())
        self._service = apiclient.discovery.build("latitude", "v1", http=http)

        self.locations = lockerfs.loadJsonFile("locations.json")
        self.update_state = lockerfs.loadJsonFile("updateState.json")
        self.update_state.setdefault('locations',
                                     {}).setdefault('syncedThrough', None)
Exemple #5
0
 def __init__(self):
     secrets = lockerfs.loadJsonFile("secrets.json");
     statusData = lockerfs.loadJsonFile("status.json")
     if "lastUpdate" in statusData:
         self.lastUpdate = datetime.fromtimestamp(int(statusData["lastUpdate"]))
     else:
         self.lastUpdate = datetime.fromtimestamp(0)
     self.gd_client = gdata.contacts.service.ContactsService()
     self.gd_client.email = secrets["consumerKey"]
     self.gd_client.password = secrets["consumerSecret"]
     self.gd_client.source = 'locker-0.1'
Exemple #6
0
def runService(info):
    app.info = info
    app.client = None
    app.started = False

    app.me_info = lockerfs.loadJsonFile("me.json")

    secrets = lockerfs.loadJsonFile("secrets.json")
    if "jid" in secrets and "password" in secrets:
        start(secrets)
    else:
        logging.info("No auth details available")
    app.debug = True
    app.run(port=app.info["port"], use_reloader=False)
Exemple #7
0
    def __init__(self, core_info, url, user, password, server_type="wordpress"):
        self.core_info = core_info
        self.me_info = lockerfs.loadJsonFile("me.json")

        assert(server_type in server_types)

        url = 'http://' + url.rstrip('/').lstrip('http://')
        if server_type == "wordpress":
            self.url = url + "/xmlrpc.php"
        else:
            self.url = url

        logging.info("Url: %s" % self.url)

        self.user = user
        self.password = password
        self.server_type = server_type

        self._server = xmlrpclib.ServerProxy(self.url)

        self.user_info = lockerfs.loadJsonFile("user_info.json")
        self.blogs = lockerfs.loadJsonFile("blogs.json")
        self.categories = lockerfs.loadJsonFile("categories.json")
        self.posts = lockerfs.loadJsonFile("posts.json")
        self.comments = lockerfs.loadJsonFile("comments.json")
        self.pingbacks = lockerfs.loadJsonFile("pingbacks.json")
        self.trackbacks = lockerfs.loadJsonFile("trackbacks.json")
Exemple #8
0
 def __init__(self):
     secrets = lockerfs.loadJsonFile("secrets.json");
     statusData = lockerfs.loadJsonFile("status.json")
     if "lastUpdate" in statusData:
         self.lastUpdate = datetime.fromtimestamp(int(statusData["lastUpdate"]))
     else:
         self.lastUpdate = datetime.fromtimestamp(0)
     self.gd_client = gdata.contacts.service.ContactsService()
     self.gd_client.email = secrets["consumerKey"]
     self.gd_client.password = secrets["consumerSecret"]
     self.gd_client.source = 'locker-0.1'
     m = hashlib.sha1()
     m.update(self.gd_client.email)
     self.uid = m.hexdigest()
Exemple #9
0
    def __init__(self, core_info, jid, password):
        xmpp.ClientXMPP.__init__(self, jid, password)

        self.core_info = core_info
        self.me_info = lockerfs.loadJsonFile("me.json")

        self.auto_reconnect = False

        self.add_event_handler("session_start", self.start)
        self.add_event_handler("message", self.message)
        self.add_event_handler("changed_status", self.status)
        self.add_event_handler("failed_auth", self.fail)
        self.add_event_handler("disconnect", self.fail)

        self.message_file = open("messages.json", "a+")
        self.message_file.seek(0)
        self.messages = [
            json.loads(msg) for msg in self.message_file.readlines()
        ]
        logging.info("Messages " + str(self.messages))

        self.status_file = open("statuses.json", "a+")
        self.status_file.seek(0)
        self.statuses = [
            json.loads(sts) for sts in self.status_file.readlines()
        ]
Exemple #10
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 #11
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 #12
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 #13
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 #14
0
def update():
    if app.consumerValidated:
        secrets = lockerfs.loadJsonFile("secrets.json");
        proc = MailboxProcessor(secrets["server"], secrets["username"], secrets["password"])
        thread.start_new_thread(proc.process,())
        return "Yep!"
    else:
        return redirect(url_for("setupAuth"))
Exemple #15
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 #16
0
def update():
    if app.consumerValidated:
        secrets = lockerfs.loadJsonFile("secrets.json");
        proc = MailboxProcessor(secrets["server"], secrets["username"], secrets["password"])
        thread.start_new_thread(proc.process,())
        return "true"
    else:
        return "<html>looks like you still need to <a href='setupAuth'>auth your account</a></html>"
Exemple #17
0
def update():
    if app.consumerValidated:
        secrets = lockerfs.loadJsonFile("secrets.json")
        proc = MailboxProcessor(secrets["server"], secrets["username"],
                                secrets["password"])
        thread.start_new_thread(proc.process, ())
        return "true"
    else:
        return "<html>looks like you still need to <a href='setupAuth'>auth your account</a></html>"
Exemple #18
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 #19
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.debug = True
    app.run(port=app.lockerInfo["port"], use_reloader=False)
Exemple #20
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 #21
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 #22
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.debug = True
    app.run(port=app.lockerInfo["port"], use_reloader=False)
Exemple #23
0
def start():
    logging.info("Starting")
    secrets = lockerfs.loadJsonFile("secrets.json")
    app.client = client.Client(app.info, jid=secrets["jid"], password=secrets["password"])
    if app.client.connect():
        app.client.process(threaded=True)
        app.started = True
    else:
        util.die("XMPP connection failed")
Exemple #24
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 #25
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 #26
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 #27
0
 def __init__(self, email, password):
     statusData = lockerfs.loadJsonFile("status.json")
     if "lastUpdate" in statusData:
         self.lastUpdate = datetime.fromtimestamp(int(statusData["lastUpdate"]))
     else:
         self.lastUpdate = datetime.fromtimestamp(0)
     self.gd_client = gdata.contacts.service.ContactsService()
     self.gd_client.email = email
     self.gd_client.password = password
     self.gd_client.source = 'locker-0.1'
Exemple #28
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 #29
0
def runService(info):
    app.info = info
    app.client = None
    app.started = False

    app.secrets = lockerfs.loadJsonFile("secrets.json")
    app.cred_storage = oauth2client.file.Storage('latitude.dat')
    app.credentials = app.cred_storage.get()
    if app.credentials and not app.credentials.invalid:
        start(app.credentials)
    else:
        logging.info("No credentials available")
    app.debug = True
    app.run(port=app.info["port"], use_reloader=False)
Exemple #30
0
def runService(info):
    app.info = info
    app.client = None
    app.started = False

    app.secrets = lockerfs.loadJsonFile("secrets.json")
    app.cred_storage = oauth2client.file.Storage('latitude.dat')
    app.credentials = app.cred_storage.get()
    if app.credentials and not app.credentials.invalid:
        start(app.credentials)
    else:
        logging.info("No credentials available")
    app.debug = True
    app.run(port=app.info["port"], use_reloader=False)
Exemple #31
0
    def __init__(self, core_info, jid=jid, password=password):
        xmpp.ClientXMPP.__init__(self, jid, password)

        self.core_info = core_info
        self.me_info = lockerfs.loadJsonFile("me.json")

        self.auto_reconnect = False

        self.add_event_handler("session_start", self.start)
        self.add_event_handler("message", self.message)
        self.add_event_handler("changed_status", self.status)
        self.add_event_handler("failed_auth", self.fail)
        self.add_event_handler("disconnect", self.fail)

        self.message_file = open("messages.json", "a+")
        self.messages = [json.loads(msg) for msg in self.message_file.readlines()]
        
        self.status_file = open("statuses.json", "a+")
        self.statuses = [json.loads(sts) for sts in self.status_file.readlines()]
Exemple #32
0
def runService(info):
    secrets = lockerfs.loadJsonFile("secrets.json")
    app.lockerInfo = info
    app.consumerValidated = "username" in secrets and "password" in secrets and "server" in secrets
    app.debug = False
    app.run(port=app.lockerInfo["port"], use_reloader=False)
Exemple #33
0
def runService(info):
    secrets = lockerfs.loadJsonFile("secrets.json");
    app.lockerInfo = info
    app.consumerValidated = "username" in secrets and "password" in secrets and "server" in secrets 
    app.debug = False
    app.run(port=app.lockerInfo["port"], use_reloader=False)