changeset 882:4749b71aa7fb

corrected bugs in storage.py when having configuration files and other files in different directories: everything should be relative to directory of command line when running the program (see FAQ)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 15 Mar 2017 12:36:03 -0400
parents 8ba82b371eea
children 5852a3cdd455
files python/events.py python/storage.py
diffstat 2 files changed, 5 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/python/events.py	Tue Mar 14 17:48:40 2017 -0400
+++ b/python/events.py	Wed Mar 15 12:36:03 2017 -0400
@@ -240,7 +240,7 @@
         # TODO add crossing zone
         pet =  moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold)
         if pet is not None: # TODO get crossing zone and time
-            self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[10], {0: pet}, mostSevereIsMax = False
+            self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[10], {0: pet}, mostSevereIsMax = False))
 
     def setCollision(self, collision):
         '''indicates if it is a collision: argument should be boolean'''
--- a/python/storage.py	Tue Mar 14 17:48:40 2017 -0400
+++ b/python/storage.py	Wed Mar 15 12:36:03 2017 -0400
@@ -1291,24 +1291,19 @@
 
         config = ConfigParser()
         config.readfp(FakeSecHead(openCheck(filename)))
-        # check if path contains directory names
-        if len(path.split(filename)[0]) == 0:
-            dirname = '.'+path.sep
-        else:
-            dirname = path.split(filename)[0]+path.sep
 
         self.sectionHeader = config.sections()[0]
         # Tracking/display parameters
         self.videoFilename = config.get(self.sectionHeader, 'video-filename')
         self.databaseFilename = config.get(self.sectionHeader, 'database-filename')
         self.homographyFilename = config.get(self.sectionHeader, 'homography-filename')
-        if path.exists(dirname+self.homographyFilename):
-            self.homography = loadtxt(dirname+self.homographyFilename)
+        if path.exists(self.homographyFilename):
+            self.homography = loadtxt(self.homographyFilename)
         else:
             self.homography = None
         self.intrinsicCameraFilename = config.get(self.sectionHeader, 'intrinsic-camera-filename')
-        if path.exists(dirname+self.intrinsicCameraFilename):
-            self.intrinsicCameraMatrix = loadtxt(dirname+self.intrinsicCameraFilename)
+        if path.exists(self.intrinsicCameraFilename):
+            self.intrinsicCameraMatrix = loadtxt(self.intrinsicCameraFilename)
         else:
             self.intrinsicCameraMatrix = None
         distortionCoefficients = getValuesFromINIFile(filename, 'distortion-coefficients', '=')