Mercurial Hosting > traffic-intelligence
changeset 1074:b123fa0e5440
merged
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 20 Jul 2018 16:24:30 -0400 |
parents | 8ab92ee3cbef (diff) c67f8c36ebc7 (current diff) |
children | 8cc3feb1c1c5 |
files | scripts/process.py |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
diff -r c67f8c36ebc7 -r b123fa0e5440 scripts/process.py --- a/scripts/process.py Thu Jul 19 01:44:11 2018 -0400 +++ b/scripts/process.py Fri Jul 20 16:24:30 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 = []
diff -r c67f8c36ebc7 -r b123fa0e5440 trafficintelligence/metadata.py --- a/trafficintelligence/metadata.py Thu Jul 19 01:44:11 2018 -0400 +++ b/trafficintelligence/metadata.py Fri Jul 20 16:24:30 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'