def mkdirSudo(path, sudoFound=None, flagStr=''): """sudo is not avail on all plats, so su root on other nixes""" if os.name == 'posix': if sudoFound == None: # test sudoFound = drawer.isSudo() # 1 if exists if drawer.isDarwin() or sudoFound: print PROMPTdarwin % ('writing directory', path) os.system('sudo mkdir %s %s' % (flagStr, path)) else: # other *nixes print PROMPTposix % ('writing directory', path) os.system('su root -c "mkdir %s %s"' % (flagStr, path)) else: os.mkdir(path)
def chmodSudo(value, path, sudoFound=None): """sudo is not avail on all plats, so su root on other nixes""" if os.name == 'posix': if not drawer.isStr(value): value = str(value) if sudoFound == None: # test sudoFound = drawer.isSudo() # 1 if exists if drawer.isDarwin() or sudoFound: print PROMPTdarwin % ('changing permissions', path) os.system('sudo chmod %s "%s"' % (value, path)) else: # other *nixes print PROMPTposix % ('changing permissions', path) os.system('su root -c "chmod %s %s"' % (value, path))
def mvSudo(src, dst, sudoFound=None): """sudo is not avail on all plats, so su root on other nixes""" if os.name == 'posix': if sudoFound == None: # test sudoFound = drawer.isSudo() # 1 if exists if drawer.isDarwin() or sudoFound: print PROMPTdarwin % ('moving', dst) os.system('sudo mv %s %s' % (src, dst)) else: # other *nixes print PROMPTposix % ('moving', dst) os.system('su root -c "mv %s %s"' % (src, dst)) else: # mac, windows shutil.move(src, dst)
def cpSudo(src, dst, sudoFound=None): """sudo is not avail on all plats, so su root on other nixes""" if os.name == 'posix': if sudoFound == None: # test sudoFound = drawer.isSudo() # 1 if exists if drawer.isDarwin() or sudoFound: print PROMPTdarwin % ('writing', dst) os.system('sudo cp %s %s' % (src, dst)) else: # other *nixes print PROMPTposix % ('writing', dst) os.system('su root -c "cp %s %s"' % (src, dst)) else: # mac, windows if os.path.isdir(): shutil.copytree(src, dst) else: # assume a file shutil.copyfile(src, dst)
def rmSudo(path, sudoFound=None): """sudo is not avail on all plats, so su root on other nixes""" if path == os.sep: raise ValueError, 'macro remove canceled' # safety if os.name == 'posix': if sudoFound == None: # test sudoFound = drawer.isSudo() # 1 if exists if drawer.isDarwin() or sudoFound: print PROMPTdarwin % ('removing', path) os.system('sudo rm -f -r "%s"' % path) else: # other *nixes print PROMPTposix % ('removing', path) os.system('su root -c "rm -f -r %s"' % path) else: # mac, windows for root, dirs, files in os.walk(path, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: os.rmdir(os.path.join(root, name)) os.rmdir(path)
optRemoveDist = 1 optRemovePthLoader = 1 # always remove, may have changed locations optRemoveLauncher = 1 optRemoveMan = 1 #-----------------------------------------------------------------||||||||||||-- # main platform specific branch environment.printWarn('active athenaCL package directory: %s' % _fpPackageDir) if optWriteManifestTemplate: writeManifestTemplate(_fpPackageDir) if os.name == 'posix': # create launch script if (optWriteLauncher or optInstallMan or optRemoveLauncher or optRemoveDist or optRemoveMan): sudoFound = drawer.isSudo() # always detect once, pass to other methods if optRemoveDist: removeDisutils(sudoFound) if optInstallDist: # update athena directory to site-packages _fpSrcDir = runDisutils(optBdistType) else: # use the src dir found based on imports, above _fpSrcDir = fpSrcDir if optRemoveLauncher: removeUnixLauncher(sudoFound) if optWriteLauncher: # will determine optInstallTool # move to /usr/local/bin depending on install too option # create launcher script