[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> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanx from Morne</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>import re<BR>import string</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>secondsMatcher=3Dre.compile("Connect =
time: (\d+)=20
secs")</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>def =
getStuff(file):<BR> closeline=20
=3D 0<BR> errorcount =3D 0<BR> =
secondscount =3D=20
0<BR> connectcount =3D 0<BR> =
data_outcount =3D=20
0<BR> data_incount =3D 0<BR> ppplist =
=3D=20
file.readlines()</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> for line in=20
ppplist:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> if=20
string.find(line,"LayerUp") >=3D=20
0:<BR> print =
"found=20
connect"<BR> =
connectline =3D=20
string.split(line)<BR> &nb=
sp;=20
connectcount =3D connectcount + 1</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> elif=20
string.find(line,"ERROR") >=3D=20
0:<BR> print =
"found=20
error"<BR> =
errorcount =3D=20
errorcount + 1</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> elif=20
string.find(line,"Connect time") >=3D=20
0:<BR> print =
"found=20
close"<BR> =20
connectSecs=3DsecondsMatcher.search(line).group(1)<BR> &=
nbsp; =20
print "Connected=20
for",connectSecs<BR>  =
;=20
closeline =3D=20
string.split(line)<BR> &nb=
sp;=20
secondscount =3D secondscount + string.atoi(connectSecs)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>def main():<BR> =20
f=3Dopen("ppp.log","r")<BR> =
getStuff(f)<BR> =20
return None</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>if =
__name__=3D=3D"__main__":<BR> =20
main()<BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_0099_01C25337.6E98A780--