[Tutor] Getting "file sizes" !!Solved!!
syn_ack at comcast.net
Wed Feb 18 23:11:55 EST 2004
Grrrrr.... Kind of funny how my monitor is like a mirror. The problem
was staring me right in the face.
Ok, this was my issue.
1) As I reread through my initial emails regarding this particular
thread, I noticed that I didn't append my initial tests. Which, if I
would've included the following, someone might of been able to point
out, right away, what the problem was. I included everything except my
loop testing and the fact that I'm running python as a normal non-root
>>> import os, os.path
>>> a = os.listdir('/var/log/portage')
>>> for x in a:
... print x, os.path.getsize(x)
Traceback (most recent call last):
File "<stdin>", line 2, in ?
File "/usr/lib/python2.3/posixpath.py", line 142, in getsize
OSError: [Errno 2] No such file or directory:
Well I know that '1782-openmotif-2.1.30-r3.log' is the first file listed
in this directory and does infact exist. BUTTTTTTT, these are the
permissions and owner/groups of the directory "portage".
drwxrwsr-x 2 root portage 4872 Feb 5 08:16 portage
It looks as though I was missing "write" permissions to simply get and
print file sizes.. Seems strange..
So I decided to run the same python commands and instead, substituted a
directory that is owned by the "non-root-user(me)".
And now joy has comeback into my life.. :D
>>> a = os.listdir('/home/jbanks/Pythontesting')
>>> for x in a:
... print x, os.path.getsize(x), "bytes"
menu.bak 43 bytes
menu.txt 43 bytes
Oldpy_stuff 256 bytes
persnl_gtr.py 270 bytes
list_emerged.py 1475 bytes
passwd.py 467 bytes
quotmanip.py 465 bytes
file2.py 108 bytes
test.py 223 bytes
file.py 107 bytes
functiontst.py 140 bytes
Lobster.py 647 bytes
functiontst2.py 25 bytes
functiontst.pyc 420 bytes
Lobster.pyc 706 bytes
pytips 0 bytes
bd1.txt 3266 bytes
bd2.txt 130 bytes
game_over.py 231 bytes
bell.py 377 bytes
useless_trivia.py 1110 bytes
ifelifelse.py 453 bytes
whiletst.py 459 bytes
game_over2.py 151 bytes
filecopy.py 331 bytes
tempature.py 735 bytes
functiontst2.pyc 278 bytes
This was a frustrating but good learning experience for me. So it
appeared that I could list the contents of the "/var/log/portage"
directory but couldn't ..." write(r-x)" write them I guess because of
the directory owner/permissions. I'm still a little baffled...but I'll
figure it out. I'm sure simply changing the the last set or permissions
to "rwx" is the ticket.
Anyways thanks to all that responded.
More information about the Tutor