Skip to content

Commit

Permalink
Fix pep8
Browse files Browse the repository at this point in the history
bugzilla: 1602858
tendrl-bug-id: Tendrl#1080

Signed-off-by: GowthamShanmugam <gshanmug@redhat.com>
  • Loading branch information
GowthamShanmugam committed Apr 19, 2019
1 parent 01c56e8 commit c4f606b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 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
2 changes: 1 addition & 1 deletion tendrl/commons/tests/manager/test_manager_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def job_consume():
return "Thread Consuming Job"
monkeypatch.setattr(jobs, 'JobConsumerThread', job_consume)
manager = Manager("test")
assert manager._sds_sync_thread is "test"
assert manager._sds_sync_thread == "test"
assert manager._message_handler_thread is None
assert manager._job_consumer_thread == "Thread Consuming Job"

Expand Down
2 changes: 1 addition & 1 deletion tendrl/commons/tests/objects/test_objects_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_save():
with patch.object(Client, "write", return_value=True):
with patch.object(Client, "read",
return_value=maps.NamedDict(value="")):
obj.save(True)
obj.save(True)
with patch.object(Client, "write", return_value=True):
with patch.object(objects.BaseObject, "_hash",
return_value=None):
Expand Down
8 changes: 4 additions & 4 deletions tendrl/commons/tests/utils/test_ansible_module_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ def test_AnsibleExecutableGenerationFailed_constructor():
ansible_obj = AnsibleExecutableGenerationFailed()
assert ansible_obj.message == "Executabe could not be generated for " \
"module None . Error: None"
ansible_obj = AnsibleExecutableGenerationFailed(module_path="Test\path",
ansible_obj = AnsibleExecutableGenerationFailed(module_path="Test\\path",
arguments="temp_args",
err="No Error")
assert ansible_obj.message == "Executabe could not be generated for " \
"module Test\path . Error: No Error"
"module Test\\path . Error: No Error"


def test_AnsibleModuleNotFound_constructor():
ansible_obj = AnsibleModuleNotFound()
assert ansible_obj.message == "Ansible module None not found"
ansible_obj = AnsibleModuleNotFound(module_path="Test\path")
assert ansible_obj.message == "Ansible module Test\path not found"
ansible_obj = AnsibleModuleNotFound(module_path="Test\\path")
assert ansible_obj.message == "Ansible module Test\\path not found"


@mock.patch('tendrl.commons.event.Event.__init__',
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 c4f606b

Please sign in to comment.