ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dankil...@apache.org
Subject incubator-ariatosca git commit: fixes
Date Tue, 29 Nov 2016 09:37:58 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-23-integrate-csar-packager 0612c6bd5 -> d25cb25c0


fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d25cb25c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d25cb25c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d25cb25c

Branch: refs/heads/ARIA-23-integrate-csar-packager
Commit: d25cb25c0b2c3b810be25b662e1a7605cb84bd08
Parents: 0612c6b
Author: Dan Kilman <dank@gigaspaces.com>
Authored: Tue Nov 29 11:37:54 2016 +0200
Committer: Dan Kilman <dank@gigaspaces.com>
Committed: Tue Nov 29 11:37:54 2016 +0200

----------------------------------------------------------------------
 aria/cli/csar.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d25cb25c/aria/cli/csar.py
----------------------------------------------------------------------
diff --git a/aria/cli/csar.py b/aria/cli/csar.py
index ae3720d..292692d 100644
--- a/aria/cli/csar.py
+++ b/aria/cli/csar.py
@@ -43,7 +43,7 @@ def write(source, entry, destination, logger):
     entry_definitions = os.path.join(source, entry)
     meta_file = os.path.join(source, META_FILE)
     if not os.path.isdir(source):
-        raise ValueError('{0} is not a directory. Please specify the service template'
+        raise ValueError('{0} is not a directory. Please specify the service template '
                          'directory.'.format(source))
     if not os.path.isfile(entry_definitions):
         raise ValueError('{0} does not exists. Please specify a valid entry point.'
@@ -52,7 +52,7 @@ def write(source, entry, destination, logger):
         raise ValueError('{0} already exists. Please provide a path to where the CSAR should
be '
                          'created.'.format(destination))
     if os.path.exists(meta_file):
-        raise ValueError('{0} already exists. This commands generates a meta file for you.
Please'
+        raise ValueError('{0} already exists. This commands generates a meta file for you.
Please '
                          'remove the existing metafile.'.format(meta_file))
     metadata = BASE_METADATA.copy()
     metadata[META_ENTRY_DEFINITIONS_KEY] = entry
@@ -71,9 +71,10 @@ def write(source, entry, destination, logger):
 class _CSARReader(object):
 
     def __init__(self, source, destination, logger):
-        if os.path.exists(destination):
-            raise ValueError('{0} already exists. Please specify the location where the CSAR
should'
-                             'be extracted.'.format(destination))
+        if os.path.isdir(destination) and os.listdir(destination):
+            raise ValueError('{0} already exists and is not empty. '
+                             'Please specify the location where the CSAR '
+                             'should be extracted.'.format(destination))
         downloaded_csar = '://' in source
         if downloaded_csar:
             fd, download_target = tempfile.mkstemp()
@@ -120,7 +121,8 @@ class _CSARReader(object):
 
     def _extract(self):
         self.logger.debug('Extracting CSAR contents')
-        os.mkdir(self.destination)
+        if not os.path.exists(self.destination):
+            os.mkdir(self.destination)
         with zipfile.ZipFile(self.source) as f:
             f.extractall(self.destination)
         self.logger.debug('CSAR contents successfully extracted')
@@ -150,8 +152,8 @@ class _CSARReader(object):
         self.logger.debug('CSAR entry definitions: {0}'.format(self.entry_definitions))
         entry_definitions_path = os.path.join(self.destination, self.entry_definitions)
         if not os.path.isfile(entry_definitions_path):
-            raise ValueError('The entry definitions {0} referenced by the metadata file does
not'
-                             'exists.'.format(entry_definitions_path))
+            raise ValueError('The entry definitions {0} referenced by the metadata file does
not '
+                             'exist.'.format(entry_definitions_path))
 
     def _download(self, url, target):
         response = requests.get(url, stream=True)


Mime
View raw message