From a2b1b78f0b01782f972d118930b39f96646a5295 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Sun, 1 Oct 2017 18:03:33 +0300 Subject: [PATCH] PEP8 + Python exception --- chaos_monkey/dropper.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/chaos_monkey/dropper.py b/chaos_monkey/dropper.py index c0b995ae8..3e0a8bff5 100644 --- a/chaos_monkey/dropper.py +++ b/chaos_monkey/dropper.py @@ -1,17 +1,17 @@ +import argparse +import ctypes +import logging import os +import pprint +import shutil +import subprocess import sys import time -import ctypes -import shutil -import pprint -import logging -import subprocess -import argparse from ctypes import c_char_p +from config import WormConfiguration from exploit.tools import build_monkey_commandline_explicitly from model import MONKEY_CMDLINE_WINDOWS, MONKEY_CMDLINE_LINUX, GENERAL_CMDLINE_LINUX -from config import WormConfiguration from system_info import SystemInfoCollector, OperatingSystem if "win32" == sys.platform: @@ -65,7 +65,7 @@ class MonkeyDrops(object): self._config['destination_path']) LOG.info("Moved source file '%s' into '%s'", - self._config['source_path'], self._config['destination_path']) + self._config['source_path'], self._config['destination_path']) file_moved = True except (WindowsError, IOError, OSError) as exc: @@ -80,7 +80,7 @@ class MonkeyDrops(object): self._config['destination_path']) LOG.info("Copied source file '%s' into '%s'", - self._config['source_path'], self._config['destination_path']) + self._config['source_path'], self._config['destination_path']) except (WindowsError, IOError, OSError) as exc: LOG.error("Error copying source file '%s' into '%s': %s", self._config['source_path'], self._config['destination_path'], @@ -95,7 +95,7 @@ class MonkeyDrops(object): dropper_date_reference_path = WormConfiguration.dropper_date_reference_path_linux try: ref_stat = os.stat(dropper_date_reference_path) - except: + except OSError as exc: LOG.warn("Cannot set reference date using '%s', file not found", dropper_date_reference_path) else: @@ -142,10 +142,10 @@ class MonkeyDrops(object): # mark the file for removal on next boot dropper_source_path_ctypes = c_char_p(self._config['source_path']) - if 0 == ctypes.windll.kernel32.MoveFileExA( dropper_source_path_ctypes, None, - MOVEFILE_DELAY_UNTIL_REBOOT): + if 0 == ctypes.windll.kernel32.MoveFileExA(dropper_source_path_ctypes, None, + MOVEFILE_DELAY_UNTIL_REBOOT): LOG.debug("Error marking source file '%s' for deletion on next boot (error %d)", self._config['source_path'], ctypes.windll.kernel32.GetLastError()) else: LOG.debug("Dropper source file '%s' is marked for deletion on next boot", - self._config['source_path']) \ No newline at end of file + self._config['source_path'])