ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject incubator-ariatosca git commit: More fixes for Windows
Date Wed, 08 Feb 2017 17:21:19 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-99-e2e-tests 344e3caa9 -> e6695d517


More fixes for Windows


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

Branch: refs/heads/ARIA-99-e2e-tests
Commit: e6695d51737e83d95acd9019341c3dfd5595f2cb
Parents: 344e3ca
Author: Tal Liron <tal.liron@gmail.com>
Authored: Wed Feb 8 11:20:37 2017 -0600
Committer: Tal Liron <tal.liron@gmail.com>
Committed: Wed Feb 8 11:20:37 2017 -0600

----------------------------------------------------------------------
 aria/cli/cli.py                 |  4 +++-
 aria/parser/loading/request.py  |  9 +++++++--
 aria/parser/loading/uri.py      |  5 +++--
 aria/storage/filesystem_rapi.py |  2 +-
 aria/utils/uris.py              | 11 +++++++----
 5 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e6695d51/aria/cli/cli.py
----------------------------------------------------------------------
diff --git a/aria/cli/cli.py b/aria/cli/cli.py
index 20ace2c..8d014b3 100644
--- a/aria/cli/cli.py
+++ b/aria/cli/cli.py
@@ -17,7 +17,9 @@
 CLI Entry point
 """
 
+import os
 import logging
+import tempfile
 
 from .. import install_aria_extensions
 from ..logger import (
@@ -100,7 +102,7 @@ def main():
     create_logger(
         handlers=[
             create_console_log_handler(),
-            create_file_log_handler(file_path='/tmp/aria_cli.log'),
+            create_file_log_handler(file_path=os.path.join(tempfile.gettempdir(), 'aria_cli.log')),
         ],
         level=logging.INFO)
     with AriaCli() as aria:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e6695d51/aria/parser/loading/request.py
----------------------------------------------------------------------
diff --git a/aria/parser/loading/request.py b/aria/parser/loading/request.py
index 6ebabfc..a809347 100644
--- a/aria/parser/loading/request.py
+++ b/aria/parser/loading/request.py
@@ -13,8 +13,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import os
+import tempfile
+
 from requests import Session
-from requests.exceptions import ConnectionError
+from requests.exceptions import (ConnectionError, InvalidSchema)
 from cachecontrol import CacheControl
 from cachecontrol.caches import FileCache
 
@@ -22,7 +25,7 @@ from .exceptions import LoaderException, DocumentNotFoundException
 from .loader import Loader
 
 SESSION = None
-SESSION_CACHE_PATH = '/tmp'
+SESSION_CACHE_PATH = os.path.join(tempfile.gettempdir(), 'aria_requests')
 
 
 class RequestLoader(Loader):
@@ -53,6 +56,8 @@ class RequestLoader(Loader):
 
         try:
             self._response = SESSION.get(self.uri, headers=self.headers)
+        except InvalidSchema as e:
+            raise DocumentNotFoundException('document not found: "%s"' % self.uri, cause=e)
         except ConnectionError as e:
             raise LoaderException('request connection error: "%s"' % self.uri, cause=e)
         except Exception as e:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e6695d51/aria/parser/loading/uri.py
----------------------------------------------------------------------
diff --git a/aria/parser/loading/uri.py b/aria/parser/loading/uri.py
index f0cde3a..1b23bf6 100644
--- a/aria/parser/loading/uri.py
+++ b/aria/parser/loading/uri.py
@@ -66,8 +66,9 @@ class UriTextLoader(Loader):
         except DocumentNotFoundException:
             # Try prefixes in order
             for prefix in self._prefixes:
-                if as_file(prefix) is not None:
-                    uri = os.path.join(prefix, self.location.uri)
+                prefix_as_file = as_file(prefix)
+                if prefix_as_file is not None:
+                    uri = os.path.join(prefix_as_file, self.location.uri)
                 else:
                     uri = urljoin(prefix, self.location.uri)
                 try:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e6695d51/aria/storage/filesystem_rapi.py
----------------------------------------------------------------------
diff --git a/aria/storage/filesystem_rapi.py b/aria/storage/filesystem_rapi.py
index eb30e0b..6693dbd 100644
--- a/aria/storage/filesystem_rapi.py
+++ b/aria/storage/filesystem_rapi.py
@@ -17,10 +17,10 @@ SQLalchemy based RAPI
 """
 import os
 import shutil
+from multiprocessing import RLock
 from contextlib import contextmanager
 from functools import partial
 from distutils import dir_util                                # https://github.com/PyCQA/pylint/issues/73;
pylint: disable=no-name-in-module
-from multiprocessing import RLock
 
 from aria.storage import (
     api,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e6695d51/aria/utils/uris.py
----------------------------------------------------------------------
diff --git a/aria/utils/uris.py b/aria/utils/uris.py
index 8c531f7..5f7bcf5 100644
--- a/aria/utils/uris.py
+++ b/aria/utils/uris.py
@@ -27,15 +27,18 @@ def as_file(uri):
     """
 
     if _IS_WINDOWS:
-        # We need this extra check in Windows because paths might have a drive prefix, e.g.
"C:",
-        # which will be considered a scheme for urlparse
-        path = uri.replace('/', os.path.sep)
+        # We need this extra check in Windows before urlparse because paths might have a
drive
+        # prefix, e.g. "C:" which will be considered a scheme for urlparse below
+        path = uri.replace('/', '\\')
         if os.path.exists(path):
             return os.path.normpath(path)
 
     url = urlparse.urlparse(uri)
     scheme = url.scheme
     if (not scheme) or (scheme == 'file'):
-        return os.path.normpath(url.path)
+        path = url.path
+        if _IS_WINDOWS:
+            path = path.replace('/', '\\')
+        return os.path.normpath(path)
 
     return None


Mime
View raw message