kai rosenthal wrote:
Hello,
with ls -l on windows I get
-rw-r--r-- 1 500 everyone 320 Nov 09 09:35 myfile
How can I get on windows with a standard python 2.2 (without windows
extensions) the information "500" and "everyone" (owner and group)?
Also I cannot use popen('ls -l').
Are you by any chance running cygwin? That comes with ls, but windows
doesn't. So you need to add the appropriate cygwin binary dirs to you path.
But you probably won't want that anyway, as thus your code would only run
on a machine with cygwin installed.
With
import stat
stat_info = os.lstat(myfile)
owner = "%-8s" % stat_info.st_uid
group = "%-8s" % stat_info.st_gid
I get 0 for owner and group.
I'm not sure if stat-calls are fully supported on windows - the windows
rights management is considerably different from unixish ones.
From the docs:
"""
For backward compatibility, the return value of stat() is also accessible as
a tuple of at least 10 integers giving the most important (and portable)
members of the stat structure, in the order st_mode, st_ino, st_dev,
st_nlink, st_uid, st_gid, st_size, st_atime, st_mtime, st_ctime. More items
may be added at the end by some implementations. The standard module stat
defines functions and constants that are useful for extracting information
from a stat structure. (On Windows, some items are filled with dummy
values.)
"""
Note the last sentence. You should try and look what win32 has to offer.
Diez