Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Fixes to improve python2.7 compatibility #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chaosmonkey/attacks/attack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Attack:
class Attack(object):
"""
Base class for attacks. Every attack must extend from this class
"""
Expand Down
4 changes: 2 additions & 2 deletions chaosmonkey/attacks/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def execute(attack_config=None, plan_id=None):
:param attack_config: **Dict** with attack configuration
:param plan_id: **String** plan id for the plan containing the executor
"""
attack_class = CMEManager.manager.attacks_store.get(attack_config.get('ref'))
attack_class = CMEManager.manager.attacks_store.get(str(attack_config.get('ref')))

if attack_class is None:
msg = '[PlanID %s] Attack ref %s not loaded in the store ' \
% (plan_id, attack_config.get('ref'))
% (plan_id, str(attack_config.get('ref')))
log.debug(msg)
raise ValueError(msg)

Expand Down
4 changes: 2 additions & 2 deletions chaosmonkey/engine/cme_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def execute_plan(self, name, planner_config, attack_config):
:param attack_config: Dict with attack config
"""
try:
planner_class = self._planners_store.get(planner_config.get("ref"))
attack_class = self._attacks_store.get(attack_config.get("ref"))
planner_class = self._planners_store.get(str(planner_config.get("ref")))
attack_class = self._attacks_store.get(str(attack_config.get("ref")))
except ModuleLookupError as e:
raise APIError("invalid planner %s" % e.message)

Expand Down
2 changes: 1 addition & 1 deletion chaosmonkey/planners/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from chaosmonkey.engine.cme_manager import manager


class Planner:
class Planner(object):
"""
Planner interface
Planners are responsible for scheduling jobs that executes attacks
Expand Down
4 changes: 2 additions & 2 deletions planners/simple_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def _get_day_attack_schedule(self):
random.seed()
attack_schedule = []
for start, end in self._split_date_range(start_date, end_date, planer_args["times"]):
attack_schedule.append(random.uniform(start, end))

tmp_schedule = random.uniform(int(start.strftime('%s')), int(end.strftime('%s')))
attack_schedule.append(datetime.fromtimestamp(tmp_schedule))
return attack_schedule

@staticmethod
Expand Down