def getGridSlices(db, databaseIds, parmIds, startTime, endTime, coordConversionString): logEvent("Getting Grids from ifpServer") request = GetASCIIGridsRequest() request.setDatabaseIds(databaseIds) request.setParmIds(parmIds) tr = TimeRange() tr.setStart(startTime) tr.setEnd(endTime) request.setTimeRange(tr) request.setCoordConversionString(coordConversionString) request.setWorkstationID(__WsId()) request.setSiteID(databaseIds[0].getSiteId()) try: serverResponse = db.sendRequest(request) except: logException("Unhandled exception thrown:") return ("", False) if (not serverResponse.isOkay()): logProblem("Problem getting grids from db: " + str(serverResponse.message())) return ("", False) return (serverResponse.getPayload(), True)
def deserialize(context): startTime = context.readI64() endTime = context.readI64() timeRange = TimeRange() # java uses milliseconds, python uses microseconds startSeconds = startTime // MILLIS_IN_SECOND endSeconds = endTime // MILLIS_IN_SECOND startExtraMicros = (startTime % MILLIS_IN_SECOND) * MICROS_IN_MILLISECOND endExtraMicros = (endTime % MILLIS_IN_SECOND) * MICROS_IN_MILLISECOND timeRange.setStart(startSeconds, startExtraMicros) timeRange.setEnd(endSeconds, endExtraMicros) return timeRange
def getStationData(self): """ Sends ThriftClient request and writes out received files.""" dtime = datetime.strptime(self.refTime, "%y%m%d/%H%M") range = TimeRange() range.setStart(dtime) range.setEnd(dtime) dataTime = DataTime(refTime=dtime, validPeriod=range) req = StationDataRequest() req.setPluginName(self.pluginName) req.setStationId(self.stationId) req.setRefTime(dataTime) req.setParmList(self.parmList) req.setPartNumber(self.partNumber) resp = self.client.sendRequest(req) return resp
def breakAllLocksGRIDRequest(officialDBs, lockTables, databaseIDs, allLocks): # break all locks (except those from official database) req = [] for lt in lockTables: if officialDB(lt.getParmId().getDbId(), officialDBs): continue if not allLocks and `lt.getParmId().getDbId()` not in databaseIDs: continue if lt.getParmId().getDbId().getFormat() == "GRID": locks = lt.getLocks() for lock in locks: tr = TimeRange() tr.setStart(lock.getStartTime()/1000.0) tr.setEnd(lock.getEndTime()/1000.0) logInfo('Lock: %s %s' % (lt.getParmId(), tr)) lr = LockRequest() lr.setParmId(lt.getParmId()) lr.setTimeRange(tr) lr.setMode("BREAK_LOCK") if len(req) == 0: siteID = lt.getParmId().getDbId().getSiteId() req.append(lr)
def getStationData(self): """ Sends ThriftClient request and writes out received files.""" dtime = datetime.strptime(self.refTime, "%y%m%d/%H%M") trange = TimeRange() trange.setStart(dtime) trange.setEnd(dtime) dataTime = DataTime(refTime=dtime, validPeriod=trange) req = StationDataRequest() req.setPluginName(self.pluginName) req.setStationId(self.stationId) req.setRefTime(dataTime) req.setParmList(self.parmList) req.setPartNumber(self.partNumber) resp = self.client.sendRequest(req) for i, rec in enumerate(resp): resp[i] = { key.decode() if isinstance(key, bytes) else key: val.decode() if isinstance(val, bytes) else val for key, val in rec.items() } return resp
def getStationData(self): """ Sends ThriftClient request and writes out received files.""" dtime = datetime.strptime(self.refTime, "%y%m%d/%H%M") trange = TimeRange() trange.setStart(dtime) trange.setEnd(dtime) dataTime = DataTime(refTime=dtime, validPeriod=trange) req = StationDataRequest() req.setPluginName(self.pluginName) req.setStationId(self.stationId) req.setRefTime(dataTime) req.setParmList(self.parmList) req.setPartNumber(self.partNumber) resp = self.client.sendRequest(req) for i, rec in enumerate(resp): resp[i] = { key.decode() if isinstance(key, bytes) else key: val.decode() if isinstance(val, bytes) else val for key, val in rec.items() } return resp
def getGridSlices(db, databaseIds, parmIds, startTime, endTime, coordConversionString): logEvent("Getting Grids from ifpServer") request = GetASCIIGridsRequest() request.setDatabaseIds(databaseIds) request.setParmIds(parmIds) tr = TimeRange() tr.setStart(startTime) tr.setEnd(endTime) request.setTimeRange(tr) request.setCoordConversionString(coordConversionString) request.setWorkstationID(__WsId()) request.setSiteID(databaseIds[0].getSiteId()) try: serverResponse = db.sendRequest(request) except: logException("Unhandled exception thrown:") return ("", False) if (not serverResponse.isOkay()): logProblem("Problem getting grids from db: " + str(serverResponse.message())) return ("", False) return (serverResponse.getPayload(), True)