def __init__(self, **kwargs): """Creates a new instance of ConfigReader.""" self._configs = ArgsUtils.get('configs', dict(), kwargs) self._filenames = ArgsUtils.get('filenames', None, kwargs) self._configPath = ArgsUtils.get( 'rootConfigPath', CadenceEnvironment.getConfigPath(), kwargs ) if self._filenames: for n,v in self._filenames.iteritems(): if not v: continue path = os.path.join(self._configPath, v) if not path.endswith('.cfg'): path += '.cfg' parser = ConfigParser.ConfigParser() if os.path.exists(path): parser.read(path) else: raise Exception, path + ' config file does not exist!' self._configs[n] = self._configParserToDict(parser) self._overrides = dict() self.setOverrides(ArgsUtils.get('overrides', None, kwargs))
def getAnalysisPath(*args, **kwargs): config = getAnalysisSettings() rootPath = config.get('OUTPUT_PATH') if not rootPath or not os.path.exists(rootPath): rootPath = CadenceEnvironment.getLocalAppResourcePath( '..', '..', 'analysis', isDir=True) return FileUtils.createPath(rootPath, *args, **kwargs)
def __init__(self, **kwargs): """ :param kwargs: """ super(TracksTrackDefault, self).__init__(**kwargs) self.uid = CadenceEnvironment.createUniqueId('track')
def createEngine(analysis =False): """ Creates the SqlAlchemy engine to connect to the database and returns that engine. :return: Engine """ name = 'analysis.vdb' if analysis else 'tracks.vdb' path = CadenceEnvironment.getLocalAppResourcePath( 'data', name, isFile=True) url = 'sqlite:///%s' % path return sqla.create_engine(url)
def _preAnalyze(self): self._frame = None path = CadenceEnvironment.getPath( '..', 'statistics', 'output', 'Clustered-Tracks.csv', isFile=True) if not os.path.exists(path): return self._frame = pd.read_csv(path)
import os import sys import random from cadence.CadenceEnvironment import CadenceEnvironment from cadence.config.ConfigReader import ConfigReader from cadence.generator.gait.GaitGenerator import GaitGenerator from cadence.shared.io.CadenceData import CadenceData #--------------------------------------------------------------------------------------------------- # GET CONFIG FILE configPath = CadenceEnvironment.getConfigPath('gait') cfgs = [] for f in os.listdir(configPath): path = os.path.join(configPath, f) if not os.path.isfile(path) or not f.endswith(ConfigReader.EXTENSION): continue cfgs.append(os.path.join('gait', f)) configFile = str(cfgs[random.randint(0,len(cfgs) - 1)]) print 'INITIALIZING Config file: ' + configFile #--------------------------------------------------------------------------------------------------- # GET CONFIG FILE g = GaitGenerator(gaitConfig=configFile) if g.run(): print 'SUCCESS: GaitGenerator.run()' g.echo() else: print 'FAILED: GaitGenerator.run()' sys.exit(1)