Skip to content

Commit

Permalink
Pep8 fix
Browse files Browse the repository at this point in the history
tendrl-bug-id: Tendrl#1080
bugzilla: 1688630

Signed-off-by: GowthamShanmugam <gshanmug@redhat.com>
  • Loading branch information
GowthamShanmugam committed Apr 25, 2019
1 parent 5e7fad4 commit ee1ef6c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions tendrl/commons/flows/unmanage_cluster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def run(self):
).load()
if _cluster.is_managed == "no":
if _cluster.current_job['job_name'] == self.__class__.__name__ \
and _cluster.current_job['status'] == 'finished':
raise FlowExecutionFailedError(
"Cluster is already in un-managed state"
)
and _cluster.current_job['status'] == 'finished':
raise FlowExecutionFailedError(
"Cluster is already in un-managed state"
)
if _cluster.current_job['status'] == 'in_progress' and \
(
'job_id' in _cluster.locked_by and
Expand Down
24 changes: 12 additions & 12 deletions tendrl/commons/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from inspect import getframeinfo
from inspect import stack
import json
from ruamel import yaml
import sys
from tendrl.commons.utils.time_utils import now # flake8:noqa
import traceback

is_collectd_imported = False
if '/usr/lib64/collectd' in sys.path:
is_collectd_imported = True
Expand All @@ -16,11 +20,6 @@
# An appropriate solution needs to be carved out


from tendrl.commons.utils.time_utils import now # flake8:noqa

import traceback
from ruamel import yaml

class Message(object):
"""At the time of message object intialization
Expand Down Expand Up @@ -96,13 +95,13 @@ def validate(self):
# Check payload type is dict
if type(self.payload) != dict:
return False

# Check mandatory fields
if (self.priority not in priorities or
self.node_id is None or
"message" not in self.payload):
return False

if self.job_id is not None:
if self.flow_id is None:
return False
Expand All @@ -119,7 +118,7 @@ def __init__(self, priority, publisher, payload):
# skip last function call
# This will give traceback upto before try function call
formatted_stack = traceback.extract_stack()[:-2]
_, _ , exc_traceback = sys.exc_info()
_, _, exc_traceback = sys.exc_info()
# This will give traceback inside try block
recent_call = traceback.extract_tb(exc_traceback)
caller = getframeinfo(stack()[1][0])
Expand Down Expand Up @@ -149,13 +148,14 @@ def format_exception(self, formatted_stack):
tb = []
for item in formatted_stack:
file, line, function, statement = item
tb.append({"file" : file,
"line" : line,
"function" : function,
"statement" : statement
tb.append({"file": file,
"line": line,
"function": function,
"statement": statement
})
return tb


# To serialize when json contains old message object
def serialize_message(obj):
if isinstance(obj, Message):
Expand Down
8 changes: 4 additions & 4 deletions tendrl/commons/utils/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def log(log_priority, publisher_id, log_payload, job_id=None,
)
)
except Exception:
if log_priority.lower() == "error":
sys.stderr.write(log_payload.get("message", "") + "\n")
else:
sys.stdout.write(log_payload.get("message", "") + "\n")
if log_priority.lower() == "error":
sys.stderr.write(log_payload.get("message", "") + "\n")
else:
sys.stdout.write(log_payload.get("message", "") + "\n")
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ commands = python check_commit_msg.py
# E123, E125 skipped as they are invalid PEP-8.
# see: http://flake8.readthedocs.io/en/latest/config.html#settings
show-source = True
ignore = E123,E125,W504
ignore = E123,E125,W504,E402
builtins = _, NS
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build

Expand Down

0 comments on commit ee1ef6c

Please sign in to comment.