Fix print statements.

This commit is contained in:
Berker Peksag 2014-06-29 04:13:23 +03:00
parent e2cb0f86fe
commit f9d93c0e9a
3 changed files with 36 additions and 29 deletions

View File

@ -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/>.
from __future__ import print_function
from mediagoblin.gmg_commands import util as commands_util
@ -32,7 +34,7 @@ def deletemedia(args):
for media in medias:
found_medias.add(media.id)
media.delete()
print 'Media ID %d has been deleted.' % media.id
print('Media ID %d has been deleted.' % media.id)
for media in media_ids - found_medias:
print 'Can\'t find a media with ID %d.' % media
print 'Done.'
print('Can\'t find a media with ID %d.' % media)
print('Done.')

View File

@ -13,6 +13,9 @@
#
# 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 argparse
import os
@ -143,7 +146,7 @@ def available(args):
manager = get_processing_manager_for_type(media_type)
except ProcessingManagerDoesNotExist:
entry = MediaEntry.query.filter_by(id=args.id_or_type).first()
print 'No such processing manager for {0}'.format(entry.media_type)
print('No such processing manager for {0}'.format(entry.media_type))
if args.state:
processors = manager.list_all_processors_by_state(args.state)
@ -152,25 +155,25 @@ def available(args):
else:
processors = manager.list_eligible_processors(media_entry)
print "Available processors:"
print "====================="
print ""
print("Available processors:")
print("=====================")
print("")
if args.action_help:
for processor in processors:
print processor.name
print "-" * len(processor.name)
print(processor.name)
print("-" * len(processor.name))
parser = processor.generate_parser()
parser.print_help()
print ""
print("")
else:
for processor in processors:
if processor.description:
print " - %s: %s" % (processor.name, processor.description)
print(" - %s: %s" % (processor.name, processor.description))
else:
print " - %s" % processor.name
print(" - %s" % processor.name)
def run(args, media_id=None):
@ -185,12 +188,12 @@ def run(args, media_id=None):
processor_class = manager.get_processor(
args.reprocess_command, media_entry)
except ProcessorDoesNotExist:
print 'No such processor "%s" for media with id "%s"' % (
args.reprocess_command, media_entry.id)
print('No such processor "%s" for media with id "%s"' % (
args.reprocess_command, media_entry.id))
return
except ProcessorNotEligible:
print 'Processor "%s" exists but media "%s" is not eligible' % (
args.reprocess_command, media_entry.id)
print('Processor "%s" exists but media "%s" is not eligible' % (
args.reprocess_command, media_entry.id))
return
reprocess_parser = processor_class.generate_parser()
@ -203,7 +206,7 @@ def run(args, media_id=None):
except ProcessingManagerDoesNotExist:
entry = MediaEntry.query.filter_by(id=media_id).first()
print 'No such processing manager for {0}'.format(entry.media_type)
print('No such processing manager for {0}'.format(entry.media_type))
def bulk_run(args):
@ -233,12 +236,12 @@ def thumbs(args):
processor_class = manager.get_processor(
'resize', media_entry)
except ProcessorDoesNotExist:
print 'No such processor "%s" for media with id "%s"' % (
'resize', media_entry.id)
print('No such processor "%s" for media with id "%s"' % (
'resize', media_entry.id))
return
except ProcessorNotEligible:
print 'Processor "%s" exists but media "%s" is not eligible' % (
'resize', media_entry.id)
print('Processor "%s" exists but media "%s" is not eligible' % (
'resize', media_entry.id))
return
reprocess_parser = processor_class.generate_parser()
@ -260,7 +263,7 @@ def thumbs(args):
reprocess_info=reprocess_request)
except ProcessingManagerDoesNotExist:
print 'No such processing manager for {0}'.format(entry.media_type)
print('No such processing manager for {0}'.format(entry.media_type))
def initial(args):
@ -276,7 +279,7 @@ def initial(args):
media_entry,
reprocess_action='initial')
except ProcessingManagerDoesNotExist:
print 'No such processing manager for {0}'.format(entry.media_type)
print('No such processing manager for {0}'.format(entry.media_type))
def reprocess(args):

View File

@ -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/>.
from __future__ import print_function
import six
from mediagoblin.gmg_commands import util as commands_util
@ -47,7 +49,7 @@ def adduser(args):
).count()
if users_with_username:
print u'Sorry, a user with that name already exists.'
print(u'Sorry, a user with that name already exists.')
else:
# Create the user
@ -68,7 +70,7 @@ def adduser(args):
entry.all_privileges = default_privileges
entry.save()
print "User created (and email marked as verified)"
print(u"User created (and email marked as verified)")
def makeadmin_parser_setup(subparser):
@ -90,9 +92,9 @@ def makeadmin(args):
db.Privilege.privilege_name==u'admin').one()
)
user.save()
print 'The user is now Admin'
print(u'The user is now Admin')
else:
print 'The user doesn\'t exist'
print(u'The user doesn\'t exist')
def changepw_parser_setup(subparser):
@ -114,6 +116,6 @@ def changepw(args):
if user:
user.pw_hash = auth.gen_password_hash(args.password)
user.save()
print 'Password successfully changed'
print(u'Password successfully changed')
else:
print 'The user doesn\'t exist'
print(u'The user doesn\'t exist')