summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rwxr-xr-xdatabase/prefab.py8
-rwxr-xr-xdatabase/prefabs.py8
2 files changed, 7 insertions, 9 deletions
diff --git a/database/prefab.py b/database/prefab.py
index 124f45e3..b993c7f0 100755
--- a/database/prefab.py
+++ b/database/prefab.py
@@ -1,4 +1,4 @@
-#!/Users/jacobburley/thesis-src/opendc/mongodb/opendc_testing/bin/python3
+#!/usr/bin/env python3
#Change shebang to /usr/bin/python3 before using with docker
# encoding: utf-8
"""
@@ -17,7 +17,7 @@ def usage():
print(" clone <prefab> [new prefab name]: clones the specified prefab, giving the new prefab a name if specified")
print(" remove <prefab>: removes the specified prefab from the database")
-def interactive(): #interactive CLI mode: recommended
+def interactive(): #interactive CLI mode: recommended
print("OpenDC Prefab CLI")
running = True
while(exit):
@@ -105,8 +105,8 @@ def main():
else:
# print "Incorrect number of arguments!\n"
- print("prefabs: try 'prefabs help' for more information\n")
+ print("prefabs: try 'prefabs help' for more information\n")
if __name__ == "__main__":
- main() \ No newline at end of file
+ main()
diff --git a/database/prefabs.py b/database/prefabs.py
index f6f46cbc..ed308d84 100755
--- a/database/prefabs.py
+++ b/database/prefabs.py
@@ -1,5 +1,3 @@
-#!/Users/jacobburley/thesis-src/opendc/mongodb/opendc_testing/bin/python3
-#Change shebang to /usr/bin/python3 before using with docker
# encoding: utf-8
"""
prefabs
@@ -69,7 +67,7 @@ def clone(prefab_name, new_name):
bson = prefabs_collection.find_one({'name': prefab_name})
json_string = dumps(bson) #convert BSON representation to JSON
chosen_prefab = json.loads(json_string) #load as a JSON object
-
+
chosen_prefab.pop("_id") # clean out our _id field from the export: mongo will generate a new one if this is imported back in
if new_name != None:
@@ -90,7 +88,7 @@ def export(prefab_name, type):
bson = prefabs_collection.find_one({'name': prefab_name})
json_string = dumps(bson) #convert BSON representation to JSON
chosen_prefab = json.loads(json_string) #load as a JSON object
-
+
chosen_prefab.pop("_id") # clean out our _id field from the export: mongo will generate a new one if this is imported back in
with open(f'{prefab_name}.json', 'w', encoding='utf8') as f:
@@ -108,7 +106,7 @@ def list():
#print(record)
json_string = dumps(record, json_options=RELAXED_JSON_OPTIONS) ##pymongo retrieves BSON objects, which need to be converted to json for pythons json module
prefabs.append(json.loads(json_string))
-
+
#print(f'There are {str(len(prefabs))} prefabs in the database. They are:')
print("Name Author")
for prefab in prefabs: