コード例 #1
0
ファイル: decorator.py プロジェクト: ext/pylistener
def interface(cls):
    def trigger(func, args, kwargs):
        return Listen._trigger(cls, func, args, kwargs)
    Listen._register_class(cls)
    cls._listener = []
    cls._trigger = staticmethod(trigger)
    return cls
コード例 #2
0
    def test_listen_changes(self, mock_observer):
        dir_listener = Listen()

        created = dir_listener.observe(fake_bucket, ADD_EVENT)
        self.assertTrue(created, 'File creation error')

        deleted = dir_listener.observe(fake_bucket, DEL_EVENT)
        self.assertTrue(deleted, 'File deletion error')

        modified = dir_listener.observe(fake_bucket, MOD_EVENT)
        self.assertTrue(modified, 'File modification error')

        moved = dir_listener.observe(fake_bucket, CUT_EVENT)
        self.assertTrue(moved, 'File cutting error')

        weird_action = dir_listener.observe(fake_bucket, 'boo')
        self.assertFalse(weird_action, 'Non existent action error')
コード例 #3
0
ファイル: decorator.py プロジェクト: ext/pylistener
 def trigger(func, args, kwargs):
     return Listen._trigger(cls, func, args, kwargs)
コード例 #4
0
ファイル: main.py プロジェクト: deeper-x/webonitor
from listener import Listen
from configuration import bucket

if __name__ == '__main__':
    a = Listen()
    a.observe(bucket, 'add')
コード例 #5
0
ファイル: main.py プロジェクト: coderwf/rinet_py
    if port <= 0 or port >= 65535:
        PORTERROR(port)


def check_host(host):
    bs = host.split(".")
    if len(bs) != 4:
        raise HOSTERROR(host)
    for b in bs:
        if int(b) < 0 or int(b) > 255:
            raise HOSTERROR(host + ":" + b)


if __name__ == "__main__":
    argv = sys.argv
    if len(argv) != 5:
        print "un support argv , check it please"
    bind_host = argv[1]
    bind_port = int(argv[2])
    target_host = argv[3]
    target_port = int(argv[4])
    check_host(target_host)
    check_host(bind_host)
    check_port(target_port)
    check_port(bind_port)
    listener = Listen(bind_host, bind_port, target_host, target_port)
    listener.start_listen()
    IoLoop.instance().start()
"""
main.py 0.0.0.0 9999 127.0.0.1 8888
"""
コード例 #6
0
        self.interface = rospy.get_param("~interface", "wlp3s0")
	print("INTERFACEEEEEEEEEE",self.interface)
        self.sniffer = cinnamon_man.Sniffer()
        self.rate = rospy.Rate(10)

    def startSniff(self):
        print("Start to sniff from "+self.interface)
        sniff(iface=self.interface, prn=self.sniffer.sniffAP, stop_filter=self.checkStop, store=0)

    def setStopSniff(self, stop_sniff):
        self.stopSniff = stop_sniff

    def checkStop(self,p):
        if self.stopSniff:
            return True
        return False

    # def spin(self):
	# 	while not rospy.is_shutdown():
	# 		self.rate.sleep()

if __name__ == '__main__':

    cinnamon = CinnamonController()

    listener = Listen(1, "Thread1", 2, cinnamon)
    listener.start()

    #cinnamon.spin()
    cinnamon.startSniff()