Пример #1
0
class TrafficTypes:
    http = 0
    https = 1
    other = 2


p = Popen(['tcpdump', '-ni', IF, 'tcp'],
          bufsize=80,
          stdin=PIPE,
          stdout=PIPE,
          close_fds=True)
stdout = p.stdout
stats = deque()
for i in range(SAMPLES):
    stats.append(Counter())
driver = Driver(DEV, substrips=4)


def get_one():
    l = stdout.readline()
    if '.80 ' in l or '.80:' in l:
        return TrafficTypes.http
    elif '.443' in l:
        return TrafficTypes.https
    else:
        return TrafficTypes.other


def rotator(stats, interval):
    while True:
        print "rotation"
Пример #2
0
 def render(self):
     Driver.render(self)
Пример #3
0
 def __init__(self, serial=None, factor=0.5, length=32):
     Driver.__init__(self, serial=serial, factor=factor, length=length)
     self.upvalues = deque(maxlen=(length - 2) / 2)
     self.downvalues = deque(maxlen=(length - 2) / 2)
Пример #4
0
            self.merge(self.driver.push_upstream(int(data['bw']['up'])),
                       self.driver.push_downstream(int(data['bw']['down'])))

            time.sleep(4)
            self.driver.render()


def setup_logging():
    logging.basicConfig(
        format='%(asctime)s %(module)-15s %(levelname)-8s %(message)s',
        level=logging.DEBUG)


def main():
    setup_logging()
    nr = NetworkRenderer(ENDPOINT)
    nr.run()


if __name__ == '__main__':
    import sys

    if len(sys.argv) == 2:
        port = sys.argv[1]
    else:
        sys.exit('usage: stripdriver.py /dev/<tty-usb>')

    d = Driver(serial=port, factor=0.05)
    main()
Пример #5
0
 def render(self):
     Driver.render(self)
Пример #6
0
 def __init__(self, serial=None, factor=0.5, length=32):
     Driver.__init__(self, serial=serial, factor=factor, length=length)
     self.upvalues = deque(maxlen=(length - 2) / 2)
     self.downvalues = deque(maxlen=(length - 2) / 2)