heeelp

Morne fromclay at maxitec.co.za
Tue Sep 3 10:36:40 EDT 2002


Could someone please help me with this?
Im really new to any kind of programming 
 
If posible would you be
able to answer in detail.
Thanx 
morne

is it wrong of me to send the ppp.log file to just anyone?

HERE IS WHAT I HAVE:

import re
import string

secondsMatcher=re.compile("Connect time: (\d+) secs")

def getStuff(file):
    closeline = 0
    errorcount = 0
    secondscount = 0
    connectcount = 0
    data_outcount = 0
    data_incount = 0
    ppplist = file.readlines()

    for line in ppplist:

      if string.find(line,"LayerUp") >= 0:
          print "found connect"
          connectline = string.split(line)
          connectcount = connectcount + 1

      elif string.find(line,"ERROR") >= 0:
          print "found error"
          errorcount = errorcount + 1

      elif string.find(line,"Connect time") >= 0:
          print "found close"
          connectSecs=secondsMatcher.search(line).group(1)
          print "Connected for",connectSecs
          closeline = string.split(line)
          secondscount = secondscount + string.atoi(connectSecs)

def main():
    f=open("C:/my documents/ppp.log","r")
    getStuff(f)
    return None

if __name__=="__main__":
    main()

THIS IS WHAT I NEED THE PROGRAM TO DO:

I want the program to read the attached ppp.log file and give me the
following type of report:


PPP Log file summary for 5 Jul 2002
-----------------------------------
Jul  5 18:15:01 Connected to internet (IP 155.239.150.146)
Jul  5 18:18:08 Closed connection. ( Connect time: 197 secs: 5091 octets in,
1864 octets out )
-----------------------------------
Successful connections: 5
Failed connections: 2
Total time online: 456 seconds
Total data in: 66576 octets
Total Data out: 66349 octets














-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20020903/5d02f49d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ppp.log
Type: application/octet-stream
Size: 33059 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020903/5d02f49d/attachment.obj>


More information about the Python-list mailing list