Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. import mysql.connector
  5. import datetime
  6. import operator
  7.  
  8. # the list of current listeners
  9. listeners = []
  10.  
  11. def main(arg):
  12.     conn = mysql.connector.connect(user = "root",
  13.                                    password = "PASS",
  14.                                    database = "DB")
  15.  
  16.     cursor1 = conn.cursor(buffered = True)
  17.  
  18.     query = ("SELECT id, start, end FROM listeners ORDER BY start ASC LIMIT 1000")
  19.     cursor1.execute(query)
  20.  
  21.     for (listenerid, start, end) in cursor1:
  22.  
  23.         listenerid = int(listenerid)
  24.  
  25.         # the list of listeners we've lost since last added client
  26.         lost_listeners = []
  27.  
  28.         num_listeners = len(listeners)
  29.  
  30.         if listenerid == 466:
  31.             for i, l in enumerate(listeners):
  32.                 print l[0]
  33.         print "----"
  34.         for i, l in enumerate(listeners):
  35.             if listenerid == 466:
  36.                 print l[0]
  37.             if start >= l[1]:
  38.                 if listenerid == 466 and l[0] == 385:
  39.                     print "yes"
  40.                 lost_listeners.append(l)
  41.                 del(listeners[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement