本文整理汇总了Python中Logging类的典型用法代码示例。如果您正苦于以下问题:Python Logging类的具体用法?Python Logging怎么用?Python Logging使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logging类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendVmnetEvent
def sendVmnetEvent(self, eventName):
binding = ("interface", "string", self.vmnetReal)
Mgmt.open()
Mgmt.event(eventName, binding)
Mgmt.close()
Logging.log(Logging.LOG_INFO, "Event %s on interface %s sent" % (
eventName, self.vmnetReal))
示例2: paintFreeMode
def paintFreeMode(self, redfunc, greenfunc, bluefunc, alphafunc, maximumValue = -1):
"""
Paints the graph of the function specified as a list of all values of the function
"""
self.dc = wx.MemoryDC()
self.dc.SelectObject(self.buffer)
d = self.maxx / float(maximumValue)
if d < 1:d = 1
if not self.background:
Logging.info("Constructing background from minval = %d, maxval = %d" % (self.minval, self.maxval))
self.background = self.drawBackground(self.minval, self.maxval)
self.dc.BeginDrawing()
self.dc.DrawBitmap(self.background, 0, 0)
coeff = float(self.maxx) / maximumValue
redline = [(int(x * coeff), self.maxy - y) for x, y in enumerate(redfunc)]
greenline = [(int(x * coeff), self.maxy - y) for x, y in enumerate(greenfunc)]
blueline = [(int(x * coeff), self.maxy - y) for x, y in enumerate(bluefunc)]
alphaline = [(int(x * coeff), self.maxy - y) for x, y in enumerate(alphafunc)]
self.dc.SetPen(wx.Pen(wx.Colour(255, 0, 0), 1))
self.dc.DrawLines(redline, self.xoffset, self.yoffset)
self.dc.SetPen(wx.Pen(wx.Colour(0, 255, 0), 1))
self.dc.DrawLines(greenline, self.xoffset, self.yoffset)
self.dc.SetPen(wx.Pen(wx.Colour(0, 0, 255), 1))
self.dc.DrawLines(blueline, self.xoffset, self.yoffset)
self.dc.SetPen(wx.Pen(wx.Colour(255, 255, 255), 1))
self.dc.DrawLines(alphaline, self.xoffset, self.yoffset)
self.dc.SelectObject(wx.NullBitmap)
self.dc = None
示例3: onFreeMode
def onFreeMode(self, event):
"""
Toggle free mode on / off
"""
was = 0
if self.freeMode:was = 1
if not was and event.GetIsDown():
self.updateCTFFromPoints()
self.updateGraph()
self.freeMode = 1
self.setFromColorTransferFunction(self.ctf, self.otf)
if was:
self.updateCTFFromPoints()
self.freeMode = event.GetIsDown()
if not self.freeMode and was and self.hasPainted:
Logging.info("Analyzing free mode for points", kw = "ctf")
self.getPointsFromFree()
n = len(self.points)
tot = 0
for i, pts in enumerate(self.points):
tot += len(pts)
maxpts = self.maxNodes.GetValue()
if maxpts < tot:
self.onSetMaxNodes(None)
self.updateGraph()
示例4: setThresholds
def setThresholds(self, ch1lower, ch1upper, ch2lower, ch2upper):
"""
Set the thresholds this scatteplot is set to
"""
Logging.info("\nScatterplot thresholds set to (%d-%d) (%d-%d)"%(ch1lower,ch1upper,ch2lower,ch2upper))
self.lower1, self.upper1, self.lower2, self.upper2 = ch1lower, ch1upper, ch2lower, ch2upper
self.paintPreview()
示例5: setZoomFactor
def setZoomFactor(self, newFactor):
"""
Sets the factor by which the image should be zoomed
"""
self.zoomToFitFlag = False
Logging.info("Setting zoom factor to ", newFactor, kw = "preview")
x, y = [a*newFactor for a in (self.dataDimX, self.dataDimY)]
if scripting.resampleToFit:
optimize.set_target_size(x, y)
newFactor = 1
px, py = self.paintSize
x = max(px, x)
y = max(py, y)
Logging.info("New dims for buffer=",x,y,kw="preview")
self.buffer = wx.EmptyBitmap(x, y)
self.setScrollbars(x, y)
if newFactor < self.zoomFactor:
# black the preview
slice = self.slice
self.slice = None
self.paintPreview()
self.slice = slice
self.zoomFactor = newFactor
scripting.zoomFactor = newFactor
self.updateAnnotations()
示例6: __init__
def __init__(self, filename = ""):
"""
Constructor of MRCDataSource
"""
DataSource.__init__(self)
self.filename = filename
self.setPath(filename)
self.bitDepth = 0
self.spacing = None
self.voxelSize = None
# Create vtkMRCReader for reading MRC files
self.reader = vtkbxd.vtkMRCReader()
self.reader.AddObserver('ProgressEvent', lib.messenger.send)
lib.messenger.connect(self.reader, 'ProgressEvent', self.updateProgress)
if self.filename:
self.reader.SetFileName(self.convertFileName(self.filename))
if self.reader.OpenFile():
if self.reader.ReadHeader():
self.setOriginalScalarRange()
else:
Logging.error("Failed to read the header of the MRC file correctly",
"Error in MRCDataSource.py in __init.py__, failed to read the header of the MRC file: %s" %(self.filename))
return
else:
Logging.error("Failed to open file",
"Error in MRCDataSource.py in __init__, failed to open file: %s" %(self.filename))
return
示例7: __del__
def __del__(self):
self._loop.assert_thread()
Logging.info('TcpServer::__del__ [%s]' % self._name)
for it in self._connections:
it.get_loop().run_in_loop(it.connection_destroyed)
pass
示例8: calculateBuffer
def calculateBuffer(self):
"""
Calculate the drawing buffer required
"""
if not self.imagedata:
return
x, y, z = self.imagedata.GetDimensions()
x, y, z = self.dataUnit.getDimensions()
if not self.sizeChanged and (x, y, z) == self.oldBufferDims and self.oldBufferMaxXY == (self.maxClientSizeX, self.maxClientSizeY):
return
self.oldBufferDims = (x, y, z)
self.oldBufferMaxXY = (self.maxClientSizeX, self.maxClientSizeY)
x, y, z = [int(i * self.zoomFactor) for i in (x, y, z)]
Logging.info("scaled size =", x, y, z, kw = "visualizer")
x += z * self.zoomZ * self.zspacing + 2 * self.xmargin
y += z * self.zoomZ * self.zspacing+ 2 * self.ymargin
x = int(max(x, self.maxClientSizeX))
y = int(max(y, self.maxClientSizeY))
self.paintSize = (x, y)
if self.buffer.GetWidth() != x or self.buffer.GetHeight() != y:
self.buffer = wx.EmptyBitmap(x, y)
Logging.info("Paint size=", self.paintSize, kw = "preview")
self.setScrollbars(x, y)
示例9: getDataSet
def getDataSet(self, i, raw = 0):
"""
Returns the timepoint at the specified index
Parameters: i The timepoint to retrieve
raw A flag indicating that the data is not to be processed in any way
"""
# No timepoint can be returned, if this LsmDataSource instance does not
# know what channel it is supposed to handle within the lsm-file.
self.setCurrentTimepoint(i)
if self.channelNum == -1:
Logging.error("No channel number specified",
"LSM Data Source got a request for dataset from timepoint "
"%d, but no channel number has been specified" % (i))
return None
self.timepoint = i
self.reader.SetUpdateChannel(self.channelNum)
self.reader.SetUpdateTimePoint(i)
data = self.reader.GetOutput()
if raw:
return data
if self.resampling or self.mask:
data = self.getResampledData(data, i)
if self.explicitScale or (data.GetScalarType() != 3 and not raw):
data = self.getIntensityScaledData(data)
return data
示例10: remove_connection_inloop
def remove_connection_inloop(self, conn):
self._loop.assert_thread()
Logging.info('TcpServer::remove_connection [%s] - [%s]' % (self._name, conn.name()))
del self._connections[conn.name()]
loop = conn.get_loop()
loop.run_in_loop(conn.connection_destroyed)
示例11: getSpacing
def getSpacing(self):
if not self.spacing:
a, b, c = self.reader.GetVoxelSizes()
Logging.info("Voxel sizes = ", a, b, c, kw = "lsmreader")
self.spacing = [1, b / a, c / a]
return self.spacing
示例12: start
def start(self):
self.cleanWildDhcpds()
# XXX/jshilkaitis: WARNING -- lame shitty hack that will break if
# VMware fixes vmnet-dhcpd. Today, vmnet-dhcpd assumes that the
# last character of the interface passed to it is the last
# character of the interface's associated device. Thus, for
# vmlocal, vmnet-dhcpd tries to attach to /dev/vmnetl (that's a
# lowercase L). It turns out we can hack around this by
# appending a 0 to the interface name. vmlocal0 causes
# vmnet-dhcpd to attach to /dev/vmnet0, ESXi's vmk0 properly gets
# a DHCP address from dhcpd and everything is happy. This is
# total crap and is brittle since VMware fixing dhcpd will
# almost certainly break us, but it works and, IMO, is better than
# slapping a random 0 after vmlocal that the user can see.
# I apologize to future generations for my expediency.
#
# P.S. I think my hack-guilt can be measured by the length
# of the XXX comment preceding the hack.
XXXlameHackSuffixForVMLocalInterface = "0"
commandList = [self.vmnetDhcpdCmd,
"-d",
"-cf", self.dhcpdConf,
"-lf", self.dhcpdLease,
"-pf", self.dhcpdPidFileName,
"%s%s" % (self.vmnetReal,
XXXlameHackSuffixForVMLocalInterface)]
Logging.log(Logging.LOG_INFO, "Starting dhcpd on %s" % (
self.interfaceName))
self.pid = self.launchProcess(commandList)
示例13: enableRPS
def enableRPS(self):
# Enable RPS
Logging.log(Logging.LOG_INFO, "Enabling RPS")
commandList = ["/bin/cat", "/cgroup/cpuset/esx/cpuset.cpus"]
(retcode, output, errmsg) = self.launchProcessAndWait(
commandList, logLevel = Logging.LOG_INFO)
cpus = output.split("-")
no_of_cpus = int(cpus[1]) - int(cpus[0]) + 1
mask = ''
for bit in range(no_of_cpus):
mask = mask + '1'
hex_mask = hex(int(mask, 2)).replace('0x', '')
rps_file = '/sys/class/net/' + self.vmnetReal + '/queues/rx-0/rps_cpus'
cmd = "/bin/echo %s > %s" % (hex_mask, rps_file)
process = subprocess.Popen(
cmd, bufsize=-1, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, errmsg = process.communicate()
if process.returncode != 0:
Logging.log(Logging.LOG_ERR,
"Launch process '%s' with error(%s):%s" % (
' '.join(cmd),
process.returncode,
errmsg))
示例14: setDataUnit
def setDataUnit(self, dataUnit, selectedItem = -1):
"""
Set the dataunit used for preview. Should be a combined
data unit, the source units of which we can get and read
as ImageData
"""
Logging.info("Setting dataunit of PreviewFrame to %s"%str(dataUnit), kw="preview")
if not dataUnit:
self.dataUnit = None
self.z = 0
self.slice = None
self.updatePreview()
self.Refresh()
return
self.dataUnit = dataUnit
self.settings = dataUnit.getSettings()
self.updateColor()
InteractivePanel.setDataUnit(self, self.dataUnit)
try:
count = dataUnit.getNumberOfTimepoints()
x, y, z = dataUnit.getDimensions()
except Logging.GUIError, ex:
ex.show()
return
示例15: onDown
def onDown(self, event):
"""
Event handler for when the mouse is pressed down over
this item. Will store the position in order to enable
dragging.
"""
x, y = event.GetPosition()
ex, ey = event.GetPosition()
#print "onDow()",x,y
self.dragMode = 0
w, h = self.GetSize()
posx, posy = self.GetPosition()
x -= posx
Logging.info("Item number #%d selected" % self.itemnum, kw = "animator")
if self.itemnum == 0 and x < DRAG_OFFSET:
# Drag mode where first item is dragged, this affects the
# empty space at the front
self.dragMode = 2
elif x < DRAG_OFFSET:
# drag mode where an item is dragged from the front
self.dragMode = 3
self.beginX = ex
elif abs(x - w) < DRAG_OFFSET:
# drag mode where an item is dragged from behind
self.dragMode = 1
self.beginX = ex
return