Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lavelle/ClipCloud
base: 7d5d20d77d
...
head fork: lavelle/ClipCloud
compare: 19a579f8d6
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
36 src/auth.html
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-
-<html lang="en">
-
-<head>
- <meta charset="utf-8" />
- <title>ClipCloud authorisation</title>
-</head>
-
-<body>
-
-<div class="container">
- <div id="code"></div>
-</div>
-
-<script>
- var GET = {};
-
- function decode(s){
- return decodeURIComponent(s.split('+').join(' '));
- }
-
- //Search the url for GET variables using a regex and store them in an object
- document.location.search.replace(
- /\??(?:([^=]+)=([^&]*)&?)/g,
- function(){
- GET[decode(arguments[1])] = decode(arguments[2]);
- }
- );
-
- document.getElementById('code').innerHTML = GET.code;
-</script>
-
-</body>
-
-</html>
View
13 src/lib/dbox.py
@@ -62,7 +62,6 @@ def __init__(self, in_user_mode=True):
# create a client from the finished session
client = DropboxClient(session)
- #print client.account_info()
self.client = client
@@ -86,7 +85,7 @@ def upload(self, path, filepath=None):
try:
self.m.message('Uploading...')
- # Open the file located at path and upload it to the dropbox servers
+ # Open the file located at path and upload it to the Dropbox servers
response = self.client.put_file(filepath, open(path, 'rb'))
self.m.message('Upload finished')
except Exception as error:
@@ -143,11 +142,10 @@ def create_folder(self, folder_name, num=1):
new_folder_name = folder_name
+ if num > 1:
+ new_folder_name += '_(%s)' % num
# Try to create a folder with the given name
try:
- if num > 1:
- new_folder_name += '_(' + str(num) + ')'
-
self.client.file_create_folder('/' + new_folder_name)
if num > 1:
@@ -158,6 +156,7 @@ def create_folder(self, folder_name, num=1):
except ErrorResponse as e:
if e.status == 403:
# It failed because a folder with that name already exists
- # Increment a number and append it to the folder name
+ # Increment a number to be appended to the folder name
# then call the function recursively until it works
- self.create_folder(folder_name, num=num + 1)
+ num += 1
+ self.create_folder(folder_name, num=num)
View
54 src/lib/gist.py
@@ -1,54 +0,0 @@
-import webbrowser
-from pyjson import *
-import os
-from settings import *
-import requests
-
-
-class Gist:
- api_root = 'https://api.github.com/gists'
-
- oauth_root = 'https://github.com/login/oauth/%s'
- oauth_url = oauth_root % 'authorize?client_id=%s'
- oauth_token_url = oauth_root % 'access_token'
-
- def __init__(self):
- api_details = PyJson('dropbox/api.json').doc['github']
-
- self.client_id = api_details['id']
- self.client_secret = api_details['secret']
-
- if os.path.exists(GITHUB_TOKEN_PATH):
- self.access_token = PyJson(GITHUB_TOKEN_PATH).doc['token']
- else:
- print 'Please authorise the app and then paste in the code you see on-screen'
- webbrowser.open(self.oauth_url % self.client_id, new=2)
- code = raw_input()
-
- data = json.dumps({
- client_id: self.client_id,
- client_secret: self.client_secret,
- code: code
- })
-
- r = requests.get(self.oauth_token_url, data=data).text
-
- self.access_token = r[r.find('=') + 1: r.find('&')]
-
- doc = PyJson(GITHUB_TOKEN_PATH)
- doc.add('token', self.access_token)
- doc.save()
-
- def upload(self, filename, text):
- data = save_json({
- "public": False,
- "files": {
- filename: {
- "content": text
- }
- }
- })
-
- url = self.api_root
- r = requests.post(url, data=data)
- print r.text
View
2  src/lib/gridformat.py
@@ -13,7 +13,7 @@ def format_grid(grid, divider_positions=[], truncatable_column=None):
"""
# find the longest cell in each column so the minimum width is known
- widths = [max([len(cell) for cell in row]) for row in [x for x in zip(*grid)]]
+ widths = [max([len(cell) for cell in row]) for row in zip(*grid)]
total = sum(widths)
# try to determine the width of the user's terminal window in characters
View
10 src/lib/history.py
@@ -33,12 +33,12 @@ def display(self, limit, sort_by, direction, start):
if limit == 0:
break
- _id = str(record['id'])
+ id_ = str(record['id'])
url = record['url']
path = record['path']
- _date = date.fromtimestamp(record['timestamp']).strftime('%d/%m/%Y')
+ date_ = date.fromtimestamp(record['timestamp']).strftime('%d/%m/%Y')
- row = [_id, url, path, _date]
+ row = [id_, url, path, date_]
grid.append(row)
@@ -57,10 +57,10 @@ def add(self, path, url):
history = self.history.doc['history']
- id = 1 if len(history) == 0 else history[-1]['id'] + 1
+ id_ = 1 if len(history) == 0 else history[-1]['id'] + 1
history.append({
- 'id': id,
+ 'id': id_,
'path': path,
'url': url,
'timestamp': time()
View
18 src/lib/main.py
@@ -76,10 +76,10 @@ def handle_files(paths, filenames, share_to):
# There's a special case if there's one file and no folders,
# It can be uploaded on its own.
if num_files == 1 and num_folders == 0:
- _file = files[0]
- d.upload(_file, filepath=filenames[0])
+ file_ = files[0]
+ d.upload(file_, filepath=filenames[0])
link = d.get_link('/' + filenames[0])
- local_paths = [os.path.abspath(_file)]
+ local_paths = [os.path.abspath(file_)]
# Otherwise it's more complicated.
# We could have multiple files, one folder, multiple folders, or a mix of files and folders
@@ -100,9 +100,9 @@ def handle_files(paths, filenames, share_to):
# Upload all the files to the root folder
i = 0
- for _file in files:
+ for file_ in files:
filename = folder_name + '/' + filenames[i]
- d.upload(_file, filepath=filename)
+ d.upload(file_, filepath=filename)
i += 1
# Then recursively upload all the folders and their contents to the root folder
@@ -110,7 +110,7 @@ def handle_files(paths, filenames, share_to):
d.upload_folder(folder_name)
link = d.get_link('/' + d.final_folder_name)
- local_paths = [os.path.abspath(_file) for _file in files]
+ local_paths = [os.path.abspath(file_) for file_ in files]
save_link(link, local_paths, share_to)
@@ -133,9 +133,6 @@ def upload(args):
def snippet(args):
"""Upload the contents of the user's clipboard as a text file"""
- # gist functionality on hold - dropbox works fine for now
- # from gist import Gist
-
clipboard = Clipboard().get()
if clipboard is None:
return
@@ -150,9 +147,6 @@ def snippet(args):
handle_files([path], [filename], args.share)
- #elif args.text == 'gist':
- # Gist().upload(filename, clipboard)
-
def history(args):
"""Display the history of previously uploaded file"""

No commit comments for this range

Something went wrong with that request. Please try again.