Reformatted manage.py

This commit is contained in:
Sybren A. Stüvel 2016-05-06 12:11:55 +02:00
parent 6f193da89d
commit 410ecac78c

View File

@ -262,13 +262,13 @@ def manage_groups():
client = MongoClient(MONGO_HOST, 27017) client = MongoClient(MONGO_HOST, 27017)
db = client.eve db = client.eve
print ("") print("")
print ("Add or Remove user from group") print("Add or Remove user from group")
print ("leave empty to cancel") print("leave empty to cancel")
print ("") print("")
# Select Action # Select Action
print ("Do you want to Add or Remove the user from the group?") print("Do you want to Add or Remove the user from the group?")
retry = True retry = True
while retry: while retry:
action = raw_input('add/remove: ') action = raw_input('add/remove: ')
@ -281,7 +281,7 @@ def manage_groups():
action = 'remove' action = 'remove'
retry = False retry = False
else: else:
print ("Incorrect action, press type 'add' or 'remove'") print("Incorrect action, press type 'add' or 'remove'")
# Select User # Select User
retry = True retry = True
@ -293,7 +293,7 @@ def manage_groups():
if user: if user:
retry = False retry = False
else: else:
print ("Incorrect user email, try again, or leave empty to cancel") print("Incorrect user email, try again, or leave empty to cancel")
# Select group # Select group
retry = True retry = True
@ -305,7 +305,7 @@ def manage_groups():
if group: if group:
retry = False retry = False
else: else:
print ("Incorrect group name, try again, or leave empty to cancel") print("Incorrect group name, try again, or leave empty to cancel")
# Do # Do
current_groups = user.get('groups', []) current_groups = user.get('groups', [])
@ -386,6 +386,7 @@ def add_parent_to_nodes():
sys.stdout = UTF8Writer(sys.stdout) sys.stdout = UTF8Writer(sys.stdout)
nodes_collection = app.data.driver.db['nodes'] nodes_collection = app.data.driver.db['nodes']
def find_parent_project(node): def find_parent_project(node):
if node and 'parent' in node: if node and 'parent' in node:
parent = nodes_collection.find_one({'_id': node['parent']}) parent = nodes_collection.find_one({'_id': node['parent']})
@ -394,6 +395,7 @@ def add_parent_to_nodes():
return node return node
else: else:
return None return None
nodes = nodes_collection.find() nodes = nodes_collection.find()
nodes_index = 0 nodes_index = 0
nodes_orphan = 0 nodes_orphan = 0
@ -467,7 +469,7 @@ def convert_assets_to_textures(project_id):
return dict(variation=variation, is_tileable=is_tileable) return dict(variation=variation, is_tileable=is_tileable)
def make_texture_node(base_node, files, parent_id=None): def make_texture_node(base_node, files, parent_id=None):
texture_node_type = node_types_collection.find_one({'name':'texture'}) texture_node_type = node_types_collection.find_one({'name': 'texture'})
files_list = [] files_list = []
is_tileable = False is_tileable = False
@ -519,7 +521,6 @@ def convert_assets_to_textures(project_id):
import pprint import pprint
pprint.pprint(node) pprint.pprint(node)
nodes_collection = app.data.driver.db['nodes'] nodes_collection = app.data.driver.db['nodes']
for n in nodes_collection.find({'project': ObjectId(project_id)}): for n in nodes_collection.find({'project': ObjectId(project_id)}):
@ -535,7 +536,7 @@ def convert_assets_to_textures(project_id):
elif n_type['name'] == 'group': elif n_type['name'] == 'group':
# Change group type to texture group # Change group type to texture group
node_type_texture = node_types_collection.find_one( node_type_texture = node_types_collection.find_one(
{'name':'group_texture'}) {'name': 'group_texture'})
n['node_type'] = node_type_texture['_id'] n['node_type'] = node_type_texture['_id']
n['properties'].pop('notes', None) n['properties'].pop('notes', None)
print("Updating {0}".format(n['name'])) print("Updating {0}".format(n['name']))
@ -707,6 +708,7 @@ def files_make_public_t():
except Exception: except Exception:
pass pass
@manager.command @manager.command
def subscribe_node_owners(): def subscribe_node_owners():
"""Automatically subscribe node owners to notifications for items created """Automatically subscribe node owners to notifications for items created