ping_object.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:any_ping_indicator 作者: leggedrobotics 项目源码 文件源码
def __init__(self, id, name, address, update_rate, number_of_pings,
                 show_indicator, show_text, is_activated=None):
        """Initialize.
        :param id:
        :param address:
        :param update_rate:
        :param number_of_pings:
        :param show_indicator:
        :param is_activated:
        """
        # init gobject
        GObject.GObject.__init__(self)
        GObject.type_register(PingObject)
        GObject.threads_init()
        # ping object properties
        self.id = id
        self.name = name
        if not self.name:
            self.name = address
        self.address = address
        self.update_rate = update_rate
        self.number_of_pings = number_of_pings
        self.show_indicator = show_indicator
        self.show_text = show_text
        if is_activated is None:
            self.is_activated = True
        else:
            self.is_activated = is_activated
        self.icon = "icon_red"
        if not self.is_activated:
            self.icon = "icon_grey"
        self.ping_warning = 50.0
        # indicator menu item
        self.menu_item = gtk.ImageMenuItem("Ping: " + address)
        # result
        self.result = PingStruct(RESULT_NO_RESPONSE, 0.0, 0.0, 0.0, 0.0)
        # gtk image for menu item
        self.image = gtk.Image()
        self.image.set_from_file(resource.image_path("icon_gray", theme.THEME))
        # ping state
        self.state = "Ping: " + self.address + " initializing."
        # store subprocess
        self.process = None
        # mutex
        self.mutex = threading.Lock()
        # thread
        self.thread = None
        self.is_running = False
        # interruptable sleep function
        self.stop_event = threading.Event()
        # current time
        self.time_last = time.time()

    # signal definition returns (id, name, icon name, show_indicator)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号