#!/usr/bin/env python
import argparse
import os
import pwd
from os.path import join
import subprocess
def 解析器():
p = argparse 。ArgumentParser ()
p 。add_argument ( "project_directory" )
返回 p
def run ( project_directory ):
#this 类似于 /projects/<username>
project_dirs = os 。listdir ( project_directory )
for dirname in project_dirs :
print dirname
path = join ( project_directory , dirname )
owner = pwd 。getpwuid (OS 。STAT (路径)。st_uid )。pw_name
子进程. check_output ([ 'chown' , '-R' , ' %s : %s ' % ( owner , owner ), path ])
子进程。check_output ([ 'chmod' , '-R' , 'g-s' , path ])
子进程。check_output ([ 'chown' , '-R' , 'wakari:wakari' , '/opt/wakari/anaconda' ])
子进程。, '-R' , 'a+r' , '/opt/wakari/anaconda' ])
子进程。check_output ([ 'chmod' , '-R' , 'o-w' , '/opt/wakari/anaconda' ])
如果 __name__ == "__main__" :
p = parser ()
args = p 。parse_args ()
运行(ARGS 。project_directory )