Oops, an error was introduced when I modified the db connection code
before posting:

c = db.cursor(...
should be
cursor = db.cursor(...

Cheers,
Einar

Einar S. Idsø wrote:
> Seems attachments don't work. Here's the text from the script. Make sure
> to fix the indentation and line-breaks before trying it out:
>
>
> #!/usr/bin/env python
>
> import sys
> import os
> import MySQLdb
> import re
>
> db = MySQLdb.connect(host, user, password, database)
> c = db.cursor(MySQLdb.cursors.DictCursor)
>
> ipRegExp = re.compile('connected, address
> "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)')
>
> logDir='./logs/' # Remember to end with '/'
>
> fileList = os.listdir(logDir)
>
> for f in fileList:
>    sys.stdout.flush()
>    fo = open(logDir+f)
>    lines = fo.readlines()
>    for line in lines:
>       m = ipRegExp.search(line)
>       if m:
>          ip = m.groups()[0]
>          cursor.execute("SELECT cc_three FROM ip2country WHERE ipfrom <=
> INET_ATON('%s') AND ipto >= INET_ATON('%s') LIMIT 1" %(ip, ip))
>          temp = cursor.fetchone()
>          if temp:
>             print temp['cc_three'] + " " + ip
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds
>


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds

Reply via email to