I found one here: http://computer-programming-forum.com/56-python/46da865fb41a1dc3.htm
Ansible worked on that as well: https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py (_symbolic_mode_to_octal, _apply_operation_to_mode, _get_octal_mode_from_symbolic_perms) Le 6 déc. 2014 à 16:24, Gary Oberbrunner <ga...@oberbrunner.com> a écrit : > > > On Sat, Dec 6, 2014 at 9:37 AM, Shreedhar Manek <shreedharma...@gmail.com> > wrote: > 256 is octal 0400, so it looks like it's only getting the S_IRUSR part. And > that's because I steered you wrong; these are bitmasks, so you have to use > bitwise OR: S_IRUSR | S_IRGRP | S_IROTH > > This was it. Thanks! > > Should I replace all integers with their counterpart string? Or only select > ones? > > Well, first, don't forget your real goal is to allow SCons users to actually > use a string to set the mode bits. These constants you're using are in the > 'stat' module (so 'import stat' will fix your bug below), but they are still > numeric absolute constants. > > I think the original issue > (http://scons.tigris.org/issues/show_bug.cgi?id=2494) asks for allowing users > to use actual strings like the chmod command-line utility, which allows > relative modes like "ug+rw,o-rwx" as well as numeric absolute modes like > "777" (that's still a string, note). (see the chmod man page, for instance > http://linux.die.net/man/1/chmod.) SCons users could already just do 'import > stat' and use the named constants, but those are absolute; the desired chmod > modes are relative to the current state. The main task for this issue is, I > think, to parse those relative modes (relative to the file's current state) > and compute the desired final mode. > > If you can write a function parse_mode_string(mode_string, > original_mode_bits), that's 90% of the work. (Actually I'm surprised there > isn't one already written out there somewhere.) > > -- Gary > > > Replacing the first 0777 with S_IRWXU | S_IRWXG | S_IRWXO in > > test.write('SConstruct', """ > Execute(Chmod('f1', 0666)) > Execute(Chmod(('f1-File'), 0666)) > Execute(Chmod('d2', S_IRWXU | S_IRWXG | S_IRWXO)) > Execute(Chmod(Dir('d2-Dir'), 0777)) > def cat(env, source, target): > target = str(target[0]) > f = open(target, "wb") > for src in source: > f.write(open(str(src), "rb").read()) > f.close() > Cat = Action(cat) > env = Environment() > env.Command('bar.out', 'bar.in', [Cat, > Chmod("f3", 0666), > Chmod("d4", 0777)]) > env = Environment(FILE = 'f5') > env.Command('f6.out', 'f6.in', [Chmod('$FILE', 0666), Cat]) > env.Command('f7.out', 'f7.in', [Cat, > Chmod('Chmod-$SOURCE', 0666), > Chmod('${TARGET}-Chmod', 0666)]) > > # Make sure Chmod works with a list of arguments > env = Environment(FILE = 'f9') > env.Command('f8.out', 'f8.in', [Chmod(['$FILE', File('f10')], 0666), Cat]) > Execute(Chmod(['d11', Dir('d12')], 0777)) > """) > > gives the following error, > > STDERR > ========================================================================= > NameError: name 'S_IRWXU' is not defined: > File "/tmp/testcmd.23013.se_zJm/SConstruct", line 4: > Execute(Chmod('d2', S_IRWXU | S_IRWXG | S_IRWXO)) > > FAILED test of /home/shrox/scons/src/script/scons.py > at line 598 of /home/shrox/scons/QMTest/TestCommon.py (_complete) > from line 701 of /home/shrox/scons/QMTest/TestCommon.py (run) > from line 390 of /home/shrox/scons/QMTest/TestSCons.py (run) > from line 123 of test/Chmod.py > > > > -- > Shreedhar Manek > > _______________________________________________ > Scons-dev mailing list > Scons-dev@scons.org > https://pairlist2.pair.net/mailman/listinfo/scons-dev > > > > > -- > Gary > _______________________________________________ > Scons-dev mailing list > Scons-dev@scons.org > https://pairlist2.pair.net/mailman/listinfo/scons-dev
_______________________________________________ Scons-dev mailing list Scons-dev@scons.org https://pairlist2.pair.net/mailman/listinfo/scons-dev