def main(): for k in ['KLOUDLESS_APP_ID']: if not os.environ.get(k): print usage_text return if os.environ.get('KLOUDLESS_BASE_URL'): kloudless.configure(base_url=os.environ['KLOUDLESS_BASE_URL']) app.run()
def test_configure(): """ This is a basic test to make sure that the configuration mechanism works. """ default_configs = kloudless.config.configuration configs = {"api_key": "TESTKEY", "api_version": 31337, "base_url": "example.com"} kloudless.configure(**configs) for key in configs.iterkeys(): assert configs[key] == kloudless.config.configuration[key] kloudless.configure(**default_configs)
def main(): for k in ["KLOUDLESS_API_KEY", "KLOUDLESS_APP_ID"]: if not os.environ.get(k): print usage_text return kloudless.configure(api_key=os.environ["KLOUDLESS_API_KEY"]) if os.environ.get("KLOUDLESS_BASE_URL"): kloudless.configure(base_url=os.environ["KLOUDLESS_BASE_URL"]) app.run()
def test_configure(): """ This is a basic test to make sure that the configuration mechanism works. """ default_configs = kloudless.config.configure() configs = {"api_key": "TESTKEY", "api_version": 31337, "base_url": "example.com"} kloudless.configure(**configs) for key in six.iterkeys(configs): assert configs[key] == kloudless.config._configuration[key] kloudless.configure(**default_configs)
def save_file(account_id, file_data, token): kloudless.configure(token=token) # Create the folder in case it doesn't exist. account = kloudless.Account(id=account_id) folder = account.folders.create(data={ "name": "Cloud File Editor Sample App", "parent_id": "root"}) f = account.files.create(file_name='test.txt', parent_id=folder.id, file_data=file_data) return jsonify(file_id=f.id)
def view_notes(request, item_id): if not request.user.is_authenticated(): print("GO") else: kloudless.configure( api_key="OiVoCBhFF0MfIqbilVx9oBpzjC9aUJTm84D_rO_CnR_9JOlo") accounts = kloudless.Account.all() account = accounts[0] if request.method == "GET": notes = Note.objects.filter(item__id=item_id) for note in notes: if note.audio: filename = '{0}/{1}_audio.mp3'.format( djangoSettings.STATIC_ROOT.replace( 'staticfiles', 'static'), note.id) if not os.path.exists(filename): with closing( account.files(id=note.audio).contents()) as r: data = r.content with open(filename, 'wb') as t: t.write(data) if note.video: filename = '{0}/{1}_video.mp4'.format( djangoSettings.STATIC_ROOT.replace( 'staticfiles', 'static'), note.id) if not os.path.exists(filename): with closing( account.files(id=note.video).contents()) as r: data = r.content with open(filename, 'wb') as t: t.write(data) if note.image: filename = '{0}/{1}_image.jpeg'.format( djangoSettings.STATIC_ROOT.replace( 'staticfiles', 'static'), note.id) if not os.path.exists(filename): with closing( account.files(id=note.image).contents()) as r: data = r.content with open(filename, 'wb') as t: t.write(data) print("yo!") return render(request, 'notes.html', {'notes': notes})
def save_file(account_id, file_data, token): kloudless.configure(token=token) # Create the folder in case it doesn't exist. account = kloudless.Account(id=account_id) folder = account.folders.create(data={ "name": "Cloud File Editor Sample App", "parent_id": "root" }) f = account.files.create(file_name='test.txt', parent_id=folder.id, file_data=file_data) return jsonify(file_id=f.id)
def create_note(request, item_id): if request.method == "GET": return render(request, 'new_note.html') else: text = request.POST.get('text') audio = request.FILES.get('audio') image = request.FILES.get('img') video = request.FILES.get('video') note = Note() note.item = Item.objects.get(id=item_id) note.text = text note.save() kloudless.configure( api_key="OiVoCBhFF0MfIqbilVx9oBpzjC9aUJTm84D_rO_CnR_9JOlo") accounts = kloudless.Account.all() account = accounts[0] if audio: k = account.files.create( file_name='{}_audio.mp3'.format(note.id), file_data=audio, parent_id='F9LfiHM4sTLkoZp5Y3pMSesUO5_yKeMrNpZBzxvERUxA=') note.audio = k['id'] if video: k = account.files.create( file_name='{}_video.mp4'.format(note.id), file_data=video, parent_id='F9LfiHM4sTLkoZp5Y3pMSesUO5_yKeMrNpZBzxvERUxA=') note.video = k['id'] if image: k = account.files.create( file_name='{}_image.jpeg'.format(note.id), file_data=image, parent_id='F9LfiHM4sTLkoZp5Y3pMSesUO5_yKeMrNpZBzxvERUxA=') note.image = k['id'] note.save() return redirect("/")
from django.shortcuts import render, redirect from django.conf import settings from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import redirect from django.contrib.auth.decorators import login_required from django.contrib.auth import logout as django_logout from social.backends.utils import load_backends from social.apps.django_app.utils import psa from sync.models import Sync, Account, Folder from django.contrib.auth.models import User from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist import kloudless; kloudless.configure(api_key=settings.KLOUDLESS_API_KEY) from tasks import process from django.views.decorators.csrf import csrf_exempt def index(request): data = {} if request.user.is_authenticated(): user_syncs = Sync.objects.filter(user=request.user) data['user_syncs'] = user_syncs return render(request, 'sync/dashboard.html', data) else: return render(request, 'sync/login.html', data) def add_sync(request):
from django.conf import settings from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import redirect from django.contrib.auth.decorators import login_required from django.contrib.auth import logout as django_logout from social.backends.utils import load_backends from social.apps.django_app.utils import psa from sync.models import Sync, Account, Folder from django.contrib.auth.models import User from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist import kloudless kloudless.configure(api_key=settings.KLOUDLESS_API_KEY) from tasks import process from django.views.decorators.csrf import csrf_exempt def index(request): data = {} if request.user.is_authenticated(): user_syncs = Sync.objects.filter(user=request.user) data['user_syncs'] = user_syncs return render(request, 'sync/dashboard.html', data) else: return render(request, 'sync/login.html', data)
#!/usr/bin/env python from __future__ import print_function import pprint, urllib, kloudless, oauth2client from .formats import csv kloudless.configure(api_key='q4djKR_UXs8MxmUv8M56WdTVihDK6Z7ci8JnL1qJvC2Xx40T') import httplib2 import os from apiclient import discovery from oauth2client import client from oauth2client import tools from oauth2client.file import Storage try: import argparse flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() except ImportError: flags = None pp = pprint.PrettyPrinter(indent=2, width=200) def getExportParams(fileData, type: str = 'getContent'): print('fileData') print(fileData) print('type') print(type) if type == 'getContent': return { 'type':
def wrapper(*args, **kwargs): default_config = kloudless.config.configure() kloudless.configure(**test_configuration) result = f(*args, **kwargs) kloudless.configure(**default_config) return result