Repository: incubator-ariatosca
Updated Branches:
  refs/heads/cli-tests f4a3f5257 -> d2953788e (forced update)


fixed simple review comments


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

Branch: refs/heads/cli-tests
Commit: 5dc3a58b58d2859939676af9861ab2d518de39d7
Parents: d6458c0
Author: Ran Ziv <[email protected]>
Authored: Thu Apr 13 17:43:29 2017 +0300
Committer: Ran Ziv <[email protected]>
Committed: Thu Apr 13 17:43:29 2017 +0300

----------------------------------------------------------------------
 aria/cli/cli/aria.py                        |  42 +++----
 aria/cli/cli/helptexts.py                   |   1 -
 aria/cli/colorful_event.py                  | 152 -----------------------
 aria/cli/commands/executions.py             |   4 +-
 aria/cli/commands/service_templates.py      |  18 +--
 aria/cli/constants.py                       |   2 +-
 aria/cli/csar.py                            |   2 +-
 aria/cli/env.py                             |   4 +-
 aria/cli/inputs.py                          |  16 +--
 aria/cli/service_template_utils.py          |  10 +-
 aria/cli/utils.py                           |   6 +-
 aria/core.py                                |  21 ++--
 aria/modeling/service_common.py             |  14 +--
 aria/modeling/service_template.py           |   1 -
 aria/modeling/utils.py                      |   5 +-
 aria/orchestrator/workflows/exceptions.py   |  10 +-
 aria/orchestrator/workflows/executor/dry.py |   8 +-
 aria/storage/instrumentation.py             |   7 +-
 aria/utils/formatting.py                    |  15 ---
 tests/cli/test_service_templates.py         |   2 +-
 tests/mock/models.py                        |   7 +-
 tests/utils/test_threading.py               |  20 ++-
 22 files changed, 94 insertions(+), 273 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/cli/aria.py
----------------------------------------------------------------------
diff --git a/aria/cli/cli/aria.py b/aria/cli/cli/aria.py
index 0177134..002846b 100644
--- a/aria/cli/cli/aria.py
+++ b/aria/cli/cli/aria.py
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 
+import os
 import sys
 import difflib
 import StringIO
@@ -22,10 +23,13 @@ from functools import wraps
 
 import click
 
-from ..env import env, logger
+from ..env import (
+    env,
+    logger
+)
 from ..cli import helptexts
 from ..inputs import inputs_to_dict
-from ..constants import SAMPLE_SERVICE_TEMPLATE_FILENAME
+from ..constants import DEFAULT_SERVICE_TEMPLATE_FILENAME
 from ...utils.exceptions import get_exception_as_string
 
 
@@ -238,8 +242,8 @@ class AliasedGroup(click.Group):
                 self.max_suggestions,
                 self.cutoff)
             if matches:
-                error_msg += '\n\nDid you mean one of these?\n    {0}'.format(
-                    '\n    '.join(matches))
+                error_msg += '{1}{1}Did you mean one of these?{1}    
{0}'.format(
+                    '{1}    '.join(matches, os.linesep))
             raise click.exceptions.UsageError(error_msg, error.ctx)
 
 
@@ -339,6 +343,12 @@ class Options(object):
             default=False,
             help=helptexts.DESCENDING)
 
+        self.service_template_filename = click.option(
+            '-n',
+            '--service-template-filename',
+            default=DEFAULT_SERVICE_TEMPLATE_FILENAME,
+            help=helptexts.SERVICE_TEMPLATE_FILENAME)
+
     @staticmethod
     def verbose(expose_value=False):
         return click.option(
@@ -359,30 +369,6 @@ class Options(object):
             help=help)
 
     @staticmethod
-    def service_template_filename():
-        return click.option(
-            '-n',
-            '--service-template-filename',
-            default=SAMPLE_SERVICE_TEMPLATE_FILENAME,
-            help=helptexts.SERVICE_TEMPLATE_FILENAME)
-
-    @staticmethod
-    def workflow_id(default):
-        return click.option(
-            '-w',
-            '--workflow-id',
-            default=default,
-            help=helptexts.WORKFLOW_TO_EXECUTE.format(default))
-
-    @staticmethod
-    def task_thread_pool_size(default=1):
-        return click.option(
-            '--task-thread-pool-size',
-            type=int,
-            default=default,
-            help=helptexts.TASK_THREAD_POOL_SIZE.format(default))
-
-    @staticmethod
     def task_max_attempts(default=1):
         return click.option(
             '--task-max-attempts',

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/cli/helptexts.py
----------------------------------------------------------------------
diff --git a/aria/cli/cli/helptexts.py b/aria/cli/cli/helptexts.py
index 0d66d6b..c50a172 100644
--- a/aria/cli/cli/helptexts.py
+++ b/aria/cli/cli/helptexts.py
@@ -22,7 +22,6 @@ INPUTS_PARAMS_USAGE = (
     '(*.yaml, /my_inputs/, etc..) to YAML files, a JSON string or as '
     'key1=value1;key2=value2). This argument can be used multiple times'
 )
-WORKFLOW_TO_EXECUTE = "The workflow to execute [default: {0}]"
 
 SERVICE_TEMPLATE_PATH = "The path to the application's service template file"
 SERVICE_TEMPLATE_ID = "The unique identifier for the service template"

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/colorful_event.py
----------------------------------------------------------------------
diff --git a/aria/cli/colorful_event.py b/aria/cli/colorful_event.py
deleted file mode 100644
index 53e3d02..0000000
--- a/aria/cli/colorful_event.py
+++ /dev/null
@@ -1,152 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from contextlib import contextmanager
-
-from colorama import Fore, Style
-
-from cloudify.event import Event
-
-
-def colorful_property(prop):
-    """
-    A decorator for coloring values of the parent event type properties
-    :param prop: the property to color (should be a method returning a color)
-    :return: a property which colors the value of the parent event type's
-             property with the same name
-    """
-    def _decorator(self):
-        # getting value of property from parent event type
-        val = getattr(super(ColorfulEvent, self), prop.__name__)
-        # getting the desired color
-        color = prop(self)
-        # coloring the value
-        return self._color_message(val, color)
-    return property(_decorator)
-
-
-class ColorfulEvent(Event):
-
-    RESET_COLOR = Fore.RESET + Style.RESET_ALL
-
-    TIMESTAMP_COLOR = Fore.RESET
-    LOG_TYPE_COLOR = Fore.YELLOW
-    EVENT_TYPE_COLOR = Fore.MAGENTA
-    DEPLOYMENT_ID_COLOR = Fore.CYAN
-    OPERATION_INFO_COLOR = Fore.RESET
-    NODE_ID_COLOR = Fore.BLUE
-    SOURCE_ID_COLOR = Fore.BLUE
-    TARGET_ID_COLOR = Fore.BLUE
-    OPERATION_COLOR = Fore.YELLOW
-
-    # colors entire message part according to event type
-    _message_color_by_event_type = {
-        'workflow_started': Style.BRIGHT + Fore.GREEN,
-        'workflow_succeeded': Style.BRIGHT + Fore.GREEN,
-        'workflow_failed': Style.BRIGHT + Fore.RED,
-        'workflow_cancelled': Style.BRIGHT + Fore.YELLOW,
-
-        'sending_task': Fore.RESET,
-        'task_started': Fore.RESET,
-        'task_succeeded': Fore.GREEN,
-        'task_rescheduled': Fore.YELLOW,
-        'task_failed': Fore.RED
-    }
-
-    # colors only the log level part
-    _log_level_to_color = {
-        'INFO': Fore.CYAN,
-        'WARN': Fore.YELLOW,
-        'WARNING': Fore.YELLOW,
-        'ERROR': Fore.RED,
-        'FATAL': Fore.RED
-    }
-
-    _color_context = RESET_COLOR
-
-    @property
-    def operation_info(self):
-        color = self.OPERATION_INFO_COLOR
-
-        with self._nest_colors(color):
-            op_info = super(ColorfulEvent, self).operation_info
-
-        return self._color_message(op_info, color)
-
-    @property
-    def text(self):
-        event_type = super(ColorfulEvent, self).event_type  # might be None
-        color = self._message_color_by_event_type.get(event_type)
-
-        with self._nest_colors(color):
-            msg = super(ColorfulEvent, self).text
-
-        return self._color_message(msg, color)
-
-    @property
-    def log_level(self):
-        lvl = super(ColorfulEvent, self).log_level
-        color = self._log_level_to_color.get(lvl)
-        return self._color_message(lvl, color)
-
-    @colorful_property
-    def timestamp(self):
-        return self.TIMESTAMP_COLOR
-
-    @colorful_property
-    def printable_timestamp(self):
-        return self.TIMESTAMP_COLOR
-
-    @colorful_property
-    def event_type_indicator(self):
-        return self.LOG_TYPE_COLOR if self.is_log_message else \
-            self.EVENT_TYPE_COLOR
-
-    @colorful_property
-    def operation(self):
-        return self.OPERATION_COLOR
-
-    @colorful_property
-    def node_id(self):
-        return self.NODE_ID_COLOR
-
-    @colorful_property
-    def source_id(self):
-        return self.SOURCE_ID_COLOR
-
-    @colorful_property
-    def target_id(self):
-        return self.TARGET_ID_COLOR
-
-    @colorful_property
-    def deployment_id(self):
-        return self.DEPLOYMENT_ID_COLOR
-
-    @contextmanager
-    def _nest_colors(self, nesting_color):
-        prev_color_context = self._color_context
-        if nesting_color:
-            self._color_context = nesting_color
-        yield
-        self._color_context = prev_color_context
-
-    def _color_message(self, val, color):
-        if not val or not color:
-            return val
-
-        return "{0}{1}{2}".format(
-            color,
-            val,
-            self._color_context)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/commands/executions.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 396985a..730fd29 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import os
+
 from .. import utils
 from ..table import print_data
 from ..cli import aria
@@ -152,7 +154,7 @@ def start(workflow_name,
     execution = workflow_runner.execution
     logger.info('Execution has ended with "{0}" 
status'.format(execution.status))
     if execution.status == Execution.FAILED and execution.error:
-        logger.info('Execution error:\n{0}'.format(execution.error))
+        logger.info('Execution error:{0}{1}'.format(os.linesep, 
execution.error))
 
     if dry:
         # remove traces of the dry execution (including tasks, logs, inputs..)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/commands/service_templates.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/service_templates.py 
b/aria/cli/commands/service_templates.py
index e2e21c7..79b2104 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -43,17 +43,17 @@ def service_templates():
 
 @service_templates.command(name='show',
                            short_help='Show service template information')
[email protected]('service-template-id')
[email protected]('service-template-name')
 @aria.options.verbose()
 @aria.pass_model_storage
 @aria.pass_logger
-def show(service_template_id, model_storage, logger):
+def show(service_template_name, model_storage, logger):
     """Show information for a specific service templates
 
-    `SERVICE_TEMPLATE_ID` is the id of the service template to show 
information on.
+    `SERVICE_TEMPLATE_NAME` is the name of the service template to show 
information on.
     """
-    logger.info('Showing service template {0}...'.format(service_template_id))
-    service_template = model_storage.service_template.get(service_template_id)
+    logger.info('Showing service template 
{0}...'.format(service_template_name))
+    service_template = 
model_storage.service_template.get_by_name(service_template_name)
     services = [d.to_dict() for d in service_template.services]
     service_template_dict = service_template.to_dict()
     service_template_dict['#services'] = len(services)
@@ -62,10 +62,12 @@ def show(service_template_id, model_storage, logger):
 
     if service_template_dict['description'] is not None:
         logger.info('Description:')
-        
logger.info('{0}\n'.format(service_template_dict['description'].encode('UTF-8') 
or ''))
+        
logger.info('{0}{1}'.format(service_template_dict['description'].encode('UTF-8')
 or '',
+                                    os.linesep))
 
     logger.info('Existing services:')
-    logger.info('{0}\n'.format([s['name'] for s in services]))
+    logger.info('{0}{1}'.format([s['name'] for s in services],
+                                os.linesep))
 
 
 @service_templates.command(name='list',
@@ -97,7 +99,7 @@ def list(sort_by, descending, model_storage, logger):
 @service_templates.command(name='store',
                            short_help='Store a service template')
 @aria.argument('service-template-path')
[email protected]('service-template-name')
[email protected]_template_filename
 @aria.options.verbose()
 @aria.pass_model_storage
 @aria.pass_resource_storage

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/constants.py
----------------------------------------------------------------------
diff --git a/aria/cli/constants.py b/aria/cli/constants.py
index 67c094d..c68fb5e 100644
--- a/aria/cli/constants.py
+++ b/aria/cli/constants.py
@@ -14,5 +14,5 @@
 # limitations under the License.
 
 
-SAMPLE_SERVICE_TEMPLATE_FILENAME = 'service_template.yaml'
+DEFAULT_SERVICE_TEMPLATE_FILENAME = 'service_template.yaml'
 HELP_TEXT_COLUMN_BUFFER = 5

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/csar.py
----------------------------------------------------------------------
diff --git a/aria/cli/csar.py b/aria/cli/csar.py
index 5ab581b..5bc35ac 100644
--- a/aria/cli/csar.py
+++ b/aria/cli/csar.py
@@ -136,7 +136,7 @@ class _CSARReader(object):
         self.logger.debug('Attempting to parse CSAR metadata YAML')
         with open(csar_metafile) as f:
             self.metadata.update(yaml.load(f))
-        self.logger.debug('CSAR 
metadata:\n{0}'.format(pprint.pformat(self.metadata)))
+        self.logger.debug('CSAR metadata:{0}{1}'.format(os.linesep, 
pprint.pformat(self.metadata)))
 
     def _validate(self):
         def validate_key(key, expected=None):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/env.py
----------------------------------------------------------------------
diff --git a/aria/cli/env.py b/aria/cli/env.py
index 6d02cf5..7fe656f 100644
--- a/aria/cli/env.py
+++ b/aria/cli/env.py
@@ -29,7 +29,7 @@ from ..storage.filesystem_rapi import FileSystemResourceAPI
 ARIA_DEFAULT_WORKDIR_NAME = '.aria'
 
 
-class Environment(object):
+class _Environment(object):
 
     def __init__(self, workdir):
 
@@ -112,7 +112,7 @@ class Environment(object):
         return PluginManager(self.model_storage, self._plugins_dir)
 
 
-env = Environment(os.path.join(
+env = _Environment(os.path.join(
     os.environ.get('ARIA_WORKDIR', os.path.expanduser('~')), 
ARIA_DEFAULT_WORKDIR_NAME))
 
 logger = env.logging.logger

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/inputs.py
----------------------------------------------------------------------
diff --git a/aria/cli/inputs.py b/aria/cli/inputs.py
index 2077b67..78db846 100644
--- a/aria/cli/inputs.py
+++ b/aria/cli/inputs.py
@@ -46,21 +46,21 @@ def inputs_to_dict(resources):
             except AriaCliError:
                 raise AriaCliError(
                     "Invalid input: {0}. It must represent a dictionary. "
-                    "Valid values can be one of:\n "
-                    "- A path to a YAML file\n "
-                    "- A path to a directory containing YAML files\n "
+                    "Valid values can be one of:{1} "
+                    "- A path to a YAML file{1} "
+                    "- A path to a directory containing YAML files{1} "
                     "- A single quoted wildcard based path "
-                    "(e.g. '*-inputs.yaml')\n "
-                    "- A string formatted as JSON/YAML\n "
+                    "(e.g. '*-inputs.yaml'){1} "
+                    "- A string formatted as JSON/YAML{1} "
                     "- A string formatted as key1=value1;key2=value2".format(
-                        resource))
+                        resource, os.linesep))
     return parsed_dict
 
 
 def _parse_single_input(resource):
     try:
         # parse resource as string representation of a dictionary
-        return plain_string_to_dict(resource)
+        return _plain_string_to_dict(resource)
     except AriaCliError:
         input_files = glob.glob(resource)
         parsed_dict = dict()
@@ -98,7 +98,7 @@ def _parse_yaml_path(resource):
     return content
 
 
-def plain_string_to_dict(input_string):
+def _plain_string_to_dict(input_string):
     input_string = input_string.strip()
     input_dict = {}
     mapped_inputs = input_string.split(';')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/service_template_utils.py
----------------------------------------------------------------------
diff --git a/aria/cli/service_template_utils.py 
b/aria/cli/service_template_utils.py
index 7f79668..caeb5c1 100644
--- a/aria/cli/service_template_utils.py
+++ b/aria/cli/service_template_utils.py
@@ -19,11 +19,11 @@ from urlparse import urlparse
 from . import csar
 from . import utils
 from .exceptions import AriaCliError
-from .constants import SAMPLE_SERVICE_TEMPLATE_FILENAME
+from .constants import DEFAULT_SERVICE_TEMPLATE_FILENAME
 from ..utils import archive as archive_utils
 
 
-def get(source, service_template_filename=SAMPLE_SERVICE_TEMPLATE_FILENAME):
+def get(source, service_template_filename=DEFAULT_SERVICE_TEMPLATE_FILENAME):
     """Get a source and return a path to the main service template file
 
     The behavior based on then source argument content is:
@@ -85,7 +85,7 @@ def _get_service_template_file_from_archive(archive, 
service_template_filename):
     if csar.is_csar_archive(archive):
         service_template_file = _extract_csar_archive(archive)
     else:
-        extract_directory = archive_utils.extract_archive(archive)(archive)
+        extract_directory = archive_utils.extract_archive(archive)
         service_template_dir = os.path.join(
             extract_directory,
             os.listdir(extract_directory)[0],
@@ -116,13 +116,13 @@ def _map_to_github_url(source):
     return url
 
 
-def generate_id(service_template_path, 
service_template_filename=SAMPLE_SERVICE_TEMPLATE_FILENAME):
+def generate_id(service_template_path, 
service_template_filename=DEFAULT_SERVICE_TEMPLATE_FILENAME):
     """The name of the service template will be the name of the folder.
     If service_template_filename is provided, it will be appended to the 
folder.
     """
     service_template_id = os.path.split(os.path.dirname(os.path.abspath(
         service_template_path)))[-1]
-    if service_template_filename != SAMPLE_SERVICE_TEMPLATE_FILENAME:
+    if service_template_filename != DEFAULT_SERVICE_TEMPLATE_FILENAME:
         filename, _ = 
os.path.splitext(os.path.basename(service_template_filename))
         service_template_id = (service_template_id + '.' + filename)
     return service_template_id.replace('_', '-')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/cli/utils.py
----------------------------------------------------------------------
diff --git a/aria/cli/utils.py b/aria/cli/utils.py
index 44358ec..fad1b07 100644
--- a/aria/cli/utils.py
+++ b/aria/cli/utils.py
@@ -147,15 +147,15 @@ def generate_progress_handler(file_path, action='', 
max_bar_length=80):
         sys.stdout.write('\r{0} {1} |{2}| {3}%'.format(
             action, file_name, bar, percents))
         if read_bytes >= total_bytes:
-            sys.stdout.write('\n')
+            sys.stdout.write(os.linesep)
 
     return print_progress
 
 
 def handle_storage_exception(e, model_class, name):
     if 'UNIQUE constraint failed' in e.message:
-        msg = 'Could not store {model_class} `{name}`\n' \
+        msg = 'Could not store {model_class} `{name}`{linesep}' \
               'There already a exists a {model_class} with the same name' \
-              .format(model_class=model_class, name=name)
+              .format(model_class=model_class, name=name, linesep=os.linesep)
         raise AriaCliError(msg)
     raise AriaCliError()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/core.py
----------------------------------------------------------------------
diff --git a/aria/core.py b/aria/core.py
index 057f716..0be53c6 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -14,12 +14,7 @@
 # limitations under the License.
 
 from . import exceptions
-from .parser.consumption import (
-    ConsumptionContext,
-    ConsumerChain,
-    Read,
-    Validate,
-    ServiceTemplate)
+from .parser import consumption
 from .parser.loading.location import UriLocation
 from .storage import exceptions as storage_exceptions
 
@@ -72,7 +67,9 @@ class Core(object):
         service_template = 
self.model_storage.service_template.get(service_template_id)
 
         # creating an empty ConsumptionContext, initiating a threadlocal 
context
-        ConsumptionContext()
+        consumption.ConsumptionContext()
+        # setting no autoflush for the duration of instantiation - this helps 
avoid dependency
+        # constraints as they're being set up
         with self.model_storage._all_api_kwargs['session'].no_autoflush:
             service = service_template.instantiate(None, inputs)
 
@@ -109,9 +106,15 @@ class Core(object):
 
     @staticmethod
     def _parse_service_template(service_template_path):
-        context = ConsumptionContext()
+        context = consumption.ConsumptionContext()
         context.presentation.location = UriLocation(service_template_path)
-        ConsumerChain(context, (Read, Validate, ServiceTemplate)).consume()
+        consumption.ConsumerChain(
+            context,
+            (
+                consumption.Read,
+                consumption.Validate,
+                consumption.ServiceTemplate
+            )).consume()
         if context.validation.dump_issues():
             raise exceptions.ParsingError('Failed to parse service template')
         return context

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index 17e0a17..d39c7b7 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -87,8 +87,8 @@ class ParameterBase(TemplateModelMixin):
         if self.description:
             console.puts(context.style.meta(self.description))
 
-    @classmethod
-    def unwrap_dict(cls, parameters_dict):
+    @staticmethod
+    def unwrap_dict(parameters_dict):
         """
         Takes a parameters dict and simplifies it into key-value dict
         :param parameters_dict: a parameter-name to parameter dict
@@ -107,12 +107,10 @@ class ParameterBase(TemplateModelMixin):
         :param description: Description (optional)
         :type description: basestring
         """
-
-        from . import models
-        return models.Parameter(name=name,
-                                type_name=formatting.full_type_name(value),
-                                value=value,
-                                description=description)
+        return cls(name=name,
+                   type_name=formatting.full_type_name(value),
+                   value=value,
+                   description=description)
 
 
 class TypeBase(InstanceModelMixin):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py 
b/aria/modeling/service_template.py
index 6271bf7..8703164 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -289,7 +289,6 @@ class ServiceTemplateBase(TemplateModelMixin):
                                  service_template=self)
         context.modeling.instance = service
 
-        # utils.instantiate_dict(self, service.inputs, self.inputs)
         service.inputs = utils.create_inputs(inputs or {}, self.inputs)
         # TODO: now that we have inputs, we should scan properties and inputs 
and evaluate functions
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index 917f495..91d7b9c 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import os
 from json import JSONEncoder
 from StringIO import StringIO
 
@@ -94,8 +95,8 @@ def _merge_and_validate_inputs(inputs, template_inputs):
     if wrong_type_inputs:
         error_message = StringIO()
         for param_name, param_type in wrong_type_inputs.iteritems():
-            error_message.write('Input "{0}" must be of type {1}\n'.
-                                format(param_name, param_type))
+            error_message.write('Input "{0}" must be of type {1}{2}'
+                                .format(param_name, param_type, os.linesep))
         raise exceptions.InputsOfWrongTypeException(error_message.getvalue())
 
     undeclared_inputs = [input_name for input_name in inputs.keys()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/orchestrator/workflows/exceptions.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/exceptions.py 
b/aria/orchestrator/workflows/exceptions.py
index 4fb8dd7..0d64d65 100644
--- a/aria/orchestrator/workflows/exceptions.py
+++ b/aria/orchestrator/workflows/exceptions.py
@@ -16,6 +16,8 @@
 """
 Workflow related Exception classes
 """
+import os
+
 from .. import exceptions
 
 
@@ -52,10 +54,10 @@ class ProcessException(ExecutorException):
         Describes the error in detail
         """
         return (
-            'Command "{error.command}" executed with an error.\n'
-            'code: {error.return_code}\n'
-            'error: {error.stderr}\n'
-            'output: {error.stdout}'.format(error=self))
+            'Command "{error.command}" executed with an error.{0}'
+            'code: {error.return_code}{0}'
+            'error: {error.stderr}{0}'
+            'output: {error.stdout}'.format(os.linesep, error=self))
 
 
 class AriaEngineError(exceptions.AriaError):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/orchestrator/workflows/executor/dry.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/dry.py 
b/aria/orchestrator/workflows/executor/dry.py
index c2b5341..b14f5d7 100644
--- a/aria/orchestrator/workflows/executor/dry.py
+++ b/aria/orchestrator/workflows/executor/dry.py
@@ -41,11 +41,9 @@ class DryExecutor(BaseExecutor):
         inputs = Parameter.unwrap_dict(task.inputs)
 
         task.context.logger.info(
-            'Executing {actor_type} {actor_name} operation {interface_name} 
{operation_name}: '
-            '{implementation} (Inputs: {inputs})'
-            .format(actor_type=actor_type, actor_name=task.actor.name,
-                    interface_name=task.interface_name, 
operation_name=task.operation_name,
-                    implementation=implementation, inputs=inputs))
+            'Executing {actor_type} {task.actor.name} operation 
{task.interface_name} '
+            '{task.operation_name}: {implementation} (Inputs: {inputs})'
+            .format(actor_type=actor_type, task=task, 
implementation=implementation, inputs=inputs))
 
         # updating the task manually instead of calling 
self._task_succeeded(task),
         # to avoid any side effects raising that event might cause

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/storage/instrumentation.py
----------------------------------------------------------------------
diff --git a/aria/storage/instrumentation.py b/aria/storage/instrumentation.py
index fb95fcf..bb21b19 100644
--- a/aria/storage/instrumentation.py
+++ b/aria/storage/instrumentation.py
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import os
 import copy
 import json
 
@@ -189,9 +190,9 @@ def apply_tracked_changes(tracked_changes, model):
             if not value:
                 del successfully_updated_changes[key]
         model.logger.error(
-            'Registering all the changes to the storage has failed. \n'
-            'The successful updates were: \n '
-            '{0}'.format(json.dumps(successfully_updated_changes, indent=4)))
+            'Registering all the changes to the storage has failed. {0}'
+            'The successful updates were: {0} '
+            '{1}'.format(os.linesep, json.dumps(successfully_updated_changes, 
indent=4)))
 
         raise
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/aria/utils/formatting.py
----------------------------------------------------------------------
diff --git a/aria/utils/formatting.py b/aria/utils/formatting.py
index f0ef146..b5e141d 100644
--- a/aria/utils/formatting.py
+++ b/aria/utils/formatting.py
@@ -111,21 +111,6 @@ def decode_dict(data):
     return decoded_dict
 
 
-def try_convert_from_str(string, target_type):
-    if target_type == basestring:
-        return string
-    if target_type == bool:
-        if string.lower() == 'true':
-            return True
-        if string.lower() == 'false':
-            return False
-        return string
-    try:
-        return target_type(string)
-    except ValueError:
-        return string
-
-
 def safe_str(value):
     """
     Like :code:`str` coercion, but makes sure that Unicode strings are properly

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py 
b/tests/cli/test_service_templates.py
index d357fad..7cf6baf 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -1,5 +1,5 @@
 from aria.cli import service_template_utils
-from aria.cli.env import Environment
+from aria.cli.env import _Environment as Environment
 from aria.cli.exceptions import AriaCliError
 from aria.core import Core
 from aria.exceptions import AriaException

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 9771fe2..4b935d2 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -169,10 +169,9 @@ def create_interface(service, interface_name, 
operation_name, operation_kwargs=N
     the_type = 
service.service_template.interface_types.get_descendant('test_interface_type')
 
     if operation_kwargs and operation_kwargs.get('inputs'):
-        wrapped_inputs = {}
-        for input_name, input_value in operation_kwargs['inputs'].iteritems():
-            wrapped_inputs[input_name] = models.Parameter.wrap(input_name, 
input_value)
-        operation_kwargs['inputs'] = wrapped_inputs
+        operation_kwargs['inputs'] = dict(
+            (input_name, models.Parameter.wrap(input_name, input_value))
+            for input_name, input_value in 
operation_kwargs['inputs'].iteritems())
 
     operation = models.Operation(
         name=operation_name,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5dc3a58b/tests/utils/test_threading.py
----------------------------------------------------------------------
diff --git a/tests/utils/test_threading.py b/tests/utils/test_threading.py
index 39ce717..d24661f 100644
--- a/tests/utils/test_threading.py
+++ b/tests/utils/test_threading.py
@@ -19,17 +19,15 @@ import pytest
 from aria.utils import threading
 
 
-class TestPluginManager(object):
+def test_exception_raised_from_thread():
 
-    def test_exception_raised_from_thread(self):
+    def error_raising_func():
+        raise ValueError('This is an error')
 
-        def error_raising_func():
-            raise ValueError('This is an error')
+    thread = threading.ExceptionThread(target=error_raising_func)
+    thread.start()
+    thread.join()
 
-        thread = threading.ExceptionThread(target=error_raising_func)
-        thread.start()
-        thread.join()
-
-        assert thread.is_error()
-        with pytest.raises(ValueError):
-            thread.raise_error_if_exists()
+    assert thread.is_error()
+    with pytest.raises(ValueError):
+        thread.raise_error_if_exists()

Reply via email to