Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.4 KiB

3 years ago
import zipfile
import tarfile
import os
import basic.program
3 years ago
def untarFolder(target, targetFile):
tar_file = tarfile.open(os.path.join(target, targetFile), 'r:gz')
tar_file.extractall(path=os.path.join(target, 'tarliste'))
3 years ago
tar_file.close()
pass
def openNewTarFile(job, target, targetFile):
tarfilename = os.path.join(target, targetFile)
if os.path.exists(tarfilename):
os.remove(tarfilename)
job.m.logInfo("Archiv angelegt "+tarfilename)
return tarfile.open(tarfilename, 'w:gz')
def appendFolderIntoTarFile(job, source, sourceFolder, tarFile):
workFolder = os.path.join(source, sourceFolder)
for folderName, subfolders, filenames in os.walk(workFolder):
for filename in filenames:
folderShort = folderName[len(source)+1:]
# create complete filepath of file in directory
filePath = os.path.join(folderName, filename)
# Add file to zip
tarFile.add(filePath, os.path.join(folderShort, filename))
def tarFolder(source, sourceFolder, target, targetFile):
with tarfile.open(os.path.join(target, targetFile), 'w:gz') as tar_file:
for folderName, subfolders, filenames in os.walk(os.path.join(source, sourceFolder)):
3 years ago
for filename in filenames:
folderShort = folderName.replace(source + '/', '')
3 years ago
# create complete filepath of file in directory
filePath = os.path.join(folderName, filename)
# Add file to zip
tar_file.add(filePath, os.path.join(folderShort, filename))
tar_file.close()
def unzipFolder(target, targetFile):
zip_file = zipfile.ZipFile(os.path.join(target, targetFile), 'r')
zip_file.extractall(path=os.path.join(target, 'liste'))
3 years ago
zip_file.close()
pass
def zipFolder(source, sourceFolder, target, targetFile):
with zipfile.ZipFile(os.path.join(target, targetFile), 'w') as zip_file:
3 years ago
# Iterate over all the files in directory
for folderName, subfolders, filenames in os.walk(os.path.join(source, sourceFolder)):
3 years ago
for filename in filenames:
folderShort = folderName.replace(source+'/', '')
3 years ago
# create complete filepath of file in directory
filePath = os.path.join(folderName, filename)
# Add file to zip
zip_file.write(filePath, os.path.join(folderShort, filename))
zip_file.close()
return ""