def _runImpl(self):
        model   = Tracks_Track.MASTER
        session = self._session if self._session else model.createSession()
        analysisModel = Analysis_Track.MASTER
        aSession = self._analysisSession if self._analysisSession else analysisModel.createSession()

        try:
            importer = TrackCsvImporter(self._path, logger=self._log)
            self._log.write(u'<h1>Beginning Import...</h1>')
            importer.read(session=session, analysisSession=aSession, compressed=self._compressed)
        except Exception as err:
            if not self._session:
                session.rollback()
                session.close()

            self._log.writeError(u'ERROR: Track Importing Error', err)
            return 1

        if self._session is None:
            session.commit()
            session.close()

        if self._analysisSession is None:
            aSession.commit()
            aSession.close()

        return 0
Beispiel #2
0
# trackCsvImport
# (C)2015
# Scott Ernst

from __future__ import print_function, absolute_import, unicode_literals, division

from pyglass.app.PyGlassEnvironment import PyGlassEnvironment
PyGlassEnvironment.initializeFromInternalPath(__file__)

from cadence.data.TrackCsvImporter import TrackCsvImporter
from cadence.models.analysis.Analysis_Track import Analysis_Track
from cadence.models.tracks.Tracks_Track import Tracks_Track

PATH = '/Users/scott/Dropbox/a16/spreadsheets/BEB_S_500/BEB_500.csv'

session = Tracks_Track.createSession()
aSession = Analysis_Track.createSession()

importer = TrackCsvImporter(path=PATH)
importer.read(session, aSession)

for t in importer.created:
    print('[CREATED]: %s (%s)' % (t.fingerprint, t.uid))

print('%s Tracks Created' % len(importer.created))
print('%s Tracks Modified' % len(importer.modified))

session.commit()
aSession.commit()