[Tutor] Fw: Clipin
Morne
Morne" <fromclay@maxitec.co.za
Tue, 3 Sep 2002 11:13:39 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_00FE_01C2533A.F4996F60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
----- Original Message -----=20
From: Morne=20
To: python tutor=20
Sent: Tuesday, September 03, 2002 10:48 AM
Subject: Clipin
ERROR IT GIVES ME with and without disk in A: drive
>>>=20
Traceback (most recent call last):
File "A:/mess", line 39, in ?
main()
File "A:/mess", line 34, in main
f=3Dopen("ppp.log","r")
IOError: [Errno 2] No such file or directory: 'ppp.log'
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\PYTHON22\lib\lib-tk\Tkinter.py", line 1292, in __call__
return apply(self.func, args)
File "C:\PYTHON22\Tools\idle\ScriptBinding.py", line 148, in =
run_script_event
interp.execfile(filename)
File "C:\PYTHON22\Tools\idle\PyShell.py", line 175, in execfile
source =3D open(filename, "r").read()
IOError: [Errno 13] Permission denied: 'A:/mess'
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
=20
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_00FE_01C2533A.F4996F60
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> </DIV>
<DIV style=3D"FONT: 10pt arial">----- Original Message -----=20
<DIV style=3D"BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> <A=20
href=3D"mailto:fromclay@maxitec.co.za" =
title=3Dfromclay@maxitec.co.za>Morne</A>=20
</DIV>
<DIV><B>To:</B> <A href=3D"mailto:tutor@python.org" =
title=3Dtutor@python.org>python=20
tutor</A> </DIV>
<DIV><B>Sent:</B> Tuesday, September 03, 2002 10:48 AM</DIV>
<DIV><B>Subject:</B> Clipin</DIV>
<DIV> </DIV>
<DIV>ERROR IT GIVES ME with and without disk in A: drive</DIV>
<DIV>>>> <BR>Traceback (most recent call last):<BR> File=20
"A:/mess", line 39, in ?<BR> main()<BR> File =
"A:/mess",=20
line 34, in main<BR> =
f=3Dopen("ppp.log","r")<BR>IOError: [Errno=20
2] No such file or directory: 'ppp.log'<BR>Exception in Tkinter=20
callback<BR>Traceback (most recent call last):<BR> File=20
"C:\PYTHON22\lib\lib-tk\Tkinter.py", line 1292, in=20
__call__<BR> return apply(self.func, args)<BR> =
File=20
"C:\PYTHON22\Tools\idle\ScriptBinding.py", line 148, in=20
run_script_event<BR> =
interp.execfile(filename)<BR> File=20
"C:\PYTHON22\Tools\idle\PyShell.py", line 175, in =
execfile<BR> =20
source =3D open(filename, "r").read()<BR>IOError: [Errno 13] Permission =
denied:=20
'A:/mess'<BR></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></DIV>
<DIV><BR></DIV>
<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_00FE_01C2533A.F4996F60--