Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created July 15, 2015 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eugeny/02a550e0dc2762e1da2e to your computer and use it in GitHub Desktop.
Save Eugeny/02a550e0dc2762e1da2e to your computer and use it in GitHub Desktop.
import grp
import os
import sys
import subprocess
root = sys.argv[1]
for project_dir in os.listdir(root):
project_dir = os.path.join(root, project_dir)
for ws_dir in os.listdir(project_dir):
ws_dir = os.path.join(project_dir, ws_dir)
gid = os.stat(ws_dir).st_gid
try:
gid = grp.getgrgid(gid).gr_name
except:
pass
print '%-80s: setting group to %05s' % (ws_dir, gid)
subprocess.call(['chmod', '-R', '2770', ws_dir])
subprocess.call(['chgrp', '-R', str(gid), ws_dir])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment