Use six.text_type instead of unicode().
I will be switch to use ``from __future__ import unicode_literals`` later.
This commit is contained in:
@@ -14,8 +14,12 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
from mediagoblin.gmg_commands import util as commands_util
|
||||
from mediagoblin.submit.lib import (
|
||||
submit_media, get_upload_file_limits,
|
||||
@@ -68,14 +72,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.username
|
||||
print("Sorry, no user by username '%s'" % args.username)
|
||||
return
|
||||
|
||||
# check for the file, if it exists...
|
||||
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
|
||||
print("Can't find a file with filename '%s'" % args.filename)
|
||||
return
|
||||
|
||||
upload_limit, max_file_size = get_upload_file_limits(user)
|
||||
@@ -85,7 +89,7 @@ def addmedia(args):
|
||||
if some_string is None:
|
||||
return None
|
||||
else:
|
||||
return unicode(some_string)
|
||||
return six.text_type(some_string)
|
||||
|
||||
try:
|
||||
submit_media(
|
||||
@@ -98,8 +102,8 @@ def addmedia(args):
|
||||
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."
|
||||
print("This file is larger than the upload limits for this site.")
|
||||
except UserUploadLimit:
|
||||
print "This file will put this user past their upload limits."
|
||||
print("This file will put this user past their upload limits.")
|
||||
except UserPastUploadLimit:
|
||||
print "This user is already past their upload limits."
|
||||
print("This user is already past their upload limits.")
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import six
|
||||
|
||||
from mediagoblin.gmg_commands import util as commands_util
|
||||
from mediagoblin import auth
|
||||
from mediagoblin import mg_globals
|
||||
@@ -50,8 +52,8 @@ def adduser(args):
|
||||
else:
|
||||
# Create the user
|
||||
entry = db.User()
|
||||
entry.username = unicode(args.username.lower())
|
||||
entry.email = unicode(args.email)
|
||||
entry.username = six.text_type(args.username.lower())
|
||||
entry.email = six.text_type(args.email)
|
||||
entry.pw_hash = auth.gen_password_hash(args.password)
|
||||
default_privileges = [
|
||||
db.Privilege.query.filter(
|
||||
@@ -81,7 +83,7 @@ def makeadmin(args):
|
||||
db = mg_globals.database
|
||||
|
||||
user = db.User.query.filter_by(
|
||||
username=unicode(args.username.lower())).one()
|
||||
username=six.text_type(args.username.lower())).one()
|
||||
if user:
|
||||
user.all_privileges.append(
|
||||
db.Privilege.query.filter(
|
||||
@@ -108,7 +110,7 @@ def changepw(args):
|
||||
db = mg_globals.database
|
||||
|
||||
user = db.User.query.filter_by(
|
||||
username=unicode(args.username.lower())).one()
|
||||
username=six.text_type(args.username.lower())).one()
|
||||
if user:
|
||||
user.pw_hash = auth.gen_password_hash(args.password)
|
||||
user.save()
|
||||
|
||||
Reference in New Issue
Block a user