diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-11-14 09:51:29 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-11-14 09:51:29 -0600 |
commit | 862e05a5b514933ac0430e01f31033e51c8ce188 (patch) | |
tree | 1316052cee73dc2794426c0d18657a88f237583c /mediagoblin/gmg_commands/addmedia.py | |
parent | 301da9cabad61c8968a6e70df673dc26f1fea102 (diff) | |
download | mediagoblin-862e05a5b514933ac0430e01f31033e51c8ce188.tar.lz mediagoblin-862e05a5b514933ac0430e01f31033e51c8ce188.tar.xz mediagoblin-862e05a5b514933ac0430e01f31033e51c8ce188.zip |
Hacks to get past unicode barriers
The methods we're using here aren't ideal but they mirror those used
in the submit views...
This commit sponsored by Alexander Couper. Thanks!
Diffstat (limited to 'mediagoblin/gmg_commands/addmedia.py')
-rw-r--r-- | mediagoblin/gmg_commands/addmedia.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/mediagoblin/gmg_commands/addmedia.py b/mediagoblin/gmg_commands/addmedia.py index 682d415f..03e11ff5 100644 --- a/mediagoblin/gmg_commands/addmedia.py +++ b/mediagoblin/gmg_commands/addmedia.py @@ -68,13 +68,14 @@ def addmedia(args): # get the user user = app.db.User.query.filter_by(username=args.username.lower()).first() if user is None: - print "Sorry, no user by username '%s'" % args.user + print "Sorry, no user by username '%s'" % args.username return # check for the file, if it exists... - filename = os.path.abspath(args.filename) - if not os.path.exists(filename): - print "Can't find a file by that filename?" + filename = os.path.split(args.filename)[-1] + abs_filename = os.path.abspath(args.filename) + if not os.path.exists(abs_filename): + print "Can't find a file with filename '%s'" % args.filename return if user.upload_limit >= 0: @@ -84,13 +85,22 @@ def addmedia(args): max_file_size = mg_globals.app_config.get('max_file_size', None) + def maybe_unicodeify(some_string): + # this is kinda terrible + if some_string is None: + return None + else: + return unicode(some_string) + try: submit_media( mg_app=app, user=user, - submitted_file=file(filename, 'r'), filename=filename, - title=args.title, description=args.description, - license=args.license, tags_string=args.tags or u'', + submitted_file=file(abs_filename, 'r'), filename=filename, + title=maybe_unicodeify(args.title), + description=maybe_unicodeify(args.description), + license=maybe_unicodeify(args.license), + tags_string=maybe_unicodeify(args.tags) or u"", upload_limit=upload_limit, max_file_size=max_file_size) except FileUploadLimit: print "This file is larger than the upload limits for this site." |