From 30259e3f29b0fed4a55ec42e3dd10f0bac2538f8 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Sun, 22 May 2016 11:15:01 -0400 Subject: [PATCH 1/2] Use py3 compatible requirements and fix syntax in snif.py --- requirements.txt | 4 +--- snif.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2aa28fd..c251915 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,10 +5,8 @@ enum34==1.1.3 netifaces==0.10.4 protobuf==3.0.0b2 phue==0.8 -pypcap==1.1.4 requests==2.9.1 -scapy==2.3.2 +scapy-python3==0.18 six==1.10.0 -wsgiref==0.1.2 zeroconf==0.17.5 read_env==1.1.0 diff --git a/snif.py b/snif.py index bc1c59e..2fe91dd 100644 --- a/snif.py +++ b/snif.py @@ -1,9 +1,15 @@ -from scapy.all import * +import logging + +from scapy.all import sniff, ARP import pychromecast from phue import Bridge import settings +logger = logging.getLogger(__name__) + +VIDEO_FILE = 'https://osf.io/zqnyu/?action=download&direct&mode=render' + def arp_display(pkt): cast = pychromecast.get_chromecast(friendly_name=settings.CHROMECAST_NAME) @@ -13,8 +19,8 @@ def arp_display(pkt): if pkt[ARP].op == 1: if pkt[ARP].psrc == '0.0.0.0': if pkt[ARP].hwsrc == settings.DASH_HMAC: - print "Ready to BLING" - mc.play_media('https://osf.io/zqnyu/?action=download&direct&mode=render', 'video/mp4') + logger.info('Ready to BLING') + mc.play_media(VIDEO_FILE, 'video/mp4') def set_hue_color(): @@ -30,5 +36,5 @@ def set_hue_color(): if __name__ == '__main__': - print sniff(prn=arp_display, filter="arp", store=0, count=10) + sniff(prn=arp_display, filter="arp", store=0, count=10) set_hue_color() From 8126dc9fb82b50d9b60b0ad95a91a7331d8812f0 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Sun, 22 May 2016 11:21:33 -0400 Subject: [PATCH 2/2] Include only top-level requirements --- requirements.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index c251915..6869b98 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,4 @@ PyChromecast==0.7.2 -## dnet==1.12 -enum-compat==0.0.2 -enum34==1.1.3 -netifaces==0.10.4 -protobuf==3.0.0b2 phue==0.8 -requests==2.9.1 scapy-python3==0.18 -six==1.10.0 -zeroconf==0.17.5 read_env==1.1.0