Just because it's not in pyanaconda doesn't mean we shouldn't hold it to the same standards.
This also changes the pre-commit hook to run against the code staged to commit instead of the code on the filesystem, which may be helpful.
--- scripts/githooks/pre-commit | 15 ++++++++++++++- tests/pylint/runpylint.sh | 9 +++++++-- 2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 7ab2df7..1528793 100755 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -9,6 +9,19 @@ import os import sys from subprocess import check_output, CalledProcessError
+def is_python(filename): + if filename.endswith(".py"): + return True + + try: + with open(filename) as testfile: + if testfile.readline().startswith("#!/usr/bin/python"): + return True + except IOError: + pass + + return False + OTHER_MODULES_PATH = ".:../blivet/:../pykickstart/"
if "NOPYLINT" in os.environ: @@ -25,7 +38,7 @@ pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines(): path = gf.split()[-1] - if path == "anaconda" or path.endswith(".py"): + if is_python(path): pylint_files.append(path)
if not pylint_files: diff --git a/tests/pylint/runpylint.sh b/tests/pylint/runpylint.sh index af4183e..1396d33 100755 --- a/tests/pylint/runpylint.sh +++ b/tests/pylint/runpylint.sh @@ -15,6 +15,9 @@ if [ -z "$top_srcdir" ]; then pylint_log=1 fi
+# Unset TERM so that things that use readline don't output terminal garbage +unset TERM + # If $top_srcdir has not been set by automake, import the test environment if [ -z "$top_srcdir" ]; then top_srcdir="$(dirname "$0")/../.." @@ -78,7 +81,9 @@ fi # run pylint one file / module at a time, otherwise it sometimes gets # confused if [ -z "$FILES" ]; then - FILES="${top_srcdir}/anaconda $(find "${top_srcdir}/pyanaconda" -type f -name '*py' ! -executable)" + # Find any file in the list of directories that either ends in .py + # or contains #!/usr/bin/python in the first line. + FILES="$(find "${top_srcdir}"/{anaconda,pyanaconda,tests,widgets,utils,scripts} -type f ( -name '*.py' -o -exec awk -e 'NR==1 { if ($0 ~ /^#!/usr/bin/python/) exit 0; else exit 1; }' -e 'END { if (NR == 0) exit 1; }' {} ; ) -print)" fi for i in $FILES; do if [ -n "$(echo "$i" | grep 'pyanaconda/packaging/dnfpayload.py$')" ]; then @@ -90,7 +95,7 @@ for i in $FILES; do -r n --disable=C,R --rcfile=/dev/null \ --dummy-variables-rgx=_ \ --ignored-classes=DefaultInstall,Popen,QueueFactory,TransactionSet \ - --defining-attr-methods=__init__,_grabObjects,initialize,reset,start \ + --defining-attr-methods=__init__,_grabObjects,initialize,reset,start,setUp \ $DISABLED_WARN_OPTIONS \ $DISABLED_ERR_OPTIONS \ $NON_STRICT_OPTIONS $i | \
Changed the pylint Module output so that it's more clear what file is being checked. Added an option to runpylint.sh to manually set the filename to display. --- scripts/githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++------------- tests/pylint/runpylint.sh | 16 ++++++++++++++- 2 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 1528793..a3307b9 100755 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -7,6 +7,7 @@ """ import os import sys +import tempfile from subprocess import check_output, CalledProcessError
def is_python(filename): @@ -14,11 +15,11 @@ def is_python(filename): return True
try: - with open(filename) as testfile: - if testfile.readline().startswith("#!/usr/bin/python"): - return True - except IOError: - pass + s = check_output(["git", "show", (":%s" % filename)]).splitlines() + if s and s[0].startswith("#!/usr/bin/python"): + return True + except CalledProcessError: + sys.exit(1)
return False
@@ -37,24 +38,44 @@ except CalledProcessError: pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines(): - path = gf.split()[-1] - if is_python(path): - pylint_files.append(path) + fields = gf.split() + + # If the file is being removed, ignore it + if fields[4] == 'D': + continue + elif is_python(fields[-1]): + pylint_files.append(fields[-1])
if not pylint_files: sys.exit(0) -pylint_files = " ".join(pylint_files)
# Make sure pykickstart and blivet can be found # Note that if the checked out versions are too far off pylint may fail env = os.environ.copy() env["PYTHONPATH"] = OTHER_MODULES_PATH
+# Make a list of tuples of (filename, tempfile) where the tempfile +# contains the file as staged for commit. +pylint_commits = [] +for pylint_file in pylint_files: + commit = tempfile.NamedTemporaryFile() + try: + commit.write(check_output(["git", "show", (":%s" % pylint_file)])) + except CalledProcessError: + sys.exit(1) + commit.flush() + pylint_commits.append((pylint_file, commit)) + print "Running pylint on %s" % pylint_files -try: - check_output("./tests/pylint/runpylint.sh %s" % pylint_files, shell=True, env=env) -except CalledProcessError as e: - print e.output +success = True +for commit in pylint_commits: + try: + check_output(["./tests/pylint/runpylint.sh", "--displayname", commit[0], commit[1].name]) + except CalledProcessError as e: + print e.output + success = False + +if not success: sys.exit(1)
sys.exit(0) diff --git a/tests/pylint/runpylint.sh b/tests/pylint/runpylint.sh index 1396d33..c943900 100755 --- a/tests/pylint/runpylint.sh +++ b/tests/pylint/runpylint.sh @@ -47,16 +47,21 @@ DISABLED_ERR_OPTIONS="--disable=E1103" DISABLED_WARN_OPTIONS="--disable=W0110,W0141,W0142,W0223,W0403,W0511,W0603,W0604,W0613,W0614"
usage () { - echo "usage: `basename $0` [--strict] [--help] [files...]" + echo "usage: `basename $0` [--strict] [--help] [--displayname NAME] [files...]" exit $1 }
FILES= +DISPLAYNAME= while [ $# -gt 0 ]; do case $1 in --strict) NON_STRICT_OPTIONS= ;; + --displayname) + DISPLAYNAME="$2" + shift + ;; --help) usage 0 ;; @@ -86,6 +91,12 @@ if [ -z "$FILES" ]; then FILES="$(find "${top_srcdir}"/{anaconda,pyanaconda,tests,widgets,utils,scripts} -type f ( -name '*.py' -o -exec awk -e 'NR==1 { if ($0 ~ /^#!/usr/bin/python/) exit 0; else exit 1; }' -e 'END { if (NR == 0) exit 1; }' {} ; ) -print)" fi for i in $FILES; do + if [ -z "$DISPLAYNAME" ]; then + _DISPLAYNAME="$i" + else + _DISPLAYNAME="$DISPLAYNAME" + fi + if [ -n "$(echo "$i" | grep 'pyanaconda/packaging/dnfpayload.py$')" ]; then continue fi @@ -104,6 +115,9 @@ for i in $FILES; do # I0011 is the informational "Locally disabling ...." message if [ -n "$(echo "$pylint_output" | fgrep -v '************* Module ' |\ grep -v '^I0011:')" ]; then + # Replace the Module line with the actual filename + pylint_output="$(echo "$pylint_output" | sed "s|* Module .*|* Module $_DISPLAYNAME|")" + if [ "$pylint_log" -ne 0 ]; then echo "$pylint_output" >> pylint-log else
On Wed, 2013-09-25 at 14:21 -0400, David Shea wrote:
Changed the pylint Module output so that it's more clear what file is being checked. Added an option to runpylint.sh to manually set the filename to display.
scripts/githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++------------- tests/pylint/runpylint.sh | 16 ++++++++++++++- 2 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 1528793..a3307b9 100755 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -7,6 +7,7 @@ """ import os import sys +import tempfile from subprocess import check_output, CalledProcessError
def is_python(filename): @@ -14,11 +15,11 @@ def is_python(filename): return True
try:
with open(filename) as testfile:
if testfile.readline().startswith("#!/usr/bin/python"):
return True
- except IOError:
pass
s = check_output(["git", "show", (":%s" % filename)]).splitlines()
if s and s[0].startswith("#!/usr/bin/python"):
return True
except CalledProcessError:
sys.exit(1)
return False
@@ -37,24 +38,44 @@ except CalledProcessError: pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines():
- path = gf.split()[-1]
- if is_python(path):
pylint_files.append(path)
- fields = gf.split()
- # If the file is being removed, ignore it
- if fields[4] == 'D':
continue
- elif is_python(fields[-1]):
pylint_files.append(fields[-1])
if not pylint_files: sys.exit(0) -pylint_files = " ".join(pylint_files)
# Make sure pykickstart and blivet can be found # Note that if the checked out versions are too far off pylint may fail env = os.environ.copy() env["PYTHONPATH"] = OTHER_MODULES_PATH
+# Make a list of tuples of (filename, tempfile) where the tempfile +# contains the file as staged for commit. +pylint_commits = [] +for pylint_file in pylint_files:
- commit = tempfile.NamedTemporaryFile()
Those files are gonna end up under /tmp, right? Won't it cause some troubles with PYTHONPATH and stuff like that?
On 09/25/2013 02:42 PM, Vratislav Podzimek wrote:
On Wed, 2013-09-25 at 14:21 -0400, David Shea wrote:
Changed the pylint Module output so that it's more clear what file is being checked. Added an option to runpylint.sh to manually set the filename to display.
scripts/githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++------------- tests/pylint/runpylint.sh | 16 ++++++++++++++- 2 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 1528793..a3307b9 100755 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -7,6 +7,7 @@ """ import os import sys +import tempfile from subprocess import check_output, CalledProcessError
def is_python(filename): @@ -14,11 +15,11 @@ def is_python(filename): return True
try:
with open(filename) as testfile:
if testfile.readline().startswith("#!/usr/bin/python"):
return True
- except IOError:
pass
s = check_output(["git", "show", (":%s" % filename)]).splitlines()
if s and s[0].startswith("#!/usr/bin/python"):
return True
except CalledProcessError:
sys.exit(1) return False
@@ -37,24 +38,44 @@ except CalledProcessError: pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines():
- path = gf.split()[-1]
- if is_python(path):
pylint_files.append(path)
fields = gf.split()
# If the file is being removed, ignore it
if fields[4] == 'D':
continue
elif is_python(fields[-1]):
pylint_files.append(fields[-1])
if not pylint_files: sys.exit(0)
-pylint_files = " ".join(pylint_files)
# Make sure pykickstart and blivet can be found # Note that if the checked out versions are too far off pylint may fail env = os.environ.copy() env["PYTHONPATH"] = OTHER_MODULES_PATH
+# Make a list of tuples of (filename, tempfile) where the tempfile +# contains the file as staged for commit. +pylint_commits = [] +for pylint_file in pylint_files:
- commit = tempfile.NamedTemporaryFile()
Those files are gonna end up under /tmp, right? Won't it cause some troubles with PYTHONPATH and stuff like that?
Erk, yeah. This'll cause trouble with modules that use relative imports. The use case I was aiming for was you get ready to commit a module, it fails pylint, you fix the problems, and then you forget to git-add before running the commit again. I figured it's probably good enough to check the staged module using imports that are on the filesystem and not necessarily staged. For the problem of relative imports, I'm tempted to un-disable W0403 ("Relative import %r...") and just make everything absolute, which will let PYTHONPATH work.
On Wed, 2013-09-25 at 15:02 -0400, David Shea wrote:
On 09/25/2013 02:42 PM, Vratislav Podzimek wrote:
On Wed, 2013-09-25 at 14:21 -0400, David Shea wrote:
Changed the pylint Module output so that it's more clear what file is being checked. Added an option to runpylint.sh to manually set the filename to display.
scripts/githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++------------- tests/pylint/runpylint.sh | 16 ++++++++++++++- 2 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 1528793..a3307b9 100755 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -7,6 +7,7 @@ """ import os import sys +import tempfile from subprocess import check_output, CalledProcessError
def is_python(filename): @@ -14,11 +15,11 @@ def is_python(filename): return True
try:
with open(filename) as testfile:
if testfile.readline().startswith("#!/usr/bin/python"):
return True
- except IOError:
pass
s = check_output(["git", "show", (":%s" % filename)]).splitlines()
if s and s[0].startswith("#!/usr/bin/python"):
return True
except CalledProcessError:
sys.exit(1) return False
@@ -37,24 +38,44 @@ except CalledProcessError: pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines():
- path = gf.split()[-1]
- if is_python(path):
pylint_files.append(path)
fields = gf.split()
# If the file is being removed, ignore it
if fields[4] == 'D':
continue
elif is_python(fields[-1]):
pylint_files.append(fields[-1])
if not pylint_files: sys.exit(0)
-pylint_files = " ".join(pylint_files)
# Make sure pykickstart and blivet can be found # Note that if the checked out versions are too far off pylint may fail env = os.environ.copy() env["PYTHONPATH"] = OTHER_MODULES_PATH
+# Make a list of tuples of (filename, tempfile) where the tempfile +# contains the file as staged for commit. +pylint_commits = [] +for pylint_file in pylint_files:
- commit = tempfile.NamedTemporaryFile()
Those files are gonna end up under /tmp, right? Won't it cause some troubles with PYTHONPATH and stuff like that?
Erk, yeah. This'll cause trouble with modules that use relative imports. The use case I was aiming for was you get ready to commit a module, it fails pylint, you fix the problems, and then you forget to git-add before running the commit again. I figured it's probably good enough to check the staged module using imports that are on the filesystem and not necessarily staged. For the problem of relative imports, I'm tempted to un-disable W0403 ("Relative import %r...") and just make everything absolute, which will let PYTHONPATH work.
+1 to that. AFAICT, relative imports also don't work with updates.img.
--- pyanaconda/anaconda.py | 8 ++++---- pyanaconda/anaconda_log.py | 2 +- pyanaconda/anaconda_optparse.py | 2 +- pyanaconda/constants.py | 2 +- pyanaconda/exception.py | 6 +++--- pyanaconda/flags.py | 2 +- pyanaconda/geoloc.py | 2 +- pyanaconda/image.py | 6 +++--- pyanaconda/installclass.py | 2 +- pyanaconda/iutil.py | 8 ++++---- pyanaconda/kickstart.py | 12 ++++++------ pyanaconda/network.py | 4 ++-- pyanaconda/packaging/livepayload.py | 2 +- pyanaconda/queue.py | 2 +- pyanaconda/rescue.py | 16 ++++++++-------- pyanaconda/simpleconfig.py | 2 +- pyanaconda/text.py | 2 +- pyanaconda/ui/__init__.py | 2 +- pyanaconda/ui/gui/__init__.py | 10 +++++----- pyanaconda/ui/tui/__init__.py | 8 ++++---- pyanaconda/ui/tui/hubs/__init__.py | 2 +- pyanaconda/ui/tui/simpleline/__init__.py | 4 ++-- pyanaconda/ui/tui/simpleline/widgets.py | 2 +- pyanaconda/ui/tui/tuiobject.py | 2 +- pyanaconda/users.py | 2 +- pyanaconda/vnc.py | 6 +++--- tests/pylint/runpylint.sh | 3 +-- 27 files changed, 60 insertions(+), 61 deletions(-)
diff --git a/pyanaconda/anaconda.py b/pyanaconda/anaconda.py index 9a5aecc..759f6d4 100644 --- a/pyanaconda/anaconda.py +++ b/pyanaconda/anaconda.py @@ -30,7 +30,7 @@
import os import sys -from constants import ROOT_PATH +from pyanaconda.constants import ROOT_PATH from tempfile import mkstemp
from pyanaconda.bootloader import get_bootloader @@ -43,7 +43,7 @@ stdoutLog = logging.getLogger("anaconda.stdout")
class Anaconda(object): def __init__(self): - import desktop + import pyanaconda.desktop as desktop
self._bootloader = None self.canReIPL = False @@ -86,7 +86,7 @@ class Anaconda(object): @property def instClass(self): if not self._instClass: - from installclass import DefaultInstall + from pyanaconda.installclass import DefaultInstall self._instClass = DefaultInstall()
return self._instClass @@ -111,7 +111,7 @@ class Anaconda(object): klass = self.instClass.getBackend()
if not klass: - from flags import flags + from pyanaconda.flags import flags
if flags.livecdInstall: from pyanaconda.packaging.livepayload import LiveImagePayload diff --git a/pyanaconda/anaconda_log.py b/pyanaconda/anaconda_log.py index e272167..c71181f 100644 --- a/pyanaconda/anaconda_log.py +++ b/pyanaconda/anaconda_log.py @@ -29,7 +29,7 @@ import sys import types import warnings
-from flags import flags +from pyanaconda.flags import flags
DEFAULT_TTY_LEVEL = logging.INFO ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)s %(name)s: %(message)s" diff --git a/pyanaconda/anaconda_optparse.py b/pyanaconda/anaconda_optparse.py index 0f123b8..1916b8a 100644 --- a/pyanaconda/anaconda_optparse.py +++ b/pyanaconda/anaconda_optparse.py @@ -19,7 +19,7 @@ # Authors: # Will Woods wwoods@redhat.com
-from flags import BootArgs +from pyanaconda.flags import BootArgs from optparse import OptionParser, OptionConflictError
class AnacondaOptionParser(OptionParser): diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py index 1ae2313..f994a07 100644 --- a/pyanaconda/constants.py +++ b/pyanaconda/constants.py @@ -31,7 +31,7 @@ ADDON_PATHS = ["/usr/share/anaconda/addons"] from pykickstart.constants import *
# common string needs to be easy to change -import product +import pyanaconda.product as product productName = product.productName productVersion = product.productVersion productArch = product.productArch diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py index 7c80ca7..2499ffe 100644 --- a/pyanaconda/exception.py +++ b/pyanaconda/exception.py @@ -24,14 +24,14 @@ from meh import Config from meh.handler import ExceptionHandler from meh.dump import ReverseExceptionDump -import isys -import iutil +import pyanaconda.isys as isys +import pyanaconda.iutil as iutil import sys import os import shutil import signal import time -import kickstart +import pyanaconda.kickstart as kickstart import blivet.errors from pyanaconda.ui.communication import hubQ from pyanaconda.constants import ROOT_PATH, THREAD_EXCEPTION_HANDLING_TEST diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py index 530a950..7489c0f 100644 --- a/pyanaconda/flags.py +++ b/pyanaconda/flags.py @@ -20,7 +20,7 @@ import selinux import shlex import glob -from constants import SELINUX_DEFAULT +from pyanaconda.constants import SELINUX_DEFAULT from collections import OrderedDict
import logging diff --git a/pyanaconda/geoloc.py b/pyanaconda/geoloc.py index b588bf7..e2bbb5d 100644 --- a/pyanaconda/geoloc.py +++ b/pyanaconda/geoloc.py @@ -106,7 +106,7 @@ import json import dbus import threading import time -import network +import pyanaconda.network as network
import logging log = logging.getLogger("anaconda") diff --git a/pyanaconda/image.py b/pyanaconda/image.py index 82f3e4f..b7480c4 100644 --- a/pyanaconda/image.py +++ b/pyanaconda/image.py @@ -17,11 +17,11 @@ # along with this program. If not, see http://www.gnu.org/licenses/. #
-import isys +import pyanaconda.isys as isys import os, os.path, stat, tempfile -from constants import ISO_DIR +from pyanaconda.constants import ISO_DIR
-from errors import errorHandler, ERROR_RAISE, InvalidImageSizeError, MediaMountError, MediaUnmountError, MissingImageError +from pyanaconda.errors import errorHandler, ERROR_RAISE, InvalidImageSizeError, MediaMountError, MediaUnmountError, MissingImageError
import blivet.util import blivet.arch diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py index 9d14b79..d7f0d74 100644 --- a/pyanaconda/installclass.py +++ b/pyanaconda/installclass.py @@ -32,7 +32,7 @@ from blivet.platform import platform import logging log = logging.getLogger("anaconda")
-from flags import flags +from pyanaconda.flags import flags
class BaseInstallClass(object): # default to not being hidden diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index 733a6f3..ad09208 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -32,15 +32,15 @@ import types from threading import Thread from Queue import Queue, Empty
-from flags import flags -from constants import DRACUT_SHUTDOWN_EJECT, ROOT_PATH, TRANSLATIONS_UPDATE_DIR, UNSUPPORTED_HW -from regexes import PROXY_URL_PARSE +from pyanaconda.flags import flags +from pyanaconda.constants import DRACUT_SHUTDOWN_EJECT, ROOT_PATH, TRANSLATIONS_UPDATE_DIR, UNSUPPORTED_HW +from pyanaconda.regexes import PROXY_URL_PARSE
import logging log = logging.getLogger("anaconda") program_log = logging.getLogger("program")
-from anaconda_log import program_log_lock +from pyanaconda.anaconda_log import program_log_lock
def augmentEnv(): env = os.environ.copy() diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 050cd59..31dbdc0 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -33,13 +33,13 @@ import blivet.zfcp import blivet.arch
import glob -import iutil +import pyanaconda.iutil as iutil import os import os.path import tempfile import subprocess -from flags import flags, can_touch_runtime_system -from constants import ADDON_PATHS, ROOT_PATH +from pyanaconda.flags import flags, can_touch_runtime_system +from pyanaconda.constants import ADDON_PATHS, ROOT_PATH import shlex import sys import urlgrabber @@ -55,8 +55,8 @@ from pyanaconda.simpleconfig import SimpleConfigFile from pyanaconda.users import getPassAlgo from pyanaconda.desktop import Desktop from pyanaconda.i18n import _ -from .ui.common import collect -from .addons import AddonSection, AddonData, AddonRegistry, collect_addon_paths +from pyanaconda.ui.common import collect +from pyanaconda.addons import AddonSection, AddonData, AddonRegistry, collect_addon_paths
from pykickstart.constants import CLEARPART_TYPE_NONE, FIRSTBOOT_SKIP, FIRSTBOOT_RECONFIG, KS_SCRIPT_POST, KS_SCRIPT_PRE, \ KS_SCRIPT_TRACEBACK, SELINUX_DISABLED, SELINUX_ENFORCING, SELINUX_PERMISSIVE @@ -71,7 +71,7 @@ log = logging.getLogger("anaconda") stderrLog = logging.getLogger("anaconda.stderr") storage_log = logging.getLogger("blivet") stdoutLog = logging.getLogger("anaconda.stdout") -from anaconda_log import logger, logLevelMap, setHandlersLevel,\ +from pyanaconda.anaconda_log import logger, logLevelMap, setHandlersLevel,\ DEFAULT_TTY_LEVEL
class AnacondaKSScript(KSScript): diff --git a/pyanaconda/network.py b/pyanaconda/network.py index f56e581..63efe23 100644 --- a/pyanaconda/network.py +++ b/pyanaconda/network.py @@ -26,7 +26,7 @@
import string import shutil -import iutil +import pyanaconda.iutil as iutil import socket import os import time @@ -36,7 +36,7 @@ import dbus import IPy import itertools
-from simpleconfig import SimpleConfigFile +from pyanaconda.simpleconfig import SimpleConfigFile from blivet.devices import FcoeDiskDevice, iScsiDiskDevice import blivet.arch
diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py index 2cf2440..6964c95 100644 --- a/pyanaconda/packaging/livepayload.py +++ b/pyanaconda/packaging/livepayload.py @@ -40,7 +40,7 @@ import urllib import hashlib import glob
-from . import ImagePayload, PayloadSetupError, PayloadInstallError +from pyanaconda.packaging import ImagePayload, PayloadSetupError, PayloadInstallError
from pyanaconda.constants import INSTALL_TREE, ROOT_PATH, THREAD_LIVE_PROGRESS from pyanaconda.constants import IMAGE_DIR diff --git a/pyanaconda/queue.py b/pyanaconda/queue.py index 22ea5de..31f6a54 100644 --- a/pyanaconda/queue.py +++ b/pyanaconda/queue.py @@ -19,7 +19,7 @@ # Author(s): Chris Lumens clumens@redhat.com
import Queue -from iutil import lowerASCII, upperASCII +from pyanaconda.iutil import lowerASCII, upperASCII
class QueueFactory(object): """Constructs a new object wrapping a Queue.Queue, complete with constants diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py index eca9d38..0c12be7 100644 --- a/pyanaconda/rescue.py +++ b/pyanaconda/rescue.py @@ -21,7 +21,7 @@ # import sys import os -import iutil +import pyanaconda.iutil as iutil import shutil import time import re @@ -29,13 +29,13 @@ import subprocess
from snack import ButtonChoiceWindow, ListboxChoiceWindow,SnackScreen
-from constants import ANACONDA_CLEANUP, ROOT_PATH -from constants_text import TEXT_OK_BUTTON, TEXT_NO_BUTTON, TEXT_YES_BUTTON -from text import WaitWindow, OkCancelWindow, ProgressWindow, PassphraseEntryWindow -from flags import flags -from installinterfacebase import InstallInterfaceBase -from i18n import _ -from kickstart import runPostScripts +from pyanaconda.constants import ANACONDA_CLEANUP, ROOT_PATH +from pyanaconda.constants_text import TEXT_OK_BUTTON, TEXT_NO_BUTTON, TEXT_YES_BUTTON +from pyanaconda.text import WaitWindow, OkCancelWindow, ProgressWindow, PassphraseEntryWindow +from pyanaconda.flags import flags +from pyanaconda.installinterfacebase import InstallInterfaceBase +from pyanaconda.i18n import _ +from pyanaconda.kickstart import runPostScripts
from blivet import mountExistingSystem from blivet.errors import StorageError diff --git a/pyanaconda/simpleconfig.py b/pyanaconda/simpleconfig.py index 53ed2d2..3d017b6 100644 --- a/pyanaconda/simpleconfig.py +++ b/pyanaconda/simpleconfig.py @@ -20,7 +20,7 @@ import shutil import shlex from pipes import _safechars import tempfile -from iutil import upperASCII +from pyanaconda.iutil import upperASCII
def unquote(s): return ' '.join(shlex.split(s)) diff --git a/pyanaconda/text.py b/pyanaconda/text.py index 3f76925..a049c30 100644 --- a/pyanaconda/text.py +++ b/pyanaconda/text.py @@ -20,7 +20,7 @@ #
from snack import ButtonBar, ButtonChoiceWindow, Entry, GridForm, Scale, TextboxReflowed -from constants_text import TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON, TEXT_OK_CHECK +from pyanaconda.constants_text import TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON, TEXT_OK_CHECK from pyanaconda.i18n import _
class WaitWindow: diff --git a/pyanaconda/ui/__init__.py b/pyanaconda/ui/__init__.py index c60698d..44f27e6 100644 --- a/pyanaconda/ui/__init__.py +++ b/pyanaconda/ui/__init__.py @@ -22,7 +22,7 @@ __all__ = ["UserInterface"]
import os -from .common import collect, PathDict +from pyanaconda.ui.common import collect, PathDict
class UserInterface(object): """This is the base class for all kinds of install UIs. It primarily diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py index 7976b29..30b595f 100644 --- a/pyanaconda/ui/gui/__init__.py +++ b/pyanaconda/ui/gui/__init__.py @@ -530,13 +530,13 @@ class GraphicalUserInterface(UserInterface):
def _list_hubs(self): """Return a list of Hub classes to be imported to this interface""" - from .hubs.summary import SummaryHub - from .hubs.progress import ProgressHub + from pyanaconda.ui.gui.hubs.summary import SummaryHub + from pyanaconda.ui.gui.hubs.progress import ProgressHub return [SummaryHub, ProgressHub]
def _is_standalone(self, obj): """Is the spoke passed as obj standalone?""" - from .spokes import StandaloneSpoke + from pyanaconda.ui.gui.spokes import StandaloneSpoke return isinstance(obj, StandaloneSpoke)
def setup(self, data): @@ -549,7 +549,7 @@ class GraphicalUserInterface(UserInterface): """Grab all relevant standalone spokes, add them to the passed list of hubs and order the list according to the relationships between hubs and standalones.""" - from .spokes import StandaloneSpoke + from pyanaconda.ui.gui.spokes import StandaloneSpoke
# First, grab a list of all the standalone spokes. standalones = self._collectActionClasses(self.paths["spokes"], StandaloneSpoke) @@ -571,7 +571,7 @@ class GraphicalUserInterface(UserInterface): window.main_window.set_transient_for(lightbox)
def _instantiateAction(self, actionClass): - from spokes import StandaloneSpoke + from pyanaconda.ui.gui.spokes import StandaloneSpoke
# Instantiate an action on-demand, passing the arguments defining our # spoke API and setting up continue/quit signal handlers. diff --git a/pyanaconda/ui/tui/__init__.py b/pyanaconda/ui/tui/__init__.py index 3114bde..5aedd85 100644 --- a/pyanaconda/ui/tui/__init__.py +++ b/pyanaconda/ui/tui/__init__.py @@ -25,10 +25,10 @@ from pyanaconda.ui import common from pyanaconda.ui.communication import hubQ from pyanaconda.flags import flags from pyanaconda.threads import threadMgr -import simpleline as tui -from hubs.summary import SummaryHub -from spokes import StandaloneSpoke -from tuiobject import YesNoDialog, ErrorDialog +import pyanaconda.ui.tui.simpleline as tui +from pyanaconda.ui.tui.hubs.summary import SummaryHub +from pyanaconda.ui.tui.spokes import StandaloneSpoke +from pyanaconda.ui.tui.tuiobject import YesNoDialog, ErrorDialog
import os import sys diff --git a/pyanaconda/ui/tui/hubs/__init__.py b/pyanaconda/ui/tui/hubs/__init__.py index 8f219c3..8d2d79d 100644 --- a/pyanaconda/ui/tui/hubs/__init__.py +++ b/pyanaconda/ui/tui/hubs/__init__.py @@ -18,7 +18,7 @@ # # Red Hat Author(s): Martin Sivak msivak@redhat.com # -from .. import simpleline as tui +from pyanaconda.ui.tui import simpleline as tui from pyanaconda.ui.tui.tuiobject import TUIObject from pyanaconda.ui.tui.spokes import collect_spokes from pyanaconda.ui import common diff --git a/pyanaconda/ui/tui/simpleline/__init__.py b/pyanaconda/ui/tui/simpleline/__init__.py index 91518c2..2c715e2 100644 --- a/pyanaconda/ui/tui/simpleline/__init__.py +++ b/pyanaconda/ui/tui/simpleline/__init__.py @@ -20,6 +20,6 @@ #
# pylint: disable-msg=W0401 -from base import * +from pyanaconda.ui.tui.simpleline.base import * # pylint: disable-msg=W0401 -from widgets import * +from pyanaconda.ui.tui.simpleline.widgets import * diff --git a/pyanaconda/ui/tui/simpleline/widgets.py b/pyanaconda/ui/tui/simpleline/widgets.py index d6ef5c6..591db3c 100644 --- a/pyanaconda/ui/tui/simpleline/widgets.py +++ b/pyanaconda/ui/tui/simpleline/widgets.py @@ -23,7 +23,7 @@
__all__ = ["TextWidget", "ColumnWidget", "CheckboxWidget", "CenterWidget"]
-import base +import pyanaconda.ui.tui.simpleline.base as base
class TextWidget(base.Widget): """Class to handle wrapped text output.""" diff --git a/pyanaconda/ui/tui/tuiobject.py b/pyanaconda/ui/tui/tuiobject.py index dc4e4fc..a6f06b9 100644 --- a/pyanaconda/ui/tui/tuiobject.py +++ b/pyanaconda/ui/tui/tuiobject.py @@ -21,7 +21,7 @@
from pyanaconda.i18n import _ from pyanaconda.ui import common -import simpleline as tui +import pyanaconda.ui.tui.simpleline as tui from pyanaconda.constants_text import INPUT_PROCESSED
class ErrorDialog(tui.UIScreen): diff --git a/pyanaconda/users.py b/pyanaconda/users.py index e831122..20c5cc0 100644 --- a/pyanaconda/users.py +++ b/pyanaconda/users.py @@ -26,7 +26,7 @@ import random import tempfile import os import os.path -import iutil +import pyanaconda.iutil as iutil import pwquality from pyanaconda.iutil import strip_accents from pyanaconda.i18n import _ diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index 2dbc9b8..fc7d352 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -21,11 +21,11 @@
import os, sys import time -import network -import product +import pyanaconda.network as network +import pyanaconda.product as product import socket import subprocess -import iutil +import pyanaconda.iutil as iutil import dbus
from pyanaconda.i18n import _, P_ diff --git a/tests/pylint/runpylint.sh b/tests/pylint/runpylint.sh index af4183e..48c9f6c 100755 --- a/tests/pylint/runpylint.sh +++ b/tests/pylint/runpylint.sh @@ -35,13 +35,12 @@ DISABLED_ERR_OPTIONS="--disable=E1103" # W0141 - Used builtin function %r # W0142 - Used * or ** magic # W0223 - Method %r is abstract in class %r but is not overridden -# W0403 - Relative import %r, should be %r # W0511 - Used when a warning note as FIXME or XXX is detected. # W0603 - Using the global statement # W0604 - Using the global statement at the module level # W0613 - Unused argument %r # W0614 - Unused import %s from wildcard import -DISABLED_WARN_OPTIONS="--disable=W0110,W0141,W0142,W0223,W0403,W0511,W0603,W0604,W0613,W0614" +DISABLED_WARN_OPTIONS="--disable=W0110,W0141,W0142,W0223,W0511,W0603,W0604,W0613,W0614"
usage () { echo "usage: `basename $0` [--strict] [--help] [files...]"
On Wed, 2013-09-25 at 16:48 -0400, David Shea wrote:
pyanaconda/anaconda.py | 8 ++++---- pyanaconda/anaconda_log.py | 2 +- pyanaconda/anaconda_optparse.py | 2 +- pyanaconda/constants.py | 2 +- pyanaconda/exception.py | 6 +++--- pyanaconda/flags.py | 2 +- pyanaconda/geoloc.py | 2 +- pyanaconda/image.py | 6 +++--- pyanaconda/installclass.py | 2 +- pyanaconda/iutil.py | 8 ++++---- pyanaconda/kickstart.py | 12 ++++++------ pyanaconda/network.py | 4 ++-- pyanaconda/packaging/livepayload.py | 2 +- pyanaconda/queue.py | 2 +- pyanaconda/rescue.py | 16 ++++++++-------- pyanaconda/simpleconfig.py | 2 +- pyanaconda/text.py | 2 +- pyanaconda/ui/__init__.py | 2 +- pyanaconda/ui/gui/__init__.py | 10 +++++----- pyanaconda/ui/tui/__init__.py | 8 ++++---- pyanaconda/ui/tui/hubs/__init__.py | 2 +- pyanaconda/ui/tui/simpleline/__init__.py | 4 ++-- pyanaconda/ui/tui/simpleline/widgets.py | 2 +- pyanaconda/ui/tui/tuiobject.py | 2 +- pyanaconda/users.py | 2 +- pyanaconda/vnc.py | 6 +++--- tests/pylint/runpylint.sh | 3 +-- 27 files changed, 60 insertions(+), 61 deletions(-)
diff --git a/pyanaconda/anaconda.py b/pyanaconda/anaconda.py index 9a5aecc..759f6d4 100644 --- a/pyanaconda/anaconda.py +++ b/pyanaconda/anaconda.py @@ -30,7 +30,7 @@
import os import sys -from constants import ROOT_PATH +from pyanaconda.constants import ROOT_PATH from tempfile import mkstemp
from pyanaconda.bootloader import get_bootloader @@ -43,7 +43,7 @@ stdoutLog = logging.getLogger("anaconda.stdout")
class Anaconda(object): def __init__(self):
import desktop
import pyanaconda.desktop as desktop
Maybe it's just a matter of opinion, but I'd like 'from pyanaconda import desktop' here more and in some other places below instead of 'import pyanaconda.MODULE as MODULE'.
On 09/26/2013 09:27 AM, Vratislav Podzimek wrote:
On Wed, 2013-09-25 at 16:48 -0400, David Shea wrote:
pyanaconda/anaconda.py | 8 ++++---- pyanaconda/anaconda_log.py | 2 +- pyanaconda/anaconda_optparse.py | 2 +- pyanaconda/constants.py | 2 +- pyanaconda/exception.py | 6 +++--- pyanaconda/flags.py | 2 +- pyanaconda/geoloc.py | 2 +- pyanaconda/image.py | 6 +++--- pyanaconda/installclass.py | 2 +- pyanaconda/iutil.py | 8 ++++---- pyanaconda/kickstart.py | 12 ++++++------ pyanaconda/network.py | 4 ++-- pyanaconda/packaging/livepayload.py | 2 +- pyanaconda/queue.py | 2 +- pyanaconda/rescue.py | 16 ++++++++-------- pyanaconda/simpleconfig.py | 2 +- pyanaconda/text.py | 2 +- pyanaconda/ui/__init__.py | 2 +- pyanaconda/ui/gui/__init__.py | 10 +++++----- pyanaconda/ui/tui/__init__.py | 8 ++++---- pyanaconda/ui/tui/hubs/__init__.py | 2 +- pyanaconda/ui/tui/simpleline/__init__.py | 4 ++-- pyanaconda/ui/tui/simpleline/widgets.py | 2 +- pyanaconda/ui/tui/tuiobject.py | 2 +- pyanaconda/users.py | 2 +- pyanaconda/vnc.py | 6 +++--- tests/pylint/runpylint.sh | 3 +-- 27 files changed, 60 insertions(+), 61 deletions(-)
diff --git a/pyanaconda/anaconda.py b/pyanaconda/anaconda.py index 9a5aecc..759f6d4 100644 --- a/pyanaconda/anaconda.py +++ b/pyanaconda/anaconda.py @@ -30,7 +30,7 @@
import os import sys -from constants import ROOT_PATH +from pyanaconda.constants import ROOT_PATH from tempfile import mkstemp
from pyanaconda.bootloader import get_bootloader @@ -43,7 +43,7 @@ stdoutLog = logging.getLogger("anaconda.stdout")
class Anaconda(object): def __init__(self):
import desktop
import pyanaconda.desktop as desktop
Maybe it's just a matter of opinion, but I'd like 'from pyanaconda import desktop' here more and in some other places below instead of 'import pyanaconda.MODULE as MODULE'.
Ok, I'll change that.
On Wed, Sep 25, 2013 at 02:21:46PM -0400, David Shea wrote:
Changed the pylint Module output so that it's more clear what file is being checked. Added an option to runpylint.sh to manually set the filename to display.
scripts/githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++------------- tests/pylint/runpylint.sh | 16 ++++++++++++++- 2 files changed, 49 insertions(+), 14 deletions(-)
@@ -37,24 +38,44 @@ except CalledProcessError: pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines():
- path = gf.split()[-1]
- if is_python(path):
pylint_files.append(path)
- fields = gf.split()
- # If the file is being removed, ignore it
- if fields[4] == 'D':
continue
- elif is_python(fields[-1]):
pylint_files.append(fields[-1])
Good idea.
+# Make a list of tuples of (filename, tempfile) where the tempfile +# contains the file as staged for commit. +pylint_commits = [] +for pylint_file in pylint_files:
- commit = tempfile.NamedTemporaryFile()
- try:
commit.write(check_output(["git", "show", (":%s" % pylint_file)]))
- except CalledProcessError:
sys.exit(1)
- commit.flush()
- pylint_commits.append((pylint_file, commit))
I'm not sure I like this. Seems like overkill, and it's going to slow the check down on larger commits.
On 09/25/2013 05:50 PM, Brian C. Lane wrote:
On Wed, Sep 25, 2013 at 02:21:46PM -0400, David Shea wrote:
Changed the pylint Module output so that it's more clear what file is being checked. Added an option to runpylint.sh to manually set the filename to display.
scripts/githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++------------- tests/pylint/runpylint.sh | 16 ++++++++++++++- 2 files changed, 49 insertions(+), 14 deletions(-)
@@ -37,24 +38,44 @@ except CalledProcessError: pylint_files = [] # Lines look like: :100755 100755 2cf57974e13a2aae778e28f942a4d44bf6567409 6fe1b6caf32d565b2cdb6d1aee250aaddc6d3a04 M tests/pylint/runpylint.sh for gf in git_files.splitlines():
- path = gf.split()[-1]
- if is_python(path):
pylint_files.append(path)
- fields = gf.split()
- # If the file is being removed, ignore it
- if fields[4] == 'D':
continue
- elif is_python(fields[-1]):
pylint_files.append(fields[-1])
Good idea.
+# Make a list of tuples of (filename, tempfile) where the tempfile +# contains the file as staged for commit. +pylint_commits = [] +for pylint_file in pylint_files:
- commit = tempfile.NamedTemporaryFile()
- try:
commit.write(check_output(["git", "show", (":%s" % pylint_file)]))
- except CalledProcessError:
sys.exit(1)
- commit.flush()
- pylint_commits.append((pylint_file, commit))
I'm not sure I like this. Seems like overkill, and it's going to slow the check down on larger commits.
Is there at least a cheap way to check if the staged data doesn't match the filesystem data so we can warn about that?
logpicker doesn't really do what we want anymore and log uploading is handled by abrt now.
We no longer use nor need the pyrc readline wrapper.
addrsize is handled by lorax and hasn't been built since F-16. --- anaconda.spec.in | 1 - configure.ac | 4 +- old_tests/logpicker_test/Makefile.am | 30 --- .../logpicker_test/archiving_test/Makefile.am | 28 --- .../archiving_test/archivebaseclass_test.py | 35 --- .../archiving_test/bzip2archive_test.py | 119 --------- .../logpicker_test/logmining_test/Makefile.am | 31 --- .../logmining_test/anacondalogminer_test.py | 125 --------- .../logmining_test/dmsetupinfologminer_test.py | 19 -- .../logmining_test/dmsetuplslogminer_test.py | 19 -- .../logmining_test/filesystemlogminer_test.py | 74 ------ .../logmining_test/logminerbaseclass_test.py | 106 -------- old_tests/logpicker_test/logpicker_test.py | 93 ------- old_tests/logpicker_test/main_test.py | 19 -- old_tests/logpicker_test/sending_test/Makefile.am | 33 --- .../sending_test/bugzillasender_test.py | 99 -------- .../sending_test/emailsender_test.py | 104 -------- .../logpicker_test/sending_test/ftpsender_test.py | 156 ------------ .../sending_test/localsender_test.py | 46 ---- .../logpicker_test/sending_test/scpsender_test.py | 106 -------- .../sending_test/senderbaseclass_test.py | 56 ----- .../sending_test/stratasender_test.py | 95 ------- scripts/Makefile.am | 1 - scripts/pyrc.py | 27 -- utils/Makefile.am | 4 +- utils/addrsize.c | 88 ------- utils/log_picker/Makefile.am | 24 -- utils/log_picker/__init__.py | 146 ----------- utils/log_picker/archiving.py | 100 -------- utils/log_picker/argparser.py | 279 --------------------- utils/log_picker/logmining.py | 255 ------------------- utils/log_picker/sending/Makefile.am | 23 -- utils/log_picker/sending/__init__.py | 42 ---- utils/log_picker/sending/bugzillasender.py | 62 ----- utils/log_picker/sending/emailsender.py | 71 ------ utils/log_picker/sending/ftpsender.py | 47 ---- utils/log_picker/sending/localsender.py | 39 --- utils/log_picker/sending/scpsender.py | 62 ----- utils/log_picker/sending/senderbaseclass.py | 25 -- utils/log_picker/sending/stratasender.py | 55 ---- utils/logpicker | 136 ---------- 41 files changed, 3 insertions(+), 2881 deletions(-) delete mode 100644 old_tests/logpicker_test/Makefile.am delete mode 100644 old_tests/logpicker_test/archiving_test/Makefile.am delete mode 100644 old_tests/logpicker_test/archiving_test/archivebaseclass_test.py delete mode 100644 old_tests/logpicker_test/archiving_test/bzip2archive_test.py delete mode 100644 old_tests/logpicker_test/logmining_test/Makefile.am delete mode 100644 old_tests/logpicker_test/logmining_test/anacondalogminer_test.py delete mode 100644 old_tests/logpicker_test/logmining_test/dmsetupinfologminer_test.py delete mode 100644 old_tests/logpicker_test/logmining_test/dmsetuplslogminer_test.py delete mode 100644 old_tests/logpicker_test/logmining_test/filesystemlogminer_test.py delete mode 100644 old_tests/logpicker_test/logmining_test/logminerbaseclass_test.py delete mode 100644 old_tests/logpicker_test/logpicker_test.py delete mode 100644 old_tests/logpicker_test/main_test.py delete mode 100644 old_tests/logpicker_test/sending_test/Makefile.am delete mode 100644 old_tests/logpicker_test/sending_test/bugzillasender_test.py delete mode 100644 old_tests/logpicker_test/sending_test/emailsender_test.py delete mode 100644 old_tests/logpicker_test/sending_test/ftpsender_test.py delete mode 100644 old_tests/logpicker_test/sending_test/localsender_test.py delete mode 100644 old_tests/logpicker_test/sending_test/scpsender_test.py delete mode 100644 old_tests/logpicker_test/sending_test/senderbaseclass_test.py delete mode 100644 old_tests/logpicker_test/sending_test/stratasender_test.py delete mode 100644 scripts/pyrc.py delete mode 100644 utils/addrsize.c delete mode 100644 utils/log_picker/Makefile.am delete mode 100644 utils/log_picker/__init__.py delete mode 100644 utils/log_picker/archiving.py delete mode 100644 utils/log_picker/argparser.py delete mode 100644 utils/log_picker/logmining.py delete mode 100644 utils/log_picker/sending/Makefile.am delete mode 100644 utils/log_picker/sending/__init__.py delete mode 100644 utils/log_picker/sending/bugzillasender.py delete mode 100644 utils/log_picker/sending/emailsender.py delete mode 100644 utils/log_picker/sending/ftpsender.py delete mode 100644 utils/log_picker/sending/localsender.py delete mode 100644 utils/log_picker/sending/scpsender.py delete mode 100644 utils/log_picker/sending/senderbaseclass.py delete mode 100644 utils/log_picker/sending/stratasender.py delete mode 100755 utils/logpicker
diff --git a/anaconda.spec.in b/anaconda.spec.in index fd7ac0a..bc3da55 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -220,7 +220,6 @@ update-desktop-database &> /dev/null || : %{_bindir}/instperf %{_sbindir}/anaconda %{_sbindir}/handle-sshpw -%{_sbindir}/logpicker %{_datadir}/anaconda %{_prefix}/libexec/anaconda %{_libdir}/python*/site-packages/pyanaconda/* diff --git a/configure.ac b/configure.ac index 3071531..c922893 100644 --- a/configure.ac +++ b/configure.ac @@ -269,7 +269,5 @@ AC_CONFIG_FILES([Makefile data/post-scripts/Makefile tests/Makefile utils/Makefile - utils/dd/Makefile - utils/log_picker/Makefile - utils/log_picker/sending/Makefile]) + utils/dd/Makefile]) AC_OUTPUT diff --git a/old_tests/logpicker_test/Makefile.am b/old_tests/logpicker_test/Makefile.am deleted file mode 100644 index 0671b2f..0000000 --- a/old_tests/logpicker_test/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# tests/logpicker_test/Makefile.am for anaconda -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# -# Author: Tomas Mlcoch tmlcoch@redhat.com - -SUBDIRS = archiving_test logmining_test sending_test - -EXTRA_DIST = *.py - -MAINTAINERCLEANFILES = Makefile.in - -ANACDIR = $(top_builddir)/pyanaconda -TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir)/tests:$(ANACDIR)/isys/.libs:$(ANACDIR):$(top_builddir):$(top_builddir)/utils - -TESTS = logpicker_test.py \ - main_test.py diff --git a/old_tests/logpicker_test/archiving_test/Makefile.am b/old_tests/logpicker_test/archiving_test/Makefile.am deleted file mode 100644 index 481672c..0000000 --- a/old_tests/logpicker_test/archiving_test/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# tests/logpicker_test/archiving_test/Makefile.am for anaconda -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# -# Author: Tomas Mlcoch tmlcoch@redhat.com - -EXTRA_DIST = *.py - -MAINTAINERCLEANFILES = Makefile.in - -ANACDIR = $(top_builddir)/pyanaconda -TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir)/tests:$(ANACDIR)/isys/.libs:$(ANACDIR):$(top_builddir):$(top_builddir)/utils - -TESTS = archivebaseclass_test.py \ - bzip2archive_test.py diff --git a/old_tests/logpicker_test/archiving_test/archivebaseclass_test.py b/old_tests/logpicker_test/archiving_test/archivebaseclass_test.py deleted file mode 100644 index 2f4f0e6..0000000 --- a/old_tests/logpicker_test/archiving_test/archivebaseclass_test.py +++ /dev/null @@ -1,35 +0,0 @@ -import mock - -class ArchiveBaseClassTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def create_tmp_tar_test(self): - import log_picker.archiving as archiving - - FILE1 = "/tmp/abcd/file1" - FILE2 = "/tmp/abcd/file2" - FILELIST = [FILE1, FILE2] - TMPFILE = "/tmp/tmpfile.tar" - - archiving.tempfile = mock.Mock() - archiving.tempfile.mkstemp.return_value = "", TMPFILE - archiving.tarfile = mock.Mock() - - self.fs.open(FILE1, 'w').write('1\n') - self.fs.open(FILE2, 'w').write('2\n') - self.fs.open(TMPFILE, 'w') - - obj = archiving.ArchiveBaseClass() - ret = obj._create_tmp_tar(FILELIST) - - self.assertEqual(TMPFILE, ret) - self.assertEqual(archiving.tarfile.open().add.call_args_list, - [((FILE1,), {'arcname': 'abcd/file1'}), - ((FILE2,), {'arcname': 'abcd/file2'})] - ) - diff --git a/old_tests/logpicker_test/archiving_test/bzip2archive_test.py b/old_tests/logpicker_test/archiving_test/bzip2archive_test.py deleted file mode 100644 index aa01e95..0000000 --- a/old_tests/logpicker_test/archiving_test/bzip2archive_test.py +++ /dev/null @@ -1,119 +0,0 @@ -import os -import mock -import tempfile -from log_picker.archiving import ArchivationError - - -class Bzip2ArchiveTest(mock.TestCase): - def setUp(self): - self.tmp_files = [] - pass - - def _get_tmp(self): - _, filename = tempfile.mkstemp() - self.tmp_files.append(filename) - return filename - - def tearDown(self): - for file in self.tmp_files: - os.unlink(file) - - def mimetype_test(self): - from log_picker.archiving import Bzip2Archive - obj = Bzip2Archive(usetar=True) - ret = obj.mimetype - self.assertEqual(ret, 'application/x-bzip2') - - def support_compression_test(self): - from log_picker.archiving import Bzip2Archive - obj = Bzip2Archive(usetar=True) - ret = obj.support_compression - self.assertTrue(ret) - - def file_ext_1_test(self): - from log_picker.archiving import Bzip2Archive - obj = Bzip2Archive(usetar=True) - ret = obj.file_ext - self.assertEqual(ret, '.tar.bz2') - - def file_ext_2_test(self): - from log_picker.archiving import Bzip2Archive - obj = Bzip2Archive(usetar=False) - ret = obj.file_ext - self.assertEqual(ret, '.bz2') - - def create_archive_1_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - infile1 = self._get_tmp() - infile2 = self._get_tmp() - - obj = Bzip2Archive(usetar=False) - self.assertRaises(ArchivationError, obj.create_archive, out_filename, \ - [infile1, infile2]) - - def create_archive_2_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - - obj = Bzip2Archive(usetar=False) - self.assertRaises(ArchivationError, obj.create_archive, out_filename, []) - - def create_archive_3_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - - obj = Bzip2Archive(usetar=True) - self.assertRaises(ArchivationError, obj.create_archive, out_filename, []) - - def create_archive_4_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - infile1 = self._get_tmp() - infile2 = self._get_tmp() - - obj = Bzip2Archive(usetar=True) - # Because both files (infile1 and infile2) are empty - self.assertRaises(ArchivationError, obj.create_archive, out_filename, - [infile1, infile2]) - - def create_archive_5_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - infile1 = self._get_tmp() - infile2 = self._get_tmp() - open(infile1, 'w').write('abcdefghijklmnopqrstuvwxyz') - open(infile2, 'w').write('1234567890') - - obj = Bzip2Archive(usetar=True) - obj.create_archive(out_filename, [infile1, infile2]) - self.assertTrue(os.path.getsize(out_filename)) - - def create_archive_6_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - infile1 = self._get_tmp() - open(infile1, 'w').write('abcdefghijklmnopqrstuvwxyz') - - obj = Bzip2Archive(usetar=False) - obj.create_archive(out_filename, [infile1]) - self.assertTrue(os.path.getsize(out_filename)) - - def create_archive_7_test(self): - from log_picker.archiving import Bzip2Archive - - out_filename = self._get_tmp() - infile1 = self._get_tmp() - open(infile1, 'w').write('abcdefghijklmnopqrstuvwxyz') - - obj = Bzip2Archive(usetar=True) - obj.create_archive(out_filename, [infile1]) - self.assertTrue(os.path.getsize(out_filename)) - - diff --git a/old_tests/logpicker_test/logmining_test/Makefile.am b/old_tests/logpicker_test/logmining_test/Makefile.am deleted file mode 100644 index 4c6dfaa..0000000 --- a/old_tests/logpicker_test/logmining_test/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# tests/logpicker_test/logmining_test/Makefile.am for anaconda -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# -# Author: Tomas Mlcoch tmlcoch@redhat.com - -EXTRA_DIST = *.py - -MAINTAINERCLEANFILES = Makefile.in - -ANACDIR = $(top_builddir)/pyanaconda -TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir)/tests:$(ANACDIR)/isys/.libs:$(ANACDIR):$(top_builddir):$(top_builddir)/utils - -TESTS = anacondalogminer_test.py \ - dmsetupinfologminer_test.py \ - dmsetuplslogminer_test.py \ - filesystemlogminer_test.py \ - logminerbaseclass_test.py diff --git a/old_tests/logpicker_test/logmining_test/anacondalogminer_test.py b/old_tests/logpicker_test/logmining_test/anacondalogminer_test.py deleted file mode 100644 index 22cd1c3..0000000 --- a/old_tests/logpicker_test/logmining_test/anacondalogminer_test.py +++ /dev/null @@ -1,125 +0,0 @@ -import mock - -class AnacondaLogMinerTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def action_test(self): - import log_picker.logmining as logmining - - ANACONDA_LOG = "anaconda-tb-log" - ANACONDA_LOG_PATH = "/tmp/%s" % ANACONDA_LOG - LOG_CONTENT = "Test content\n" - - self.fs.open(ANACONDA_LOG_PATH, 'w').write(LOG_CONTENT) - - logmining.os = mock.Mock() - listdir_values = [[ANACONDA_LOG], []] - logmining.os.listdir.side_effect = lambda x: listdir_values.pop() - - logmining.open = self.fs.open - self.fs.open('/var/run/anaconda.pid', 'w').write('555\n') - - proc_mock = mock.Mock() - proc_mock.returncode = 0 - logmining.subprocess = mock.Mock() - logmining.subprocess.Popen.return_value = proc_mock - - logmining.time = mock.Mock() - - OUTFILE = '/tmp/outfile' - f = self.fs.open(OUTFILE, 'w') - - obj = logmining.AnacondaLogMiner(f) - obj._action() - f.close() - - self.assertEqual(self.fs[OUTFILE], - "%s:\n%s\n" % (ANACONDA_LOG_PATH, LOG_CONTENT)) - - def action_raise_1_test(self): - import log_picker.logmining as logmining - - logmining.os = mock.Mock() - listdir_values = [[]] - logmining.os.listdir.side_effect = lambda x: listdir_values.pop() - - logmining.open = self.fs.open - - obj = logmining.AnacondaLogMiner() - self.assertRaises(logmining.LogMinerError, obj._action) - - def action_raise_2_test(self): - import log_picker.logmining as logmining - - logmining.os = mock.Mock() - listdir_values = [[]] - logmining.os.listdir.side_effect = lambda x: listdir_values.pop() - - logmining.open = self.fs.open - self.fs.open('/var/run/anaconda.pid', 'w').write('555\n') - - proc_mock = mock.Mock() - proc_mock.returncode = 1 - logmining.subprocess = mock.Mock() - logmining.subprocess.Popen.return_value = proc_mock - - obj = logmining.AnacondaLogMiner() - self.assertRaises(logmining.LogMinerError, obj._action) - - def action_raise_3_test(self): - import log_picker.logmining as logmining - - ANACONDA_LOG = "anaconda-tb-log" - ANACONDA_LOG_PATH = "/tmp/%s" % ANACONDA_LOG - LOG_CONTENT = "Test content\n" - - self.fs.open(ANACONDA_LOG_PATH, 'w').write(LOG_CONTENT) - - logmining.os = mock.Mock() - listdir_values = [[], []] - logmining.os.listdir.side_effect = lambda x: listdir_values.pop() - - logmining.open = self.fs.open - self.fs.open('/var/run/anaconda.pid', 'w').write('555\n') - - proc_mock = mock.Mock() - proc_mock.returncode = 0 - logmining.subprocess = mock.Mock() - logmining.subprocess.Popen.return_value = proc_mock - - logmining.time = mock.Mock() - - obj = logmining.AnacondaLogMiner() - self.assertRaises(logmining.LogMinerError, obj._action) - - def action_raise_4_test(self): - import log_picker.logmining as logmining - - ANACONDA_LOG = "different-log" - ANACONDA_LOG_PATH = "/tmp/%s" % ANACONDA_LOG - LOG_CONTENT = "Test content\n" - - self.fs.open(ANACONDA_LOG_PATH, 'w').write(LOG_CONTENT) - - logmining.os = mock.Mock() - listdir_values = [[ANACONDA_LOG], []] - logmining.os.listdir.side_effect = lambda x: listdir_values.pop() - - logmining.open = self.fs.open - self.fs.open('/var/run/anaconda.pid', 'w').write('555\n') - - proc_mock = mock.Mock() - proc_mock.returncode = 0 - logmining.subprocess = mock.Mock() - logmining.subprocess.Popen.return_value = proc_mock - - logmining.time = mock.Mock() - - obj = logmining.AnacondaLogMiner() - self.assertRaises(logmining.LogMinerError, obj._action) - diff --git a/old_tests/logpicker_test/logmining_test/dmsetupinfologminer_test.py b/old_tests/logpicker_test/logmining_test/dmsetupinfologminer_test.py deleted file mode 100644 index 9aa3c81..0000000 --- a/old_tests/logpicker_test/logmining_test/dmsetupinfologminer_test.py +++ /dev/null @@ -1,19 +0,0 @@ -import mock - -class DmSetupInfoLogMinerTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def action_test(self): - import log_picker.logmining as logmining - - obj = logmining.DmSetupInfoLogMiner() - obj._run_command = mock.Mock() - obj._action() - - self.assertTrue(obj._run_command.called) - diff --git a/old_tests/logpicker_test/logmining_test/dmsetuplslogminer_test.py b/old_tests/logpicker_test/logmining_test/dmsetuplslogminer_test.py deleted file mode 100644 index c0d4bc4..0000000 --- a/old_tests/logpicker_test/logmining_test/dmsetuplslogminer_test.py +++ /dev/null @@ -1,19 +0,0 @@ -import mock - -class DmSetupLsLogMinerTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def action_test(self): - import log_picker.logmining as logmining - - obj = logmining.DmSetupLsLogMiner() - obj._run_command = mock.Mock() - obj._action() - - self.assertTrue(obj._run_command.called) - diff --git a/old_tests/logpicker_test/logmining_test/filesystemlogminer_test.py b/old_tests/logpicker_test/logmining_test/filesystemlogminer_test.py deleted file mode 100644 index a9d9836..0000000 --- a/old_tests/logpicker_test/logmining_test/filesystemlogminer_test.py +++ /dev/null @@ -1,74 +0,0 @@ -import mock - -class FileSystemLogMinerTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def size_conversion_1_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(24) - self.assertEqual(size, 24) - self.assertEqual(unit, "") - - def size_conversion_2_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(2400) - self.assertEqual(size, 2.3) - self.assertEqual(unit, "K") - - def size_conversion_3_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(1024) - self.assertEqual(size, 1) - self.assertEqual(unit, "K") - - def size_conversion_4_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(1048576) - self.assertEqual(size, 1) - self.assertEqual(unit, "M") - - def size_conversion_5_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(1160576) - self.assertEqual(size, 1.1) - self.assertEqual(unit, "M") - - def size_conversion_6_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(1073741824) - self.assertEqual(size, 1) - self.assertEqual(unit, "G") - - def size_conversion_7_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(1273741824) - self.assertEqual(size, 1.2) - self.assertEqual(unit, "G") - - def size_conversion_8_test(self): - import log_picker.logmining as logmining - - obj = logmining.FileSystemLogMiner() - size, unit = obj._size_conversion(0) - self.assertEqual(size, 0) - self.assertEqual(unit, "") - diff --git a/old_tests/logpicker_test/logmining_test/logminerbaseclass_test.py b/old_tests/logpicker_test/logmining_test/logminerbaseclass_test.py deleted file mode 100644 index aad9af8..0000000 --- a/old_tests/logpicker_test/logmining_test/logminerbaseclass_test.py +++ /dev/null @@ -1,106 +0,0 @@ -import mock - -class LogminingBaseClassTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def get_filename_test(self): - from log_picker.logmining import LogMinerBaseClass - - ret = LogMinerBaseClass.get_filename() - self.assertEqual(ret, LogMinerBaseClass._filename) - - def get_description_test(self): - from log_picker.logmining import LogMinerBaseClass - - ret = LogMinerBaseClass.get_description() - self.assertEqual(ret, LogMinerBaseClass._description) - - def set_logfile_test(self): - from log_picker.logmining import LogMinerBaseClass - - FILENAME = "file123" - - obj = LogMinerBaseClass() - obj.set_logfile(FILENAME) - self.assertEqual(FILENAME, obj.logfile) - - def write_separator_test(self): - import log_picker.logmining as logmining - logmining.open = self.fs.open - - OUTFILE = '/tmp/logfile' - f = self.fs.open(OUTFILE, 'w') - - obj = logmining.LogMinerBaseClass(f) - obj._write_separator() - f.close() - - self.assertEqual(self.fs[OUTFILE], '\n\n') - - def write_files_1_test(self): - import log_picker.logmining as logmining - logmining.open = self.fs.open - - FILE = '/tmp/infile' - CONTENT = "some_random_456_content\n" - self.fs.open(FILE, 'w').write(CONTENT) - - OUTFILE = '/tmp/logfile' - f = self.fs.open(OUTFILE, 'w') - - obj = logmining.LogMinerBaseClass(f) - obj._write_files(FILE) - f.close() - - self.assertEqual('%s:\n%s\n' % (FILE, CONTENT), self.fs[OUTFILE]) - - def write_files_2_test(self): - import log_picker.logmining as logmining - logmining.open = self.fs.open - - FILE_1 = '/tmp/infile1' - FILE_2 = '/tmp/infile2' - CONTENT_1 = "some_random_456_content\n" - CONTENT_2 = "next_line_789\n" - self.fs.open(FILE_1, 'w').write(CONTENT_1) - self.fs.open(FILE_2, 'w').write(CONTENT_2) - - OUTFILE = '/tmp/logfile' - f = self.fs.open(OUTFILE, 'w') - - obj = logmining.LogMinerBaseClass(f) - obj._write_files([FILE_1, FILE_2]) - f.close() - - self.assertEqual('%s:\n%s\n%s:\n%s\n' % \ - (FILE_1, CONTENT_1, FILE_2, CONTENT_2), self.fs[OUTFILE]) - - def run_command_test(self): - import log_picker.logmining as logmining - - COMMAND = "some_command param1 param2" - STDOUT = "some output" - STDERR = "some error" - RETCODE = 1 - - proc_mock = mock.Mock() - proc_mock.returncode = RETCODE - proc_mock.communicate.return_value = (STDOUT, STDERR) - logmining.subprocess = mock.Mock() - logmining.subprocess.Popen.return_value = proc_mock - - OUTFILE = "/tmp/outfile" - f = self.fs.open(OUTFILE, 'w') - - obj = logmining.LogMinerBaseClass(f) - obj._run_command(COMMAND) - f.close() - - self.assertEqual(self.fs[OUTFILE], - "STDOUT:\nsome output\nSTDERR:\nsome error\nRETURN CODE: 1\n") - diff --git a/old_tests/logpicker_test/logpicker_test.py b/old_tests/logpicker_test/logpicker_test.py deleted file mode 100644 index a62d63d..0000000 --- a/old_tests/logpicker_test/logpicker_test.py +++ /dev/null @@ -1,93 +0,0 @@ -import os -import sys -import mock - - -class LogPickerTest(mock.TestCase): - def setUp(self): - pass - - def getlogs_1_test(self): - from log_picker import LogPicker - - miner = mock.Mock() - - obj = LogPicker(miners=[miner], use_one_file=True) - obj.getlogs() - - self.assertTrue(miner.set_logfile.called) - self.assertTrue(miner.getlog.called) - - def getlogs_2_test(self): - from log_picker import LogPicker - from log_picker.logmining import LogMinerError - - miner = mock.Mock() - miner.getlog.side_effect = LogMinerError('Just a test') - - obj = LogPicker(miners=[miner], use_one_file=True) - # Temporary redirect stderr output - sys.stderr, backup = mock.Mock(), sys.stderr - obj.getlogs() - sys.stderr = backup - - self.assertTrue(True) - - def send_1_test(self): - from log_picker import LogPicker - - sender = mock.Mock() - - obj = LogPicker(sender_obj=sender) - obj.files = ["file"] - obj.send() - - self.assertTrue(sender.sendfile.called) - self.assertEqual(sender.sendfile.call_args, - (('file', 'text/plain'), {})) - - def send_2_test(self): - from log_picker import LogPicker - - sender = mock.Mock() - archiver = mock.Mock() - archiver.mimetype = "application/anything" - - obj = LogPicker(sender_obj=sender, archive_obj=archiver) - obj.files = ["file"] - obj.archive = "file2" - obj.send() - - self.assertTrue(sender.sendfile.called) - self.assertEqual(sender.sendfile.call_args, - (('file2', 'application/anything'), {})) - - def create_archive_1_test(self): - from log_picker import LogPicker - - archiver = mock.Mock() - archiver.file_ext = ".zip" - - obj = LogPicker(archive_obj=archiver) - obj.create_archive() - - self.assertTrue(archiver.create_archive.called) - - def get_tmp_file_test(self): - from log_picker import LogPicker - - obj = LogPicker() - ret = obj._get_tmp_file("name") - self.assertTrue(os.path.isfile(ret)) - - def errprint_test(self): - from log_picker import LogPicker - - obj = LogPicker() - # Temporary redirect stderr output - sys.stderr, backup = mock.Mock(), sys.stderr - obj._errprint("message") - res, sys.stderr = sys.stderr, backup - self.assertTrue(res.write.called) - self.assertEqual(res.write.call_args[0][0], 'message\n') - diff --git a/old_tests/logpicker_test/main_test.py b/old_tests/logpicker_test/main_test.py deleted file mode 100644 index 0c53dde..0000000 --- a/old_tests/logpicker_test/main_test.py +++ /dev/null @@ -1,19 +0,0 @@ -#import mock - -# -# Cannot be used, because main file "logpicker" doesn't have ".py" -# extension ( => logpicker cannot be imported) -# - - -#class LogPickerMainTest(mock.TestCase): -# def setUp(self): -# pass -# -# def injector_injectarchivator_test(self): -# import logpicker -# import log_picker.archiving as archiving -# -# ret = logpicker.Injector.injectArchivator(mock.Mock()) -# self.assertEqual(ret, archiving.Bzip2Archive) - diff --git a/old_tests/logpicker_test/sending_test/Makefile.am b/old_tests/logpicker_test/sending_test/Makefile.am deleted file mode 100644 index 6c944a6..0000000 --- a/old_tests/logpicker_test/sending_test/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# tests/logpicker_test/sending_test/Makefile.am for anaconda -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# -# Author: Tomas Mlcoch tmlcoch@redhat.com - -EXTRA_DIST = *.py - -MAINTAINERCLEANFILES = Makefile.in - -ANACDIR = $(top_builddir)/pyanaconda -TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir)/tests:$(ANACDIR)/isys/.libs:$(ANACDIR):$(top_builddir):$(top_builddir)/utils - -TESTS = bugzillasender_test.py \ - emailsender_test.py \ - ftpsender_test.py \ - localsender_test.py \ - scpsender_test.py \ - senderbaseclass_test.py \ - stratasender_test.py diff --git a/old_tests/logpicker_test/sending_test/bugzillasender_test.py b/old_tests/logpicker_test/sending_test/bugzillasender_test.py deleted file mode 100644 index 03b07f3..0000000 --- a/old_tests/logpicker_test/sending_test/bugzillasender_test.py +++ /dev/null @@ -1,99 +0,0 @@ -import mock - -class BugzillaBaseClassTest(mock.TestCase): - def setUp(self): - self.setupModules(['report.plugins.bugzilla', - 'report.plugins.bugzilla.filer']) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def connect_and_login_test(self): - import log_picker.sending.bugzillasender as bugzillasender - - bugzillasender.filer = mock.Mock() - - USERNAME = "user" - PASSWORD = "foopassword" - - obj = bugzillasender.BugzillaBaseClass() - obj.connect_and_login(USERNAME, PASSWORD) - - self.assertTrue(bugzillasender.filer.BugzillaFiler().login.called) - self.assertEqual(bugzillasender.filer.BugzillaFiler().login.call_args, - (('user', 'foopassword'), {})) - - def connect_and_login_fail_test(self): - import log_picker.sending.bugzillasender as bugzillasender - - bugzillasender.filer = mock.Mock() - bugzillasender.filer.BugzillaFiler().login.side_effect = \ - bugzillasender.LoginError('foo', 'bar') - - USERNAME = "user" - PASSWORD = "foopassword" - - obj = bugzillasender.BugzillaBaseClass() - self.assertRaises(bugzillasender.SenderError, obj.connect_and_login, \ - USERNAME, PASSWORD) - self.assertTrue(bugzillasender.filer.BugzillaFiler().login.called) - self.assertEqual(bugzillasender.filer.BugzillaFiler().login.call_args, - (('user', 'foopassword'), {})) - - def set_bug_test(self): - import log_picker.sending.bugzillasender as bugzillasender - - BUGID = "123456789" - - obj = bugzillasender.BugzillaBaseClass() - obj.set_bug(BUGID) - - self.assertEqual(BUGID, obj.bug_id) - - def set_comment_test(self): - import log_picker.sending.bugzillasender as bugzillasender - - COMMENT = "some comment" - - obj = bugzillasender.BugzillaBaseClass() - obj.set_comment(COMMENT) - - self.assertEqual(COMMENT, obj.comment) - - def sendfile_test(self): - import log_picker.sending.bugzillasender as bugzillasender - - bugzillasender.os = mock.Mock() - bugzillasender.os.path = mock.Mock() - bugzillasender.os.path.basename = lambda x: x - - FILE = "/tmp/somefile" - MIMETYPE = "text/plain" - - obj = bugzillasender.BugzillaBaseClass() - obj._get_description = mock.Mock() - obj.bzfiler = mock.Mock() - obj.sendfile(FILE, MIMETYPE) - - self.assertTrue(obj._get_description.called) - self.assertTrue(obj.bzfiler.getbug.called) - self.assertTrue(obj.bzfiler.getbug().attachfile.called) - - def sendfile_raise_test(self): - import log_picker.sending.bugzillasender as bugzillasender - - bugzillasender.os = mock.Mock() - bugzillasender.os.path = mock.Mock() - bugzillasender.os.path.basename = lambda x: x - - FILE = "/tmp/somefile" - MIMETYPE = "text/plain" - - obj = bugzillasender.BugzillaBaseClass() - obj._get_description = mock.Mock() - obj.bzfiler = mock.Mock() - obj.bzfiler.getbug.side_effect = ValueError('Test exception') - - self.assertRaises(bugzillasender.SenderError, obj.sendfile, FILE, MIMETYPE) - diff --git a/old_tests/logpicker_test/sending_test/emailsender_test.py b/old_tests/logpicker_test/sending_test/emailsender_test.py deleted file mode 100644 index 504138a..0000000 --- a/old_tests/logpicker_test/sending_test/emailsender_test.py +++ /dev/null @@ -1,104 +0,0 @@ -import mock - -class EmailSenderTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def set_comment_test(self): - import log_picker.sending.emailsender as email_s - - COMMENT = "test comment" - - obj = email_s.EmailSender("", "", "", "") - obj.set_comment(COMMENT) - - self.assertEqual(COMMENT, obj.comment) - - def sendfile_test(self): - import log_picker.sending.emailsender as email_s - - FILE = "/tmp/some_file" - MIMETYPE = "text/plain" - - email_s.smtplib = mock.Mock() - email_s.open = self.fs.open - self.fs.open(FILE, 'w').write('some file content\n') - - class Fake_MIMEMultipart(mock.Mock): - def __getitem__(self, key): - return self.__dict__[key] - - def __setitem__(self, key, value): - self.__dict__[key] = value - - email_s.email = mock.Mock() - email_s.email.mime.multipart.MIMEMultipart.return_value = \ - Fake_MIMEMultipart() - - obj = email_s.EmailSender("", "", "", "") - obj.sendfile(FILE, MIMETYPE) - - self.assertTrue(email_s.smtplib.SMTP().sendmail.called) - self.assertTrue(email_s.smtplib.SMTP().quit.called) - self.assertEqual(2, - len(email_s.email.mime.base.MIMEBase().set_payload.call_args_list)) - - def sendfile_fail_1_test(self): - import log_picker.sending.emailsender as email_s - - FILE = "/tmp/some_file" - MIMETYPE = "text/plain" - - email_s.smtplib = mock.Mock() - import socket - email_s.smtplib.socket.gaierror = socket.gaierror - email_s.smtplib.SMTP.side_effect = email_s.smtplib.socket.gaierror() - email_s.open = self.fs.open - self.fs.open(FILE, 'w').write('some file content\n') - - class Fake_MIMEMultipart(mock.Mock): - def __getitem__(self, key): - return self.__dict__[key] - - def __setitem__(self, key, value): - self.__dict__[key] = value - - email_s.email = mock.Mock() - email_s.email.mime.multipart.MIMEMultipart.return_value = \ - Fake_MIMEMultipart() - - obj = email_s.EmailSender("", "", "", "") - self.assertRaises(email_s.SenderError, obj.sendfile, FILE, MIMETYPE) - - def sendfile_fail_2_test(self): - import log_picker.sending.emailsender as email_s - - FILE = "/tmp/some_file" - MIMETYPE = "text/plain" - - email_s.smtplib = mock.Mock() - import smtplib - email_s.smtplib.SMTPRecipientsRefused = smtplib.SMTPRecipientsRefused - email_s.smtplib.SMTP().sendmail.side_effect = \ - smtplib.SMTPRecipientsRefused("") - email_s.open = self.fs.open - self.fs.open(FILE, 'w').write('some file content\n') - - class Fake_MIMEMultipart(mock.Mock): - def __getitem__(self, key): - return self.__dict__[key] - - def __setitem__(self, key, value): - self.__dict__[key] = value - - email_s.email = mock.Mock() - email_s.email.mime.multipart.MIMEMultipart.return_value = \ - Fake_MIMEMultipart() - - obj = email_s.EmailSender("", "", "", "") - self.assertRaises(email_s.SenderError, obj.sendfile, FILE, MIMETYPE) - diff --git a/old_tests/logpicker_test/sending_test/ftpsender_test.py b/old_tests/logpicker_test/sending_test/ftpsender_test.py deleted file mode 100644 index 0bbc1e4..0000000 --- a/old_tests/logpicker_test/sending_test/ftpsender_test.py +++ /dev/null @@ -1,156 +0,0 @@ -import mock - -class FtpSenderTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def set_host_1_test(self): - import log_picker.sending.ftpsender as ftp_s - - HOST = "foobar" - - obj = ftp_s.FtpSender() - obj.set_host(HOST) - - self.assertEqual("ftp://%s" % HOST, obj.host) - - def set_host_2_test(self): - import log_picker.sending.ftpsender as ftp_s - - HOST = "ftp://foobar" - - obj = ftp_s.FtpSender() - obj.set_host(HOST) - - self.assertEqual(HOST, obj.host) - - def set_login_test(self): - import log_picker.sending.ftpsender as ftp_s - - LOGIN = "spiderman" - PASSWORD = "jarfly" - - obj = ftp_s.FtpSender() - obj.set_login(LOGIN, PASSWORD) - - self.assertEqual(LOGIN, obj.username) - self.assertEqual(PASSWORD, obj.password) - - def sendfile_1_test(self): - import log_picker.sending.ftpsender as ftp_s - - ftp_s.open = self.fs.open - ftp_s.ftplib = mock.Mock() - ftp_s.os = mock.Mock() - ftp_s.os.path.basename = lambda x: x - ftp_s.file = lambda x: x - - HOST = "localhost" - FILE = "/tmp/somefile" - MIMETYPE = "application/x-bzip2" - - self.fs.open(FILE, 'w').write("some content") - - obj = ftp_s.FtpSender() - obj.set_host(HOST) - obj.sendfile(FILE, MIMETYPE) - - method_calls = ftp_s.ftplib.FTP().method_calls - method_names = [x[0] for x in ftp_s.ftplib.FTP().method_calls] - - # Check calls order - self.assertEqual(method_names, - ['connect', 'login', 'cwd', 'set_pasv', 'storbinary', 'quit']) - - # Check arguments - PARAMS = 1 - - CONNECT = 0 - LOGIN = 1 - CWD = 2 - SET_PASV = 3 - STORBINARY = 4 - QUIT = 5 - - self.assertEqual(method_calls[CONNECT][PARAMS], (HOST, 21)) - self.assertEqual(method_calls[LOGIN][PARAMS], ()) - self.assertEqual(method_calls[CWD][PARAMS], ('',)) - self.assertEqual(method_calls[SET_PASV][PARAMS], (True,)) - self.assertEqual(method_calls[STORBINARY][PARAMS], - ('STOR %s' % FILE, FILE)) - - def sendfile_2_test(self): - import log_picker.sending.ftpsender as ftp_s - - ftp_s.open = self.fs.open - ftp_s.ftplib = mock.Mock() - ftp_s.os = mock.Mock() - ftp_s.os.path.basename = lambda x: x - ftp_s.file = lambda x: x - - PORT = "55" - HOST = "localhost" - ADDRESS = "%s:%s" % (HOST, PORT) - USERNAME = "foo" - PASSWORD = "bar" - FILE = "/tmp/somefile" - MIMETYPE = "application/x-bzip2" - - self.fs.open(FILE, 'w').write("some content") - - obj = ftp_s.FtpSender() - obj.set_host(ADDRESS) - obj.set_login(USERNAME, PASSWORD) - obj.sendfile(FILE, MIMETYPE) - - method_calls = ftp_s.ftplib.FTP().method_calls - method_names = [x[0] for x in ftp_s.ftplib.FTP().method_calls] - - # Check calls order - self.assertEqual(method_names, - ['connect', 'login', 'cwd', 'set_pasv', 'storbinary', 'quit']) - - # Check arguments - PARAMS = 1 - - CONNECT = 0 - LOGIN = 1 - CWD = 2 - SET_PASV = 3 - STORBINARY = 4 - QUIT = 5 - - self.assertEqual(method_calls[CONNECT][PARAMS], (HOST, PORT)) - self.assertEqual(method_calls[LOGIN][PARAMS], (USERNAME, PASSWORD)) - self.assertEqual(method_calls[CWD][PARAMS], ('',)) - self.assertEqual(method_calls[SET_PASV][PARAMS], (True,)) - self.assertEqual(method_calls[STORBINARY][PARAMS], - ('STOR %s' % FILE, FILE)) - - def sendfile_fail_test(self): - import log_picker.sending.ftpsender as ftp_s - - ftp_s.open = self.fs.open - ftp_s.ftplib = mock.Mock() - ftp_s.os = mock.Mock() - ftp_s.file = mock.Mock() - import ftplib - ftp_s.ftplib = mock.Mock() - ftp_s.ftplib.all_errors = ftplib.all_errors - ftp_s.ftplib.FTP().storbinary.side_effect = ftplib.error_temp("some") - - HOST = "localhost" - FILE = "/tmp/somefile" - MIMETYPE = "application/x-bzip2" - - self.fs.open(FILE, 'w').write("some content") - - obj = ftp_s.FtpSender() - obj.set_host(HOST) - self.assertRaises(ftp_s.SenderError, obj.sendfile, FILE, MIMETYPE) - - diff --git a/old_tests/logpicker_test/sending_test/localsender_test.py b/old_tests/logpicker_test/sending_test/localsender_test.py deleted file mode 100644 index cc9d888..0000000 --- a/old_tests/logpicker_test/sending_test/localsender_test.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import shutil -import mock - -class ScpSenderTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def set_path_test(self): - import log_picker.sending.localsender as local_s - - PATH = "/tmp/somewhere" - - obj = local_s.LocalSender() - obj.set_path(PATH) - - self.assertEqual(PATH, obj.path) - - def sendfile(self): - import log_picker.sending.localsender as local_s - - PATH = "/tmp/a_logfile_xa54hfd4j/" - FILE = "testfile" - - if os.path.exists(PATH): - if os.path.isdir(PATH): - shutil.rmtree(PATH) - else: - self.assertTrue(False, "Cannot create test directory: %s" % PATH) - - os.mkdir(PATH) - - obj = local_s.LocalSender() - obj.set_path(PATH) - obj.sendfile(FILE, "") - - files = len(os.listdir(PATH)) - - shutil.rmtree(PATH) - - self.assertTrue(files) - diff --git a/old_tests/logpicker_test/sending_test/scpsender_test.py b/old_tests/logpicker_test/sending_test/scpsender_test.py deleted file mode 100644 index 41c3ace..0000000 --- a/old_tests/logpicker_test/sending_test/scpsender_test.py +++ /dev/null @@ -1,106 +0,0 @@ -import mock - -class ScpSenderTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def set_host_1_test(self): - import log_picker.sending.scpsender as scp_s - - HOST = "localhost" - - obj = scp_s.ScpSender() - obj.set_host(HOST) - - self.assertEqual(HOST, obj.host) - - def set_host_2_test(self): - import log_picker.sending.scpsender as scp_s - - HOST = "localhost" - PORT = 12345 - ADDRESS = "%s:%s" % (HOST, PORT) - - obj = scp_s.ScpSender() - obj.set_host(ADDRESS) - - self.assertEqual(HOST, obj.host) - self.assertEqual(PORT, obj.port) - - def set_host_3_test(self): - import log_picker.sending.scpsender as scp_s - - HOST = "localhost" - PORT = "abc" - ADDRESS = "%s:%s" % (HOST, PORT) - - obj = scp_s.ScpSender() - obj.set_host(ADDRESS) - - self.assertEqual(HOST, obj.host) - self.assertEqual(None, obj.port) - - def set_login_test(self): - import log_picker.sending.scpsender as scp_s - - USERNAME = "foo" - - obj = scp_s.ScpSender() - obj.set_login(USERNAME) - - self.assertEqual(USERNAME, obj.username) - - def set_path_1_test(self): - import log_picker.sending.scpsender as scp_s - - PATH = "/tmp/something" - - obj = scp_s.ScpSender() - obj.set_path(PATH) - - self.assertEqual(PATH, obj.path) - - def set_path_2_test(self): - import log_picker.sending.scpsender as scp_s - - obj = scp_s.ScpSender() - obj.set_path(None) - - self.assertEqual(".", obj.path) - - def sendfile_test(self): - import log_picker.sending.scpsender as scp_s - - FILE = "/tmp/file" - MIMETYPE = "text/plain" - USERNAME = "foo" - HOST = "localhost" - PATH = "/home/foo" - - scp_s.subprocess = mock.Mock() - scp_s.subprocess.Popen().returncode = False - - obj = scp_s.ScpSender() - obj.set_host(HOST) - obj.set_login(USERNAME) - obj.set_path(PATH) - obj.sendfile(FILE, MIMETYPE) - - TARGET = "%s@%s:%s" % (USERNAME, HOST, PATH) - self.assertTrue(TARGET in scp_s.subprocess.Popen.call_args[0][0]) - - def sendfile_fail_1_test(self): - import log_picker.sending.scpsender as scp_s - - FILE = "/tmp/file" - MIMETYPE = "text/plain" - - scp_s.subprocess = mock.Mock() - - obj = scp_s.ScpSender() - self.assertRaises(scp_s.SenderError, obj.sendfile, FILE, MIMETYPE) - diff --git a/old_tests/logpicker_test/sending_test/senderbaseclass_test.py b/old_tests/logpicker_test/sending_test/senderbaseclass_test.py deleted file mode 100644 index 8540ee5..0000000 --- a/old_tests/logpicker_test/sending_test/senderbaseclass_test.py +++ /dev/null @@ -1,56 +0,0 @@ -import mock - -class SenderBaseClassTest(mock.TestCase): - def setUp(self): - self.setupModules([]) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def get_description_1_test(self): - import log_picker.sending.senderbaseclass as senderbaseclass - - HOSTNAME = "tiger" - DATE = "2010-10-10" - - senderbaseclass.gethostname = mock.Mock(return_value = HOSTNAME) - - senderbaseclass.datetime = mock.Mock() - senderbaseclass.datetime.datetime.now().strftime.return_value = DATE - - obj = senderbaseclass.SenderBaseClass() - ret = obj._get_description() - self.assertEqual(ret, "%s (%s) %s" % ("", HOSTNAME, DATE)) - - def get_description_2_test(self): - import log_picker.sending.senderbaseclass as senderbaseclass - - PREFIX = "description" - HOSTNAME = "lion" - DATE = "2011-11-11" - - senderbaseclass.gethostname = mock.Mock(return_value = HOSTNAME) - - senderbaseclass.datetime = mock.Mock() - senderbaseclass.datetime.datetime.now().strftime.return_value = DATE - - obj = senderbaseclass.SenderBaseClass() - ret = obj._get_description(PREFIX) - self.assertEqual(ret, "%s (%s) %s" % (PREFIX, HOSTNAME, DATE)) - - def get_description_3_test(self): - import log_picker.sending.senderbaseclass as senderbaseclass - - PREFIX = "description" - DATE = "2012-12-12" - - senderbaseclass.gethostname = mock.Mock(side_effect=Exception) - - senderbaseclass.datetime = mock.Mock() - senderbaseclass.datetime.datetime.now().strftime.return_value = DATE - - obj = senderbaseclass.SenderBaseClass() - ret = obj._get_description(PREFIX) - self.assertEqual(ret, "%s (%s) %s" % (PREFIX, "", DATE)) - diff --git a/old_tests/logpicker_test/sending_test/stratasender_test.py b/old_tests/logpicker_test/sending_test/stratasender_test.py deleted file mode 100644 index fcb94b7..0000000 --- a/old_tests/logpicker_test/sending_test/stratasender_test.py +++ /dev/null @@ -1,95 +0,0 @@ -import mock - -class StrataSenderTest(mock.TestCase): - def setUp(self): - self.setupModules(['report.plugins.strata']) - self.fs = mock.DiskIO() - - def tearDown(self): - self.tearDownModules() - - def set_login_test(self): - import log_picker.sending.stratasender as stratasender - - LOGIN = "foo" - PASSWORD = "bar" - - obj = stratasender.StrataSender() - obj.set_login(LOGIN, PASSWORD) - - self.assertEqual(LOGIN, obj.username) - self.assertEqual(PASSWORD, obj.password) - - def set_case_number_test(self): - import log_picker.sending.stratasender as stratasender - - CASE_NUM = "123" - - obj = stratasender.StrataSender() - obj.set_case_number(CASE_NUM) - self.assertEqual(CASE_NUM, obj.case_number) - - def sendfile_test(self): - import log_picker.sending.stratasender as stratasender - - FILE = "/tmp/somefile" - RESPONSE = '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> - <response><title>File Attachment Succeeded</title><body>.</body></response>''' - - stratasender.send_report_to_existing_case = mock.Mock(return_value=RESPONSE) - - obj = stratasender.StrataSender() - obj.sendfile(FILE, "") - - self.assertTrue(stratasender.send_report_to_existing_case.called) - - def sendfile_raise_1_test(self): - import log_picker.sending.stratasender as stratasender - - FILE = "/tmp/somefile" - RESPONSE = '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> - <response><title>File Attachment Failed</title><body>401 Unauthorized - This request requires authentication....</body></response>''' - - stratasender.send_report_to_existing_case = mock.Mock(return_value=RESPONSE) - - obj = stratasender.StrataSender() - self.assertRaises(stratasender.SenderError, obj.sendfile, FILE, "") - - def sendfile_raise_2_test(self): - import log_picker.sending.stratasender as stratasender - - FILE = "/tmp/somefile" - RESPONSE = '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> - <response><title>File Attachment Failed</title><body>Error : CASE_NOT_FOUND - Message: Case 99999999 does not exist</body></response>''' - - stratasender.send_report_to_existing_case = mock.Mock(return_value=RESPONSE) - - obj = stratasender.StrataSender() - self.assertRaises(stratasender.SenderError, obj.sendfile, FILE, "") - - def sendfile_raise_3_test(self): - import log_picker.sending.stratasender as stratasender - - FILE = "/tmp/somefile" - RESPONSE = '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> - <response><title>File Attachment Failed</title><body>Error : Your - computer is under attack of alien intruders (from Mars).</body></response>''' - - stratasender.send_report_to_existing_case = mock.Mock(return_value=RESPONSE) - - obj = stratasender.StrataSender() - self.assertRaises(stratasender.SenderError, obj.sendfile, FILE, "") - - def sendfile_raise_4_test(self): - import log_picker.sending.stratasender as stratasender - - FILE = "/tmp/somefile" - RESPONSE = '''This is not XML valid response => something is wrong.''' - - stratasender.send_report_to_existing_case = mock.Mock(return_value=RESPONSE) - - obj = stratasender.StrataSender() - self.assertRaises(stratasender.SenderError, obj.sendfile, FILE, "") - diff --git a/scripts/Makefile.am b/scripts/Makefile.am index f667f46..0035373 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -19,7 +19,6 @@
scriptsdir = $(libexecdir)/$(PACKAGE_NAME) dist_scripts_SCRIPTS = upd-updates run-anaconda anaconda-yum -dist_scripts_DATA = pyrc.py dist_noinst_SCRIPTS = upd-kernel makeupdates
dist_bin_SCRIPTS = analog anaconda-cleanup instperf diff --git a/scripts/pyrc.py b/scripts/pyrc.py deleted file mode 100644 index 6acee5b..0000000 --- a/scripts/pyrc.py +++ /dev/null @@ -1,27 +0,0 @@ -# -# pyrc.py -# -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# - -try: - import readline - import rlcompleter - readline.parse_and_bind("tab: complete") - del rlcompleter - del readline -except: - pass diff --git a/utils/Makefile.am b/utils/Makefile.am index e955ce2..cf48b68 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -17,8 +17,8 @@ # # Author: David Cantrell dcantrell@redhat.com
-SUBDIRS = log_picker dd +SUBDIRS = dd
-dist_sbin_SCRIPTS = logpicker handle-sshpw +dist_sbin_SCRIPTS = handle-sshpw
MAINTAINERCLEANFILES = Makefile.in diff --git a/utils/addrsize.c b/utils/addrsize.c deleted file mode 100644 index be3bd97..0000000 --- a/utils/addrsize.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * addrsize.c - * Generate initrd.addrsize file for s390x platforms. - * Takes an integer argument and writes out the binary representation of - * that value to the initrd.addrsize file. - * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197773 - * https://bugzilla.redhat.com/show_bug.cgi?id=546422 - * - * Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <netinet/in.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> - -int main(int argc,char **argv) { - char *cmd = basename(argv[0]); - char *address = NULL, *input = NULL, *output = NULL; - struct stat initrd_stat; - unsigned int addr = 0, size = 0, zero = 0; - int fd, rc; - mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH; - - if (argc != 4) { - printf("Generate initrd address and size file used by the .ins LPAR load mechanism\n"); - printf("Usage: %s [address] [initrd] [output file]\n", cmd); - printf("Example: %s 0x02000000 initrd.img initrd.addrsize\n", cmd); - return 1; - } - - address = argv[1]; - input = argv[2]; - output = argv[3]; - - rc = stat(input, &initrd_stat); - if (rc) { - perror("Error getting initrd stats "); - return 2; - } - - addr = htonl(strtoul(address, NULL, 0)); - size = htonl(initrd_stat.st_size); - fd = open(output, O_CREAT | O_RDWR, mode); - - if (write(fd, &zero, sizeof(int)) == -1) { - perror("writing initrd.addr (zero) "); - return 3; - } - - if (write(fd, &addr, sizeof(int)) == -1) { - perror("writing initrd.addr (addr) "); - return 4; - } - - if (write(fd, &zero, sizeof(int)) == -1) { - perror("writing initrd.addr (zero) "); - return 5; - } - - if (write(fd, &size, sizeof(int)) == -1) { - perror("writing initrd.addr (size) "); - return 6; - } - - close(fd); - return EXIT_SUCCESS; -} diff --git a/utils/log_picker/Makefile.am b/utils/log_picker/Makefile.am deleted file mode 100644 index e9cb273..0000000 --- a/utils/log_picker/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# log_picker/Makefile.am -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. - -SUBDIRS = sending - -pkgpyexecdir = $(pyexecdir)/log_picker -logpickerdir = $(pkgpyexecdir) -logpicker_PYTHON = $(srcdir)/*.py - -MAINTAINERCLEANFILES = Makefile.in diff --git a/utils/log_picker/__init__.py b/utils/log_picker/__init__.py deleted file mode 100644 index 61bdaa1..0000000 --- a/utils/log_picker/__init__.py +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/python - -import os -import sys -import tempfile - -import log_picker.archiving as archiving -from log_picker.archiving import ArchivationError -from log_picker.archiving import NoFilesArchivationError -import log_picker.sending as sending -from log_picker.sending import SenderError -import log_picker.logmining as logmining -from log_picker.logmining import LogMinerError - - -class LogPickerError(Exception): - pass - - -class LogPicker(object): - - def __init__(self, archive_obj=None, sender_obj=None, miners=[], - use_one_file=False): - self.sender_obj = sender_obj - self.archive_obj = archive_obj - self.miners = miners - - self.archive = None - self.tmpdir = None - self.files = [] - self.filename = self._get_tmp_file("completelog") if use_one_file else None - - - def _errprint(self, msg): - """Print message on stderr.""" - sys.stderr.write('%s\n' % msg) - - - def _get_tmp_file(self, name, suffix="", register=True): - """Create temp file.""" - if not self.tmpdir: - self.tmpdir = tempfile.mkdtemp(prefix="lp-logs-", dir="/tmp") - - name += suffix - filename = os.path.join(self.tmpdir, name) - open(filename, 'w') # Create empty file - - if register: - self.files.append(filename) - return filename - - - def create_archive(self, name=""): - """Create archive (one file) containing multiple log files.""" - name = name or self.tmpdir or "logs" - self.archive = self._get_tmp_file(name, - suffix=self.archive_obj.file_ext, register=False) - try: - self.archive_obj.create_archive(self.archive, self.files) - except (ArchivationError): - os.remove(self.archive) - raise - - - def send(self): - """Send log/archive with logs via sender object.""" - - if not len(self.files): - return - - if not self.archive and len(self.files) > 1: - raise LogPickerError('More than one file to send. ' + \ - 'You have to create archive. Use create_archive() method.') - - file = self.files[0] - contenttype = "text/plain" - if self.archive: - file = self.archive - contenttype = self.archive_obj.mimetype - - self.sender_obj.sendfile(file, contenttype) - - - def getlogs(self): - """Collect logs generated by miners passed to the constructor.""" - - # self.filename != None means that we should put all logs into one file. - # self.filename == None means that every log should have its own file. - if self.filename: - f = open(self.filename, 'w') - - for miner in self.miners: - if not self.filename: - tmpfilename = self._get_tmp_file(miner.get_filename()) - f = open(tmpfilename, 'w') - - desc = "%s\n\n" % (miner.get_description()) - f.write(desc) - try: - miner.set_logfile(f) - miner.getlog() - except (LogMinerError) as e: - self._errprint("Warning: %s - %s" % (miner._name, e)) - f.write("\n%s\n\n\n" % e) - - if not self.filename: - f.close() - # XXX Cut our anaconda dump into pieces. - if isinstance(miner, logmining.AnacondaLogMiner): - self._cut_to_pieces(tmpfilename) - - if self.filename: - f.close() - - - def _cut_to_pieces(self, filename): - """Create multiple log files from Anaconda dump. - Attention: Anaconda dump file on input will be used and overwritten! - @filename file with Anaconda dump""" - actual_file = os.path.basename(filename) - files = {actual_file: []} - empty_lines = 0 - - # Split file into memmory - for line in open(filename): - striped = line.strip() - - if not striped: - empty_lines += 1 - elif empty_lines > 1 and striped.startswith('/') \ - and striped.endswith(':') and len(line) > 2: - actual_file = striped[:-1].rsplit('/', 1)[-1]#.replace('.', '-') - files[actual_file] = [] - empty_lines = 0 - - files[actual_file].append(line) - - # Overwrite original file - actual_file = os.path.basename(filename) - open(filename, 'w').writelines(files[actual_file]) - del files[actual_file] - - # Write other individual files - for file in files: - open(self._get_tmp_file(file), 'w').writelines(files[file]) - diff --git a/utils/log_picker/archiving.py b/utils/log_picker/archiving.py deleted file mode 100644 index fb3da9c..0000000 --- a/utils/log_picker/archiving.py +++ /dev/null @@ -1,100 +0,0 @@ -import os -import tempfile -import tarfile -import bz2 - - -class ArchivationError(Exception): - pass - -class NoFilesArchivationError(ArchivationError): - pass - -class ArchiveBaseClass(object): - """Base class for archive classes.""" - - _compression = False - _ext = ".ext" - _mimetype = "" - - def __init__(self, *args, **kwargs): - self._tar_ext = ".tar" - - @property - def support_compression(self): - """Return True if compression is supported/used.""" - return self._compression - - @property - def file_ext(self): - """Return extension for output file.""" - return self._ext - - @property - def mimetype(self): - """Return archive mime type.""" - return self._mimetype - - def _create_tmp_tar(self, filelist): - _, tmpfile = tempfile.mkstemp(suffix=self._tar_ext) - tar = tarfile.open(tmpfile, "w") - for name in filelist: - pieces = name.rsplit('/', 2) - arcname = "%s/%s" % (pieces[-2], pieces[-1]) - tar.add(name, arcname=arcname) - tar.close() - return tmpfile - - def create_archive(self, outfilename, filelist): - raise NotImplementedError() - - -class Bzip2Archive(ArchiveBaseClass): - """Class for bzip2 compression.""" - - _compression = True - _ext = ".bz2" - _mimetype = "application/x-bzip2" - - def __init__(self, usetar=True, *args, **kwargs): - ArchiveBaseClass.__init__(self, args, kwargs) - self.usetar = usetar - - @property - def file_ext(self): - """Return extension for output file.""" - if self.usetar: - return "%s%s" % (self._tar_ext, self._ext) - return self._ext - - def create_archive(self, outfilename, filelist): - """Create compressed archive containing files listed in filelist.""" - if not filelist: - raise NoFilesArchivationError("No files to archive.") - - size = 0 - for file in filelist: - size += os.path.getsize(file) - if size <= 0: - raise NoFilesArchivationError("No files to archive.") - - if not self.usetar and len(filelist) > 1: - raise ArchivationError( \ - "Bzip2 cannot archive multiple files without tar.") - - if self.usetar: - f_in_path = self._create_tmp_tar(filelist) - else: - f_in_path = filelist[0] - - f_in = open(f_in_path, 'rb') - f_out = bz2.BZ2File(outfilename, 'w') - f_out.writelines(f_in) - f_out.close() - f_in.close() - - if self.usetar: - os.remove(f_in_path) - - return outfilename - diff --git a/utils/log_picker/argparser.py b/utils/log_picker/argparser.py deleted file mode 100644 index 7bc8a0b..0000000 --- a/utils/log_picker/argparser.py +++ /dev/null @@ -1,279 +0,0 @@ -import optparse -import log_picker.sending as sending - - -class ArgError(Exception): - pass - - -class SimpleOptionGroup (optparse.OptionGroup): - - def _group_info_helper(self, formatter): - res = "" - lines = self.description.split('\n') - for line in lines: - res += formatter._format_text(line) - res += '\n' - return res - - def format_help(self, formatter): - result = formatter.format_heading(self.title) - formatter.indent() - result += self._group_info_helper(formatter) - formatter.dedent() - return result - - -class _OptionParserWithRaise(optparse.OptionParser): - def error(self, msg): - raise ArgError(msg) - - -class ArgParser(object): - - def __init__(self): - self.options = None - self.parser = None - - - def _generate_bz_it_group(self): - if sending.RHBZ in sending.NOT_AVAILABLE and \ - sending.STRATA in sending.NOT_AVAILABLE: - return None - - if sending.RHBZ in sending.NOT_AVAILABLE: - title = "Send the report to the Red Hat Ticketing system | options" - params_info = \ - "-r, --rhel \n"\ - " Send the report to the Red Hat Ticketing \n"\ - " system. \n"\ - "-i ID, --idbug=ID \n"\ - " The case number in the Red Hat Ticketing \n"\ - " system. \n"\ - "-l USERNAME, --login=USERNAME \n"\ - " Set the Red Hat Customer Portal username. \n" - - bzg = SimpleOptionGroup(self.parser, title, params_info) - bzg.add_option("-r", "--rhel", action="store_true", dest="strata") - - elif sending.STRATA in sending.NOT_AVAILABLE: - title = "Send the report to the Bugzilla | options" - params_info = \ - "-b, --bugzilla \n"\ - " Send the report to the Bugzilla. \n"\ - "-i ID, --idbug=ID \n"\ - " Set the bug id in the Bugzilla. \n"\ - "-l USERNAME, --login=USERNAME \n"\ - " Set the bugzilla username. \n" - - bzg = SimpleOptionGroup(self.parser, title, params_info) - bzg.add_option("-b", "--bugzilla", action="store_true", - dest="bugzilla") - - else: - title = "Send the report to the Bugzilla or the Red Hat Ticketing" \ - " system | options" - params_info = \ - "-b, --bugzilla \n"\ - " Send the report to the Bugzilla. \n"\ - "-r, --rhel \n"\ - " Send the report to the Red Hat Ticketing \n"\ - " system. \n"\ - "-i ID, --idbug=ID \n"\ - " Set the bug id in the Bugzilla/Case number \n"\ - " in the Red Hat Ticketing system. \n"\ - "-l USERNAME, --login=USERNAME \n"\ - " Set the Bugzilla/Red Hat Cutomer Portal \n"\ - " username. \n" - - bzg = SimpleOptionGroup(self.parser, title, params_info) - bzg.add_option("-b", "--bugzilla", action="store_true", - dest="bugzilla") - bzg.add_option("-r", "--rhel", action="store_true", dest="strata") - - bzg.add_option("-i", "--idbug", dest="bug_id", metavar="ID") - bzg.add_option("-l", "--login", dest="login", metavar="USERNAME") - - return bzg - - - def _generate_email_group(self): - if sending.EMAIL in sending.NOT_AVAILABLE: - return None - - title = "Send the report to an email | options" - params_info = \ - "-e, --email \n"\ - " Send the report to an email address. \n"\ - "-s ADDRESS, --server=ADDRESS \n"\ - " Set the SMTP server address. \n"\ - "-f EMAIL, --from=EMAIL \n"\ - " Set your email address. \n"\ - "-t EMAIL, --to=EMAIL \n"\ - " Set the destination email address. \n" - - - emailg = SimpleOptionGroup(self.parser, title, params_info) - emailg.add_option("-e", "--email", action="store_true", dest="email") - emailg.add_option("-s", "--server", dest="smtp_addr", metavar="ADDRESS") - emailg.add_option("-f", "--from", dest="from_addr", metavar="EMAIL") - emailg.add_option("-t", "--to", dest="to_addr", metavar="EMAIL") - return emailg - - - def _generate_scp_group(self): - if sending.SCP in sending.NOT_AVAILABLE: - return None - - title = "Send the report via secure copy (scp) | options" - params_info = \ - "-o, --scp \n"\ - " Send the report to the remote computer via scp.\n"\ - "-l USERNAME, --login=USERNAME \n"\ - " Set the remote username. \n"\ - "-a HOST, --host=HOST \n"\ - " Set the remote host address. \n"\ - "-p PATH, --path=PATH \n"\ - " Set the file path on the remote host. \n" - - scpg = SimpleOptionGroup(self.parser, title, params_info) - scpg.add_option("-o", "--scp", action="store_true", dest="scp") - scpg.add_option("-l", "--login", dest="login", metavar="USERNAME") - scpg.add_option("-a", "--host", dest="host", metavar="HOST") - scpg.add_option("-p", "--path", dest="path", metavar="PATH") - return scpg - - - def _generate_ftp_group(self): - if sending.FTP in sending.NOT_AVAILABLE: - return None - - title = "Upload the report via FTP | options" - params_info = \ - "-q, --ftp \n"\ - " Upload the report via ftp. \n"\ - "-l USERNAME, --login=USERNAME \n"\ - " Set the ftp username. \n"\ - " Note: For anonymous login don't use this option\n"\ - "-a HOST, --host=HOST \n"\ - " Set the remote host address. \n"\ - " Address syntax: [ftp://]host[:port][path] \n"\ - " Examples of host addresses: \n"\ - " host.com, ftp://host.com:21/path/on/the/host \n" - - ftpg = SimpleOptionGroup(self.parser, title, params_info) - ftpg.add_option("-q", "--ftp", action="store_true", dest="ftp") - ftpg.add_option("-l", "--login", dest="login", metavar="USERNAME") - ftpg.add_option("-a", "--host", dest="host", metavar="HOST") - return ftpg - - - def _generate_local_group(self): - if sending.LOCAL in sending.NOT_AVAILABLE: - return None - - title = "Save the report to the local computer | options" - params_info = \ - "-m, --local \n"\ - " Save the report to a directory on the computer.\n"\ - "-p DIRECTORY, --path=DIRECTORY \n"\ - " Set the local directory. \n" - - localg = SimpleOptionGroup(self.parser, title, params_info) - localg.add_option("-m", "--local", action="store_true", dest="local") - localg.add_option("-p", "--path", dest="path", metavar="PATH") - return localg - - - def _create_parser(self): - self.parser = _OptionParserWithRaise(conflict_handler="resolve") - self.parser.add_option("-c", "--comment", dest="bug_comment", - default=None, help="Report comment.", metavar="COMMENT") - - # Bugzilla and Red Hat Ticketing system options - group = self._generate_bz_it_group() - if group: self.parser.add_option_group(group) - - # Email options - group = self._generate_email_group() - if group: self.parser.add_option_group(group) - - # Scp options - group = self._generate_scp_group() - if group: self.parser.add_option_group(group) - - # Ftp options - group = self._generate_ftp_group() - if group: self.parser.add_option_group(group) - - # Local options - group = self._generate_local_group() - if group: self.parser.add_option_group(group) - - def _parse(self): - (self.options, _) = self.parser.parse_args() - - # Set sender attribute - if self.options.ensure_value('email', None): - self.options.sender = sending.EMAIL - elif self.options.ensure_value('strata', None): - self.options.sender = sending.STRATA - elif self.options.ensure_value('bugzilla', None): - self.options.sender = sending.RHBZ - elif self.options.ensure_value('scp', None): - self.options.sender = sending.SCP - elif self.options.ensure_value('ftp', None): - self.options.sender = sending.FTP - elif self.options.ensure_value('local', None): - self.options.sender = sending.LOCAL - else: - self.options.sender = None - - def _validate(self): - cnt = 0 - if self.options.ensure_value('email', None): cnt += 1 - if self.options.ensure_value('bugzilla', None): cnt += 1 - if self.options.ensure_value('strata', None): cnt += 1 - if self.options.ensure_value('scp', None): cnt += 1 - if self.options.ensure_value('ftp', None): cnt += 1 - if self.options.ensure_value('local', None): cnt += 1 - - if not cnt: - raise ArgError("No send method selected.") - elif cnt > 1: - raise ArgError("Options -b, -r, -e, -o, -q and -m" \ - " are mutually exclusive.") - - missing = [] - if self.options.ensure_value('email', None): - if not self.options.smtp_addr: missing.append('-s') - if not self.options.from_addr: missing.append('-f') - if not self.options.to_addr: missing.append('-t') - elif self.options.ensure_value('bugzilla', None): - if not self.options.bug_id: missing.append('-i') - if not self.options.login: missing.append('-l') - elif self.options.ensure_value('strata', None): - if not self.options.bug_id: missing.append('-i') - if not self.options.login: missing.append('-l') - elif self.options.ensure_value('scp', None): - if not self.options.login: missing.append('-l') - if not self.options.host: missing.append('-a') - elif self.options.ensure_value('ftp', None): - if not self.options.host: missing.append('-a') - elif self.options.ensure_value('local', None): - if not self.options.path: missing.append('-p') - - if missing: - msg = "" - for arg in missing: - msg += '\nArgument "%s" is missing!' % arg - raise ArgError(msg) - - - def parse(self): - """Parse and validate command line arguments.""" - self._create_parser() - self._parse() - self._validate() - return self.options - diff --git a/utils/log_picker/logmining.py b/utils/log_picker/logmining.py deleted file mode 100644 index 2bbf1c3..0000000 --- a/utils/log_picker/logmining.py +++ /dev/null @@ -1,255 +0,0 @@ -import os -import stat -import shlex -import time -import subprocess - - -class LogMinerError(Exception): - pass - - -class LogMinerBaseClass(object): - """Base class for LogMiner classes. - LogMiner object represents one file/command/function - to get useful information (log).""" - - _name = "name" - _description = "Description" - _filename = "filename" - _prefer_separate_file = True - - def __init__(self, logfile=None, *args, **kwargs): - """@logfile open file object. This open file object will be used for - output generated during getlog() call.""" - self.logfile = logfile - self._used = False - - @classmethod - def get_filename(cls): - """Suggested log filename.""" - return cls._filename - - @classmethod - def get_description(cls): - """Log description.""" - return cls._description - - def set_logfile(self, logfile): - self.logfile = logfile - - def _write_separator(self): - self.logfile.write('\n\n') - - def _write_files(self, files): - if not isinstance(files, list): - files = [files] - - if self._used: - self._write_separator() - self._used = True - - for filename in files: - self.logfile.write('%s:\n' % filename) - try: - with open(filename, 'r') as f: - self.logfile.writelines(f) - self.logfile.write('\n') - except (IOError) as e: - self.logfile.write("Exception while opening: %s\n" % e) - continue - - def _run_command(self, command): - if self._used: - self._write_separator() - self._used = True - - if isinstance(command, basestring): - command = shlex.split(command) - - proc = subprocess.Popen(command, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (out, err) = proc.communicate() - self.logfile.write('STDOUT:\n%s\n' % out) - self.logfile.write('STDERR:\n%s\n' % err) - self.logfile.write('RETURN CODE: %s\n' % proc.returncode) - - def getlog(self): - """Create log and write it to a file object - recieved in the constructor.""" - self._action() - self._write_separator() - - def _action(self): - raise NotImplementedError() - - - -class AnacondaLogMiner(LogMinerBaseClass): - """Class represents way to get Anaconda dump.""" - - _name = "anaconda_log" - _description = "Log dumped from Anaconda." - _filename = "anaconda-dump" - _prefer_separate_file = True - - def _action(self): - # Actual state of /tmp - old_state = set(os.listdir('/tmp')) - - # Tell Anaconda to dump itself - try: - anaconda_pid = open('/var/run/anaconda.pid').read().strip() - except (IOError): - raise LogMinerError("Anaconda pid file doesn't exists") - - proc = subprocess.Popen(shlex.split("kill -s USR2 %s" % anaconda_pid), - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - proc.communicate() - if proc.returncode: - raise LogMinerError('Error while sending signal to Anaconda') - - time.sleep(5) - - # Check if new traceback file exists - new_state = set(os.listdir('/tmp')) - tbpfiles = list(new_state - old_state) - - if not len(tbpfiles): - raise LogMinerError('Error: No anaconda traceback file exist') - - for file in tbpfiles: - if file.startswith('anaconda-tb-'): - tbpfile_name = file - break - else: - raise LogMinerError('Error: No anaconda traceback file exist') - - # Copy anaconda traceback log - self._write_files('/tmp/%s' % tbpfile_name) - - - -class FileSystemLogMiner(LogMinerBaseClass): - """Class represents way to get image of filesystem structure.""" - - _name = "filesystem" - _description = "Image of disc structure." - _filename = "filesystem" - _prefer_separate_file = True - - FSTREE_FORMAT = "%1s %6s%1s %s" # Format example: "d 1023.9K somedir" - DADPOINT = 1 # Number of Digits After the Decimal POINT - - def _action(self): - self._get_tree_structure() - - def _size_conversion(self, size): - """Converts bytes into KB, MB or GB""" - if size >= 1073741824: # Gigabytes - size = round(size / 1073741824.0, self.DADPOINT) - unit = "G" - elif size >= 1048576: # Megabytes - size = round(size / 1048576.0, self.DADPOINT) - unit = "M" - elif size >= 1024: # Kilobytes - size = round(size / 1024.0, self.DADPOINT) - unit = "K" - else: - size = size - unit = "" - return size, unit - - - def _get_tree_structure(self, human_readable=True): - """Creates filesystem structure image.""" - white_list = ['/sys'] - - logfile = self.logfile - - for path, dirs, files in os.walk('/'): - line = "\n%s:" % (path) - logfile.write('%s\n' % line) - - # List dirs - dirs.sort() - for directory in dirs: - fullpath = os.path.join(path, directory) - size = os.path.getsize(fullpath) - unit = "" - if human_readable: - size, unit = self._size_conversion(size) - line = self.FSTREE_FORMAT % ("d", size, unit, directory) - logfile.write('%s\n' % line) - - # Skip mounted directories - original_dirs = dirs[:] - for directory in original_dirs: - dirpath = os.path.join(path, directory) - if os.path.ismount(dirpath) and not dirpath in white_list: - dirs.remove(directory) - - # List files - files.sort() - for filename in files: - fullpath = os.path.join(path, filename) - if os.path.islink(fullpath): - line = self.FSTREE_FORMAT % ("l", "0", "", filename) - line += " -> %s" % os.path.realpath(fullpath) - if not os.path.isfile(fullpath): - # Broken symlink - line += " (Broken)" - else: - stat_res = os.stat(fullpath)[stat.ST_MODE] - if stat.S_ISREG(stat_res): - filetype = "-" - elif stat.S_ISCHR(stat_res): - filetype = "c" - elif stat.S_ISBLK(stat_res): - filetype = "b" - elif stat.S_ISFIFO(stat_res): - filetype = "p" - elif stat.S_ISSOCK(stat_res): - filetype = "s" - else: - filetype = "-" - - size = os.path.getsize(fullpath) - unit = "" - if human_readable: - size, unit = self._size_conversion(size) - line = self.FSTREE_FORMAT % (filetype, size, unit, filename) - logfile.write('%s\n' % line) - - - -class DmSetupLsLogMiner(LogMinerBaseClass): - """Class represents way to get 'dmsetup ls --tree' output.""" - - _name = "dmsetup ls" - _description = "Output from "dmsetup ls --tree"." - _filename = "dmsetup-ls" - _prefer_separate_file = True - - def _action(self): - self._run_command("dmsetup ls --tree") - - -class DmSetupInfoLogMiner(LogMinerBaseClass): - """Class represents way to get 'dmsetup info' output.""" - - _name = "dmsetup info" - _description = "Output from "dmsetup info -c"." - _filename = "dmsetup-info" - _prefer_separate_file = True - - def _action(self): - self._run_command("dmsetup info -c") - - -ALL_MINERS = [AnacondaLogMiner(), - FileSystemLogMiner(), - DmSetupLsLogMiner(), - DmSetupInfoLogMiner(), - ] - diff --git a/utils/log_picker/sending/Makefile.am b/utils/log_picker/sending/Makefile.am deleted file mode 100644 index 7f284b5..0000000 --- a/utils/log_picker/sending/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# log_picker/Makefile.am -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. - - -pkgpyexecdir = $(pyexecdir)/log_picker -sendingdir = $(pkgpyexecdir)/sending -sending_PYTHON = $(srcdir)/*.py - -MAINTAINERCLEANFILES = Makefile.in diff --git a/utils/log_picker/sending/__init__.py b/utils/log_picker/sending/__init__.py deleted file mode 100644 index 9571af4..0000000 --- a/utils/log_picker/sending/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -from log_picker.sending.senderbaseclass import SenderError - -RHBZ = 0 # RedHat Bugzilla -EMAIL = 1 # Email -STRATA = 2 # Red Hat ticketing system -SCP = 3 # Scp -FTP = 4 # Ftp -LOCAL = 5 # Local - -NOT_AVAILABLE = [] - - -try: - from log_picker.sending.bugzillasender import RedHatBugzilla -except (ImportError): - NOT_AVAILABLE.append(RHBZ) - -try: - from log_picker.sending.emailsender import EmailSender -except (ImportError): - NOT_AVAILABLE.append(EMAIL) - -try: - from log_picker.sending.stratasender import StrataSender -except (ImportError): - NOT_AVAILABLE.append(STRATA) - -try: - from log_picker.sending.scpsender import ScpSender -except (ImportError): - NOT_AVAILABLE.append(SCP) - -try: - from log_picker.sending.ftpsender import FtpSender -except (ImportError): - NOT_AVAILABLE.append(FTP) - -try: - from log_picker.sending.localsender import LocalSender -except (ImportError): - NOT_AVAILABLE.append(LOCAL) - diff --git a/utils/log_picker/sending/bugzillasender.py b/utils/log_picker/sending/bugzillasender.py deleted file mode 100644 index 1fc4d59..0000000 --- a/utils/log_picker/sending/bugzillasender.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -from log_picker.sending.senderbaseclass import SenderBaseClass -from log_picker.sending.senderbaseclass import SenderError -from report.plugins.bugzilla import filer -from report.plugins.bugzilla.filer import CommunicationError -from report.plugins.bugzilla.filer import LoginError - - -class BugzillaBaseClass(SenderBaseClass): - - _bz_address = "" - _bz_xmlrpc = "" - _description = "" - - def __init__(self, *args, **kwargs): - SenderBaseClass.__init__(self, args, kwargs) - self.bzfiler = None - self.bug_id = None - self.comment = None - - def connect_and_login(self, username, password): - try: - self.bzfiler = filer.BugzillaFiler(self._bz_xmlrpc, self._bz_address, - filer.getVersion(), filer.getProduct()) - self.bzfiler.login(username, password) - except (CommunicationError, LoginError) as e: - raise SenderError("%s. Bad username or password?" % e) - except (ValueError) as e: - raise SenderError("%s" % e) - - def set_bug(self, bug_id): - self.bug_id = bug_id - - def set_comment(self, comment): - self.comment = comment - - def sendfile(self, filename, contenttype): - description = self._get_description(self._description) - - dict_args = {'isprivate': False, - 'filename': os.path.basename(filename), - 'contenttype': contenttype} - - if self.comment: - dict_args['comment'] = self.comment - - try: - bug = self.bzfiler.getbug(self.bug_id) - bug.attachfile(filename, description, **dict_args) - except (CommunicationError, ValueError) as e: - raise SenderError(e) - - -class RedHatBugzilla(BugzillaBaseClass): - - _bz_address = "http://bugzilla.redhat.com" - _bz_xmlrpc = "https://bugzilla.redhat.com/xmlrpc.cgi" - _description = "LogPicker" - - def __init__(self, *args, **kwargs): - BugzillaBaseClass.__init__(self, args, kwargs) - diff --git a/utils/log_picker/sending/emailsender.py b/utils/log_picker/sending/emailsender.py deleted file mode 100644 index 03c94ca..0000000 --- a/utils/log_picker/sending/emailsender.py +++ /dev/null @@ -1,71 +0,0 @@ -import os -import smtplib -import email -import email.encoders -import email.mime.multipart -from log_picker.sending.senderbaseclass import SenderBaseClass -from log_picker.sending.senderbaseclass import SenderError - - -class EmailSender(SenderBaseClass): - - _description = "Email from LogPicker" - - def __init__(self, sendby, addresses, smtp_server, *args, **kwargs): - """Send file by email. - @sendby - Sender email address. (string) - @addresses - List of destination email addresses. (list) - @smtp_server - SMTP server address. (string)""" - - SenderBaseClass.__init__(self, args, kwargs) - self.smtp_server = smtp_server - self.sendby = sendby - self.addresses = addresses - self.comment = "" - - def set_comment(self, comment): - self.comment = comment - - def sendfile(self, filename, contenttype): - # Create email message - msg = email.mime.multipart.MIMEMultipart() - msg['Subject'] = self._get_description(self._description) - msg['From'] = self.sendby - msg['To'] = ', '.join(self.addresses) - msg.preamble = 'This is a multi-part message in MIME format.' - - # Add message text - msgtext = email.mime.base.MIMEBase("text", "plain") - msgtext.set_payload(self.comment) - msg.attach(msgtext) - - # Add message attachment - cont_type = contenttype.split('/', 1) - if len(cont_type) == 1: - cont_type.append("") - elif not cont_type: - cont_type = ["application", "octet-stream"] - - attach_data = open(filename, 'rb').read() - - msgattach = email.mime.base.MIMEBase(cont_type[0], cont_type[1]) - msgattach.set_payload(attach_data) - email.encoders.encode_base64(msgattach) - msgattach.add_header('Content-Disposition', 'attachment', - filename=os.path.basename(filename)) - msg.attach(msgattach) - - # Send message - try: - s = smtplib.SMTP(self.smtp_server) - except(smtplib.socket.gaierror, smtplib.SMTPServerDisconnected): - raise SenderError("Email cannot be send. " +\ - "Error while connecting to smtp server.") - - try: - s.sendmail(self.sendby, self.addresses, msg.as_string()) - except(smtplib.SMTPRecipientsRefused) as e: - raise SenderError("Email cannot be send. Wrong destination " +\ - "email address?\nErr message: %s" % e) - s.quit() - diff --git a/utils/log_picker/sending/ftpsender.py b/utils/log_picker/sending/ftpsender.py deleted file mode 100644 index 9ecf095..0000000 --- a/utils/log_picker/sending/ftpsender.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -import urlparse -import ftplib -from log_picker.sending.senderbaseclass import SenderBaseClass -from log_picker.sending.senderbaseclass import SenderError - -# This class uses code from module report.plugins.scp - -class FtpSender(SenderBaseClass): - - def __init__(self, *args, **kwargs): - SenderBaseClass.__init__(self, args, kwargs) - self.host = None - self.username = None - self.password = None - - def set_host(self, host): - if not host.startswith('ftp://'): - host = 'ftp://' + host - self.host = host - - def set_login(self, username, password): - self.username = username - self.password = password - - def sendfile(self, filename, contenttype): - _, netloc, path, _, _, _ = urlparse.urlparse(self.host) - if netloc.find(':') > 0: - netloc, port = netloc.split(':') - else: - port = 21 - - try: - ftp = ftplib.FTP() - ftp.connect(netloc, port) - if self.username: - ftp.login(self.username, self.password) - else: - ftp.login() - ftp.cwd(path) - ftp.set_pasv(True) - ftp.storbinary('STOR %s' % os.path.basename(filename), \ - file(filename)) - ftp.quit() - except ftplib.all_errors as e: - raise SenderError("FTP upload failed: %(error)s" % {'error':e}) - diff --git a/utils/log_picker/sending/localsender.py b/utils/log_picker/sending/localsender.py deleted file mode 100644 index 24fe9ec..0000000 --- a/utils/log_picker/sending/localsender.py +++ /dev/null @@ -1,39 +0,0 @@ -import os -import shutil -from log_picker.sending.senderbaseclass import SenderBaseClass -from log_picker.sending.senderbaseclass import SenderError - - -class LocalSender(SenderBaseClass): - - def __init__(self, *args, **kwargs): - SenderBaseClass.__init__(self, args, kwargs) - self.path = None - - def set_path(self, directory): - self.path = directory - - if os.path.exists(self.path) and not os.path.isdir(self.path): - raise SenderError('Cannot create "%s" directory. A file of ' - 'the same name already exists.' % self.path) - - - def sendfile(self, filename, contenttype): - - # Another check due possibility of race condition - if os.path.exists(self.path): - if not os.path.isdir(self.path): - raise SenderError('Cannot create "%s" directory. A file of ' - 'the same name already exists.' % self.path) - else: - try: - os.makedirs(self.path) - except Exception as e: - raise SenderError('Cannot create "%s" directory: %s' % \ - (self.path, e)) - try: - shutil.copy(filename, self.path) - except Exception as e: - raise SenderError('Could not save "%s" to "%s": %s' % \ - (os.path.basename(filename), self.path, e)) - diff --git a/utils/log_picker/sending/scpsender.py b/utils/log_picker/sending/scpsender.py deleted file mode 100644 index a3842ed..0000000 --- a/utils/log_picker/sending/scpsender.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -import subprocess -from log_picker.sending.senderbaseclass import SenderBaseClass -from log_picker.sending.senderbaseclass import SenderError - - -class ScpSender(SenderBaseClass): - - def __init__(self, *args, **kwargs): - SenderBaseClass.__init__(self, args, kwargs) - self.host = None - self.port = None - self.username = None - self.path = "." - - - def set_host(self, host): - if host.find(":") != -1: - (self.host, port) = host.split(":") - try: - self.port = int(port) - except ValueError: - self.port = None - else: - self.host = host - - - def set_login(self, username): - self.username = username - - - def set_path(self, path): - if path: self.path = path - - - def sendfile(self, filename, contenttype): - port_args = [] - if self.port: - port_args = ["-P", self.port] - - target = "%s@%s:%s" % (self.username, self.host, self.path) - - command = ["scp", - "-q", - "-oGSSAPIAuthentication=no", - "-oHostbasedAuthentication=no", - "-oPubkeyAuthentication=no", - "-oChallengeResponseAuthentication=no", - "-oPasswordAuthentication=yes", - "-oNumberOfPasswordPrompts=1", - "-oStrictHostKeyChecking=no", - "-oUserKnownHostsFile=/dev/null", - ] + port_args + [filename, target] - - p = subprocess.Popen(command, stdin=subprocess.PIPE) - p.communicate() - - if p.returncode: - raise SenderError("Scp sending failed.\n" + \ - "Possible causes: Bad hostname, bad username, "\ - "bad password, host is down.") - diff --git a/utils/log_picker/sending/senderbaseclass.py b/utils/log_picker/sending/senderbaseclass.py deleted file mode 100644 index 30aec02..0000000 --- a/utils/log_picker/sending/senderbaseclass.py +++ /dev/null @@ -1,25 +0,0 @@ -import datetime -from socket import gethostname - - -class SenderError(Exception): - pass - - -class SenderBaseClass(object): - - def __init__(self, *args, **kwargs): - pass - - def sendfile(self, filename, contenttype): - raise NotImplementedError() - - def _get_description(self, prefix=""): - try: - hostname = gethostname() - except: - hostname = "" - date_str = datetime.datetime.now().strftime("%Y-%m-%d") - description = "%s (%s) %s" % (prefix, hostname, date_str) - return description - diff --git a/utils/log_picker/sending/stratasender.py b/utils/log_picker/sending/stratasender.py deleted file mode 100644 index 4f242da..0000000 --- a/utils/log_picker/sending/stratasender.py +++ /dev/null @@ -1,55 +0,0 @@ -import xml.dom.minidom -from log_picker.sending.senderbaseclass import SenderBaseClass -from log_picker.sending.senderbaseclass import SenderError -from report.plugins.strata import send_report_to_existing_case -from report.plugins.strata import strata_client_strerror - - -class StrataSender(SenderBaseClass): - - _URL = "https://api.access.redhat.com/rs" - _CERT_DATA = "INSECURE" - - def __init__(self, *args, **kwargs): - SenderBaseClass.__init__(self, args, kwargs) - self.username = None - self.password = None - self.case_number = None - - def set_login(self, username, password): - self.username = username - self.password = password - - def set_case_number(self, case_num): - self.case_number = case_num - - def sendfile(self, filename, contenttype): - response = send_report_to_existing_case(self._URL, - self._CERT_DATA, - self.username, - self.password, - self.case_number, - filename) - - if not response: - raise SenderError("Sending log to the Red Hat Ticket System fail" +\ - " - %s" % strata_client_strerror()) - - # Try parse response - try: - dom = xml.dom.minidom.parseString(response) - mnode = dom.getElementsByTagName("response")[0] - title = mnode.getElementsByTagName("title")[0].childNodes[0].data - body = mnode.getElementsByTagName("body")[0].childNodes[0].data - except Exception as e: - raise SenderError("Sending log to the Red Hat Ticket System fail.") - - if title == "File Attachment Failed": - if body.startswith("401 Unauthorized"): - raise SenderError("Bad login or password.") - elif body.startswith("Error : CASE_NOT_FOUND"): - raise SenderError("Selected case doesn't exist.") - else: - raise SenderError("Sending log to the " +\ - "Red Hat Ticket System fail - %s" % body.strip()) - diff --git a/utils/logpicker b/utils/logpicker deleted file mode 100755 index 03d1669..0000000 --- a/utils/logpicker +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/python - -import sys -import getpass -import log_picker - -import log_picker.argparser as argparser -from log_picker.argparser import ArgError -import log_picker.archiving as archiving -from log_picker.archiving import NoFilesArchivationError -import log_picker.sending as sending -from log_picker.sending import SenderError -import log_picker.logmining as logmining - - -class ApplicationScope(object): - """Application configuration class.""" - - def __init__(self, parser_options): - self.bug_comment = parser_options.ensure_value('bug_comment', None) - - self.bug_id = parser_options.ensure_value('bug_id', None) - self.login = parser_options.ensure_value('login', None) - self.password = None - - self.smtp_server = parser_options.ensure_value('smtp_addr', None) - self.from_addr = parser_options.ensure_value('from_addr', None) - self.to_addr = [] - if parser_options.ensure_value('to_addr', None): - self.to_addr = [parser_options.to_addr] - self.host = parser_options.ensure_value('host', None) - self.path = parser_options.ensure_value('path', None) - - # sender - self.sender = parser_options.ensure_value('sender', None) - - # miners - self.miners = logmining.ALL_MINERS - - -class Injector(object): - """Main factory class.""" - - @staticmethod - def inject_main_helper(scope): - logpicker = Injector.inject_logpicker(scope) - return MainHelper(logpicker) - - @staticmethod - def inject_logpicker(scope): - sender = Injector.inject_sender(scope) - archivator = Injector.inject_archivator(scope) - return log_picker.LogPicker(archive_obj=archivator, sender_obj=sender, - miners=scope.miners) - - @staticmethod - def inject_sender(scope): - if scope.sender == sending.RHBZ: - sender = sending.RedHatBugzilla() - sender.set_bug(scope.bug_id) - sender.set_comment(scope.bug_comment) - sender.connect_and_login(scope.login, scope.password) - return sender - if scope.sender == sending.EMAIL: - sender = sending.EmailSender(scope.from_addr, scope.to_addr, - scope.smtp_server) - sender.set_comment(scope.bug_comment) - return sender - if scope.sender == sending.STRATA: - sender = sending.StrataSender() - sender.set_login(scope.login, scope.password) - sender.set_case_number(scope.bug_id) - return sender - if scope.sender == sending.SCP: - sender = sending.ScpSender() - sender.set_login(scope.login) - sender.set_path(scope.path) - sender.set_host(scope.host) - return sender - if scope.sender == sending.FTP: - sender = sending.FtpSender() - sender.set_login(scope.login, scope.password) - sender.set_host(scope.host) - return sender - if scope.sender == sending.LOCAL: - sender = sending.LocalSender() - sender.set_path(scope.path) - return sender - - raise Exception("Unknown sender type.") - - @staticmethod - def inject_archivator(scope): - return archiving.Bzip2Archive() - - -class MainHelper(object): - """Main application class.""" - - def __init__(self, logpicker): - self.picker = logpicker - - def run(self): - self.picker.getlogs() - self.picker.create_archive() - self.picker.send() - print "Successfully completed!" - - - -if __name__ == "__main__": - - # Argument parsing - try: - options = argparser.ArgParser().parse() - except (ArgError) as e: - sys.stderr.write("Argument error: %s\n" % e) - sys.exit(1) - - # Application scope - scope = ApplicationScope(options) - if scope.sender == sending.RHBZ or scope.sender == sending.STRATA or \ - (scope.sender == sending.FTP and scope.login): - scope.password = getpass.getpass("Password: ") - - # Application - try: - app = Injector.inject_main_helper(scope) - app.run() - except (NoFilesArchivationError): - sys.stderr.write("Nothing to report.\n") - sys.exit(0) - except (SenderError) as e: - sys.stderr.write("Error: %s\n" % e) - sys.exit(1) -
--- pyanaconda/ui/gui/tools/run-spoke.py | 4 ++-- scripts/makeupdates | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pyanaconda/ui/gui/tools/run-spoke.py b/pyanaconda/ui/gui/tools/run-spoke.py index d7101cf..6ac3b75 100755 --- a/pyanaconda/ui/gui/tools/run-spoke.py +++ b/pyanaconda/ui/gui/tools/run-spoke.py @@ -98,8 +98,8 @@ payload.setup(storage)
spoke = spokeClass(ksdata, storage, payload, instclass) if hasattr(spoke, "register_event_cb"): - spoke.register_event_cb("continue", lambda: Gtk.main_quit()) - spoke.register_event_cb("quit", lambda: Gtk.main_quit()) + spoke.register_event_cb("continue", Gtk.main_quit) + spoke.register_event_cb("quit", Gtk.main_quit)
if hasattr(spoke, "set_path"): spoke.set_path("categories", [ diff --git a/scripts/makeupdates b/scripts/makeupdates index beeda18..71f2b4f 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -392,7 +392,7 @@ def addRpms(updates_path, add_rpms): """ # convert all the RPM paths to absolute paths, so that # relative paths can be used with -a/--add - add_rpms = map(lambda x: os.path.abspath(x), add_rpms) + add_rpms = map(os.path.abspath, add_rpms)
for rpm in add_rpms: cmd = "cd %s && rpm2cpio %s | cpio -dium" % (updates_path, rpm) @@ -556,7 +556,7 @@ def check_for_new_packages(tag, arch, added_rpms, specfile_path): if new_packages: include_rpms.extend(get_RPMs_from_koji(new_packages, fedora_number, arch)) # return absolute paths for the packages - return map(lambda x: os.path.abspath(x), include_rpms) + return map(os.path.abspath, include_rpms)
def remove_local_packages(packages, arch, added_rpms): """Remove locally available RPMs from the list of needed packages,
--- scripts/anaconda-cleanup | 2 -- scripts/anaconda-yum | 1 - scripts/instperf | 2 -- scripts/makebumpver | 4 ++-- scripts/makeupdates | 15 ++------------- tests/pyanaconda_tests/timezone_test.py | 1 - tests/regex_tests/groupparse_test.py | 2 +- tests/regex_tests/proxy_test.py | 2 +- 8 files changed, 6 insertions(+), 23 deletions(-)
diff --git a/scripts/anaconda-cleanup b/scripts/anaconda-cleanup index 1682f59..8664685 100755 --- a/scripts/anaconda-cleanup +++ b/scripts/anaconda-cleanup @@ -38,8 +38,6 @@ flags.imageInstall = True import pyanaconda.anaconda_log pyanaconda.anaconda_log.init()
-from pyanaconda import iutil - from blivet import StorageDiscoveryConfig from blivet.devicetree import DeviceTree from blivet import devicelibs diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum index da40fcc..98ebcd1 100755 --- a/scripts/anaconda-yum +++ b/scripts/anaconda-yum @@ -18,7 +18,6 @@ # # Red Hat Author(s): Brian C. Lane bcl@redhat.com # -import logging import os import sys import argparse diff --git a/scripts/instperf b/scripts/instperf index f0f53cc..2caa222 100755 --- a/scripts/instperf +++ b/scripts/instperf @@ -22,8 +22,6 @@ def logit(): swapTotal = 0 swapFree = 0
- global mem_logger - with open("/proc/meminfo") as f: for line in f.readlines(): if line.startswith("Buffers:"): diff --git a/scripts/makebumpver b/scripts/makebumpver index b70a006..cac6bc3 100755 --- a/scripts/makebumpver +++ b/scripts/makebumpver @@ -400,10 +400,10 @@ def main(argv): name, version, release, bugreport = None, None, None, None ignore, bugmap = None, None show_help, unknown = False, False - opts, args = [], [] + opts = []
try: - opts, args = getopt.getopt(sys.argv[1:], 'n:v:r:b:i:m:d?', + opts, _args = getopt.getopt(sys.argv[1:], 'n:v:r:b:i:m:d?', ['name=', 'version=', 'release=', 'bugreport=', 'ignore=', 'map=', 'debug', 'help']) diff --git a/scripts/makeupdates b/scripts/makeupdates index 71f2b4f..ef935ca 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -134,7 +134,7 @@ def get_req_tuple(pkg_tuple, version_request): :returns: version request tuple :rtype: tuple """ - name, arch, epoch, version, release = pkg_tuple + name, _arch, epoch, version, release = pkg_tuple return (name, version_request, (epoch, version, release))
@@ -191,15 +191,6 @@ def create_RPM_cache_folder(): os.makedirs(RPM_FOLDER_NAME)
def copyUpdatedFiles(tag, updates, cwd): - def pruneFile(src, names): - lst = [] - - for name in names: - if name.startswith('Makefile') or name.endswith('.pyc'): - lst.append(name) - - return lst - def install_to_dir(fname, relpath): sys.stdout.write("Including %s\n" % fname) outdir = os.path.join(updates, relpath) @@ -207,8 +198,6 @@ def copyUpdatedFiles(tag, updates, cwd): os.makedirs(outdir) shutil.copy2(file, outdir)
- subdirs = [] - # Updates get overlaid onto the runtime filesystem. Anaconda expects them # to be in /run/install/updates, so put them in # $updatedir/run/install/updates. @@ -644,7 +633,7 @@ def get_RPMs_from_koji(packages, fedora_number, arch):
index = 1 print("starting %d worker threads" % len(packages)) - for package_name, package in packages.iteritems(): + for _package_name, package in packages.iteritems(): thread = threading.Thread(name=index, target=get_rpm_from_Koji_thread, args=(package, fedora_number, arch, rpm_paths, print_lock)) diff --git a/tests/pyanaconda_tests/timezone_test.py b/tests/pyanaconda_tests/timezone_test.py index c277bd0..3514d1f 100644 --- a/tests/pyanaconda_tests/timezone_test.py +++ b/tests/pyanaconda_tests/timezone_test.py @@ -20,7 +20,6 @@
from pyanaconda import timezone import unittest -import langtable import mock
class TimezonesListings(unittest.TestCase): diff --git a/tests/regex_tests/groupparse_test.py b/tests/regex_tests/groupparse_test.py index 2802cad..6d5b793 100644 --- a/tests/regex_tests/groupparse_test.py +++ b/tests/regex_tests/groupparse_test.py @@ -53,7 +53,7 @@ class GroupParseTestCase(unittest.TestCase): for group, result in tests: try: self.assertEqual(GROUPLIST_FANCY_PARSE.match(group).groups(), result) - except AssertionError as error: + except AssertionError: got_error = True print("Group parse error: `%s' did not not parse as `%s'" % (group, result))
diff --git a/tests/regex_tests/proxy_test.py b/tests/regex_tests/proxy_test.py index 0e551f1..6fae463 100644 --- a/tests/regex_tests/proxy_test.py +++ b/tests/regex_tests/proxy_test.py @@ -111,7 +111,7 @@ class ProxyRegexTestCase(unittest.TestCase): for proxy, result in tests: try: self.assertEqual(PROXY_URL_PARSE.match(proxy).groups(), result) - except AssertionError as error: + except AssertionError: got_error = True print("Proxy parse error: `%s' did not parse as `%s'" % (proxy, result))
On 09/25/2013 02:21 PM, David Shea wrote:
scripts/anaconda-cleanup | 2 -- scripts/anaconda-yum | 1 - scripts/instperf | 2 -- scripts/makebumpver | 4 ++-- scripts/makeupdates | 15 ++------------- tests/pyanaconda_tests/timezone_test.py | 1 - tests/regex_tests/groupparse_test.py | 2 +- tests/regex_tests/proxy_test.py | 2 +- 8 files changed, 6 insertions(+), 23 deletions(-)
Found two more in pyanaconda/ui/tui/__init__.py. It doesn't need the i18n or common imports.
--- scripts/anaconda-yum | 50 +++++++++++++++++++++++++------------------------- scripts/makeupdates | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum index 98ebcd1..2bd2a76 100755 --- a/scripts/anaconda-yum +++ b/scripts/anaconda-yum @@ -75,31 +75,31 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l env_remove = ('DISPLAY', 'DBUS_SESSION_BUS_ADDRESS') [os.environ.pop(k) for k in env_remove if k in os.environ]
- try: - # Setup the basics, point to the config file and install_root - yb = yum.YumBase() - yb.use_txmbr_in_callback = True - - # Set some configuration parameters that don't get set through a config - # file. yum will know what to do with these. - # Enable all types of yum plugins. We're somewhat careful about what - # plugins we put in the environment. - yb.preconf.plugin_types = yum.plugins.ALL_TYPES - yb.preconf.enabled_plugins = YUM_PLUGINS - yb.preconf.fn = yum_conf - yb.preconf.root = install_root - yb.preconf.releasever = release - - if debug: - yb.preconf.debuglevel = 10 - yb.preconf.errorlevel = 10 - yb.preconf.rpmverbosity = "debug" - - # Setup yum cache dir outside the installroot - if yb.conf.cachedir.startswith(yb.conf.installroot): - root = yb.conf.installroot - yb.conf.cachedir = yb.conf.cachedir[len(root):] + # Setup the basics, point to the config file and install_root + yb = yum.YumBase() + yb.use_txmbr_in_callback = True + + # Set some configuration parameters that don't get set through a config + # file. yum will know what to do with these. + # Enable all types of yum plugins. We're somewhat careful about what + # plugins we put in the environment. + yb.preconf.plugin_types = yum.plugins.ALL_TYPES + yb.preconf.enabled_plugins = YUM_PLUGINS + yb.preconf.fn = yum_conf + yb.preconf.root = install_root + yb.preconf.releasever = release + + if debug: + yb.preconf.debuglevel = 10 + yb.preconf.errorlevel = 10 + yb.preconf.rpmverbosity = "debug" + + # Setup yum cache dir outside the installroot + if yb.conf.cachedir.startswith(yb.conf.installroot): + root = yb.conf.installroot + yb.conf.cachedir = yb.conf.cachedir[len(root):]
+ try: # Load the transaction file and execute it yb.load_ts(ts_file) yb.initActionTs() @@ -151,7 +151,7 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l finally: yb.ts.close() logfile.close() - except Exception as e: + except YumBaseError as e: print("ERROR: transaction error: %s" % e) finally: print("QUIT:") diff --git a/scripts/makeupdates b/scripts/makeupdates index ef935ca..2ee3ee5 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -181,7 +181,7 @@ def download_to_file(url, path): result = urllib.urlretrieve(url, path) # return the storage path return result[0] - except Exception, e: + except IOError, e: print("download of %s to %s failed with exception: %s" % (url, path, e)) return None
On Wed, Sep 25, 2013 at 02:21:50PM -0400, David Shea wrote:
scripts/anaconda-yum | 50 +++++++++++++++++++++++++------------------------- scripts/makeupdates | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum index 98ebcd1..2bd2a76 100755 --- a/scripts/anaconda-yum +++ b/scripts/anaconda-yum @@ -75,31 +75,31 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l env_remove = ('DISPLAY', 'DBUS_SESSION_BUS_ADDRESS') [os.environ.pop(k) for k in env_remove if k in os.environ]
- try:
# Setup the basics, point to the config file and install_root
yb = yum.YumBase()
yb.use_txmbr_in_callback = True
[snip]
- except Exception as e:
- except YumBaseError as e: print("ERROR: transaction error: %s" % e) finally: print("QUIT:")
This is broad on purpose. We want to tell anaconda what the error is when it fails, not just die with a traceback. The caller is waiting for output from anaconda-yum and handling any errors that show up.
If anything add another except Exception with a more generic error instead of transaction error.
On 09/25/2013 05:59 PM, Brian C. Lane wrote:
- except Exception as e:
- except YumBaseError as e: print("ERROR: transaction error: %s" % e) finally: print("QUIT:")
This is broad on purpose. We want to tell anaconda what the error is when it fails, not just die with a traceback. The caller is waiting for output from anaconda-yum and handling any errors that show up.
If anything add another except Exception with a more generic error instead of transaction error.
Fair enough. I'll put the try: back where it was and add a handler and pylint exception for Exception. It should probably exit with a failure there, though, right?
On Thu, Sep 26, 2013 at 08:59:21AM -0400, David Shea wrote:
On 09/25/2013 05:59 PM, Brian C. Lane wrote:
- except Exception as e:
- except YumBaseError as e: print("ERROR: transaction error: %s" % e) finally: print("QUIT:")
This is broad on purpose. We want to tell anaconda what the error is when it fails, not just die with a traceback. The caller is waiting for output from anaconda-yum and handling any errors that show up.
If anything add another except Exception with a more generic error instead of transaction error.
Fair enough. I'll put the try: back where it was and add a handler and pylint exception for Exception. It should probably exit with a failure there, though, right?
Just make it do a print("ERROR: ... so that the main anaconda process will catch it and report it. If you look at the block in yumpayload.py you'll see what it does with the output of anaconda-yum
Switch to absolute module names for importing the gi data. Besides breaking the pylint check, using relative imports meant that AnacondaWidgets.py could only be used when installed.
Add an __init__ for AnacondaWidgets.TimezoneMap --- widgets/python/AnacondaWidgets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/widgets/python/AnacondaWidgets.py b/widgets/python/AnacondaWidgets.py index 9b268a5..512eb5e 100644 --- a/widgets/python/AnacondaWidgets.py +++ b/widgets/python/AnacondaWidgets.py @@ -24,8 +24,8 @@ where necessary. For instance instead of creating a class and then setting a bunch of properties, these classes allow passing the properties at creation time. """ -from ..importer import modules -from ..overrides import override +from gi.importer import modules +from gi.overrides import override
Anaconda = modules['AnacondaWidgets']._introspection_module __all__ = [] @@ -78,6 +78,9 @@ DiskOverview = override(DiskOverview) __all__.append('DiskOverview')
class TimezoneMap(Anaconda.TimezoneMap): + def __init__(self): + Anaconda.TimezoneMap.__init__(self) + def set_timezone(self, timezone, no_signal=False): Anaconda.TimezoneMap.set_timezone(self, timezone, no_signal)
On Wed, 2013-09-25 at 14:21 -0400, David Shea wrote:
Switch to absolute module names for importing the gi data. Besides breaking the pylint check, using relative imports meant that AnacondaWidgets.py could only be used when installed.
Add an __init__ for AnacondaWidgets.TimezoneMap
widgets/python/AnacondaWidgets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/widgets/python/AnacondaWidgets.py b/widgets/python/AnacondaWidgets.py index 9b268a5..512eb5e 100644 --- a/widgets/python/AnacondaWidgets.py +++ b/widgets/python/AnacondaWidgets.py @@ -24,8 +24,8 @@ where necessary. For instance instead of creating a class and then setting a bunch of properties, these classes allow passing the properties at creation time. """ -from ..importer import modules -from ..overrides import override +from gi.importer import modules +from gi.overrides import override
Anaconda = modules['AnacondaWidgets']._introspection_module __all__ = [] @@ -78,6 +78,9 @@ DiskOverview = override(DiskOverview) __all__.append('DiskOverview')
class TimezoneMap(Anaconda.TimezoneMap):
- def __init__(self):
Anaconda.TimezoneMap.__init__(self)
What is this __init__ good for? Wouldn't it be the same if it was omitted?
On 09/25/2013 02:47 PM, Vratislav Podzimek wrote:
On Wed, 2013-09-25 at 14:21 -0400, David Shea wrote:
Switch to absolute module names for importing the gi data. Besides breaking the pylint check, using relative imports meant that AnacondaWidgets.py could only be used when installed.
Add an __init__ for AnacondaWidgets.TimezoneMap
widgets/python/AnacondaWidgets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/widgets/python/AnacondaWidgets.py b/widgets/python/AnacondaWidgets.py index 9b268a5..512eb5e 100644 --- a/widgets/python/AnacondaWidgets.py +++ b/widgets/python/AnacondaWidgets.py @@ -24,8 +24,8 @@ where necessary. For instance instead of creating a class and then setting a bunch of properties, these classes allow passing the properties at creation time. """ -from ..importer import modules -from ..overrides import override +from gi.importer import modules +from gi.overrides import override
Anaconda = modules['AnacondaWidgets']._introspection_module __all__ = [] @@ -78,6 +78,9 @@ DiskOverview = override(DiskOverview) __all__.append('DiskOverview')
class TimezoneMap(Anaconda.TimezoneMap):
- def __init__(self):
Anaconda.TimezoneMap.__init__(self)
What is this __init__ good for? Wouldn't it be the same if it was omitted?
It's good for making the error go away :-) I'll switch this to a disable-msg=W0232. The only reason it's warning us here is because the parent class is coming out of gi, so pylint thinks there is no parent constructor.
--- tests/pyanaconda_tests/timezone_test.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tests/pyanaconda_tests/timezone_test.py b/tests/pyanaconda_tests/timezone_test.py index 3514d1f..62ff2cd 100644 --- a/tests/pyanaconda_tests/timezone_test.py +++ b/tests/pyanaconda_tests/timezone_test.py @@ -56,7 +56,9 @@ class s390HWclock(unittest.TestCase): self.arch_mock.isS390.return_value = True self.iutil_mock = mock.Mock()
+ # pylint: disable-msg=E1101 timezone.save_hw_clock.func_globals["arch"] = self.arch_mock + # pylint: disable-msg=E1101 timezone.save_hw_clock.func_globals["iutil"] = self.iutil_mock
def s390_save_hw_clock_test(self):
--- scripts/instperf | 2 +- scripts/makebumpver | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/instperf b/scripts/instperf index 2caa222..f0d53b2 100755 --- a/scripts/instperf +++ b/scripts/instperf @@ -41,7 +41,7 @@ def logit(): "swapUsed": int(swapTotal)-int(swapFree), "procs": topProcesses()}
- mem_logger.debug("%(memUsed)d %(swapUsed)d %(procs)s" % d) + mem_logger.debug("%(memUsed)d %(swapUsed)d %(procs)s", d)
mem_logger = logging.getLogger("memLog") mem_logger.setLevel(logging.DEBUG) diff --git a/scripts/makebumpver b/scripts/makebumpver index cac6bc3..f686da1 100755 --- a/scripts/makebumpver +++ b/scripts/makebumpver @@ -37,7 +37,7 @@ import textwrap
class MakeBumpVer: def __init__(self, *args, **kwargs): - log.debug("%s" % (kwargs,)) + log.debug("%s", kwargs) self.bzserver = 'bugzilla.redhat.com' self.bzurl = "https://%s/xmlrpc.cgi" % self.bzserver self.username = None @@ -141,10 +141,10 @@ class MakeBumpVer:
if not self.bz.logged_in: rc = self.bz.login(self.username, self.password) - log.debug("login rc = %s" % (rc,)) + log.debug("login rc = %s", rc)
bugs = self.bz.query({'bug_id': bug}) - log.debug("bugs = %s" % (bugs)) + log.debug("bugs = %s", bugs)
if len(bugs) != 1: return None
--- scripts/anaconda-yum | 8 ++-- scripts/makebumpver | 6 +-- scripts/makeupdates | 102 ++++++++++++++++++++++++++------------------------- utils/handle-sshpw | 2 +- 4 files changed, 62 insertions(+), 56 deletions(-)
diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum index 2bd2a76..1f0c3a9 100755 --- a/scripts/anaconda-yum +++ b/scripts/anaconda-yum @@ -73,7 +73,9 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l
# remove some environmental variables that can cause problems with package scripts env_remove = ('DISPLAY', 'DBUS_SESSION_BUS_ADDRESS') - [os.environ.pop(k) for k in env_remove if k in os.environ] + for k in env_remove: + if k in os.environ: + os.environ.pop(k)
# Setup the basics, point to the config file and install_root yb = yum.YumBase() @@ -330,8 +332,8 @@ class RPMCallback(object):
if __name__ == "__main__": - parser = setup_parser() - args = parser.parse_args() + arg_parser = setup_parser() + args = arg_parser.parse_args()
# force output to be flushed sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) diff --git a/scripts/makebumpver b/scripts/makebumpver index f686da1..3fc8320 100755 --- a/scripts/makebumpver +++ b/scripts/makebumpver @@ -232,7 +232,7 @@ class MakeBumpVer: rhbz = set()
# look for a bug in the summary line, validate if found - m = re.search("(#\d+(,.*)*)", summary) + m = re.search(r"(#\d+(,.*)*)", summary) if m: fullbug = summary[m.start():m.end()] bugstr = summary[m.start()+2:m.end()-1] @@ -277,14 +277,14 @@ class MakeBumpVer: summary += " (%s)" % author
for bodyline in body: - m = re.match("^(Resolves|Related|Conflicts):\ +rhbz#\d+.*$", + m = re.match(r"^(Resolves|Related|Conflicts):\ +rhbz#\d+.*$", bodyline) if not m: continue
actionre = re.search("(Resolves|Related|Conflicts)", bodyline) - bugre = re.search("\d+", bodyline) + bugre = re.search(r"\d+", bodyline) if actionre and bugre: action = actionre.group() bug = bugre.group() diff --git a/scripts/makeupdates b/scripts/makeupdates index 2ee3ee5..f185a88 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -104,7 +104,7 @@ def getArchiveTagOffset(configure, spec, offset):
def get_anaconda_version(): """Get current anaconda version as string from the configure script""" - with open("configure.ac", "rc") as f: + with open("configure.ac") as f: match = re.search(r"AC_INIT([.*],\ [(.*)],\ [.*])", f.read()) return match.groups()[0]
@@ -157,7 +157,9 @@ def check_package_version(filename, package): pkg_tuple = get_pkg_tuple(filename) return miscutils.rangeCheck(package.req_tuple, pkg_tuple)
-def doGitDiff(tag, args=[]): +def doGitDiff(tag, args=None): + if args is None: + args=[] proc = subprocess.Popen(['git', 'diff', '--name-status', tag] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() @@ -165,7 +167,9 @@ def doGitDiff(tag, args=[]): lines = proc[0].split('\n') return lines
-def doGitContentDiff(tag, args=[]): +def doGitContentDiff(tag, args=None): + if args is None: + args = [] proc = subprocess.Popen(['git', 'diff', tag] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() @@ -181,7 +185,7 @@ def download_to_file(url, path): result = urllib.urlretrieve(url, path) # return the storage path return result[0] - except IOError, e: + except IOError as e: print("download of %s to %s failed with exception: %s" % (url, path, e)) return None
@@ -196,7 +200,7 @@ def copyUpdatedFiles(tag, updates, cwd): outdir = os.path.join(updates, relpath) if not os.path.isdir(outdir): os.makedirs(outdir) - shutil.copy2(file, outdir) + shutil.copy2(fname, outdir)
# Updates get overlaid onto the runtime filesystem. Anaconda expects them # to be in /run/install/updates, so put them in @@ -213,74 +217,74 @@ def copyUpdatedFiles(tag, updates, cwd): continue
status = fields[0] - file = fields[1] + gitfile = fields[1]
if status == "D": - if file.startswith('pyanaconda/'): + if gitfile.startswith('pyanaconda/'): # deleted python module, write out a stub raising ImportError - file_path = os.path.join(tmpupdates, file) + file_path = os.path.join(tmpupdates, gitfile) with open(file_path, "w") as fobj: fobj.write('raise ImportError("This module no longer exists!")')
continue
- if file.endswith('.spec.in') or (file.find('Makefile') != -1) or \ - file.endswith('.c') or file.endswith('.h') or \ - file.endswith('.sh') or file == 'configure.ac': + if gitfile.endswith('.spec.in') or (gitfile.find('Makefile') != -1) or \ + gitfile.endswith('.c') or gitfile.endswith('.h') or \ + gitfile.endswith('.sh') or gitfile == 'configure.ac': continue
- if file.endswith('.glade'): + if gitfile.endswith('.glade'): # Some UI files should go under ui/<dir> where dir is the # directory above the file.glade - dir_parts = os.path.dirname(file).split(os.path.sep) + dir_parts = os.path.dirname(gitfile).split(os.path.sep) g_idx = dir_parts.index("gui") uidir = os.path.sep.join(dir_parts[g_idx+1:]) path_comps = [tmpupdates, "ui"] if uidir: path_comps.append(uidir) - install_to_dir(file, os.path.join(*path_comps)) - elif file.startswith('pyanaconda/'): + install_to_dir(gitfile, os.path.join(*path_comps)) + elif gitfile.startswith('pyanaconda/'): # pyanaconda stuff goes into /tmp/updates/[path] - dirname = os.path.join(tmpupdates, os.path.dirname(file)) - install_to_dir(file, dirname) - elif file == 'anaconda': + dirname = os.path.join(tmpupdates, os.path.dirname(gitfile)) + install_to_dir(gitfile, dirname) + elif gitfile == 'anaconda': # anaconda itself we just overwrite - install_to_dir(file, "usr/sbin") - elif file.endswith('.service') or file.endswith(".target"): + install_to_dir(gitfile, "usr/sbin") + elif gitfile.endswith('.service') or gitfile.endswith(".target"): # same for systemd services - install_to_dir(file, "lib/systemd/system") - elif file.endswith('/anaconda-generator'): + install_to_dir(gitfile, "lib/systemd/system") + elif gitfile.endswith('/anaconda-generator'): # yeah, this should probably be more clever.. - install_to_dir(file, "lib/systemd/system-generators") - elif file == "data/tmux.conf": - install_to_dir(file, "usr/share/anaconda") - elif file == "data/anaconda-gtk.css": - install_to_dir(file, "usr/share/anaconda") - elif file == "data/interactive-defaults.ks": - install_to_dir(file, "usr/share/anaconda") - elif file == "data/liveinst/liveinst": - install_to_dir(file, "usr/sbin") - elif file.startswith("data/pixmaps"): - install_to_dir(file, "usr/share/anaconda/pixmaps") - elif file.startswith("data/ui/"): - install_to_dir(file, "usr/share/anaconda/ui") - elif file.startswith("data/post-scripts/"): - install_to_dir(file, "usr/share/anaconda/post-scripts") - elif file.endswith("anaconda-yum"): - install_to_dir(file, "usr/libexec/anaconda") - elif file.find('/') != -1: - fields = file.split('/') + install_to_dir(gitfile, "lib/systemd/system-generators") + elif gitfile == "data/tmux.conf": + install_to_dir(gitfile, "usr/share/anaconda") + elif gitfile == "data/anaconda-gtk.css": + install_to_dir(gitfile, "usr/share/anaconda") + elif gitfile == "data/interactive-defaults.ks": + install_to_dir(gitfile, "usr/share/anaconda") + elif gitfile == "data/liveinst/liveinst": + install_to_dir(gitfile, "usr/sbin") + elif gitfile.startswith("data/pixmaps"): + install_to_dir(gitfile, "usr/share/anaconda/pixmaps") + elif gitfile.startswith("data/ui/"): + install_to_dir(gitfile, "usr/share/anaconda/ui") + elif gitfile.startswith("data/post-scripts/"): + install_to_dir(gitfile, "usr/share/anaconda/post-scripts") + elif gitfile.endswith("anaconda-yum"): + install_to_dir(gitfile, "usr/libexec/anaconda") + elif gitfile.find('/') != -1: + fields = gitfile.split('/') subdir = fields[0] if subdir in ['po', 'scripts','command-stubs', 'tests', 'docs', 'fonts', 'utils', 'liveinst', 'dracut', 'data']: continue else: - sys.stdout.write("Including %s\n" % (file,)) - install_to_dir(file, tmpupdates) + sys.stdout.write("Including %s\n" % (gitfile,)) + install_to_dir(gitfile, tmpupdates) else: - sys.stdout.write("Including %s\n" % (file,)) - install_to_dir(file, tmpupdates) + sys.stdout.write("Including %s\n" % (gitfile,)) + install_to_dir(gitfile, tmpupdates)
def _compilableChanged(tag, compilable): lines = doGitDiff(tag, [compilable]) @@ -292,13 +296,13 @@ def _compilableChanged(tag, compilable): continue
status = fields[0] - file = fields[1] + gitfile = fields[1]
if status == "D": continue
- if file.startswith('Makefile') or file.endswith('.h') or \ - file.endswith('.c') or file.endswith('.py'): + if gitfile.startswith('Makefile') or gitfile.endswith('.h') or \ + gitfile.endswith('.c') or gitfile.endswith('.py'): return True
return False @@ -407,7 +411,7 @@ def check_for_new_packages(tag, arch, added_rpms, specfile_path): diff = doGitContentDiff(tag, ["anaconda.spec.in"]) new_requires = filter(lambda x: x.startswith("+Requires:"), diff) new_defines = filter(lambda x: x.startswith("+%define"), diff) - with open(specfile_path, "rc") as f: + with open(specfile_path) as f: spec_content = f.readlines() all_defines = filter(lambda x: x.startswith("%define"), spec_content) all_requires = filter(lambda x: x.startswith("Requires:"), spec_content) diff --git a/utils/handle-sshpw b/utils/handle-sshpw index f4fbfc7..8965572 100755 --- a/utils/handle-sshpw +++ b/utils/handle-sshpw @@ -24,7 +24,7 @@ # import os import sys -from pykickstart.parser import * +from pykickstart.parser import KickstartParser from pykickstart.version import makeVersion import pyanaconda.users as users
On Wed, 2013-09-25 at 14:21 -0400, David Shea wrote:
Just because it's not in pyanaconda doesn't mean we shouldn't hold it to the same standards.
This also changes the pre-commit hook to run against the code staged to commit instead of the code on the filesystem, which may be helpful.
Other than those two questions these look good to me.
anaconda-patches@lists.fedorahosted.org