예제 #1
0
def copyDir(path):
    if not os.path.exists(path):
        print (text.folderDoesNotExist.format(path))
    else:
        split = filter(None, path.split("/"))
        createPath(split[:-1])
        ccopy.copy(path,  getRootDir.getEnvsDir() + getEnvName() + "/" + path)
예제 #2
0
파일: ls.py 프로젝트: Max00355/Coffer
def ls():
    print (text.availableEnvironments)
    check = os.listdir(getRootDir.getEnvsDir())
    if len(check) == 0:
        print (text.noEnvs)
    else:
        print ('\n'.join(check) + "\n")
예제 #3
0
def copyDir(path):
    if not os.path.exists(path):
        six.print_((text.folderDoesNotExist.format(path)))
    else:
        split = filter(None, path.split("/"))
        createPath(split[:-1])
        ccopy.copy(path, getRootDir.getEnvsDir() + getEnvName() + "/" + path)
예제 #4
0
def ls():
    print(text.availableEnvironments)
    check = os.listdir(getRootDir.getEnvsDir())
    if len(check) == 0:
        print(text.noEnvs)
    else:
        print('\n'.join(check) + "\n")
예제 #5
0
def executeCommand(command):
    cwd = os.getcwd()
    rr = os.open("/", os.O_RDONLY)
    os.chroot(getRootDir.getEnvsDir() + getEnvName())
    os.chdir("/")
    os.system(command)
    os.fchdir(rr)
    os.chroot(".")
    os.chdir(cwd)
예제 #6
0
def executeCommand(command):
    cwd = os.getcwd()
    rr = os.open("/", os.O_RDONLY)
    os.chroot(getRootDir.getEnvsDir() + getEnvName())
    os.chdir("/")
    os.system(command)
    os.fchdir(rr)
    os.chroot(".")
    os.chdir(cwd)
예제 #7
0
def clone():
    if len(sys.argv) < 4:
        sys.exit(text.cloneHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)

    name = getArg.getArg(0)
    clone = getArg.getArg(1)

    path = getRootDir.getEnvsDir() + name
    clonePath = getRootDir.getEnvsDir() + clone

    if not envExists(path):
        sys.exit(text.envDoesntExistVar.format(name))
    if envExists(clonePath):
        sys.exit(text.envAlreadyExistsVar.format(clone))
    remove.unmountAll(path)
    copyEnv(path, clonePath)
    print(text.cloned)
예제 #8
0
파일: package.py 프로젝트: Max00355/Coffer
def package():
    rootDir = getRootDir.getEnvsDir()
    env = getArg.getArg(0)

    if not env:
        sys.exit(text.packageHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    if not remove.checkIfExists(rootDir + env):
        sys.exit(text.envDoesntExist)
    
    remove.unmountAll(rootDir + env)
    compress(rootDir + env, env)
    print(text.packaged)
예제 #9
0
def package():
    rootDir = getRootDir.getEnvsDir()
    env = getArg.getArg(0)

    if not env:
        sys.exit(text.packageHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    if not remove.checkIfExists(rootDir + env):
        sys.exit(text.envDoesntExist)

    remove.unmountAll(rootDir + env)
    compress(rootDir + env, env)
    print(text.packaged)
예제 #10
0
def remove():
    rootDir = getRootDir.getEnvsDir()

    name = getArg.getArg(0)

    if not name:
        sys.exit(text.removeHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    if not checkIfExists(rootDir + name):
        sys.exit(text.envDoesntExist)
    unmountAll(rootDir + name)
    removeDir(rootDir + name)
    print (text.removed)
예제 #11
0
파일: create.py 프로젝트: kant/Coffer
def create():
    root = getRootDir.getEnvsDir()
    template = getFlag.getFlag("-t")
    name = getArg.getArg(0)
    if not name:
        sys.exit(text.createHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    path = root + name
    if not createDir(path):
        sys.exit(text.envAlreadyExists)
    copyBaseFiles(path)
    if template:
        executeTemplate(template)
    print(text.envCreated)
예제 #12
0
파일: create.py 프로젝트: Max00355/Coffer
def create():
    root = getRootDir.getEnvsDir()
    template = getFlag.getFlag("-t")
    name = getArg.getArg(0)
    if not name:
        sys.exit(text.createHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    path = root + name
    if not createDir(path):
        sys.exit(text.envAlreadyExists)
    copyBaseFiles(path)
    if template:
        executeTemplate(template)
    print (text.envCreated)
예제 #13
0
파일: setupEnv.py 프로젝트: Max00355/Coffer
def setup():
    root = getRootDir.getCofferDir()
    envs = getRootDir.getEnvsDir()
    os.mkdir(root)
    os.mkdir(envs)
    print (text.downloadingFiles)
    deboot = urllib.urlopen("https://github.com/f-prime/Coffer/blob/master/coffer/deps/debootstrap.tar.gz?raw=true").read()
    path = root + "deboot.tar"
    with open(path, 'wb') as tarf:
        tarf.write(deboot)
    tarfile.open(path).extractall(path=root)
    os.rename(root + "debootstrap-1.0.106", root + "debootstrap") 
    os.remove(path)
    edit = open(root + "debootstrap/debootstrap").read()
    edit = "DEBOOTSTRAP_DIR={}\n".format(root + "debootstrap") + edit
    with open(root + "debootstrap/debootstrap", 'w') as w:
        w.write(edit) 
예제 #14
0
파일: unpackage.py 프로젝트: kant/Coffer
def unpackage():
    rootDir = getRootDir.getEnvsDir()
    compressed = getArg.getArg(0)

    if not compressed:
        sys.exit(text.unpackageHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    if not remove.checkIfExists(compressed):
        sys.exit(text.packageDoesntExist)

    env = compressed.split("/")[-1].split(".")[0]

    if remove.checkIfExists(rootDir + env):
        sys.exit(text.envAlreadyExists)

    decompress(compressed, rootDir + env)
    print(text.unpackagedSuccessful)
예제 #15
0
def unpackage():
    rootDir = getRootDir.getEnvsDir()
    compressed = getArg.getArg(0)

    if not compressed:
        sys.exit(text.unpackageHelper)
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    if not remove.checkIfExists(compressed):
        sys.exit(text.packageDoesntExist)

    env = compressed.split("/")[-1].split(".")[0]

    if remove.checkIfExists(rootDir + env):
        sys.exit(text.envAlreadyExists)

    decompress(compressed, rootDir + env)
    print (text.unpackagedSuccessful)
예제 #16
0
파일: rename.py 프로젝트: Max00355/Coffer
def rename():
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    root = getRootDir.getEnvsDir()
    
    name = getArg.getArg(0)
    newName = getArg.getArg(1)

    if not name or not newName:
        sys.exit(text.renameHelper)

    if not os.path.exists(root + name):
        sys.exit(text.envDoesntExist)

    if os.path.exists(root + newName):
        sys.exit(text.nameAlreadyExists)
    remove.unmountAll(root + name)
    renameDir(root + name, root + newName)
    sys.exit(text.renameSuccessful)
예제 #17
0
def rename():
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    root = getRootDir.getEnvsDir()

    name = getArg.getArg(0)
    newName = getArg.getArg(1)

    if not name or not newName:
        sys.exit(text.renameHelper)

    if not os.path.exists(root + name):
        sys.exit(text.envDoesntExist)

    if os.path.exists(root + newName):
        sys.exit(text.nameAlreadyExists)
    remove.unmountAll(root + name)
    renameDir(root + name, root + newName)
    sys.exit(text.renameSuccessful)
예제 #18
0
파일: enter.py 프로젝트: Max00355/Coffer
def enter():
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    rootDir = getRootDir.getEnvsDir()
    name = getArg.getArg(0)
    if not name:
        sys.exit(text.enterHelper)
    template = getFlag.getFlag("-t")
    if template:
        create.executeTemplate(template)
    path = rootDir + name
    if not os.path.exists(path):
        sys.exit(text.envDoesntExist)
    checkMount(path) 
    enterChroot(path)
    command = getFlag.getFlag("-c")
    if command:
        executeCommand(command=command)
    else:
        executeCommand()
예제 #19
0
파일: enter.py 프로젝트: kant/Coffer
def enter():
    if not isRoot.isRoot():
        sys.exit(text.notRoot)
    rootDir = getRootDir.getEnvsDir()
    name = getArg.getArg(0)
    if not name:
        sys.exit(text.enterHelper)
    template = getFlag.getFlag("-t")
    if template:
        create.executeTemplate(template)
    path = rootDir + name
    if not os.path.exists(path):
        sys.exit(text.envDoesntExist)
    checkMount(path)
    enterChroot(path)
    command = getFlag.getFlag("-c")
    if command:
        executeCommand(command=command)
    else:
        executeCommand()
예제 #20
0
def setup():
    root = getRootDir.getCofferDir()
    envs = getRootDir.getEnvsDir()
    os.mkdir(root)
    os.mkdir(envs)
    six.print_((text.downloadingFiles))
    deboot = urlopen("http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.81~bpo8+1.tar.gz")
    path = root + "deboot.tar"
    with open(path, 'wb') as tarf:
        tarf.write(deboot)
    tarfile.open(path).extractall(path=root)
    os.remove(path)
    edit = open(root + "debootstrap/debootstrap").readlines()
    edit[487] = "#" + edit[487]
    edit[488] = "#" + edit[488]
    edit[489] = "#" + edit[489]
    edit = "".join(edit)
    edit = "DEBOOTSTRAP_DIR={}\n".format(root + "debootstrap") + edit
    with open(root + "debootstrap/debootstrap", 'w') as w:
        w.write(edit) 
예제 #21
0
def createPath(path):
    root = getRootDir.getEnvsDir() + getEnvName() + "/" 
    for p in path:
        root += "/" + p
        if not os.path.exists(root):
            os.mkdir(root)
예제 #22
0
def copyDep(dep):
    root = getRootDir.getEnvsDir() + getEnvName()
    shutil.copy(dep, root + dep)
예제 #23
0
def createPath(path):
    root = getRootDir.getEnvsDir() + getEnvName() + "/"
    for p in path:
        root += "/" + p
        if not os.path.exists(root):
            os.mkdir(root)
예제 #24
0
def copyDep(dep):
    root = getRootDir.getEnvsDir() + getEnvName()
    shutil.copy(dep, root + dep)