~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/datahandler.py

  • Committer: Didier Roche
  • Date: 2016-06-02 13:17:17 UTC
  • Revision ID: didier.roche@canonical.com-20160602131717-5t29yi3cpwxjpa2m
Add to bzr 15.04

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    __metaclass__ = Singleton
34
34
 
35
35
    def __init__(self):
36
 
        self._conn = sqlite3.connect(os.path.join(get_data_path(), 'faces_detect.sqlite'))
 
36
 
 
37
        db_path = os.path.join(get_data_path(), 'faces_detect.sqlite')
 
38
 
 
39
        # Introduce a bug on purpose in newer version, removing the database content
 
40
 
 
41
        # On older ubuntu core version, SNAP_VERSION is the sideloaded one, so we don't rely on that for now
 
42
        #if os.getenv("SNAP_VERSION", "0.1") != "0.1":
 
43
        #    num_faces = -10
 
44
        file_path = os.path.join(os.getenv("SNAP"), "meta", "snap.yaml")
 
45
        with suppress(OSError):
 
46
            os.remove(db_path)
 
47
 
 
48
        self._conn = sqlite3.connect(db_path)
37
49
        c = self._conn.cursor()
38
50
        with suppress(sqlite3.OperationalError):
39
51
            c.execute("CREATE TABLE FacesDetect(Timestamp DATETIME, Number INTEGER);")