changeset 259:ca2f200f37be

Automatically go to right folder when running server locally so you can drag and drop the script in Terminal (after typing 'Python').
author Brecht De Man <b.deman@qmul.ac.uk>
date Fri, 03 Jul 2015 19:50:12 +0100
parents a2800d0b5656
children be08f0bc3f31
files pythonServer.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pythonServer.py	Thu Jul 02 15:44:35 2015 +0100
+++ b/pythonServer.py	Fri Jul 03 19:50:12 2015 +0100
@@ -2,10 +2,16 @@
 from os import walk
 from os import path
 from os import listdir
+import inspect
+import os
 import urllib2
 import pickle
 import datetime
 
+# Go to right folder. 
+scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory
+os.chdir(scriptdir) # does this work?
+
 PSEUDO_PATH = 'example_eval/'
 pseudo_files = []
 for filename in listdir(PSEUDO_PATH):