def test_zipdir(self): """ Tests the zipdir function :return: """ testdatadir = os.path.join(os.path.dirname(__file__), '__testdata__') src_path = os.path.join(testdatadir, 'zipthisfolder') target_path = os.path.join(testdatadir, 'result.zip') utils.zipdir(src_path, target_path) self.assertTrue(os.path.exists(target_path))
def export_data_dir(target_path): """ Exports the media files of the application and bundles a zip archive :return: the target path of the zip archive """ from django_productline import utils from django.conf import settings utils.zipdir(settings.PRODUCT_CONTEXT.DATA_DIR, target_path, wrapdir='__data__') print('... wrote {target_path}'.format(target_path=target_path)) return target_path
def test_zipdir(self): """ Tests the zipdir function :return: """ testdatadir = os.path.join(os.path.dirname(__file__), '__testdata__') zipthisfolder = os.path.join(testdatadir, 'zipthisfolder') os.makedirs(zipthisfolder) os.mknod(os.path.join(zipthisfolder, 'file')) src_path = os.path.join(testdatadir, 'zipthisfolder') target_path = os.path.join(testdatadir, 'result.zip') utils.zipdir(src_path, target_path) self.assertTrue(os.path.exists(target_path)) shutil.rmtree(zipthisfolder) os.remove(target_path)
def export_data_dir(): """ Exports the media files of the application and bundles a zip archive :return: the target path of the zip archive """ from django_productline import utils from django.conf import settings import time tasks.create_export_dir() print('*** Exporting DATA_DIR') filename = '{number}.zip'.format( number=time.time() ) target_path = os.path.join(settings.EXPORT_DIR, filename) utils.zipdir(settings.PRODUCT_CONTEXT.DATA_DIR, target_path, wrapdir='__data__') print('... wrote {target_path}'.format(target_path=target_path)) return target_path