Commit 14cfda6 Merge #327 `[backend] resolving pylint warnings - wrong import position and order, reimported, unused import`

13 files Merged and Committed by clime 4 days ago
 1 @@ -3,18 +3,17 @@
 2   import os.path
 3   import shutil
 4   import time
 5 - import glob
 6   import traceback
 7   import base64
 8 - import modulemd
 9 - import tempfile
10   
11 - from munch import Munch
12   from distutils.dir_util import copy_tree
13   from distutils.errors import DistutilsFileError
14 + from urllib.request import urlretrieve
15   from copr.exceptions import CoprRequestException
16   from requests import RequestException
17 - from urllib.request import urlretrieve
18 + from munch import Munch
19 + 
20 + import modulemd
21   
22   from .sign import create_user_keys, CoprKeygenRequestError
23   from .createrepo import createrepo
 1 @@ -1,4 +1,5 @@
 2   import os
 3 + from logging import Formatter
 4   
 5   mockchain = "/usr/bin/mockchain"
 6   # rsync path
 7 @@ -36,7 +37,6 @@
 8   
 9   LOG_PUB_SUB = "copr:backend:log:pubsub::"
10   
11 - from logging import Formatter
12   default_log_format = Formatter(
13       '[%(asctime)s][%(levelname)6s][%(name)10s][%(filename)s:%(funcName)s:%(lineno)d] %(message)s')
14   build_log_format = Formatter(
 1 @@ -1,8 +1,8 @@
 2   import os
 3   from subprocess import Popen, PIPE
 4   
 5 - from setproctitle import getproctitle, setproctitle
 6   from shlex import split
 7 + from setproctitle import getproctitle, setproctitle
 8   from lockfile import LockFile
 9   
10   # todo: add logging here
1 @@ -1,6 +1,6 @@
2   # coding: utf-8
3   
4 - import json
5 + import json #line 49 # pylint: disable=unused-import
6   import time
7   import multiprocessing
8   from setproctitle import setproctitle
 1 @@ -2,21 +2,15 @@
 2   
 3   import grp
 4   import pwd
 5 - import signal
 6   import sys
 7 - import time
 8 - from collections import defaultdict
 9   
10   import lockfile
11   from daemon import DaemonContext
12   from requests import RequestException
13 - from retask import ConnectionError
14   from backend.frontend import FrontendClient
15   
16   from ..exceptions import CoprBackendError
17   from ..helpers import BackendConfigReader, get_redis_logger
18 - from .build_dispatcher import BuildDispatcher
19 - from .action_dispatcher import ActionDispatcher
20   
21   
22   class CoprBackend(object):
 1 @@ -1,9 +1,11 @@
 2   # coding: utf-8
 3   
 4   import time
 5 - import os
 6   import multiprocessing
 7 - import json
 8 + import json #line 85 # pylint: disable=unused-import
 9 + 
10 + from collections import defaultdict
11 + 
12   from setproctitle import setproctitle
13   from requests import get, RequestException
14   
15 @@ -16,7 +18,6 @@
16   from ..constants import BuildStatus
17   from .worker import Worker
18   
19 - from collections import defaultdict
20   
21   class BuildDispatcher(multiprocessing.Process):
22       """
 1 @@ -1,11 +1,10 @@
 2   # coding: utf-8
 3   
 4 - import json
 5 - 
 6   from multiprocessing import Process
 7   import time
 8 - from setproctitle import setproctitle
 9   import traceback
10 + from setproctitle import setproctitle
11 + 
12   
13   from ..vm_manage import VmStates
14   from ..exceptions import VmSpawnLimitReached
 1 @@ -1,5 +1,3 @@
 2 - from datetime import datetime
 3 - import json
 4   import os
 5   import time
 6   import gzip
 7 @@ -9,13 +7,12 @@
 8   import glob
 9   from setproctitle import setproctitle
10   
11 - from ..exceptions import MockRemoteError, CoprWorkerError, VmError, NoVmAvailable
12 - from ..job import BuildJob
13 + from ..exceptions import MockRemoteError, CoprWorkerError, VmError
14 + from ..job import BuildJob #line 151 (will be implemented?) #pylint: disable=unused-import
15   from ..mockremote import MockRemote
16   from ..constants import BuildStatus, build_log_format
17 - from ..helpers import register_build_result, get_redis_connection, get_redis_logger, \
18 + from ..helpers import register_build_result, get_redis_logger, \
19       local_file_logger, run_cmd
20 - from ..vm_manage import VmStates
21   
22   from ..msgbus import MsgBusStomp, MsgBusFedmsg
23   from ..sshcmd import SSHConnectionError
 1 @@ -8,29 +8,33 @@
 2   import time
 3   import types
 4   import glob
 5 + 
 6   import configparser
 7 + from configparser import ConfigParser
 8   
 9   from contextlib import contextmanager
10   from operator import methodcaller
11 - from configparser import ConfigParser
12   
13   import traceback
14   
15   from datetime import datetime
16 + 
17 + import subprocess
18 + 
19   import pytz
20   
21 + import munch
22   from munch import Munch
23 + 
24   from redis import StrictRedis
25 - from . import constants
26   
27   from copr.client import CoprClient
28   from backend.constants import DEF_BUILD_USER, DEF_BUILD_TIMEOUT, DEF_CONSECUTIVE_FAILURE_THRESHOLD, \
29       CONSECUTIVE_FAILURE_REDIS_KEY, default_log_format
30   from backend.exceptions import CoprBackendError
31   
32 - import subprocess
33 - import logging
34 - import munch
35 + from . import constants
36 + 
37   
38   def pyconffile(filename):
39       """
 1 @@ -1,20 +1,18 @@
 2   import os
 3   import pipes
 4 - import socket
 5 + import socket #mentioned in TODO # pylint: disable=unused-import 
 6   from subprocess import Popen
 7 - import time
 8   from urllib.parse import urlparse
 9 - import glob
10   
11   from backend.vm_manage import PUBSUB_INTERRUPT_BUILDER
12 - from ..helpers import get_redis_connection, ensure_dir_exists
13   
14 - from ..exceptions import BuilderError, RemoteCmdError, VmError
15 + import modulemd
16   
17 + from ..helpers import get_redis_connection, ensure_dir_exists
18 + from ..exceptions import BuilderError, RemoteCmdError, VmError
19   from ..constants import rsync
20 - from ..sshcmd import SSHConnectionError, SSHConnection
21 + from ..sshcmd import SSHConnection
22   
23 - import modulemd
24   
25   
26   class Builder(object):
 1 @@ -1,9 +1,9 @@
 2   # coding: utf-8
 3   import json
 4   from multiprocessing import Process
 5 - from setproctitle import setproctitle
 6   from threading import Thread
 7   import time
 8 + from setproctitle import setproctitle
 9   
10   from backend.exceptions import VmDescriptorNotFound
11   from backend.helpers import get_redis_logger
 1 @@ -1,8 +1,8 @@
 2   # coding: utf-8
 3   
 4   from pprint import pformat
 5 - from . import KEY_VM_INSTANCE
 6   from backend.exceptions import VmDescriptorNotFound
 7 + from . import KEY_VM_INSTANCE
 8   
 9   
10   class VmDescriptor(object):
 1 @@ -7,10 +7,10 @@
 2   
 3   from netaddr import IPAddress
 4   
 5 - from ..ans_utils import run_ansible_playbook_cli
 6   from backend.helpers import get_redis_connection
 7   from backend.vm_manage import PUBSUB_MB, EventTopics
 8   from backend.vm_manage.executor import Executor
 9 + from ..ans_utils import run_ansible_playbook_cli
10   from ..exceptions import CoprSpawnFailError
11   from ..helpers import get_redis_logger
12   from ..vm_manage import terminate