Commit 2ca4abda authored by Jérome Perrin's avatar Jérome Perrin Committed by Sebastien Robin

Make topology file path an argument to the program

parent 5f4af8e5
...@@ -27,6 +27,7 @@ import numpy as np ...@@ -27,6 +27,7 @@ import numpy as np
import json import json
from random import Random from random import Random
import sys import sys
import os.path
#reads general simulation inputs #reads general simulation inputs
def readGeneralInput(): def readGeneralInput():
...@@ -256,19 +257,20 @@ def activateObjects(): ...@@ -256,19 +257,20 @@ def activateObjects():
except AttributeError: except AttributeError:
pass pass
#the main script that is ran #the main script that is ran
def main(): def main(argv=[]):
argv = argv or sys.argv[1:]
#create an empty list to store all the objects in #create an empty list to store all the objects in
G.ObjList=[] G.ObjList=[]
#user inputs the id of the JSON file # user passes the topology filename as first argument to the program
topologyId=raw_input("give the topology id\n") filename = argv[0]
try: try:
G.JSONFile=open('JSONInputs/Topology'+str(topologyId)+'.JSON', "r") G.JSONFile=open(filename, "r")
except IOError: except IOError:
print "no such topology file. The programm is terminated" print "%s could not be open" % filename
sys.exit() return "ERROR"
start=time.time() #start counting execution time start=time.time() #start counting execution time
...@@ -314,4 +316,5 @@ def main(): ...@@ -314,4 +316,5 @@ def main():
G.outputFile.save("output.xls") G.outputFile.save("output.xls")
print "execution time="+str(time.time()-start) print "execution time="+str(time.time()-start)
if __name__ == '__main__': main() if __name__ == '__main__':
\ No newline at end of file main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment