def csv(self): dbHnd=sqlite.sqlite3MDIO() dbHnd.openDB(self.AnalysisDBFile) self.responseDict["dbName"]=self.AnalysisDBFile.split(path_separator())[-1].split('.')[0] self.responseDict["dbData"]=base64.b64encode(dbHnd.csvString(self.queryString)) return self.responseDict
def listActiveSessions(): sessions={} for key in gAnalysisSessions.keys(): sessions[key]={ 'dataPath': str(gAnalysisSessions.getSessionAttribute(key, 'dataPath')).split(path_separator())[-1], 'analysisRunning': gAnalysisSessions.getSessionAttribute(key, 'analysisRunning'), 'sessionCreateTime': time.strftime('%m/%d/%Y, %I:%M:%S %p', gAnalysisSessions.getSessionAttribute(key, 'sessionCreateTime')) } return jsonify( respondingURL='list-active-sessions', sessions=sessions ), 200
def csv(self): dbHnd = sqlite.sqlite3MDIO() dbHnd.openDB(self.AnalysisDBFile) self.responseDict["dbName"] = self.AnalysisDBFile.split( path_separator())[-1].split('.')[0] self.responseDict["dbData"] = base64.b64encode( dbHnd.csvString(self.queryString)) return self.responseDict
def listActiveSessions(): sessions = {} for key in gAnalysisSessions.keys(): sessions[key] = { 'dataPath': str(gAnalysisSessions.getSessionAttribute(key, 'dataPath')).split( path_separator())[-1], 'analysisRunning': gAnalysisSessions.getSessionAttribute(key, 'analysisRunning'), 'sessionCreateTime': time.strftime( '%m/%d/%Y, %I:%M:%S %p', gAnalysisSessions.getSessionAttribute(key, 'sessionCreateTime')) } return jsonify(respondingURL='list-active-sessions', sessions=sessions), 200
class metaTrajIO(object): """ .. warning:: |metaclass| Initialize a TrajIO object. The object can load all the data in a directory, N files from a directory or from an explicit list of filenames. In addition to the arguments defined below, implementations of this meta class may require the definition of additional arguments. See the documentation of those classes for what those may be. For example, the qdfTrajIO implementation of metaTrajIO also requires the feedback resistance (Rfb) and feedback capacitance (Cfb) to be passed at initialization. :Parameters: - `dirname` : all files from a directory ('<full path to data directory>') - `nfiles` : if requesting N files (in addition to dirname) from a specified directory - `fnames` : explicit list of filenames ([file1, file2,...]). This argument cannot be used in conjuction with dirname/nfiles. The filter argument is ignored when used in combination with fnames. - `filter` : '<wildcard filter>' (optional, filter is '*' if not specified) - `start` : Data start point in seconds. - `end` : Data end point in seconds. - `datafilter` : Handle to the algorithm to use to filter the data. If no algorithm is specified, datafilter is None and no filtering is performed. - `dcOffset` : Subtract a DC offset from the ionic current data. :Properties: - `FsHz` : sampling frequency in Hz. If the data was decimated, this property will hold the sampling frequency after decimation. - `LastFileProcessed` : return the data file that was last processed. - `ElapsedTimeSeconds` : return the analysis time in sec. :Errors: - `IncompatibleArgumentsError` : when conflicting arguments are used. - `EmptyDataPipeError` : when out of data. - `FileNotFoundError` : when data files do not exist in the specified path. - `InsufficientArgumentsError` : when incompatible arguments are passed """ __metaclass__ = ABCMeta def __init__(self, **kwargs): """ """ self.CHUNKSIZE = 10000 self.dataGenerator = None # start by setting all passed keyword arguments as class attributes for (k, v) in kwargs.iteritems(): setattr(self, k, v) # Check if the passed arguments are sane if hasattr(self, 'dirname') and hasattr(self, 'fnames'): raise IncompatibleArgumentsError( "Incompatible arguments: expect either 'dirname' or 'fnames' when initializing class {0}." .format(type(self).__name__)) # Check for the filter arg if not hasattr(self, 'filter'): self.filter = '*' if hasattr(self, 'fnames'): # set fnames here. self.dataFiles = self.fnames delattr(self, 'fnames') else: try: if hasattr(self, 'dirname') and hasattr(self, 'nfiles'): # N files from a directory self.dataFiles = self._buildFileList( self.dirname, self.filter)[:int(self.nfiles)] delattr(self, 'dirname') delattr(self, 'nfiles') elif hasattr(self, 'dirname'): # all files from a directory self.dataFiles = self._buildFileList( self.dirname, self.filter) delattr(self, 'dirname') else: raise IncompatibleArgumentsError( "Missing arguments: 'dirname' or 'fnames' must be supplied to initialize {0}" .format(type(self).__name__)) except AttributeError, err: raise IncompatibleArgumentsError(err) # set additional meta-data self.nFiles = len(self.dataFiles) self.fileFormat = 'N/A' try: sep = path_separator() self.datPath = format_path( sep.join((self.dataFiles[0].split(sep))[:-1])) except IndexError, err: raise FileNotFoundError("Files not found.")