on winblows you can make a folder "read only" but it has no special
effect since you can rename it without it compaining.
However, you can change the attribute to read only on a file, and then
winblows will complain that you are tinkering with a file.
try this and see the results
---------------------------------------------------------------------------------------------
import os, stat, sys
path = "c:/PermissionTest/"
# Check if path exists and make folders
if os.path.exists(path):
os.chmod(path, stat.S_IREAD)
else:
os.mkdir(path)
os.chmod(path, stat.S_IREAD)
# check if file exists, then create and make file readonly
if os.path.exists( path + "thefile.txt" ):
print "done!"
else:
text_file = open( path + "thefile.txt", "w")
text_file.close()
os.chmod(path + "thefile.txt", stat.S_IREAD)
raw_input("press enter to exit")
-------------------------------------------------------------------------------
regards
stefan andersson
On 2/3/06, kim aldis <kim(at)cg-soup.com> wrote:
> You could try a straight system call in a conditional statement. If you are
> cross platform it's worth looking at Cygwin to cover the missing windows
> bits.
>
> Shame there isn't a preprcessor for these scripting languages.
>
> > -----Original Message-----
> > From: owner-xsi(at)Softimage.COM
> > [mailto:owner-xsi(at)Softimage.COM] On Behalf Of brad
> > Sent: 03-February-2006 04:16
> > To: XSI(at)Softimage.COM
> > Subject: Re: PY: Python and setting permissions on windows?
> >
> > Hmmm, don't think I can do that. Whatever solution must be
> > cross platform since our pieline includes Mac and linux.
> >
> >
> > > -------Original Message-------
> > > Hi Brad,
> > >
> > > I don't know for the native python, but you can also try pywin32:
> > > win32file.CreateDirectoryW
> > > You can look into pywin32.win32file documentation for more details.
> > >
> > > Cheers,
> > >
> > > Aloys
> > >
> > >
> > > On 2/3/06, BRAD <[LINK: mailto:brad(at)cg-soup.com]
> > brad(at)cg-soup.com> wrote:
> > > Anybody working with Python on windows have experience
> > manipulating
> > > permissions for folders or files?
> > > The docs I've found all say that stat.S_IREAD and stat.S_IWRITE
> > > should at least work with windows, but I'm having no luck or no
> > > effect on permissions for directories:
> > >
> > > # 1. Run this
> > > import os, stat
> > > path = "c:/PermissionTest"
> > > os.makedirs(path, stat.S_IWRITE)
> > >
> > > # 2. Check if path exists, then run this path =
> > "c:/PermissionTest"
> > > os.chmod(path, stat.S_IREAD)
> > >
> > >
> > > I get no errors, but then, no permissions are changed on
> > the file either.
> > > Any help in this department, or a link to the right
> > reference would
> > > be appreciated.
> > >
> > > -Brad
> > > ---
> > > Unsubscribe? Mail [LINK: mailto:Majordomo(at)Softimage.COM]
> > > Majordomo(at)Softimage.COM with the following text in body:
> > > unsubscribe xsi
> > >
> > >
> > > --
> > > Aloys Baillet - XSI Technical Director Character Dpt -
> > Animal Logic
> > > --
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following
> > text in body:
> > unsubscribe xsi
> >
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>
--
________________________________________________________________________
http://stefan.sanders3d.com/
http://os3d.blogspot.com/
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi