当前位置: 首页>>代码示例>>Python>>正文


Python Status.getNet方法代码示例

本文整理汇总了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
开发者ID:shofmeyr,项目名称:indicators,代码行数:48,代码来源:indicator-net.py

示例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
开发者ID:shofmeyr,项目名称:indicators,代码行数:24,代码来源:indicator-sys.py


注:本文中的status.Status.getNet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。