changeset 1073:8ab92ee3cbef

minor
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 20 Jul 2018 16:23:56 -0400
parents 58994b08be42
children b123fa0e5440
files scripts/process.py trafficintelligence/metadata.py
diffstat 2 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/process.py	Wed Jul 18 02:12:47 2018 -0400
+++ b/scripts/process.py	Fri Jul 20 16:23:56 2018 -0400
@@ -110,7 +110,7 @@
 #################################
 # Report progress in the processing
 #################################
-if args.progress:
+if args.progress: # TODO find video sequences that have null camera view, to work with them
     print('Providing information on data progress')
     headers = ['site', 'vs', 'features', 'objects', 'interactions'] # todo add prototypes and object classification
     data = []
--- a/trafficintelligence/metadata.py	Wed Jul 18 02:12:47 2018 -0400
+++ b/trafficintelligence/metadata.py	Fri Jul 20 16:23:56 2018 -0400
@@ -1,4 +1,5 @@
 from datetime import datetime, timedelta
+from pathlib import Path
 from os import path, listdir, sep
 from math import floor
 
@@ -339,16 +340,24 @@
 
 def createDatabase(filename):
     'creates a session to query the filename'
-    engine = create_engine('sqlite:///'+filename)
-    Base.metadata.create_all(engine)
-    Session = sessionmaker(bind=engine)
-    return Session()
+    if Path(filename).is_file():
+        engine = create_engine('sqlite:///'+filename)
+        Base.metadata.create_all(engine)
+        Session = sessionmaker(bind=engine)
+        return Session()
+    else:
+        print('The file '+filename+' does not exist')
+        return None
 
 def connectDatabase(filename):
     'creates a session to query the filename'
-    engine = create_engine('sqlite:///'+filename)
-    Session = sessionmaker(bind=engine)
-    return Session()
+    if Path(filename).is_file():
+        engine = create_engine('sqlite:///'+filename)
+        Session = sessionmaker(bind=engine)
+        return Session()
+    else:
+        print('The file '+filename+' does not exist')
+        return None
 
 def getSite(session, siteId = None, name = None, description = None):
     'Returns the site(s) matching the index or the name'