From 103ba2e0c527973703a0e4f380d91d442e7121dc Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 10 Aug 2012 14:41:52 +0800 Subject: [PATCH] Function to recursively chmod a directory --- lib/tools.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/tools.py b/lib/tools.py index 039a7a0..fef1909 100644 --- a/lib/tools.py +++ b/lib/tools.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import sys +import os import subprocess, shlex import re @@ -14,6 +15,16 @@ def yesOrNo(q): elif i == 'n': return False +def chmodRecursive(path, chmod): + os.chmod(path, chmod) + for (dirpath, dirnames, filenames) in os.walk(path): + for d in dirnames: + dir = os.path.join(dirpath, d) + os.chmod(dir, chmod) + for f in filenames: + file = os.path.join(dirpath, f) + os.chmod(file, chmod) + def debug(str): print str sys.stdout.flush() -- 2.11.0