[Tutor] Clipin

Morne Morne" <fromclay@maxitec.co.za
Tue, 3 Sep 2002 10:48:26 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0099_01C25337.6E98A780
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi ,OK Here I have done somthing else but it seems not to work when I =
copy and then paste it to the Python "eddit" It gives me this error ,can =
some one help me please.

Just say I want to open the file ppp.log "path: C:\my documents\ppp.log =
would that work"
Not that Im very new to python and dont know my way around but am going =
to know in some time.

Thanx from Morne

import re
import string

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

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

    for line in ppplist:

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

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

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

def main():
    f=3Dopen("ppp.log","r")
    getStuff(f)
    return None

if __name__=3D=3D"__main__":
    main()


------=_NextPart_000_0099_01C25337.6E98A780
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi ,OK Here I have done somthing else =
but it seems=20
not to work when I copy and then paste it to the Python "eddit" It gives =
me this=20
error ,can some one help me please.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Just say I want to open the file =
ppp.log "path:=20
C:\my documents\ppp.log would that work"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Not that Im very new to python and dont =
know my way=20
around but am going to know in some time.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanx from Morne</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import re<BR>import string</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>secondsMatcher=3Dre.compile("Connect =
time: (\d+)=20
secs")</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def =
getStuff(file):<BR>&nbsp;&nbsp;&nbsp; closeline=20
=3D 0<BR>&nbsp;&nbsp;&nbsp; errorcount =3D 0<BR>&nbsp;&nbsp;&nbsp; =
secondscount =3D=20
0<BR>&nbsp;&nbsp;&nbsp; connectcount =3D 0<BR>&nbsp;&nbsp;&nbsp; =
data_outcount =3D=20
0<BR>&nbsp;&nbsp;&nbsp; data_incount =3D 0<BR>&nbsp;&nbsp;&nbsp; ppplist =
=3D=20
file.readlines()</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; for line in=20
ppplist:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if=20
string.find(line,"LayerUp") &gt;=3D=20
0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print =
"found=20
connect"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
connectline =3D=20
string.split(line)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
connectcount =3D connectcount + 1</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif=20
string.find(line,"ERROR") &gt;=3D=20
0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print =
"found=20
error"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
errorcount =3D=20
errorcount + 1</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif=20
string.find(line,"Connect time") &gt;=3D=20
0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print =
"found=20
close"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
connectSecs=3DsecondsMatcher.search(line).group(1)<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print "Connected=20
for",connectSecs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
closeline =3D=20
string.split(line)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
secondscount =3D secondscount + string.atoi(connectSecs)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def main():<BR>&nbsp;&nbsp;&nbsp;=20
f=3Dopen("ppp.log","r")<BR>&nbsp;&nbsp;&nbsp; =
getStuff(f)<BR>&nbsp;&nbsp;&nbsp;=20
return None</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>if =
__name__=3D=3D"__main__":<BR>&nbsp;&nbsp;&nbsp;=20
main()<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_0099_01C25337.6E98A780--