Compute full file paths so program can be run from another path
Closed this issue · 0 comments
answerquest commented
Problem description
If we run the program by command-line or shortcut from another working folder, example:
python3 some/folder/path/GTFSManager.py
Then the program errors out because it is unable to find the supporting files in the working path.
Expected Action
Program should run no matter where it's called from.
Anything else
We were already computing the absolute path in order to launch Tornado web server.
root = os.path.dirname(__file__) # needed for tornado
So, simply pre-pend the path stored in root
variable to all the external file / folder paths.
uploadFolder = os.path.join(root,'uploads/')
xmlFolder = os.path.join(root,'xml_related/')
logFolder = os.path.join(root,'logs/')
configFolder = os.path.join(root,'config/')
dbFolder = os.path.join(root,'db/')
exportFolder = os.path.join(root,'export/')