aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2002-02-05 03:04:22 +0000
committerFrederic Lepied <flepied@mandriva.com>2002-02-05 03:04:22 +0000
commit80cefb79e864c848e2c066a9b9d9d76ed0794e3c (patch)
tree2eced0d45e264bd2a00db9ea58c81099bb71d369 /share
parente448d987519d170920f158961be791abe1273a29 (diff)
downloadmsec-80cefb79e864c848e2c066a9b9d9d76ed0794e3c.tar
msec-80cefb79e864c848e2c066a9b9d9d76ed0794e3c.tar.gz
msec-80cefb79e864c848e2c066a9b9d9d76ed0794e3c.tar.bz2
msec-80cefb79e864c848e2c066a9b9d9d76ed0794e3c.tar.xz
msec-80cefb79e864c848e2c066a9b9d9d76ed0794e3c.zip
process the options like msec to be able to log the same way.
Diffstat (limited to 'share')
-rwxr-xr-xshare/Perms.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/share/Perms.py b/share/Perms.py
index 60d52f7..7120467 100755
--- a/share/Perms.py
+++ b/share/Perms.py
@@ -182,12 +182,46 @@ def chmod(f, newperm):
if __name__ == '__main__':
import sys
+ import Config
+ import getopt
+
+ _interactive = sys.stdin.isatty()
- initlog('msec')
+ # process the options
+ try:
+ (opt, args) = getopt.getopt(sys.argv[1:], 'o:',
+ ['option'])
+ except getopt.error:
+ error(_('Invalid option. Use %s (-o var=<val>...) ([0-5])') % sys.argv[0])
+ sys.exit(1)
+
+ for o in opt:
+ if o[0] == '-o' or o[0] == '--option':
+ pair = string.split(o[1], '=')
+ if len(pair) != 2:
+ error(_('Invalid option format %s %s: use -o var=<val>') % (o[0], o[1]))
+ sys.exit(1)
+ else:
+ print 'setting', pair[0], pair[1]
+ Config.set_config(pair[0], pair[1])
+
+ # initlog must be done after processing the option because we can change
+ # the way to report log with options...
+ if _interactive:
+ import syslog
+
+ initlog('msec', syslog.LOG_LOCAL1)
+ else:
+ initlog('msec')
+
+ _interactive and log(_('Fixing owners and permissions of files and directories'))
- for p in sys.argv[1:]:
+ # process the files
+ for p in args:
+ _interactive and log(_('Reading data from %s') % p)
fix_perms(p)
+ # do the modifications
act()
# Perms.py ends here