Example #1
0
def revisions():
    # Shared Link from Dropbox Chooser
    link = request.args["link"]

    # Calling Dropbox API v1
    metadata = requests.post(
        "https://api.dropbox.com/1/metadata/link",
        params={"link": link},
        headers={"Authorization": "Bearer " + str(session["access_token"])},
    ).json()

    # Calling Dropbox API v2
    dbx = Dropbox(session["access_token"])
    entries = dbx.files_list_revisions(metadata["path"]).entries

    return render_template("revisions.html", path=metadata["path"], revisions=entries)
Example #2
0
def revisions():
	# Shared Link from Dropbox Chooser
	link = request.args['link']

	# Calling Dropbox API v1
	metadata = requests.post('https://api.dropbox.com/1/metadata/link', params={'link': link},
		headers={'Authorization': 'Bearer ' + str(session['access_token'])}).json()

	# Calling Dropbox API v2
	if not metadata.get('path'):
		return redirect(url_for('index'))
	else:
		dbx = Dropbox(session['access_token'])
		entries = sorted(dbx.files_list_revisions(metadata['path']).entries, key=lambda entry: entry.client_modified)
		entries.reverse()
		return render_template('revisions.html', path=metadata['path'], filename=os.path.split(metadata['path'])[1],
			revisions=entries)
Example #3
0
def process_user(uid):
    '''Call /delta for the given user ID and process any changes.'''

    # OAuth token for the user
    token = redis_client.hget('tokens', uid)

    # /delta cursor for the user (None the first time)
    cursor = redis_client.hget('cursors', uid)

    dbx = Dropbox(token)
    has_more = True
    trello_client = trello.TrelloClient(TRELLO_API_KEY, token=TRELLO_API_TOKEN)

    while has_more:
        if cursor is None:
            result = dbx.files_list_folder(path='/remote_workspace')
        else:
            result = dbx.files_list_folder_continue(cursor)

        for entry in result.entries:
            # Ignore deleted files, folders, and non-markdown files
            if (isinstance(entry, DeletedMetadata) or isinstance(entry, FolderMetadata)):
                continue

            card = get_card_by_name(trello_client, entry.name.encode('utf-8'))
            
            if(card == False):
                trello_post(trello_client, entry.name.encode('utf-8'))
                continue

            card.set_pos("top")
            card.comment("update! revision: %s" % entry.rev)

            revs = dbx.files_list_revisions(entry.path_lower)
            if(card.list_id == "577db30f129e87073996cc1a" and len(revs.entries) >= 2):
                card.change_list("577db3127b9a95030e956ab8")



        # Update cursor
        cursor = result.cursor
        redis_client.hset('cursors', uid, cursor)

        # Repeat only if there's more to do
        has_more = result.has_more