Added sqliterc

This commit is contained in:
Fergal Moran
2016-05-02 20:37:20 +01:00
parent ccb620671f
commit 7f355f8c2b
6 changed files with 184 additions and 7 deletions

View File

@@ -4,7 +4,7 @@
#
# dropbox
# Dropbox frontend script
# This file is part of nautilus-dropbox 1.6.2.
# This file is part of nautilus-dropbox 2015.10.28.
#
# nautilus-dropbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -212,7 +212,7 @@ def verify_signature(key_file, sig_file, plain_file):
def download_file_chunk(url, buf):
opener = urllib2.build_opener()
opener.addheaders = [('User-Agent', "DropboxLinuxDownloader/1.6.2")]
opener.addheaders = [('User-Agent', "DropboxLinuxDownloader/2015.10.28")]
sock = opener.open(url)
size = int(sock.info()['content-length'])
@@ -995,10 +995,10 @@ This is an alias for filestatus -l
@command
@requires_dropbox_running
def puburl(args):
u"""get public url of a file in your dropbox
u"""get public url of a file in your dropbox's public folder
dropbox puburl FILE
Prints out a public url for FILE.
Prints out a public url for FILE (which must be in your public folder).
"""
if len(args) != 1:
console_print(puburl.__doc__,linebreak=False)
@@ -1017,6 +1017,153 @@ Prints out a public url for FILE.
except DropboxCommand.CouldntConnectError, e:
console_print(u"Dropbox isn't running!")
@command
@requires_dropbox_running
def sharelink(args):
u"""get a shared link for a file in your dropbox
dropbox sharelink FILE
Prints out a shared link for FILE.
"""
if len(args) != 1:
console_print(sharelink.__doc__, linebreak=False)
return
try:
with closing(DropboxCommand()) as dc:
try:
path = unicode_abspath(args[0].decode(sys.getfilesystemencoding()))
link = dc.get_shared_link(path=path).get('link', [u'No link'])[0]
console_print(link)
except DropboxCommand.CommandError, e:
console_print(u"Couldn't get shared link: " + str(e))
except DropboxCommand.BadConnectionError, e:
console_print(u"Dropbox isn't responding!")
except DropboxCommand.EOFError:
console_print(u"Dropbox daemon stopped.")
except DropboxCommand.CouldntConnectError, e:
console_print(u"Dropbox isn't running!")
@command
@requires_dropbox_running
def proxy(args):
u"""set proxy settings for Dropbox
dropbox proxy MODE [TYPE] [HOST] [PORT] [USERNAME] [PASSWORD]
Set proxy settings for Dropbox.
MODE - one of "none", "auto", "manual"
TYPE - one of "http", "socks4", "socks5" (only valid with "manual" mode)
HOST - proxy hostname (only valid with "manual" mode)
PORT - proxy port (only valid with "manual" mode)
USERNAME - (optional) proxy username (only valid with "manual" mode)
PASSWORD - (optional) proxy password (only valid with "manual" mode)
"""
mode = None
type_ = None
if len(args) >= 1:
mode = args[0].decode(sys.getfilesystemencoding()).lower()
if len(args) >= 2:
type_ = args[1].decode(sys.getfilesystemencoding()).lower()
if (len(args) == 0 or
mode not in [u'none', u'auto', u'manual'] or
(mode == 'manual' and len(args) not in (4, 6)) or
(mode != 'manual' and len(args) != 1) or
(mode == 'manual' and type_ not in [u'http', u'socks4', u'socks5'])):
# Print help
console_print(proxy.__doc__, linebreak=False)
return
ARGS = ['mode', 'type', 'host', 'port', 'username', 'password']
# Load the args into a dictionary
kwargs = dict(zip(ARGS, [a.decode(sys.getfilesystemencoding()) for a in args]))
# Re-set these two because they were coerced to lower case
kwargs['mode'] = mode
if type_:
kwargs['type'] = type_
try:
with closing(DropboxCommand()) as dc:
try:
dc.set_proxy_settings(**kwargs)
console_print(u'set')
except DropboxCommand.CommandError, e:
console_print(u"Couldn't set proxy: " + str(e))
except DropboxCommand.BadConnectionError, e:
console_print(u"Dropbox isn't responding!")
except DropboxCommand.EOFError:
console_print(u"Dropbox daemon stopped.")
except DropboxCommand.CouldntConnectError, e:
console_print(u"Dropbox isn't running!")
@command
@requires_dropbox_running
def throttle(args):
u"""set bandwidth limits for Dropbox
dropbox throttle DOWNLOAD UPLOAD
Set bandwidth limits for file sync.
DOWNLOAD - either "unlimited" or a manual limit in KB/s
UPLOAD - one of "unlimited", "auto", or a manual limit in KB/s
"""
if len(args) != 2:
console_print(throttle.__doc__, linebreak=False)
return
downlimit = args[0].decode(sys.getfilesystemencoding()).lower()
uplimit = args[1].decode(sys.getfilesystemencoding()).lower()
download_limit = None
download_mode = None
if downlimit == u'unlimited':
download_mode = downlimit
else:
try:
download_limit = int(downlimit)
download_mode = u'manual'
except ValueError:
console_print(throttle.__doc__, linebreak=False)
return
upload_limit = None
upload_mode = None
if uplimit in [u'unlimited', u'auto']:
upload_mode = uplimit
else:
try:
upload_limit = int(uplimit)
upload_mode = u'manual'
except ValueError:
console_print(throttle.__doc__, linebreak=False)
return
kwargs = {
u'download_mode': download_mode,
u'upload_mode': upload_mode,
}
if download_limit:
kwargs[u'download_limit'] = unicode(download_limit)
if upload_limit:
kwargs[u'upload_limit'] = unicode(upload_limit)
try:
with closing(DropboxCommand()) as dc:
try:
dc.set_bandwidth_limits(**kwargs)
console_print(u'set')
except DropboxCommand.CommandError, e:
console_print(u"Couldn't set bandwidth limits: " + str(e))
except DropboxCommand.BadConnectionError, e:
console_print(u"Dropbox isn't responding!")
except DropboxCommand.EOFError:
console_print(u"Dropbox daemon stopped.")
except DropboxCommand.CouldntConnectError, e:
console_print(u"Dropbox isn't running!")
@command
@requires_dropbox_running
def status(args):