From f368539447fb67a0c9dd7a79df58d05278832234 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 22 Aug 2017 10:58:30 +0200 Subject: [PATCH] Some pylint cleaning. --- cdist/banner.py | 2 -- cdist/config.py | 11 +++++------ cdist/core/code.py | 2 -- cdist/emulator.py | 4 ++-- cdist/exec/local.py | 2 -- cdist/exec/remote.py | 2 -- cdist/exec/util.py | 1 - cdist/message.py | 2 -- cdist/shell.py | 1 - scripts/cdist | 4 +--- 10 files changed, 8 insertions(+), 23 deletions(-) diff --git a/cdist/banner.py b/cdist/banner.py index edfa72e8..da4dea5d 100644 --- a/cdist/banner.py +++ b/cdist/banner.py @@ -20,8 +20,6 @@ # import logging -import sys - import cdist log = logging.getLogger(__name__) diff --git a/cdist/config.py b/cdist/config.py index 14533237..3e786272 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -27,7 +27,6 @@ import sys import time import itertools import tempfile -import socket import multiprocessing from cdist.mputil import mp_pool_run, mp_sig_handler import atexit @@ -49,14 +48,17 @@ class Config(object): """Cdist main class to hold arbitrary data""" def __init__(self, local, remote, dry_run=False, jobs=None, - cleanup_cmds=[]): + cleanup_cmds=None): self.local = local self.remote = remote self._open_logger() self.dry_run = dry_run self.jobs = jobs - self.cleanup_cmds = cleanup_cmds + if cleanup_cmds: + self.cleanup_cmds = cleanup_cmds + else: + self.cleanup_cmds = [] self.explorer = core.Explorer(self.local.target_host, self.local, self.remote, jobs=self.jobs) @@ -111,7 +113,6 @@ class Config(object): if not (args.hostfile or args.host): args.hostfile = '-' - initial_manifest_tempfile = None if args.manifest == '-': # read initial manifest from stdin try: @@ -623,8 +624,6 @@ class Config(object): raise cdist.Error(("Attempting to run an already finished " "object: %s"), cdist_object) - cdist_type = cdist_object.cdist_type - # Generate self.log.debug("Generating code for %s" % (cdist_object.name)) cdist_object.code_local = self.code.run_gencode_local(cdist_object) diff --git a/cdist/core/code.py b/cdist/core/code.py index 173d192d..94ede0f9 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -23,8 +23,6 @@ import os -import cdist - ''' common: diff --git a/cdist/emulator.py b/cdist/emulator.py index bba46260..f1419ceb 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -98,7 +98,7 @@ class Emulator(object): self.init_object() # locking for parallel execution - with flock.Flock(self.flock_path) as lock: + with flock.Flock(self.flock_path): self.setup_object() self.save_stdin() self.record_requirements() @@ -112,7 +112,7 @@ class Emulator(object): if '__cdist_loglevel' in self.env: try: level = int(self.env['__cdist_loglevel']) - except: + except ValueError: level = logging.WARNING else: level = logging.WARNING diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 23ad4ce9..7726c604 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -21,7 +21,6 @@ # # -import io import os import sys import re @@ -348,7 +347,6 @@ class Local(object): continue for entry in os.listdir(current_dir): - rel_entry_path = os.path.join(sub_dir, entry) src = os.path.abspath(os.path.join(conf_dir, sub_dir, entry)) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 10b43e15..85cd193d 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -20,9 +20,7 @@ # # -import io import os -import sys import glob import subprocess import logging diff --git a/cdist/exec/util.py b/cdist/exec/util.py index 9ed7103b..b71b9bcc 100644 --- a/cdist/exec/util.py +++ b/cdist/exec/util.py @@ -20,7 +20,6 @@ # import subprocess -import sys from tempfile import TemporaryFile import cdist diff --git a/cdist/message.py b/cdist/message.py index 98a6e8cf..450fc3c3 100644 --- a/cdist/message.py +++ b/cdist/message.py @@ -24,8 +24,6 @@ import os import shutil import tempfile -import cdist - log = logging.getLogger(__name__) diff --git a/cdist/shell.py b/cdist/shell.py index 44cdd49d..a9457aaf 100644 --- a/cdist/shell.py +++ b/cdist/shell.py @@ -21,7 +21,6 @@ import logging import os -import subprocess import tempfile # initialise cdist diff --git a/scripts/cdist b/scripts/cdist index d9dce35f..384610b1 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -21,7 +21,6 @@ # # -import collections import logging @@ -34,8 +33,6 @@ def commandline(): import cdist.install import cdist.shell import cdist.inventory - import shutil - import os parser = cdist.argparse.get_parsers() args = parser['main'].parse_args(sys.argv[1:]) @@ -64,6 +61,7 @@ def commandline(): cdist.argparse.check_beta(vars(args)) args.func(args) + if __name__ == "__main__": import sys