aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmini-dinstall27
1 files changed, 10 insertions, 17 deletions
diff --git a/mini-dinstall b/mini-dinstall
index 63a5471..6261934 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -156,31 +156,24 @@ for key, val in opts:
elif key in ('-k', '--kill'):
kill_mode = 1
-def do_mkdir(name):
- if os.access(name, os.X_OK):
- return
+def do_and_log(msg, function, *args):
try:
- logger.info('Creating directory "%s"' % (name))
+ logger.debug(msg)
except:
pass
if not no_act:
- os.mkdir(name)
+ function(*args)
+
+def do_mkdir(name):
+ if os.access(name, os.X_OK):
+ return
+ do_and_log('Creating directory "%s"' % (name), os.mkdir, name)
def do_rename(source, target):
- try:
- logger.debug('Renaming "%s" to "%s"' % (source, target))
- except:
- pass
- if not no_act:
- os.rename(source, target)
+ do_and_log('Renaming "%s" to "%s"' % (source, target), os.rename, source, target)
def do_chmod(name, mode):
- try:
- logger.info('Changing mode of "%s" to %o' % (name, mode))
- except:
- pass
- if not no_act:
- os.chmod(name, mode)
+ do_and_log('Changing mode of "%s" to %o' % (name, mode), os.chmod, name, mode)
logger.setLevel(logging.DEBUG)
stderr_handler = logging.StreamHandler(strm=sys.stderr)