incubator-ariatosca git commit: reworked the entire config process. it is now possible to config the styles and formats directly from the config file

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-146-Support-colorful-execution-logging 2dd9830f5 -> 81bd26a7f


reworked the entire config process. it is now possible to config the styles and 
formats directly from the config file


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

Branch: refs/heads/ARIA-146-Support-colorful-execution-logging
Commit: 81bd26a7fb453e02eab1e1b8100bb9c3057928cd
Parents: 2dd9830
Author: max-orlov 
Authored: Wed Apr 26 00:24:37 2017 +0300
Committer: max-orlov 
Committed: Wed Apr 26 00:24:37 2017 +0300

--
 aria/cli/color.py|   5 +-
 aria/cli/commands/executions.py  |   6 +-
 aria/cli/commands/logs.py|   3 +-
 aria/cli/config/config_template.yaml |  40 ++
 aria/cli/execution_logging.py| 209 --
 5 files changed, 130 insertions(+), 133 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/81bd26a7/aria/cli/color.py
--
diff --git a/aria/cli/color.py b/aria/cli/color.py
index 77bfe77..49675de 100644
--- a/aria/cli/color.py
+++ b/aria/cli/color.py
@@ -66,8 +66,7 @@ class Color(object):
 
 @classmethod
 def markup(cls, str_to_stylize, matches, schema):
-modified_str = str_to_stylize
 for group_index in xrange(len(matches.regs)):
 match = matches.group(group_index)
-modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
-return modified_str
+str_to_stylize = str_to_stylize.replace(match, schema + match + 
cls.Back.RESET)
+return str_to_stylize

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/81bd26a7/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 3eb53ab..7f55e6a 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -149,8 +149,7 @@ def start(workflow_name,
 log_iterator = cli_logger.ModelLogIterator(model_storage, 
workflow_runner.execution_id)
 try:
 while execution_thread.is_alive():
-with execution_logging.format(mark_pattern=mark_pattern):
-execution_logging.log_list(log_iterator)
+execution_logging.log_list(log_iterator, mark_pattern=mark_pattern)
 execution_thread.join(1)
 
 except KeyboardInterrupt:
@@ -158,8 +157,7 @@ def start(workflow_name,
 
 # It might be the case where some logs were written and the execution was 
terminated, thus we
 # need to drain the remaining logs.
-with execution_logging.format(mark_pattern=mark_pattern):
-execution_logging.log_list(log_iterator)
+execution_logging.log_list(log_iterator, mark_pattern=mark_pattern)
 
 # raise any errors from the execution thread (note these are not workflow 
execution errors)
 execution_thread.raise_error_if_exists()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/81bd26a7/aria/cli/commands/logs.py
--
diff --git a/aria/cli/commands/logs.py b/aria/cli/commands/logs.py
index 350a035..2f7f361 100644
--- a/aria/cli/commands/logs.py
+++ b/aria/cli/commands/logs.py
@@ -38,8 +38,7 @@ def list(execution_id, mark_pattern, model_storage, logger):
 logger.info('Listing logs for execution id {0}'.format(execution_id))
 log_iterator = ModelLogIterator(model_storage, execution_id)
 
-with execution_logging.format(mark_pattern=mark_pattern):
-any_logs = execution_logging.log_list(log_iterator)
+any_logs = execution_logging.log_list(log_iterator, 
mark_pattern=mark_pattern)
 
 if not any_logs:
 logger.info('\tNo logs')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/81bd26a7/aria/cli/config/config_template.yaml
--
diff --git a/aria/cli/config/config_template.yaml 
b/aria/cli/config/config_template.yaml
index 66c606e..b8bad3b 100644
--- a/aria/cli/config/config_template.yaml
+++ b/aria/cli/config/config_template.yaml
@@ -9,3 +9,43 @@ logging:
 
 # main logger of the cli. provides basic descriptions for executed 
operations.
 aria.cli.main: info
+
+  execution_logging:
+formatting:
+  # According to verbosity level 0 - no verbose. 3 - high verbose
+  0: '{message}'
+  1: '{timestamp:%H:%M:%S} | 

incubator-ariatosca git commit: Improve execution cancelling [Forced Update!]

2017-04-25 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-143-improve-cancelling-of-workflow-execution 4e81d7fff -> 
11e7fb6a7 (forced update)


Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is logged.


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 11e7fb6a7a1eadb43eb4999fc8ca878a7fe95bbd
Parents: 7a4a1dd
Author: Avia Efrat 
Authored: Thu Apr 20 13:23:32 2017 +0300
Committer: Avia Efrat 
Committed: Tue Apr 25 19:55:24 2017 +0300

--
 aria/cli/commands/executions.py | 12 +++-
 aria/modeling/orchestration.py  |  9 +++---
 .../workflows/core/events_handler.py| 32 +++-
 aria/orchestrator/workflows/events_logging.py   |  1 +
 tests/modeling/test_models.py   | 22 +++---
 tests/orchestrator/test_workflow_runner.py  |  2 +-
 .../orchestrator/workflows/core/test_engine.py  |  2 +-
 7 files changed, 47 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/11e7fb6a/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 6a1f02a..cb86376 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -139,7 +139,6 @@ def start(workflow_name,
 execution_thread_name = '{0}_{1}'.format(service_name, workflow_name)
 execution_thread = 
threading.ExceptionThread(target=workflow_runner.execute,
  name=execution_thread_name)
-execution_thread.daemon = True  # allows force-cancel to exit immediately
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if 
dry else ''))
 execution_thread.start()
@@ -172,11 +171,10 @@ def start(workflow_name,
 
 def _cancel_execution(workflow_runner, execution_thread, logger, log_iterator):
 logger.info('Cancelling execution. Press Ctrl+C again to force-cancel')
-try:
-workflow_runner.cancel()
-while execution_thread.is_alive():
+workflow_runner.cancel()
+while execution_thread.is_alive():
+try:
 execution_logging.log_list(log_iterator)
 execution_thread.join(1)
-except KeyboardInterrupt:
-logger.info('Force-cancelling execution')
-# TODO handle execution (update status etc.) and exit process
+except KeyboardInterrupt:
+pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/11e7fb6a/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index b9a75e9..f163903 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -56,21 +56,20 @@ class ExecutionBase(ModelMixin):
 __private_fields__ = ['service_fk',
   'service_template']
 
-TERMINATED = 'terminated'
+SUCCEEDED = 'succeeded'
 FAILED = 'failed'
 CANCELLED = 'cancelled'
 PENDING = 'pending'
 STARTED = 'started'
 CANCELLING = 'cancelling'
-FORCE_CANCELLING = 'force_cancelling'
 
-STATES = (TERMINATED, 

[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983171#comment-15983171
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113237634
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
--- End diff --

revert back not to reset but to last back color


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983172#comment-15983172
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113236075
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
--- End diff --

put on bottom of the class


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983158#comment-15983158
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113225121
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
--- End diff --

space


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113225121
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
--- End diff --

space


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983159#comment-15983159
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113227289
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
--- End diff --

default


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983167#comment-15983167
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113236673
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
--- End diff --

stay with original parameter?


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983162#comment-15983162
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113237789
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
--- End diff --

consider using stylize


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113235649
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
--- End diff --

use itertools if necessary


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983168#comment-15983168
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113235649
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
--- End diff --

use itertools if necessary


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983169#comment-15983169
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113227303
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
--- End diff --

default


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983165#comment-15983165
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113231457
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
+SUCCESS_STATE: Color.Fore.GREEN,
+CANCEL_STATE: Color.Fore.YELLOW,
+FAIL_STATE: Color.Fore.RED,
+}
 }
 
+_PATTERNS = {
+SUCCESS_STATE: re.compile(_SUCCESSFUL_EXECUTION_PATTERN),
+CANCEL_STATE: re.compile(_CANCELED_EXECUTION_PATTERN),
+FAIL_STATE: re.compile(_FAILED_EXECUTION_PATTERN)
+
+}
+
+
+class _StylizedLogs(object):
+
+def __init__(self):
+self._formats = DEFAULT_FORMATTING
+self._styles = DEFAULT_STYLING
+self._mark_pattern = None
+
+def _push(self, styles=None, formats=None, mark_pattern=None):
+self._styles = styles or self._styles
+self._formats = formats or self._formats
+self._mark_pattern = mark_pattern
+
+def _implementation(self, implementation, log_item):
+return self._stylize(implementation, log_item, IMPLEMENTATION)
+
+def _inputs(self, inputs, log_item):
+

[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983161#comment-15983161
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113227509
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
--- End diff --

extract somehow so this isnt configurable


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983166#comment-15983166
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113235566
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
--- End diff --

extract kwargs


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983164#comment-15983164
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113227856
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
+SUCCESS_STATE: Color.Fore.GREEN,
+CANCEL_STATE: Color.Fore.YELLOW,
+FAIL_STATE: Color.Fore.RED,
+}
 }
 
+_PATTERNS = {
--- End diff --

consider also checking log for whether its task related or workflow related


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113226725
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
--- End diff --

1) support default in case user doesnt provide
2) have 'default' log level coloring


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113236673
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
--- End diff --

stay with original parameter?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113237789
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
--- End diff --

consider using stylize


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113233667
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
+SUCCESS_STATE: Color.Fore.GREEN,
+CANCEL_STATE: Color.Fore.YELLOW,
+FAIL_STATE: Color.Fore.RED,
+}
 }
 
+_PATTERNS = {
+SUCCESS_STATE: re.compile(_SUCCESSFUL_EXECUTION_PATTERN),
+CANCEL_STATE: re.compile(_CANCELED_EXECUTION_PATTERN),
+FAIL_STATE: re.compile(_FAILED_EXECUTION_PATTERN)
+
+}
+
+
+class _StylizedLogs(object):
+
+def __init__(self):
+self._formats = DEFAULT_FORMATTING
+self._styles = DEFAULT_STYLING
+self._mark_pattern = None
+
+def _push(self, styles=None, formats=None, mark_pattern=None):
+self._styles = styles or self._styles
+self._formats = formats or self._formats
+self._mark_pattern = mark_pattern
+
+def _implementation(self, implementation, log_item):
+return self._stylize(implementation, log_item, IMPLEMENTATION)
+
+def _inputs(self, inputs, log_item):
+return self._stylize(inputs, log_item, INPUTS)
+
+def _timestamp(self, timestamp, log_item):
+return self._stylize(timestamp, log_item, TIMESTAMP)
+
+def _message(self, message, log_item):
+   

[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113234319
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
+SUCCESS_STATE: Color.Fore.GREEN,
+CANCEL_STATE: Color.Fore.YELLOW,
+FAIL_STATE: Color.Fore.RED,
+}
 }
 
+_PATTERNS = {
+SUCCESS_STATE: re.compile(_SUCCESSFUL_EXECUTION_PATTERN),
+CANCEL_STATE: re.compile(_CANCELED_EXECUTION_PATTERN),
+FAIL_STATE: re.compile(_FAILED_EXECUTION_PATTERN)
+
+}
+
+
+class _StylizedLogs(object):
+
+def __init__(self):
+self._formats = DEFAULT_FORMATTING
+self._styles = DEFAULT_STYLING
+self._mark_pattern = None
+
+def _push(self, styles=None, formats=None, mark_pattern=None):
--- End diff --

remove


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113237634
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
--- End diff --

revert back not to reset but to last back color


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113236075
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
--- End diff --

put on bottom of the class


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113235566
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
--- End diff --

extract kwargs


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113227509
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
--- End diff --

extract somehow so this isnt configurable


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113231457
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
+SUCCESS_STATE: Color.Fore.GREEN,
+CANCEL_STATE: Color.Fore.YELLOW,
+FAIL_STATE: Color.Fore.RED,
+}
 }
 
+_PATTERNS = {
+SUCCESS_STATE: re.compile(_SUCCESSFUL_EXECUTION_PATTERN),
+CANCEL_STATE: re.compile(_CANCELED_EXECUTION_PATTERN),
+FAIL_STATE: re.compile(_FAILED_EXECUTION_PATTERN)
+
+}
+
+
+class _StylizedLogs(object):
+
+def __init__(self):
+self._formats = DEFAULT_FORMATTING
+self._styles = DEFAULT_STYLING
+self._mark_pattern = None
+
+def _push(self, styles=None, formats=None, mark_pattern=None):
+self._styles = styles or self._styles
+self._formats = formats or self._formats
+self._mark_pattern = mark_pattern
+
+def _implementation(self, implementation, log_item):
+return self._stylize(implementation, log_item, IMPLEMENTATION)
+
+def _inputs(self, inputs, log_item):
+return self._stylize(inputs, log_item, INPUTS)
+
+def _timestamp(self, timestamp, log_item):
+return self._stylize(timestamp, log_item, TIMESTAMP)
+
+def _message(self, message, log_item):
+   

[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983163#comment-15983163
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113234319
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+MESSAGE: {
+'info': Color.Fore.LIGHTBLUE_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLUE_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+IMPLEMENTATION: {
+'info': Color.Fore.LIGHTBLACK_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTBLACK_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+INPUTS: {
+'info': Color.Fore.BLUE,
+'debug': Color.Schema(fore=Color.Fore.BLUE, style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
+},
+TRACEBACK: {'error': Color.Fore.RED},
+
+MARKER: Color.Back.LIGHTYELLOW_EX,
+FINAL_STATES: {
+SUCCESS_STATE: Color.Fore.GREEN,
+CANCEL_STATE: Color.Fore.YELLOW,
+FAIL_STATE: Color.Fore.RED,
+}
 }
 
+_PATTERNS = {
+SUCCESS_STATE: re.compile(_SUCCESSFUL_EXECUTION_PATTERN),
+CANCEL_STATE: re.compile(_CANCELED_EXECUTION_PATTERN),
+FAIL_STATE: re.compile(_FAILED_EXECUTION_PATTERN)
+
+}
+
+
+class _StylizedLogs(object):
+
+def __init__(self):
+self._formats = DEFAULT_FORMATTING
+self._styles = DEFAULT_STYLING
+self._mark_pattern = None
+
+def _push(self, styles=None, formats=None, mark_pattern=None):
--- End diff --

remove


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>

[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983157#comment-15983157
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113226725
  
--- Diff: aria/cli/execution_logging.py ---
@@ -12,62 +12,208 @@
 # 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.
-
+import os
+import re
 from StringIO import StringIO
+from contextlib import contextmanager
 
 from . import logger
+from .color import Color
 from .env import env
 
+
+LEVEL = 'level'
+TIMESTAMP = 'timestamp'
+MESSAGE = 'message'
+IMPLEMENTATION = 'implementation'
+INPUTS = 'inputs'
+TRACEBACK = 'traceback'
+MARKER = 'marker'
+
+FINAL_STATES = 'final_states'
+SUCCESS_STATE = 'success'
+CANCEL_STATE = 'cancel'
+FAIL_STATE = 'fail'
+
+
+_EXECUTION_BASE_PATTERN = "\'.*\' workflow execution "
+_SUCCESSFUL_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "succeeded"
+_FAILED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "failed"
+_CANCELED_EXECUTION_PATTERN = _EXECUTION_BASE_PATTERN + "canceled"
+
 DEFAULT_FORMATTING = {
-logger.NO_VERBOSE: {'message': '{item.msg}'},
+logger.NO_VERBOSE: {'message': '{message}'},
 logger.LOW_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {item.msg}',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {message}',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S',
 },
 logger.MEDIUM_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | {implementation} | 
{item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
 },
 logger.HIGH_VERBOSE: {
-'message': '{timestamp} | {item.level[0]} | 
{implementation}({inputs}) | {item.msg} ',
-'timestamp': '%H:%M:%S'
+MESSAGE: '{timestamp} | {level} | {implementation} | {inputs} | 
{message} ',
+LEVEL: '{level[0]}',
+TIMESTAMP: '%H:%M:%S'
+},
+}
+
+DEFAULT_STYLING = {
+LEVEL: {
+'info': Color.Fore.LIGHTMAGENTA_EX,
+'debug': Color.Schema(fore=Color.Fore.LIGHTMAGENTA_EX, 
style=Color.Style.DIM),
+'error': Color.Schema(fore=Color.Fore.RED, 
style=Color.Style.BRIGHT),
 },
+TIMESTAMP: {
--- End diff --

1) support default in case user doesnt provide
2) have 'default' log level coloring


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #110: Improve execution cancelling

2017-04-25 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/110

Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is 
logged.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-143-improve-cancelling-of-workflow-execution

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/110.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #110


commit 4e81d7fff45bae1a2ccb9f0b897179c95076cf3f
Author: Avia Efrat 
Date:   2017-04-20T10:23:32Z

Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is 
logged.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


incubator-ariatosca git commit: Improve execution cancelling [Forced Update!]

2017-04-25 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-143-improve-cancelling-of-workflow-execution 884c3915e -> 
4e81d7fff (forced update)


Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is logged.


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 4e81d7fff45bae1a2ccb9f0b897179c95076cf3f
Parents: 7a4a1dd
Author: Avia Efrat 
Authored: Thu Apr 20 13:23:32 2017 +0300
Committer: Avia Efrat 
Committed: Tue Apr 25 18:21:11 2017 +0300

--
 aria/cli/commands/executions.py | 13 +++
 aria/modeling/orchestration.py  |  9 +++--
 aria/orchestrator/workflow_runner.py|  1 +
 .../workflows/core/events_handler.py| 38 ++--
 aria/orchestrator/workflows/events_logging.py   |  1 +
 tests/modeling/test_models.py   | 22 ++--
 tests/orchestrator/test_workflow_runner.py  |  2 +-
 .../orchestrator/workflows/core/test_engine.py  |  2 +-
 8 files changed, 51 insertions(+), 37 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e81d7ff/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 6a1f02a..8b61c02 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -139,7 +139,6 @@ def start(workflow_name,
 execution_thread_name = '{0}_{1}'.format(service_name, workflow_name)
 execution_thread = 
threading.ExceptionThread(target=workflow_runner.execute,
  name=execution_thread_name)
-execution_thread.daemon = True  # allows force-cancel to exit immediately
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if 
dry else ''))
 execution_thread.start()
@@ -172,11 +171,7 @@ def start(workflow_name,
 
 def _cancel_execution(workflow_runner, execution_thread, logger, log_iterator):
 logger.info('Cancelling execution. Press Ctrl+C again to force-cancel')
-try:
-workflow_runner.cancel()
-while execution_thread.is_alive():
-execution_logging.log_list(log_iterator)
-execution_thread.join(1)
-except KeyboardInterrupt:
-logger.info('Force-cancelling execution')
-# TODO handle execution (update status etc.) and exit process
+workflow_runner.cancel()
+while execution_thread.is_alive():
+execution_logging.log_list(log_iterator)
+execution_thread.join(1)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e81d7ff/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index b9a75e9..f163903 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -56,21 +56,20 @@ class ExecutionBase(ModelMixin):
 __private_fields__ = ['service_fk',
   'service_template']
 
-TERMINATED = 'terminated'
+SUCCEEDED = 'succeeded'
 FAILED = 'failed'
 CANCELLED = 'cancelled'
 PENDING = 'pending'
 STARTED = 'started'
 CANCELLING = 'cancelling'
-   

[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983039#comment-15983039
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113223683
  
--- Diff: aria/cli/core/aria.py ---
@@ -425,5 +425,14 @@ def service_template_name(required=False):
 required=required,
 help=helptexts.SERVICE_ID)
 
+@staticmethod
+def mark_pattern(default=None):
+return click.option(
+'-m',
+'--mark-pattern',
+help='pattern this',
--- End diff --

update


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113223683
  
--- Diff: aria/cli/core/aria.py ---
@@ -425,5 +425,14 @@ def service_template_name(required=False):
 required=required,
 help=helptexts.SERVICE_ID)
 
+@staticmethod
+def mark_pattern(default=None):
+return click.option(
+'-m',
+'--mark-pattern',
+help='pattern this',
--- End diff --

update


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983041#comment-15983041
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113223779
  
--- Diff: aria/cli/core/aria.py ---
@@ -425,5 +425,14 @@ def service_template_name(required=False):
 required=required,
 help=helptexts.SERVICE_ID)
 
+@staticmethod
+def mark_pattern(default=None):
+return click.option(
+'-m',
+'--mark-pattern',
+help='pattern this',
+type=str,
+default=default
--- End diff --

required=false


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113223779
  
--- Diff: aria/cli/core/aria.py ---
@@ -425,5 +425,14 @@ def service_template_name(required=False):
 required=required,
 help=helptexts.SERVICE_ID)
 
+@staticmethod
+def mark_pattern(default=None):
+return click.option(
+'-m',
+'--mark-pattern',
+help='pattern this',
+type=str,
+default=default
--- End diff --

required=false


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #109: ARIA-146-Support-colorful-execution-l...

2017-04-25 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113221527
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
--- End diff --

format 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-146) Support colorful execution logging

2017-04-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15983031#comment-15983031
 ] 

ASF GitHub Bot commented on ARIA-146:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/109#discussion_r113221527
  
--- Diff: aria/cli/color.py ---
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from 
colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter 
is in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
--- End diff --

format 


> Support colorful execution logging
> --
>
> Key: ARIA-146
> URL: https://issues.apache.org/jira/browse/ARIA-146
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
>Priority: Minor
>
> Add support for printing execution logs in color



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


incubator-ariatosca git commit: Improve execution cancelling [Forced Update!]

2017-04-25 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-143-improve-cancelling-of-workflow-execution 8d68c6b32 -> 
884c3915e (forced update)


Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is logged.


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 884c3915eb3a82c70a6653ae3c7a2f2645050a53
Parents: 1e0a597
Author: Avia Efrat 
Authored: Tue Apr 25 15:00:03 2017 +0300
Committer: Avia Efrat 
Committed: Tue Apr 25 17:01:50 2017 +0300

--
 aria/cli/commands/executions.py |  4 +--
 aria/modeling/orchestration.py  |  9 +++--
 aria/orchestrator/workflow_runner.py|  1 +
 .../workflows/core/events_handler.py| 38 ++--
 aria/orchestrator/workflows/events_logging.py   |  1 +
 tests/modeling/test_models.py   | 22 ++--
 tests/orchestrator/test_workflow_runner.py  |  2 +-
 .../orchestrator/workflows/core/test_engine.py  |  2 +-
 8 files changed, 49 insertions(+), 30 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/884c3915/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 6a1f02a..10e1b1d 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -178,5 +178,5 @@ def _cancel_execution(workflow_runner, execution_thread, 
logger, log_iterator):
 execution_logging.log_list(log_iterator)
 execution_thread.join(1)
 except KeyboardInterrupt:
-logger.info('Force-cancelling execution')
-# TODO handle execution (update status etc.) and exit process
+# TODO think about how to ignore more keyboard interrupt (consider the 
daemon thing)
+pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/884c3915/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index b9a75e9..f163903 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -56,21 +56,20 @@ class ExecutionBase(ModelMixin):
 __private_fields__ = ['service_fk',
   'service_template']
 
-TERMINATED = 'terminated'
+SUCCEEDED = 'succeeded'
 FAILED = 'failed'
 CANCELLED = 'cancelled'
 PENDING = 'pending'
 STARTED = 'started'
 CANCELLING = 'cancelling'
-FORCE_CANCELLING = 'force_cancelling'
 
-STATES = (TERMINATED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING, 
FORCE_CANCELLING)
-END_STATES = (TERMINATED, FAILED, CANCELLED)
+STATES = (SUCCEEDED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING)
+END_STATES = (SUCCEEDED, FAILED, CANCELLED)
 
 VALID_TRANSITIONS = {
 PENDING: (STARTED, CANCELLED),
 STARTED: END_STATES + (CANCELLING,),
-CANCELLING: END_STATES + (FORCE_CANCELLING,)
+CANCELLING: END_STATES
 }
 
 @orm.validates('status')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/884c3915/aria/orchestrator/workflow_runner.py

[jira] [Closed] (ARIA-152) Openstack hello-world example

2017-04-25 Thread Maxim Orlov (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maxim Orlov closed ARIA-152.

   Resolution: Fixed
Fix Version/s: 0.1.0

> Openstack hello-world example
> -
>
> Key: ARIA-152
> URL: https://issues.apache.org/jira/browse/ARIA-152
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Maxim Orlov
> Fix For: 0.1.0
>
>
> Write an hello-world example which runs on Openstack, using the Openstack 
> plugin.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[3/3] incubator-ariatosca git commit: Improve execution cancelling and implement force-cancelling

2017-04-25 Thread avia
Improve execution cancelling and implement force-cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

5.


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 8d68c6b32d3b422fb89fef24852e533e82946374
Parents: 1e0a597
Author: Avia Efrat 
Authored: Tue Apr 25 15:00:03 2017 +0300
Committer: Avia Efrat 
Committed: Tue Apr 25 15:22:46 2017 +0300

--
 aria/cli/commands/executions.py |  2 +-
 aria/modeling/orchestration.py  | 13 +++---
 aria/orchestrator/events.py |  1 +
 aria/orchestrator/workflow_runner.py|  3 ++
 aria/orchestrator/workflows/core/engine.py  |  6 ++-
 .../workflows/core/events_handler.py| 48 
 tests/modeling/test_models.py   | 22 -
 tests/orchestrator/test_workflow_runner.py  |  2 +-
 .../orchestrator/workflows/core/test_engine.py  |  2 +-
 9 files changed, 68 insertions(+), 31 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8d68c6b3/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 6a1f02a..343ce6f 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -179,4 +179,4 @@ def _cancel_execution(workflow_runner, execution_thread, 
logger, log_iterator):
 execution_thread.join(1)
 except KeyboardInterrupt:
 logger.info('Force-cancelling execution')
-# TODO handle execution (update status etc.) and exit process
+workflow_runner.force_cancel()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8d68c6b3/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index b9a75e9..f49591d 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -56,21 +56,22 @@ class ExecutionBase(ModelMixin):
 __private_fields__ = ['service_fk',
   'service_template']
 
-TERMINATED = 'terminated'
+SUCCEEDED = 'succeeded'
 FAILED = 'failed'
 CANCELLED = 'cancelled'
 PENDING = 'pending'
 STARTED = 'started'
 CANCELLING = 'cancelling'
-FORCE_CANCELLING = 'force_cancelling'
+FORCE_CANCELLED = 'force_cancelled'
 
-STATES = (TERMINATED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING, 
FORCE_CANCELLING)
-END_STATES = (TERMINATED, FAILED, CANCELLED)
+STATES = (SUCCEEDED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING, 
FORCE_CANCELLED)
+END_STATES = (SUCCEEDED, FAILED, CANCELLED, FORCE_CANCELLED)
+CANCEL_STATES = (CANCELLING, CANCELLED, FORCE_CANCELLED)
 
 VALID_TRANSITIONS = {
-PENDING: (STARTED, CANCELLED),
+PENDING: (STARTED, CANCELLED, FORCE_CANCELLED),
 STARTED: END_STATES + (CANCELLING,),
-CANCELLING: END_STATES + (FORCE_CANCELLING,)
+CANCELLING: END_STATES
 }
 
 @orm.validates('status')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8d68c6b3/aria/orchestrator/events.py
--
diff --git a/aria/orchestrator/events.py b/aria/orchestrator/events.py
index a1c4922..bcc0627 100644
--- a/aria/orchestrator/events.py
+++ b/aria/orchestrator/events.py
@@ -32,5 +32,6 @@ on_failure_task_signal = signal('failure_task_signal')
 start_workflow_signal = signal('start_workflow_signal')
 on_cancelling_workflow_signal = signal('on_cancelling_workflow_signal')
 on_cancelled_workflow_signal = signal('on_cancelled_workflow_signal')
+on_force_cancelled_workflow_signal = 
signal('on_force_cancelled_workflow_signal')
 on_success_workflow_signal = 

[jira] [Commented] (ARIA-150) Simple hello-world example missing host error

2017-04-25 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15982836#comment-15982836
 ] 

ASF subversion and git services commented on ARIA-150:
--

Commit 7a4a1ddabadef814affb56778c7614256ca8fe00 in incubator-ariatosca's branch 
refs/heads/ARIA-143-improve-cancelling-of-workflow-execution from [~ran]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=7a4a1dd ]

ARIA-150 Fixed simple hello-world example

The simple hello-world example had a missing host node,
which caused an error at service creation phase.
The example now uses custom types which do not require
the extra host node.


> Simple hello-world example missing host error
> -
>
> Key: ARIA-150
> URL: https://issues.apache.org/jira/browse/ARIA-150
> Project: AriaTosca
>  Issue Type: Bug
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> The simple hello-world example currently doesn't run properly - there is a 
> missing host error at service creation phase, due to the 
> {{tosca.nodes.WebServer}} type having a requirement for a {{host}} node.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[1/3] incubator-ariatosca git commit: ARIA-150 Fixed simple hello-world example [Forced Update!]

2017-04-25 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-143-improve-cancelling-of-workflow-execution 0da519783 -> 
8d68c6b32 (forced update)


ARIA-150 Fixed simple hello-world example

The simple hello-world example had a missing host node,
which caused an error at service creation phase.
The example now uses custom types which do not require
the extra host node.


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 7a4a1ddabadef814affb56778c7614256ca8fe00
Parents: 29bc84b
Author: Ran Ziv 
Authored: Sun Apr 23 15:39:57 2017 +0300
Committer: Ran Ziv 
Committed: Sun Apr 23 15:39:57 2017 +0300

--
 examples/hello-world/helloworld.yaml | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7a4a1dda/examples/hello-world/helloworld.yaml
--
diff --git a/examples/hello-world/helloworld.yaml 
b/examples/hello-world/helloworld.yaml
index b6efaca..77cef30 100644
--- a/examples/hello-world/helloworld.yaml
+++ b/examples/hello-world/helloworld.yaml
@@ -1,18 +1,23 @@
-tosca_definitions_version: tosca_simple_profile_for_nfv_1_0
+tosca_definitions_version: tosca_simple_yaml_1_0
 
 node_types:
+  web_server:
+derived_from: tosca.nodes.Root
+capabilities:
+  host:
+type: tosca.capabilities.Container
+
   web_app:
 derived_from: tosca.nodes.WebApplication
 properties:
   port:
 type: integer
-default: 8080
 
 topology_template:
 
   node_templates:
 web_server:
-  type: tosca.nodes.WebServer
+  type: web_server
 
 web_app:
   type: web_app



[2/3] incubator-ariatosca git commit: Comment out two lines to enable installing hello world

2017-04-25 Thread avia
Comment out two lines to enable installing hello world


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 1e0a597381f7e34e5690771d1d08a92a6c3194ee
Parents: 7a4a1dd
Author: Avia Efrat 
Authored: Thu Apr 20 13:23:32 2017 +0300
Committer: Avia Efrat 
Committed: Tue Apr 25 15:22:04 2017 +0300

--
 aria/core.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1e0a5973/aria/core.py
--
diff --git a/aria/core.py b/aria/core.py
index af1984a..4e19506 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -77,8 +77,8 @@ class Core(object):
 consumption.ConsumerChain(
 context,
 (
-consumption.SatisfyRequirements,
-consumption.ValidateCapabilities,
+# consumption.SatisfyRequirements,
+# consumption.ValidateCapabilities,
 consumption.FindHosts,
 consumption.ConfigureOperations
 )).consume()



[2/2] incubator-ariatosca git commit: Improve execution cancelling and implement force-cancelling

2017-04-25 Thread avia
Improve execution cancelling and implement force-cancelling


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: 0da519783567ec5ceee20297893ff235a13cb9e1
Parents: b446643
Author: Avia Efrat 
Authored: Tue Apr 25 15:00:03 2017 +0300
Committer: Avia Efrat 
Committed: Tue Apr 25 15:00:03 2017 +0300

--
 aria/cli/commands/executions.py |  2 +-
 aria/modeling/orchestration.py  | 13 +++---
 aria/orchestrator/events.py |  1 +
 aria/orchestrator/workflow_runner.py|  3 ++
 aria/orchestrator/workflows/core/engine.py  | 11 -
 .../workflows/core/events_handler.py| 48 
 tests/modeling/test_models.py   | 22 -
 tests/orchestrator/test_workflow_runner.py  |  2 +-
 .../orchestrator/workflows/core/test_engine.py  |  2 +-
 9 files changed, 73 insertions(+), 31 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0da51978/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 6a1f02a..343ce6f 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -179,4 +179,4 @@ def _cancel_execution(workflow_runner, execution_thread, 
logger, log_iterator):
 execution_thread.join(1)
 except KeyboardInterrupt:
 logger.info('Force-cancelling execution')
-# TODO handle execution (update status etc.) and exit process
+workflow_runner.force_cancel()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0da51978/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index b9a75e9..f49591d 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -56,21 +56,22 @@ class ExecutionBase(ModelMixin):
 __private_fields__ = ['service_fk',
   'service_template']
 
-TERMINATED = 'terminated'
+SUCCEEDED = 'succeeded'
 FAILED = 'failed'
 CANCELLED = 'cancelled'
 PENDING = 'pending'
 STARTED = 'started'
 CANCELLING = 'cancelling'
-FORCE_CANCELLING = 'force_cancelling'
+FORCE_CANCELLED = 'force_cancelled'
 
-STATES = (TERMINATED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING, 
FORCE_CANCELLING)
-END_STATES = (TERMINATED, FAILED, CANCELLED)
+STATES = (SUCCEEDED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING, 
FORCE_CANCELLED)
+END_STATES = (SUCCEEDED, FAILED, CANCELLED, FORCE_CANCELLED)
+CANCEL_STATES = (CANCELLING, CANCELLED, FORCE_CANCELLED)
 
 VALID_TRANSITIONS = {
-PENDING: (STARTED, CANCELLED),
+PENDING: (STARTED, CANCELLED, FORCE_CANCELLED),
 STARTED: END_STATES + (CANCELLING,),
-CANCELLING: END_STATES + (FORCE_CANCELLING,)
+CANCELLING: END_STATES
 }
 
 @orm.validates('status')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0da51978/aria/orchestrator/events.py
--
diff --git a/aria/orchestrator/events.py b/aria/orchestrator/events.py
index a1c4922..bcc0627 100644
--- a/aria/orchestrator/events.py
+++ b/aria/orchestrator/events.py
@@ -32,5 +32,6 @@ on_failure_task_signal = signal('failure_task_signal')
 start_workflow_signal = signal('start_workflow_signal')
 on_cancelling_workflow_signal = signal('on_cancelling_workflow_signal')
 on_cancelled_workflow_signal = signal('on_cancelled_workflow_signal')
+on_force_cancelled_workflow_signal = 
signal('on_force_cancelled_workflow_signal')
 on_success_workflow_signal = signal('on_success_workflow_signal')
 on_failure_workflow_signal = signal('on_failure_workflow_signal')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0da51978/aria/orchestrator/workflow_runner.py
--
diff --git a/aria/orchestrator/workflow_runner.py 
b/aria/orchestrator/workflow_runner.py
index 8f25cce..32cf02d 100644
--- a/aria/orchestrator/workflow_runner.py
+++ b/aria/orchestrator/workflow_runner.py
@@ -107,6 +107,9 @@ class WorkflowRunner(object):
 def cancel(self):
 self._engine.cancel_execution()
 
+def force_cancel(self):
+self._engine.force_cancel_execution()
+
 def 

[1/2] incubator-ariatosca git commit: Comment out two lines to enable installing hello world

2017-04-25 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-143-improve-cancelling-of-workflow-execution [created] 
0da519783


Comment out two lines to enable installing hello world


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

Branch: refs/heads/ARIA-143-improve-cancelling-of-workflow-execution
Commit: b44664366271e3e79d97e6a370cae0c7a6b4ee5e
Parents: 29bc84b
Author: Avia Efrat 
Authored: Thu Apr 20 13:23:32 2017 +0300
Committer: Avia Efrat 
Committed: Thu Apr 20 15:56:32 2017 +0300

--
 aria/core.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b4466436/aria/core.py
--
diff --git a/aria/core.py b/aria/core.py
index af1984a..4e19506 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -77,8 +77,8 @@ class Core(object):
 consumption.ConsumerChain(
 context,
 (
-consumption.SatisfyRequirements,
-consumption.ValidateCapabilities,
+# consumption.SatisfyRequirements,
+# consumption.ValidateCapabilities,
 consumption.FindHosts,
 consumption.ConfigureOperations
 )).consume()



[incubator-ariatosca] Git Push Summary

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/unified_coerce [deleted] d22162416


incubator-ariatosca git commit: wip [Forced Update!]

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-146-Support-colorful-execution-logging c5e1b1153 -> 18046aac3 
(forced update)


wip


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

Branch: refs/heads/ARIA-146-Support-colorful-execution-logging
Commit: 18046aac31291b623cc917d32f7c10e2f3b962e7
Parents: b69a459
Author: max-orlov 
Authored: Tue Apr 25 11:02:30 2017 +0300
Committer: max-orlov 
Committed: Tue Apr 25 11:33:47 2017 +0300

--
 aria/cli/color.py   |  73 
 aria/cli/config/config_template.yaml|   1 -
 aria/cli/execution_logging.py   | 110 ++-
 aria/cli/logger.py  |  17 ---
 .../execution_plugin/ssh/operations.py  |   5 -
 5 files changed, 131 insertions(+), 75 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/18046aac/aria/cli/color.py
--
diff --git a/aria/cli/color.py b/aria/cli/color.py
new file mode 100644
index 000..77bfe77
--- /dev/null
+++ b/aria/cli/color.py
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter is 
in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
+return modified_str

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/18046aac/aria/cli/config/config_template.yaml
--
diff --git a/aria/cli/config/config_template.yaml 
b/aria/cli/config/config_template.yaml
index 13f2cf9..66c606e 100644
--- a/aria/cli/config/config_template.yaml
+++ b/aria/cli/config/config_template.yaml
@@ -1,4 +1,3 @@
-colors: {{ enable_colors }}
 
 logging:
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/18046aac/aria/cli/execution_logging.py
--
diff --git a/aria/cli/execution_logging.py b/aria/cli/execution_logging.py
index 9631d30..c6d7266 100644
--- 

[incubator-ariatosca] Git Push Summary

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/logger_task [deleted] ba04748ef


[incubator-ariatosca] Git Push Summary

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/Requirments-arent-instantiated-properly [deleted] 8ced0f49e


[incubator-ariatosca] Git Push Summary

2017-04-25 Thread ran
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-150-hello-world-missing-host-fix [deleted] 7a4a1ddab


[incubator-ariatosca] Git Push Summary

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/Implementation-less-relationship-tasks-are-being-created [deleted] 
9f9dc3ec9


incubator-ariatosca git commit: wip [Forced Update!]

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-146-Support-colorful-execution-logging db0be8784 -> c5e1b1153 
(forced update)


wip


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

Branch: refs/heads/ARIA-146-Support-colorful-execution-logging
Commit: c5e1b11539a2c2667b52b24fbf2404d6cbc61bb3
Parents: b69a459
Author: max-orlov 
Authored: Tue Apr 25 11:02:30 2017 +0300
Committer: max-orlov 
Committed: Tue Apr 25 11:10:32 2017 +0300

--
 aria/cli/color.py|  73 
 aria/cli/config/config_template.yaml |   1 -
 aria/cli/execution_logging.py| 110 --
 aria/cli/logger.py   |  17 -
 4 files changed, 131 insertions(+), 70 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c5e1b115/aria/cli/color.py
--
diff --git a/aria/cli/color.py b/aria/cli/color.py
new file mode 100644
index 000..77bfe77
--- /dev/null
+++ b/aria/cli/color.py
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either
+the color is lower case letter, or the actual color from colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter is 
in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
+return modified_str

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c5e1b115/aria/cli/config/config_template.yaml
--
diff --git a/aria/cli/config/config_template.yaml 
b/aria/cli/config/config_template.yaml
index 13f2cf9..66c606e 100644
--- a/aria/cli/config/config_template.yaml
+++ b/aria/cli/config/config_template.yaml
@@ -1,4 +1,3 @@
-colors: {{ enable_colors }}
 
 logging:
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c5e1b115/aria/cli/execution_logging.py
--
diff --git a/aria/cli/execution_logging.py b/aria/cli/execution_logging.py
index 9631d30..c6d7266 100644
--- a/aria/cli/execution_logging.py
+++ b/aria/cli/execution_logging.py
@@ -16,9 

incubator-ariatosca git commit: wip

2017-04-25 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-146-Support-colorful-execution-logging b69a459bf -> db0be8784


wip


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

Branch: refs/heads/ARIA-146-Support-colorful-execution-logging
Commit: db0be878476be4c00e935d4c8519b730285c5ec9
Parents: b69a459
Author: max-orlov 
Authored: Tue Apr 25 11:02:30 2017 +0300
Committer: max-orlov 
Committed: Tue Apr 25 11:02:30 2017 +0300

--
 aria/cli/color.py|  73 
 aria/cli/commands/executions.py  |   4 +-
 aria/cli/commands/logs.py|   2 +-
 aria/cli/config/config_template.yaml |   1 -
 aria/cli/execution_logging.py| 109 --
 aria/cli/logger.py   |  17 -
 6 files changed, 135 insertions(+), 71 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/db0be878/aria/cli/color.py
--
diff --git a/aria/cli/color.py b/aria/cli/color.py
new file mode 100644
index 000..3a44011
--- /dev/null
+++ b/aria/cli/color.py
@@ -0,0 +1,73 @@
+# 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 StringIO import StringIO
+
+import colorama
+
+colorama.init()
+
+
+def _get_colors(color_type):
+for name in dir(color_type):
+if not name.startswith('_'):
+yield (name.lower(), getattr(color_type, name))
+
+
+class Color(object):
+Fore = colorama.Fore
+Back = colorama.Back
+Style = colorama.Style
+
+_colors = {
+'fore': dict(_get_colors(Fore)),
+'back': dict(_get_colors(Back)),
+'style': dict(_get_colors(Style))
+}
+
+class Schema(object):
+def __init__(self, **kwargs):
+"""
+It is possible to provide fore, back and style arguments. each 
could be either 
+the color is lower case letter, or the actual color from colorama.
+
+"""
+assert all(arg in Color._colors for arg in kwargs)
+self._kwargs = kwargs
+self._str = StringIO()
+for type_, colors in Color._colors.items():
+value = kwargs.pop(type_, None)
+# the former case is if the value is a string, the latter is 
in case of an object.
+self._str.write(colors.get(value) or value)
+
+def __str__(self):
+return self._str.getvalue()
+
+def __add__(self, other):
+return str(self) + str(other)
+
+def __radd__(self, other):
+return str(other) + str(self)
+
+@classmethod
+def stylize(cls, str_to_stylize, schema):
+return schema + str(str_to_stylize) + cls.Style.RESET_ALL
+
+@classmethod
+def markup(cls, str_to_stylize, matches, schema):
+modified_str = str_to_stylize
+for group_index in xrange(len(matches.regs)):
+match = matches.group(group_index)
+modified_str = modified_str.replace(match, schema + match + 
cls.Back.RESET)
+return modified_str

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/db0be878/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index 3eb53ab..77ca77a 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -149,7 +149,7 @@ def start(workflow_name,
 log_iterator = cli_logger.ModelLogIterator(model_storage, 
workflow_runner.execution_id)
 try:
 while execution_thread.is_alive():
-with execution_logging.format(mark_pattern=mark_pattern):
+with execution_logging.formats(mark_pattern=mark_pattern):