@@ -995,10 +995,10 @@ This is an alias for filestatus -l
995995@command
996996@requires_dropbox_running
997997def puburl (args ):
998- u"""get public url of a file in your dropbox
998+ u"""get public url of a file in your dropbox's public folder
999999dropbox puburl FILE
10001000
1001- Prints out a public url for FILE.
1001+ Prints out a public url for FILE (which must be in your public folder) .
10021002"""
10031003 if len (args ) != 1 :
10041004 console_print (puburl .__doc__ ,linebreak = False )
@@ -1017,6 +1017,153 @@ Prints out a public url for FILE.
10171017 except DropboxCommand .CouldntConnectError , e :
10181018 console_print (u"Dropbox isn't running!" )
10191019
1020+ @command
1021+ @requires_dropbox_running
1022+ def sharelink (args ):
1023+ u"""get a shared link for a file in your dropbox
1024+ dropbox sharelink FILE
1025+
1026+ Prints out a shared link for FILE.
1027+ """
1028+ if len (args ) != 1 :
1029+ console_print (sharelink .__doc__ , linebreak = False )
1030+ return
1031+
1032+ try :
1033+ with closing (DropboxCommand ()) as dc :
1034+ try :
1035+ path = unicode_abspath (args [0 ].decode (sys .getfilesystemencoding ()))
1036+ link = dc .get_shared_link (path = path ).get ('link' , [u'No link' ])[0 ]
1037+ console_print (link )
1038+ except DropboxCommand .CommandError , e :
1039+ console_print (u"Couldn't get shared link: " + str (e ))
1040+ except DropboxCommand .BadConnectionError , e :
1041+ console_print (u"Dropbox isn't responding!" )
1042+ except DropboxCommand .EOFError :
1043+ console_print (u"Dropbox daemon stopped." )
1044+ except DropboxCommand .CouldntConnectError , e :
1045+ console_print (u"Dropbox isn't running!" )
1046+
1047+ @command
1048+ @requires_dropbox_running
1049+ def proxy (args ):
1050+ u"""set proxy settings for Dropbox
1051+ dropbox proxy MODE [TYPE] [HOST] [PORT] [USERNAME] [PASSWORD]
1052+
1053+ Set proxy settings for Dropbox.
1054+
1055+ MODE - one of "none", "auto", "manual"
1056+ TYPE - one of "http", "socks4", "socks5" (only valid with "manual" mode)
1057+ HOST - proxy hostname (only valid with "manual" mode)
1058+ PORT - proxy port (only valid with "manual" mode)
1059+ USERNAME - (optional) proxy username (only valid with "manual" mode)
1060+ PASSWORD - (optional) proxy password (only valid with "manual" mode)
1061+ """
1062+ mode = None
1063+ type_ = None
1064+ if len (args ) >= 1 :
1065+ mode = args [0 ].decode (sys .getfilesystemencoding ()).lower ()
1066+ if len (args ) >= 2 :
1067+ type_ = args [1 ].decode (sys .getfilesystemencoding ()).lower ()
1068+
1069+ if (len (args ) == 0 or
1070+ mode not in [u'none' , u'auto' , u'manual' ] or
1071+ (mode == 'manual' and len (args ) not in (4 , 6 )) or
1072+ (mode != 'manual' and len (args ) != 1 ) or
1073+ (mode == 'manual' and type_ not in [u'http' , u'socks4' , u'socks5' ])):
1074+ # Print help
1075+ console_print (proxy .__doc__ , linebreak = False )
1076+ return
1077+
1078+ ARGS = ['mode' , 'type' , 'host' , 'port' , 'username' , 'password' ]
1079+
1080+ # Load the args into a dictionary
1081+ kwargs = dict (zip (ARGS , [a .decode (sys .getfilesystemencoding ()) for a in args ]))
1082+
1083+ # Re-set these two because they were coerced to lower case
1084+ kwargs ['mode' ] = mode
1085+ if type_ :
1086+ kwargs ['type' ] = type_
1087+
1088+ try :
1089+ with closing (DropboxCommand ()) as dc :
1090+ try :
1091+ dc .set_proxy_settings (** kwargs )
1092+ console_print (u'set' )
1093+ except DropboxCommand .CommandError , e :
1094+ console_print (u"Couldn't set proxy: " + str (e ))
1095+ except DropboxCommand .BadConnectionError , e :
1096+ console_print (u"Dropbox isn't responding!" )
1097+ except DropboxCommand .EOFError :
1098+ console_print (u"Dropbox daemon stopped." )
1099+ except DropboxCommand .CouldntConnectError , e :
1100+ console_print (u"Dropbox isn't running!" )
1101+
1102+ @command
1103+ @requires_dropbox_running
1104+ def throttle (args ):
1105+ u"""set bandwidth limits for Dropbox
1106+ dropbox throttle DOWNLOAD UPLOAD
1107+
1108+ Set bandwidth limits for file sync.
1109+
1110+ DOWNLOAD - either "unlimited" or a manual limit in KB/s
1111+ UPLOAD - one of "unlimited", "auto", or a manual limit in KB/s
1112+ """
1113+ if len (args ) != 2 :
1114+ console_print (throttle .__doc__ , linebreak = False )
1115+ return
1116+
1117+ downlimit = args [0 ].decode (sys .getfilesystemencoding ()).lower ()
1118+ uplimit = args [1 ].decode (sys .getfilesystemencoding ()).lower ()
1119+
1120+ download_limit = None
1121+ download_mode = None
1122+ if downlimit == u'unlimited' :
1123+ download_mode = downlimit
1124+ else :
1125+ try :
1126+ download_limit = int (downlimit )
1127+ download_mode = u'manual'
1128+ except ValueError :
1129+ console_print (throttle .__doc__ , linebreak = False )
1130+ return
1131+
1132+ upload_limit = None
1133+ upload_mode = None
1134+ if uplimit in [u'unlimited' , u'auto' ]:
1135+ upload_mode = uplimit
1136+ else :
1137+ try :
1138+ upload_limit = int (uplimit )
1139+ upload_mode = u'manual'
1140+ except ValueError :
1141+ console_print (throttle .__doc__ , linebreak = False )
1142+ return
1143+
1144+ kwargs = {
1145+ u'download_mode' : download_mode ,
1146+ u'upload_mode' : upload_mode ,
1147+ }
1148+ if download_limit :
1149+ kwargs [u'download_limit' ] = unicode (download_limit )
1150+ if upload_limit :
1151+ kwargs [u'upload_limit' ] = unicode (upload_limit )
1152+
1153+ try :
1154+ with closing (DropboxCommand ()) as dc :
1155+ try :
1156+ dc .set_bandwidth_limits (** kwargs )
1157+ console_print (u'set' )
1158+ except DropboxCommand .CommandError , e :
1159+ console_print (u"Couldn't set bandwidth limits: " + str (e ))
1160+ except DropboxCommand .BadConnectionError , e :
1161+ console_print (u"Dropbox isn't responding!" )
1162+ except DropboxCommand .EOFError :
1163+ console_print (u"Dropbox daemon stopped." )
1164+ except DropboxCommand .CouldntConnectError , e :
1165+ console_print (u"Dropbox isn't running!" )
1166+
10201167@command
10211168@requires_dropbox_running
10221169def status (args ):
0 commit comments