本文整理汇总了Python中status.Status.getNet方法的典型用法代码示例。如果您正苦于以下问题:Python Status.getNet方法的具体用法?Python Status.getNet怎么用?Python Status.getNet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类status.Status
的用法示例。
在下文中一共展示了Status.getNet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_net
# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import getNet [as 别名]
def read_net(self, event=None):
if self.reading_net: return gtk.TRUE
self.reading_net = True
inKB, outKB = Status.getNet()
if inKB > 9999: inKB = 999
if outKB > 999: outKB = 999
pingTimeGoogle = Status.getPingTime("google.com")
if self.gw == None:
self.gw = get_gw()
print "gateway:", self.gw
if self.gw != None:
pingTimeGW = Status.getPingTime(self.gw, 2)
self.statusStr = "%04d" % inKB +":"+"%03d" % outKB +"K/s " + " " + \
pingTimeGoogle + "|" + pingTimeGW + "ms"
if pingTimeGW == "-1":
try:
self.gw = get_gw()
print "gateway:", self.gw
except:
pass
self.statusStr = self.statusStr
else:
self.statusStr = strike("NET ")
print "%.2f " % (time.time() - self.t), self.statusStr
self.ind.set_label(self.statusStr)
if self.gw != None:
fullStatusStr = "UP: %03d" % inKB +"K/s\n"+"DOWN: %03d" % outKB +"K/s\n" + \
"Google ping: " + pingTimeGoogle + "ms\n" + \
"GW (" + self.gw + ") ping: " + pingTimeGW
else:
fullStatusStr = "No network"
self.netMenuItem.set_label(fullStatusStr)
self.counter += 1
icon_name = "network"
net_level = 5.0
if outKB >= net_level:
icon_name += "-transmit"
if inKB >= net_level:
icon_name += "-receive"
if outKB < net_level and inKB < net_level:
icon_name += "-idle"
self.ind.set_icon(icon_name)
self.t = time.time()
self.reading_net = False
return gtk.TRUE
示例2: run
# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import getNet [as 别名]
def run(self):
i = 0
statusStr = " Init... "
while(self.parent.alive.isSet()):
if self.mustExit: return
# update stats every 2s
if not (i % 2):
# statusStr = Status.getCpuPerc() + " | " +
# statusStr = Status.getTemp() + " | " +
statusStr = Status.getNet() + " | " + \
Status.getPingTime()
self.parent.updateText(statusStr)
temp = Status.getTemp()
if temp < 50: iconNum = 1
elif temp < 70: iconNum = 2
elif temp < 80: iconNum = 3
elif temp < 90: iconNum = 4
else: iconNum = 5
self.parent.setIcon("/home/sah/dev/indicators/temperature-%d-icon.png" % iconNum)
self.parent.updateTempMenuItem("%.1f C" % temp)
time.sleep(1)
i += 1