[Tutor] directory listing and file mod times

temp accounts@internews.org
Mon, 27 Nov 2000 17:26:49 -0800


This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C05897.394E1B60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm making some progress with Mark Hammonds Win32 book, but on pp =
311-312 there are listings that look like they would help in doing basic =
file/directory file mod time feedback, but I get this error.=20

I actually understand the code up to the point of the 'decode_stat' part =
which Python gripes about anyway. I assume that there's a function or =
module that it refers to that I don't have?


>>> os.stat('C:\Updates')
(16895, 0, 2, 1, 0, 0, 0, 973065600, 973117026, 973117024)

I get this far just fine...roll your own path, use os.stat on it and get =
the items back calculated since epoch.

Now I write the function listed in the book, I just call my function =
'fileinfo' instead of 'getfileinfo', which I hope is no grevous crime. I =
also didn't put in the code pertaining to file size or access, since my =
mission is geared to when last changes were made. (it should be simpler, =
right?)

>>> import os, time, stat
>>> def fileinfo(filename):
...  modified =3D stats[stat.ST_MTIME]
...  print 'last modified :' + time.ctime(modified)
... =20
>>> decode_stat.fileinfo('C:\Updates')
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
NameError: There is no variable named 'decode_stat'

It blows up here. I don't understand where 'decode_stat' came from and =
apparantly neither does Python.=20

Any ideas? (this could be 'operator error' related)

Once I get this figured out, I can go on to working with 'walk'..which =
may generate as many questions..;)

Thanks in advance,

Larry Kuhn
lkuhn@internews.org or=20
codepuppy@internews.org


------=_NextPart_000_0005_01C05897.394E1B60
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.3019.2500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I'm making some progress with Mark =
Hammonds Win32=20
book, but on pp 311-312 there are listings that look like they would =
help in=20
doing basic file/directory file mod time feedback, but I get this error. =

</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I actually understand the code up to =
the point of=20
the 'decode_stat' part which Python gripes about anyway. I assume that =
there's a=20
function or module that it refers to that I don't have?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&gt;&gt;&gt; =
os.stat('C:\Updates')<BR>(16895,=20
0, 2, 1, 0, 0, 0, 973065600, 973117026, 973117024)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I get this far just fine...roll your =
own path, use=20
os.stat on it and get the items back calculated since =
epoch.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I write the function listed in the =
book, I just=20
call my function 'fileinfo' instead of 'getfileinfo', which I hope is no =
grevous=20
crime. I also didn't put in the code pertaining to file size or access, =
since my=20
mission is geared to when last changes were made. (it should be simpler, =

right?)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&gt;&gt;&gt; import os, time,=20
stat<BR>&gt;&gt;&gt; def fileinfo(filename):<BR>... &nbsp;modified =3D=20
stats[stat.ST_MTIME]<BR>... &nbsp;print 'last modified :' +=20
time.ctime(modified)<BR>... &nbsp;<BR>&gt;&gt;&gt;=20
decode_stat.fileinfo('C:\Updates')<BR>Traceback (innermost =
last):<BR>&nbsp; File=20
"&lt;interactive input&gt;", line 1, in ?<BR>NameError: There is no =
variable=20
named 'decode_stat'</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>It blows up here. I don't understand =
where=20
'decode_stat' came from and apparantly neither does Python. =
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any ideas? (this could be 'operator =
error'=20
related)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Once I get this figured out, I can go =
on to working=20
with 'walk'..which may generate as many questions..;)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Larry Kuhn</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:lkuhn@internews.org">lkuhn@internews.org</A> or =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:codepuppy@internews.org">codepuppy@internews.org</A><BR></=
DIV></FONT></BODY></HTML>

------=_NextPart_000_0005_01C05897.394E1B60--