From e3805a6410b5cd26118e676b1fbe6a7a1eedc671 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Tue, 4 Nov 2014 15:15:04 +0100 Subject: [PATCH] Support for server side file unzipping --- webservice/bam/application/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/webservice/bam/application/__init__.py b/webservice/bam/application/__init__.py index 6a8382d..8990ecf 100644 --- a/webservice/bam/application/__init__.py +++ b/webservice/bam/application/__init__.py @@ -177,10 +177,16 @@ class FileAPI(Resource): # and all the next steps could be done in another loop, or triggered again via # another request filename = werkzeug.secure_filename(file.filename) - #file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + tmp_filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) + file.save(tmp_filepath) # 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 + fh = open(tmp_filepath, 'rb') + z = zipfile.ZipFile(fh) + z.extractall(os.path.splitext(tmp_filepath)[0]) + fh.close() # TODO, dry run commit (using committ message) # Seems not easily possible with SVN @@ -189,9 +195,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)