From fe5e460d0607cb0989a92441afe2bdd52640f214 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 13 Oct 2010 18:44:17 -0500 Subject: Mirror check script cleanup Don't import all the constants from logging, just use logging.* instead. Also, fix some typos that somehow snuck into one of my commits. Signed-off-by: Dan McGee --- mirrors/management/commands/mirrorcheck.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py index 4f677a2..bab7921 100644 --- a/mirrors/management/commands/mirrorcheck.py +++ b/mirrors/management/commands/mirrorcheck.py @@ -18,18 +18,15 @@ import re import socket import sys import time -import thread from threading import Thread import types from Queue import Queue, Empty import urllib2 -from logging import ERROR, WARNING, INFO, DEBUG - -from mirrors.models import Mirror, MirrorUrl, MirrorLog +from mirrors.models import MirrorUrl, MirrorLog logging.basicConfig( - level=WARNING, + level=logging.WARNING, format='%(asctime)s -> %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', stream=sys.stderr) @@ -41,11 +38,11 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): v = int(options.get('verbosity', 0)) if v == 0: - logger.level = ERROR + logger.level = logging.ERROR elif v == 1: - logger.level = WARNING + logger.level = logging.WARNING elif v == 2: - logger.level = DEBUG + logger.level = logging.DEBUG import signal, traceback handler = lambda sig, stack: traceback.print_stack(stack) @@ -109,7 +106,7 @@ def check_mirror_url(mirror_url): log.error = str(e) logger.debug("failed: %s, %s" % (url, log.error)) except urllib2.URLError, e: - log.is_success=False + log.is_success = False log.error = e.reason if isinstance(e.reason, types.StringTypes) and \ re.search(r'550.*No such file', e.reason): @@ -122,7 +119,7 @@ def check_mirror_url(mirror_url): log.error = e.reason.args[1] logger.debug("failed: %s, %s" % (url, log.error)) except socket.timeout, e: - log.is_success = false + log.is_success = False log.error = "Connection timed out." logger.debug("failed: %s, %s" % (url, log.error)) -- cgit v1.2.3-24-g4f1b