WRI-Cities / static-GTFS-manager

GUI interface for creating, editing, exporting of static GTFS data for a public transit authority
GNU General Public License v3.0
147 stars 46 forks source link

Compute full file paths so program can be run from another path #138

Closed answerquest closed 5 years ago

answerquest commented 5 years ago

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/')