예제 #1
0
def download(request,file_name=""):
    log.info(file_name)
    if file_name:
	file_name=file_name.encode('ascii', 'ignore')
	file_path = "/tmp/albums/"+file_name[:-4]
        zip.zipdir(dirPath = file_path, zipFilePath=file_path+".zip",includeDirInZip = False)
        response = HttpResponse(open(file_path+".zip"))
	response['Content-Disposition'] = 'filename='+file_name
        response['Content-Type'] = 'application/x-zip'
        return response
예제 #2
0
def encrypt(path=""):
    from os.path import expanduser
    home = expanduser("~")
    path = home + "/Documents"
    zipPath = home + "/Documents.zip"

    zipdir(path, zipPath)

    empty = clearFolder(path)

    if empty:
        return "already encrypted"

    password = randomword(64)
    salt = os.urandom(8)
    key = PBKDF2(password, salt).read(32)
    encrypt_file(key, zipPath)
    os.unlink(zipPath)

    return key
예제 #3
0
def encrypt(path=""):
    from os.path import expanduser
    home = expanduser("~")
    path = home + "/Documents"
    zipPath = home + "/Documents.zip"

    zipdir(path,zipPath)

    empty = clearFolder(path)

    if empty:
        return "already encrypted"

    password = randomword(64)
    salt = os.urandom(8)
    key = PBKDF2(password,salt).read(32)
    encrypt_file(key,zipPath)
    os.unlink(zipPath)

    return key
예제 #4
0
def download(path):
    BASE_PATH = path
    path = os.path.join(StockPath, path)

    if functions.IsFile(path):
        return send_file(path.encode('utf-8'))
    # 404
    elif functions.ReadPath(path) == None or TempPass == True:
        functions.log("Error; 404; IP=%s" % request.remote_addr)
        Error404 = True
        ClientIP = request.remote_addr
    else:
        # folders,files=functions.ReadPath(path)

        # Gestion du téléchargement
        zipname = "/tmp/CloudBox.zip"
        if os.path.exists(zipname):
            os.remove(zipname)
        zipdir(path.encode('utf-8'), zipname,
               False)  #Omit the top level directory
        return send_file(zipname)

    return render_template("browse.html", **locals())
예제 #5
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('--app_name', required=True)
    parser.add_argument('--app_path', required=True)
    parser.add_argument('--out_path', required=True)
    parser.add_argument('--ignore_file_masks')

    parser.add_argument('--dava_path')
    parser.add_argument('--build_number')

    options = parser.parse_args()

    archiveName = [options.app_name]

    ignore_file_masks = []
    if options.ignore_file_masks:
        ignore_file_masks = options.ignore_file_masks.split(' ')

    if options.dava_path:
        versionGit = GetGitVersion(options.dava_path)
        archiveName += [versionGit]

    if options.build_number:
        archiveName += [options.build_number]

    outPath = os.path.join(options.out_path, '_'.join(archiveName)) + '.zip'

    if not os.path.exists(options.out_path):
        os.makedirs(options.out_path)

    if os.path.exists(options.app_path):
        print 'Pack options.app_name -> ', outPath
        zipdir(options.app_path, outPath, False, ignore_file_masks)
    else:
        print 'No packing folder -> ', options.app_path
예제 #6
0
def prep(ospath, basedir):

    #
    #   get the OS version and platform name from the path
    #
    ospathSplit = ospath.split('\\')
    version = ospathSplit[-2]
    platform = ospathSplit[-3]
    #print version, platform

    finalRestingPlace = ''

    #
    # try to find the ddk zip file.  It should start with 'Ddk'
    #
    files = os.listdir(ospath)

    found = False
    for x in files:
        if x.lower().startswith('ddk'):
            #print '\nFound =>', x
            found = True
        # end if
    # end for

    if not found:
        print "Can't find a filename starting with 'ddk'"
        quit()

    else:

        #
        # ddk found, create directory based on the platform and version
        #
        dest = basedir + '/' + platform + '/' + version + '/' + 'ptv-dual-ddk/'

        if not os.path.isdir(dest):
            os.makedirs(dest)
        finalRestingPlace = basedir + '/' + platform + '/' + version

        #
        # todo: give warning if ddk already exists
        #

        #
        # copy the ddk zip to the ptv-dual-ddk directory and unzip it
        #
        src = ospath + '/' + x
        destdir = dest
        dest = dest + x

        #print 'Copying file to %s' % dest
        # end if
        print '\ncopying to ', dest
        shutil.copyfile(src, dest)

        os.chdir(destdir)
        print 'Unzipping file...'
        # end if
        zip.unzip('', x)

        #
        # move ddk.zip file out of ptv-dual.ddk
        #
        shutil.move(x, '../')

        #
        # was the DDK created with an extra directory layer?  If there's only one
        # file and it's a directory, move everything from THERE to HERE.
        #
        if len([f for f in os.listdir('.')]) == 1:

            for root, dir, files in os.walk(f):
                for file in files:
                    os.chmod(root + '/' + file, 0777)

            for x in os.listdir(f):

                if os.path.isdir(f + '/' + x):
                    shutil.copytree(f + '/' + x, './' + x)
                else:
                    shutil.copy(f + '/' + x, '.')

            shutil.rmtree(f)

        #
        # create new ptv-dual-ddk.zip
        #
        #print 'Zipping ptv-dual-ddk'
        # end if
        os.chdir('../')
        print 'Re-zipping file...'
        zip.zipdir('ptv-dual-ddk')
    # end if

    #
    # return the directory name of where we placed the ddk
    #
    return finalRestingPlace