[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>&nbsp;</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>&nbsp;</DIV>
<DIV>ERROR IT GIVES ME with and without disk in A: drive</DIV>
<DIV>&gt;&gt;&gt; <BR>Traceback (most recent call last):<BR>&nbsp; File=20
"A:/mess", line 39, in ?<BR>&nbsp;&nbsp;&nbsp; main()<BR>&nbsp; File =
"A:/mess",=20
line 34, in main<BR>&nbsp;&nbsp;&nbsp; =
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>&nbsp; File=20
"C:\PYTHON22\lib\lib-tk\Tkinter.py", line 1292, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; return apply(self.func, args)<BR>&nbsp; =
File=20
"C:\PYTHON22\Tools\idle\ScriptBinding.py", line 148, in=20
run_script_event<BR>&nbsp;&nbsp;&nbsp; =
interp.execfile(filename)<BR>&nbsp; File=20
"C:\PYTHON22\Tools\idle\PyShell.py", line 175, in =
execfile<BR>&nbsp;&nbsp;&nbsp;=20
source =3D open(filename, "r").read()<BR>IOError: [Errno 13] Permission =
denied:=20
'A:/mess'<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</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>&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_00FE_01C2533A.F4996F60--