本文整理汇总了Python中seiscomp3.Logging.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.debug方法的具体用法?Python Logging.debug怎么用?Python Logging.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seiscomp3.Logging
的用法示例。
在下文中一共展示了Logging.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resumeProducing
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def resumeProducing(self):
rec = None
try: rec = self.rsInput.next()
except Exception, e: Logging.warning("%s" % str(e))
if self.written == 0:
# read first record to test if any data exists at all
if not rec:
msg = "no waveform data found"
data = HTTP.renderErrorPage(self.req, http.NO_CONTENT, msg, self.ro)
if data:
self.req.write(data)
self.req.unregisterProducer()
self.req.finish()
return
self.req.setHeader('Content-Type', 'application/vnd.fdsn.mseed')
self.req.setHeader('Content-Disposition', "attachment; " \
"filename=%s" % self.fileName)
if not rec:
self.req.unregisterProducer()
Logging.debug("%s: returned %i bytes of mseed data" % (
self.ro.service, self.written))
utils.accessLog(self.req, self.ro, http.OK, self.written, None)
self.req.finish()
return
data = rec.raw().str()
self.req.write(data)
self.written += len(data)
示例2: _processRequest
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def _processRequest(self, req, ro, dbq, exp):
if req._disconnected:
return False
DataModel.PublicObject.SetRegistrationEnabled(False)
# query event(s)
ep = DataModel.EventParameters()
if ro.eventIDs:
for eID in ro.eventIDs:
event = dbq.getEventByPublicID(eID)
event = DataModel.Event.Cast(event)
if event:
ep.add(event)
else:
self._findEvents(ep, ro, dbq)
if ep.eventCount() == 0:
msg = "no matching events found"
utils.writeTS(req,
HTTP.renderErrorPage(req, http.NO_CONTENT, msg, ro))
return False
Logging.debug("events found: %i" % ep.eventCount())
if ro.format == 'csv' or not exp:
req.setHeader('Content-Type', 'text/plain')
else:
req.setHeader('Content-Type', 'application/xml')
if exp:
return self._processRequestExp(req, ro, dbq, exp, ep)
return self._processRequestText(req, ro, dbq, ep)
示例3: _loadInventory
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def _loadInventory(self):
Logging.debug("loading inventory")
dbr = DataModel.DatabaseReader(self.database())
self._inv = DataModel.Inventory()
# Load networks and stations
staCount = 0
for i in xrange(dbr.loadNetworks(self._inv)):
staCount += dbr.load(self._inv.network(i))
Logging.debug("loaded %i stations from %i networks" % (staCount, self._inv.networkCount()))
# Load sensors, skip calibrations (not needed by StationXML exporter)
Logging.debug("loaded %i sensors" % dbr.loadSensors(self._inv))
# Load datalogger and its decimations, skip calibrations (not needed by
# StationXML exporter)
deciCount = 0
for i in xrange(dbr.loadDataloggers(self._inv)):
deciCount += dbr.loadDecimations(self._inv.datalogger(i))
Logging.debug("loaded %i decimations from %i dataloggers" % (deciCount, self._inv.dataloggerCount()))
# Load responses
resPAZCount = dbr.loadResponsePAZs(self._inv)
resFIRCount = dbr.loadResponseFIRs(self._inv)
resPolCount = dbr.loadResponsePolynomials(self._inv)
resCount = resPAZCount + resFIRCount + resPolCount
Logging.debug(
"loaded %i responses (PAZ: %i, FIR: %i, Poly: %i)" % (resCount, resPAZCount, resFIRCount, resPolCount)
)
Logging.info("inventory loaded")
示例4: onRequestServed
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def onRequestServed(success, req):
if req._disconnected:
Logging.debug("Request aborted")
return
Logging.debug("Request %s" % (
"successfully served" if success else "failed"))
reactor.callFromThread(req.finish)
示例5: getResourceFor
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def getResourceFor(self, request):
Logging.debug("request (%s): %s" % (request.getClientIP(),
request.uri))
request.setHeader('Server', "SeisComP3-FDSNWS/%s" % VERSION)
request.setHeader('Access-Control-Allow-Origin', '*')
request.setHeader('Access-Control-Allow-Headers', 'Authorization')
request.setHeader('Access-Control-Expose-Headers', 'WWW-Authenticate')
return server.Site.getResourceFor(self, request)
示例6: _processRequest
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def _processRequest(self, req, ro, dbq, exp):
if req._disconnected:
return False
DataModel.PublicObject.SetRegistrationEnabled(False)
# query event(s)
ep = DataModel.EventParameters()
if ro.eventIDs:
for eID in ro.eventIDs:
obj = dbq.getEventByPublicID(eID)
e = DataModel.Event.Cast(obj)
if not e:
continue
if self._eventTypeWhitelist or self._eventTypeBlacklist:
eType = None
try: eType = DataModel.EEventTypeNames_name(e.type())
except ValueException: pass
if self._eventTypeWhitelist and \
not eType in self._eventTypeWhitelist: continue
if self._eventTypeBlacklist and \
eType in self._eventTypeBlacklist: continue
if self._evaluationMode is not None:
obj = dbq.getObject(DataModel.Origin.TypeInfo(),
e.preferredOriginID())
o = DataModel.Origin.Cast(obj)
try:
if o is None or \
o.evaluationMode() != self._evaluationMode:
continue
except ValueException:
continue
ep.add(e)
else:
self._findEvents(ep, ro, dbq)
if ep.eventCount() == 0:
msg = "no matching events found"
data = HTTP.renderErrorPage(req, http.NO_CONTENT, msg, ro)
if data:
utils.writeTS(req, data)
return True
Logging.debug("events found: %i" % ep.eventCount())
if ro.format == 'csv' or not exp:
req.setHeader('Content-Type', 'text/plain')
else:
req.setHeader('Content-Type', 'application/xml')
if exp:
return self._processRequestExp(req, ro, dbq, exp, ep)
return self._processRequestText(req, ro, dbq, ep)
示例7: run
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def run(self):
rules = self.rules
iv = Client.Inventory.Instance().inventory()
if not rules:
return False
if not iv:
return False
Logging.debug("Loaded %d networks" % iv.networkCount())
if self.outputFile is None:
DataModel.Notifier.Enable()
self.setInterpretNotifierEnabled(True)
for net in self._loop(iv.network, iv.networkCount()):
(ncode, nstart, nend) = self._collect(net)
key = rules.findKey(ncode, nstart, nend)
if not key:
continue
att = rules.getNetworkAttributes(key)
self._modifyInventory("network", net, att)
Logging.info("%s %s" % (ncode, att))
for sta in self._loop(net.station, net.stationCount()):
(scode, sstart, send) = self._collect(sta)
att = rules.getStationAttributes(key, ncode, scode, None, None, sstart, send)
self._modifyInventory("station", sta, att)
if att:
Logging.info(" %s %s" % (scode, att))
for loc in self._loop(sta.sensorLocation, sta.sensorLocationCount()):
(lcode, lstart, lend) = self._collect(loc)
att = rules.getStationAttributes(key, ncode, scode, lcode, None, lstart, lend)
self._modifyInventory("location", loc, att)
if att:
Logging.info(" %s %s" % (lcode, att))
for cha in self._loop(loc.stream, loc.streamCount()):
(ccode, cstart, cend) = self._collect(cha)
att = rules.getStationAttributes(key, ncode, scode, lcode, ccode, cstart, cend)
self._modifyInventory("channel", cha, att)
if att:
Logging.info(" %s %s" % (ccode, att))
for sensor in self._loop(iv.sensor, iv.sensorCount()):
att = rules.getInstrumentsAttributes(sensor.name(), "Se")
self._modifyInventory("sensor", sensor, att)
for datalogger in self._loop(iv.datalogger, iv.dataloggerCount()):
att = rules.getInstrumentsAttributes(datalogger.name(), "Dl")
self._modifyInventory("datalogger", datalogger, att)
return True
示例8: send_notifiers
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def send_notifiers(self, group):
Nsize = DataModel.Notifier.Size()
if Nsize > 0:
Logging.info("trying to apply %d change%s" % (Nsize, "s" if Nsize != 1 else ""))
else:
Logging.info("no changes to apply")
return 0
Nmsg = DataModel.Notifier.GetMessage(True)
it = Nmsg.iter()
msg = DataModel.NotifierMessage()
maxmsg = 100
sent = 0
mcount = 0
try:
try:
while it.get():
msg.attach(DataModel.Notifier_Cast(it.get()))
mcount += 1
if msg and mcount == maxmsg:
sent += mcount
Logging.debug("sending message (%5.1f %%)" % (sent / float(Nsize) * 100.0))
self.send(group, msg)
msg.clear()
mcount = 0
self.sync()
it.next()
except:
pass
finally:
if msg.size():
Logging.debug("sending message (%5.1f %%)" % 100.0)
self.send(group, msg)
msg.clear()
self.sync()
Logging.info("done")
return mcount
示例9: _finish
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def _finish(self):
if self.written == 0:
msg = "no waveform data found"
HTTP.renderErrorPage(self.req, http.NO_CONTENT, msg, self.ro)
if self.tracker:
self.tracker.volume_status("fdsnws", "NODATA", 0, "")
self.tracker.request_status("END", "")
else:
Logging.debug("%s: returned %i bytes of mseed data" % (
self.ro.service, self.written))
utils.accessLog(self.req, self.ro, http.OK, self.written, None)
if self.tracker:
self.tracker.volume_status("fdsnws", "OK", self.written, "")
self.tracker.request_status("END", "")
self.req.unregisterProducer()
self.req.finish()
示例10: run
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def run(self):
if self._xmlFile:
Logging.debug("running in batch mode")
Logging.debug("input file is %s" % self._xmlFile)
return self._runBatchMode()
self._xmlFile = tempfile.mktemp(".xml", dir=self._tmpDir)
Logging.debug("running in stream mode")
Logging.debug("temp file is %s" % self._xmlFile)
status = self._runStreamMode()
if os.path.exists(self._xmlFile):
os.unlink(self._xmlFile)
return status
示例11: onFinish
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def onFinish(result, req):
Logging.debug("finish value = %s" % str(result))
if isinstance(result, Failure):
err = result.value
if isinstance(err, defer.CancelledError):
Logging.error("request canceled")
return
Logging.error("%s %s" % (result.getErrorMessage(),
traceback.format_tb(result.getTracebackObject())))
else:
if result:
Logging.debug("request successfully served")
else:
Logging.debug("request failed")
reactor.callFromThread(req.finish)
示例12: init
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def init(self):
if not Client.Application.init(self):
return False
try:
start = self.commandline().optionString("begin")
except:
start = "1900-01-01T00:00:00Z"
self._startTime = _parseTime(start)
if self._startTime is None:
Logging.error("Wrong 'begin' format '%s'" % start)
return False
Logging.debug("Setting start to %s" % self._startTime.toString("%FT%TZ"))
try:
end = self.commandline().optionString("end")
except:
end = "2500-01-01T00:00:00Z"
self._endTime = _parseTime(end)
if self._endTime is None:
Logging.error("Wrong 'end' format '%s'" % end)
return False
Logging.debug("Setting end to %s" % self._endTime.toString("%FT%TZ"))
try:
self._delimiter = self.commandline().optionString("delimiter")
except:
self._delimiter = "\n"
try:
modifiedAfter = self.commandline().optionString("modified-after")
self._modifiedAfterTime = _parseTime(modifiedAfter)
if self._modifiedAfterTime is None:
Logging.error("Wrong 'modified-after' format '%s'" % modifiedAfter)
return False
Logging.debug("Setting 'modified-after' time to %s" % self._modifiedAfterTime.toString("%FT%TZ"))
except: pass
return True
示例13: _processRequestExp
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
#.........这里部分代码省略.........
# iterate over inventory networks
for net in ro.networkIter(self._inv, levelNet):
if req._disconnected: return False
if skipRestricted and utils.isRestricted(net): continue
newNet = DataModel.Network(net)
# Copy comments
for i in xrange(net.commentCount()):
newNet.add(DataModel.Comment(net.comment(i)))
# iterate over inventory stations of current network
for sta in ro.stationIter(net, levelSta):
if req._disconnected:
return False
if skipRestricted and utils.isRestricted(sta):
continue
if not HTTP.checkObjects(req, objCount, self._maxObj):
return False
if ro.includeCha:
numCha, numLoc, d, s, e = \
self._processStation(newNet, net, sta, ro, dac,
skipRestricted)
if numCha > 0:
locCount += numLoc
chaCount += numCha
extCount += len(e)
objCount += numLoc + numCha + extCount
if not HTTP.checkObjects(req, objCount, self._maxObj):
return False
dataloggers |= d
sensors |= s
extents |= e
elif self._matchStation(net, sta, ro, dac):
if ro.includeSta:
newSta = DataModel.Station(sta)
# Copy comments
for i in xrange(sta.commentCount()):
newSta.add(DataModel.Comment(sta.comment(i)))
newNet.add(newSta)
else:
# no station output requested: one matching station
# is sufficient to include the network
newInv.add(newNet)
objCount += 1
break
if newNet.stationCount() > 0:
newInv.add(newNet)
staCount += newNet.stationCount()
objCount += staCount + 1
# Return 204 if no matching inventory was found
if newInv.networkCount() == 0:
msg = "no matching inventory found"
data = HTTP.renderErrorPage(req, http.NO_CONTENT, msg, ro)
if data:
utils.writeTS(req, data)
return True
# Copy references (dataloggers, responses, sensors)
decCount, resCount = 0, 0
if ro.includeCha:
decCount = self._copyReferences(newInv, req, objCount, self._inv,
ro, dataloggers, sensors, self._maxObj)
if decCount is None:
return False
else:
resCount = newInv.responsePAZCount() + \
newInv.responseFIRCount() + \
newInv.responsePolynomialCount() + \
newInv.responseFAPCount() + \
newInv.responseIIRCount()
objCount += resCount + decCount + newInv.dataloggerCount() + \
newInv.sensorCount()
# Copy data extents
objOut = newInv
if len(extents) > 0:
objCount += 1
da = DataModel.DataAvailability()
for e in extents:
da.add(DataModel.DataExtent(e))
objOut = ExportObjectList()
objOut.append(newInv)
objOut.append(da)
sink = utils.Sink(req)
if not exp.write(sink, objOut):
return False
Logging.debug("%s: returned %iNet, %iSta, %iLoc, %iCha, " \
"%iDL, %iDec, %iSen, %iRes, %iDAExt (total objects/" \
"bytes: %i/%i) " % (ro.service, newInv.networkCount(),
staCount, locCount, chaCount, newInv.dataloggerCount(),
decCount, newInv.sensorCount(), resCount, extCount,
objCount, sink.written))
utils.accessLog(req, ro, http.OK, sink.written, None)
return True
示例14: len
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
# sort lines and append to final data string
lines.sort(key = lambda line: line[0])
for line in lines:
data += line[1]
# Return 204 if no matching inventory was found
if len(lines) == 0:
msg = "no matching inventory found"
data = HTTP.renderErrorPage(req, http.NO_CONTENT, msg, ro)
if data:
utils.writeTS(req, data)
return False
utils.writeTS(req, data)
Logging.debug("%s: returned %i lines (total bytes: %i)" % (
ro.service, len(lines), len(data)))
utils.accessLog(req, ro, http.OK, len(data), None)
return True
#---------------------------------------------------------------------------
# Checks if at least one location and channel combination matches the
# request options
@staticmethod
def _matchStation(net, sta, ro, dac):
# No filter: return true immediately
if dac is None and \
( not ro.channel or ( not ro.channel.loc and not ro.channel.cha ) ):
return True
for loc in ro.locationIter(net, sta, False):
示例15: _processRequest
# 需要导入模块: from seiscomp3 import Logging [as 别名]
# 或者: from seiscomp3.Logging import debug [as 别名]
def _processRequest(self, req, ro):
if ro.quality != 'B' and ro.quality != 'M':
msg = "quality other than 'B' or 'M' not supported"
return HTTP.renderErrorPage(req, http.SERVICE_UNAVAILABLE, msg, ro)
if ro.minimumLength:
msg = "enforcing of minimum record length not supported"
return HTTP.renderErrorPage(req, http.SERVICE_UNAVAILABLE, msg, ro)
if ro.longestOnly:
msg = "limitation to longest segment not supported"
return HTTP.renderErrorPage(req, http.SERVICE_UNAVAILABLE, msg, ro)
app = Application.Instance()
ro._checkTimes(app._realtimeGap)
# Open record stream
rs = RecordStream.Open(self._rsURL)
if rs is None:
msg = "could not open record stream"
return HTTP.renderErrorPage(req, http.SERVICE_UNAVAILABLE, msg, ro)
maxSamples = None
if app._samplesM is not None:
maxSamples = app._samplesM * 1000000
samples = 0
# Add request streams
# iterate over inventory networks
for s in ro.streams:
for net in self._networkIter(s):
if ro.userName is None and utils.isRestricted(net):
continue
for sta in self._stationIter(net, s):
if ro.userName is None and utils.isRestricted(sta):
continue
for loc in self._locationIter(sta, s):
for cha in self._streamIter(loc, s):
# enforce maximum sample per request restriction
if maxSamples is not None:
try:
n = cha.sampleRateNumerator()
d = cha.sampleRateDenominator()
except ValueException:
msg = "skipping stream without sampling " \
"rate definition: %s.%s.%s.%s" % (
net.code(), sta.code(), loc.code(),
cha.code())
Logging.warning(msg)
continue
# calculate number of samples for requested
# time window
diffSec = (s.time.end - s.time.start).length()
samples += int(diffSec * n / d)
if samples > maxSamples:
msg = "maximum number of %sM samples " \
"exceeded" % str(app._samplesM)
return HTTP.renderErrorPage(req,
http.REQUEST_ENTITY_TOO_LARGE, msg,
ro)
Logging.debug("adding stream: %s.%s.%s.%s %s - %s" \
% (net.code(), sta.code(), loc.code(),
cha.code(), s.time.start.iso(),
s.time.end.iso()))
rs.addStream(net.code(), sta.code(), loc.code(),
cha.code(), s.time.start, s.time.end)
# Build output filename
fileName = Application.Instance()._fileNamePrefix+'.mseed'
# Create producer for async IO
req.registerProducer(_WaveformProducer(req, ro, rs, fileName), False)
# The request is handled by the deferred object
return server.NOT_DONE_YET