From 8015f0d1060b283d39ac2de8ac09ba5cd1d67180 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Tue, 4 Nov 2014 18:53:55 +0100 Subject: [PATCH] Unzipping, copying and committing server side --- webservice/bam/application/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/webservice/bam/application/__init__.py b/webservice/bam/application/__init__.py index d1f4b86..416ef85 100644 --- a/webservice/bam/application/__init__.py +++ b/webservice/bam/application/__init__.py @@ -183,9 +183,18 @@ class FileAPI(Resource): # TODO, once all files are uploaded, unpack and run the tasklist (copy, add, remove # files on a filesystem level and subsequently as svn commands) import zipfile + + tmp_extracted_folder = os.path.splitext(tmp_filepath)[0] with open(tmp_filepath, 'rb') as zipped_file: z = zipfile.ZipFile(zipped_file) - z.extractall(os.path.splitext(tmp_filepath)[0]) + z.extractall(tmp_extracted_folder) + + with open(os.path.join(tmp_extracted_folder, '.bam_paths_remap.json'), 'r') as path_remap: + path_remap = json.load(path_remap) + + import shutil + for source_file_path, destination_file_pah in path_remap.items(): + shutil.move(os.path.join(tmp_extracted_folder, source_file_path), destination_file_pah) # TODO, dry run commit (using committ message) # Seems not easily possible with SVN @@ -194,9 +203,9 @@ class FileAPI(Resource): combine=True) # Commit command - # result = local_client.run_command('commit', - # [local_client.info()['entry_path'], '--message', arguments['message']], - # combine=True) + result = local_client.run_command('commit', + [local_client.info()['entry_path'], '--message', arguments['message']], + combine=True) print(result)