Merge remote-tracking branch 'remotes/nyergler/pep8-ification'

Conflicts:
	mediagoblin/db/migrations.py
	mediagoblin/db/models.py
	mediagoblin/user_pages/views.py
	mediagoblin/util.py
This commit is contained in:
Christopher Allan Webber
2011-11-13 20:23:26 -06:00
44 changed files with 159 additions and 123 deletions

View File

@@ -29,7 +29,7 @@ SUBCOMMAND_MAP = {
'setup': 'mediagoblin.gmg_commands.migrate:migrate_parser_setup',
'func': 'mediagoblin.gmg_commands.migrate:migrate',
'help': 'Apply all unapplied bulk migrations to the database'},
'adduser':{
'adduser': {
'setup': 'mediagoblin.gmg_commands.users:adduser_parser_setup',
'func': 'mediagoblin.gmg_commands.users:adduser',
'help': 'Creates an user'},
@@ -68,7 +68,7 @@ def main_cli():
subparsers = parser.add_subparsers(help='sub-command help')
for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
if command_struct.has_key('help'):
if 'help' in command_struct:
subparser = subparsers.add_parser(
command_name, help=command_struct['help'])
else:
@@ -94,4 +94,3 @@ def main_cli():
if __name__ == '__main__':
main_cli()

View File

@@ -88,7 +88,7 @@ def _import_database(db, args):
args.mongorestore_path,
'-d', db.name,
os.path.join(args._cache_path['database'], db.name)])
p.wait()
_log.info('...Database imported')
@@ -226,7 +226,8 @@ def env_export(args):
'''
if args.cache_path:
if os.path.exists(args.cache_path):
_log.error('The cache directory must not exist before you run this script')
_log.error('The cache directory must not exist '
'before you run this script')
_log.error('Cache directory: {0}'.format(args.cache_path))
return False
@@ -242,7 +243,7 @@ def env_export(args):
globa_config, app_config = setup_global_and_app_config(args.conf_file)
setup_storage()
connection, db = setup_connection_and_db_from_config(
app_config, use_pymongo=True)

View File

@@ -53,13 +53,13 @@ def migrate(args):
for collection, index_name in removed_indexes:
print "Removed index '%s' in collection '%s'" % (
index_name, collection)
# Migrate
print "\n== Applying migrations... =="
migration_manager.migrate_new(
pre_callback=_print_started_migration,
post_callback=_print_finished_migration)
# Add new indexes
print "\n== Adding new indexes... =="
new_indexes = db_util.add_new_indexes(db)

View File

@@ -38,7 +38,7 @@ def adduser(args):
db = mg_globals.database
users_with_username = \
db.User.find({
'username': args.username.lower()
'username': args.username.lower(),
}).count()
if users_with_username:
@@ -68,7 +68,7 @@ def makeadmin(args):
db = mg_globals.database
user = db.User.one({'username':unicode(args.username.lower())})
user = db.User.one({'username': unicode(args.username.lower())})
if user:
user['is_admin'] = True
user.save()
@@ -91,11 +91,10 @@ def changepw(args):
db = mg_globals.database
user = db.User.one({'username':unicode(args.username.lower())})
user = db.User.one({'username': unicode(args.username.lower())})
if user:
user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(args.password)
user.save()
print 'Password successfully changed'
else:
print 'The user doesn\'t exist'