diff options
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | firstaidkit.spec | 37 | ||||
-rw-r--r-- | plugins/mdadm_conf.py | 1 | ||||
-rw-r--r-- | plugins/passwd.py | 1 | ||||
-rw-r--r-- | plugins/xserver.py | 11 | ||||
-rw-r--r-- | pyfirstaidkit/__init__.py | 13 | ||||
-rw-r--r-- | pyfirstaidkit/configuration.py | 2 | ||||
-rw-r--r-- | pyfirstaidkit/interpret.py | 10 | ||||
-rw-r--r-- | pyfirstaidkit/plugins.py | 38 | ||||
-rw-r--r-- | pyfirstaidkit/utils/backup.py | 7 |
10 files changed, 73 insertions, 58 deletions
@@ -18,11 +18,19 @@ NAME := "firstaidkit" VERSION := $(shell awk '/Version:/ { print $$2 }' firstaidkit.spec) RELEASE := $(shell awk '/Release:/ { print $$2 }' firstaidkit.spec) +DATADIR := $(shell rpm --eval "%_datadir") PLUGIN_PATH = plugins # all the plugins that have a make build to run PLUGIN_DIRS = undelparts +build: subdirs about + +about: + @echo "[about]" >> etc/firstaidkit/about; \ + echo "version=$(VERSION)" >> etc/firstaidkit/about; \ + echo "copying=$(DATADIR)/doc/$(NAME)-$(VERSION)/COPYING" >> etc/firstaidkit/about + tarball: git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD | bzip2 -f > $(NAME)-$(VERSION).tar.bz2 @@ -34,7 +42,7 @@ subdirs: for d in $(PLUGIN_DIRS); do make -C $(PLUGIN_PATH)/$$d build; [ $$? == 0 ] || exit 1; done bumpver: - @MAYORVER=$$(echo $(VERSION) | cut -d . -f 0-2); \ + @MAYORVER=$$(echo $(VERSION) | cut -d . -f 1-2); \ NEWSUBVER=$$((`echo $(VERSION) | cut -d . -f 3`+1)); \ sed -i "s/Version: $(VERSION)/Version: $$MAYORVER.$$NEWSUBVER/" firstaidkit.spec; \ sed -i "s/Release: .*%/Release: 1%/" firstaidkit.spec; \ @@ -43,5 +51,4 @@ bumpver: newver: make bumpver - git commit -a -m "new minor version" make rpm-all diff --git a/firstaidkit.spec b/firstaidkit.spec index c701d8e..8ffe293 100644 --- a/firstaidkit.spec +++ b/firstaidkit.spec @@ -14,15 +14,10 @@ Source0: %{name}-%{version}.tar.bz2 Source3: %{name}.desktop BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: desktop-file-utils BuildRequires: python-devel -# Take this away in the future. when f7 is gone. -%if 0%{?fedora} >= 8 -BuildRequires: python-setuptools-devel -%else -BuildRequires: python-setuptools -%endif +BuildRequires: python-setuptools-devel BuildArch: noarch -BuildRequires: desktop-file-utils %description A tool that automates simple and common system recovery tasks. @@ -81,7 +76,6 @@ password. Group: Applications/System Summary: FirstAidKit plugin to recover xserver configuration files Requires: %{name} = %{version}-%{release} -Requires: rhpl, rhpxl %description plugin-xserver This FirstAidKit plugin automates the recovery of the xserver @@ -91,7 +85,6 @@ configuration file xorg.conf. Group: Applications/System Summary: FirstAidKit plugin to diagnose or repair the GRUB instalation Requires: %{name} = %{version}-%{release} - Requires: dbus-python Requires: grub Requires: pyparted @@ -99,12 +92,6 @@ Requires: pyparted %description plugin-grub This FirstAidKit plugin automates the recovery from the GRUB bootloader problems. -%package plugin-rpm -Group: Applications/System -Summary: FirstAidKit plugin to diagnose or repair the RPM packaging system -Requires: %{name} = %{version}-%{release} -Requires: rpm, rpm-python - %package plugin-mdadm-conf Group: Applications/System Summary: Firstaidkit plugin to diagnose software raid configuration file @@ -115,6 +102,12 @@ Requires: mdadm This plugin will assess the validity and existence of the mdadm.conf file. The file will get replaced if any inconsistencies are found. +%package plugin-rpm +Group: Applications/System +Summary: FirstAidKit plugin to diagnose or repair the RPM packaging system +Requires: %{name} = %{version}-%{release} +Requires: rpm, rpm-python + %description plugin-rpm This FirstAidKit plugin automates the tasks related to RPM problems. For example: corrupted database or important system packages missing. @@ -128,19 +121,16 @@ Requires: pygtk2, pygtk2-libglade %description gui This package contains the Gtk based FirstAidKit GUI + %prep %setup -q -#execute the testsuite -./test +#./test -#generate the about file with version and license path -echo "[about]" >> etc/firstaidkit/about -echo "version=%{version}" >> etc/firstaidkit/about -echo "copying=%{_docdir}/%{name}-%{version}/COPYING" >> etc/firstaidkit/about %build %{__python} setup.py build -%{__make} subdirs +%{__make} build + %install %{__rm} -rf $RPM_BUILD_ROOT @@ -148,7 +138,9 @@ echo "copying=%{_docdir}/%{name}-%{version}/COPYING" >> etc/firstaidkit/about #docs %{__install} -d $RPM_BUILD_ROOT%{_mandir}/man1 +%{__install} -d $RPM_BUILD_ROOT%{_datadir}/doc/%name-%version %{__install} -p doc/firstaidkit-plugin.1 doc/firstaidkit.1 $RPM_BUILD_ROOT%{_mandir}/man1 +%{__install} -p COPYING $RPM_BUILD_ROOT%{_datadir}/doc/%name-%version/COPYING #examples %{__install} -d $RPM_BUILD_ROOT%{_libdir}/firstaidkit/plugins/examples @@ -193,6 +185,7 @@ desktop-file-install --vendor="fedora" --dir=${RPM_BUILD_ROOT}%{_datadir}/applic %config(noreplace) %{_sysconfdir}/firstaidkit/firstaidkit.conf %{_sysconfdir}/firstaidkit/about %attr(0644,root,root) %{_mandir}/man1/firstaidkit.1.gz +%attr(0644,root,root) %{_datadir}/doc/%name-%version/COPYING %files gui %{_libdir}/firstaidkit/frontend/*.py* diff --git a/plugins/mdadm_conf.py b/plugins/mdadm_conf.py index 55bb6be..9ba19f2 100644 --- a/plugins/mdadm_conf.py +++ b/plugins/mdadm_conf.py @@ -31,6 +31,7 @@ class MdadmConfig(Plugin): name = "mdadm configuration" version = "0.0.1" author = "Joel Andres Granados" + description = "Assess the validity and existence of the mdadm.conf file" @classmethod def getDeps(cls): diff --git a/plugins/passwd.py b/plugins/passwd.py index 508ec0b..9500f04 100644 --- a/plugins/passwd.py +++ b/plugins/passwd.py @@ -42,6 +42,7 @@ class PasswdPlugin(Plugin): name = "Password plugin" version = "0.0.1" author = "Martin Sivak" + description = "Automates the recovery of the root system passwd" @classmethod def getDeps(cls): diff --git a/plugins/xserver.py b/plugins/xserver.py index 71c7d2c..86bb569 100644 --- a/plugins/xserver.py +++ b/plugins/xserver.py @@ -23,15 +23,7 @@ from pyfirstaidkit.issue import SimpleIssue from pyfirstaidkit import Config from pyfirstaidkit.errors import * -import rhpxl.xserver -import rhpl.keyboard -import tempfile -import subprocess -import time -import signal -import os -import os.path -import shutil +import tempfile, subprocess, time, signal, os, os.path, shutil class Xserver(Plugin): """ Plugin to detect an rescue faulty xserver configurations. """ @@ -48,6 +40,7 @@ class Xserver(Plugin): name = "X server" version = "0.0.1" author = "Joel Andres Granados" + description = "Automates recovery of the xserver" @classmethod def getDeps(cls): diff --git a/pyfirstaidkit/__init__.py b/pyfirstaidkit/__init__.py index 2468ddb..874f57c 100644 --- a/pyfirstaidkit/__init__.py +++ b/pyfirstaidkit/__init__.py @@ -24,11 +24,18 @@ def initLogger(config=None): """We want to initialize loger when we have the filename.""" Logger = logging.getLogger("firstaidkit") Logger.setLevel(logging.DEBUG) + if config.log.method == "none": - Logger.addHandler(logging.FileHandler("/dev/null")) + handler = logging.FileHandler("/dev/null") + elif config.log.method == "stdout" or config.log.method == None: - Logger.addHandler(logging.StreamHandler(sys.stdout)) + handler = logging.StreamHandler(sys.stdout) + else: # if nothing else matches we just put it into the file. - Logger.addHandler(logging.FileHandler(config.log.filename)) + handler = logging.FileHandler(config.log.filename) + + formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") + handler.setFormatter(formatter) + Logger.addHandler(handler) diff --git a/pyfirstaidkit/configuration.py b/pyfirstaidkit/configuration.py index 01f4ac7..cb8c5ea 100644 --- a/pyfirstaidkit/configuration.py +++ b/pyfirstaidkit/configuration.py @@ -44,7 +44,7 @@ def createDefaultConfig(config): config.log.fallbacks = "firstaidkit.log,/tmp/firstaidkit.log,/dev/null" config.plugin.disabled = "" config.backup.method = "file" - config.backup.rootpath = "/tmp/fakbackup" + config.backup.rootpath = "/tmp" config.backup.fullpath = "" config.revert.all = "False" config.revert.dir = "" diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py index 54342eb..a55ab0e 100644 --- a/pyfirstaidkit/interpret.py +++ b/pyfirstaidkit/interpret.py @@ -26,8 +26,6 @@ from utils import FileBackupStore from dependency import Dependencies from configuration import Info -Logger=logging.getLogger("firstaidkit") - class Tasker: """The main interpret of tasks described in Config object""" @@ -180,8 +178,9 @@ class Tasker: try: p = pluginSystem.getplugin(self._config.operation.params) except KeyError: - Logger.error("No such plugin '%s'" % - (self._config.operation.params,)) + self._reporting.info(message = "No such plugin '%s'" % \ + (self._config.operation.params,), level = TASKER, \ + origin = self) return False flowinfo = [ (f, p.getFlow(f).description) for f in p.getFlows() ] rep = {"id": self._config.operation.params, "name": p.name, @@ -194,7 +193,8 @@ class Tasker: # Any other case else: - Logger.error("Incorrect task specified") + self._reporting.info(message = "Incorrect task specified", \ + level = TASKER, origin = self) self._reporting.stop(level = TASKER, origin = self) return False diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py index 3c6d27d..ae73ae6 100644 --- a/pyfirstaidkit/plugins.py +++ b/pyfirstaidkit/plugins.py @@ -561,17 +561,21 @@ class PluginSystem(object): raise InvalidPluginNameException(plugin) plugindir = os.path.dirname(self._plugins[plugin].__file__) - Logger.info("Plugin information...") - Logger.info("name:%s , version:%s , author:%s " % pklass.info()) + self._reporting.info(message = "Plugin information...", \ + level = PLUGINSYSTEM, origin = self) + self._reporting.info(message = "name:%s , version:%s , author:%s " \ + % pklass.info(), level = PLUGINSYSTEM, origin = self) flows = pklass.getFlows() - Logger.info("Provided flows : %s " % flows) + self._reporting.info(message = "Provided flows : %s " % flows, \ + level = PLUGINSYSTEM, origin = self) if flow==None: flowName = pklass.default_flow else: flowName = flow - Logger.info("Using %s flow" % flowName) + self._reporting.info(message = "Using %s flow" % flowName, \ + level = PLUGINSYSTEM, origin = self) if flowName not in flows: self._reporting.exception(message = "Flow %s does not exist in " "plugin %s" % (flowName, plugin), level = PLUGINSYSTEM, @@ -582,22 +586,26 @@ class PluginSystem(object): if dependencies: deps = pklass.getDeps() if len(deps)>0: - Logger.info("depends on: %s" % (", ".join(deps),)) + self._reporting.info(message = "depends on: %s" % \ + (", ".join(deps),), level = PLUGINSYSTEM, \ + origin = self) for d in deps: if not self._deps.require(d): - Logger.info("depends on unsatisfied condition: %s" % - (d,)) + self._reporting.info(message = "depends on " \ + "unsatisfied condition: %s" % (d,), \ + level = PLUGINSYSTEM, origin = self) self._reporting.stop(level = PLUGIN, origin = self, message = plugin) return False deps = pklass.getConflicts() if len(deps)>0: - Logger.info("depends on flags to be unset: %s" % - (", ".join(deps),)) + self._reporting.info(message = "depends on flags to be unset: %s" % \ + (", ".join(deps),), level = PLUGINSYSTEM, origin = self) for d in deps: if self._deps.require(d): - Logger.info("depends on condition to be UNset: %s" % - (d,)) + self._reporting.info(message = "depends on condition to be " \ + "UNset: %s" % (d,), level = PLUGINSYSTEM, \ + origin = self) self._reporting.stop(level = PLUGIN, origin = self, message = plugin) return False @@ -620,9 +628,11 @@ class PluginSystem(object): dependencies = self._deps, backups = self._backups, path = plugindir, info = infosection, args = " ".join(args)) for (step, rv) in p: #autorun all the needed steps - Logger.info("Running step %s in plugin %s ...", step, plugin) - Logger.info("%s is current step and %s is result of that step." % - (step, rv)) + self._reporting.info(message = "Running step %s in plugin %s ..."% \ + (step, plugin), level = PLUGINSYSTEM, origin = self) + self._reporting.info(message = "%s is current step and %s is result " \ + "of that step." % (step, rv), level = PLUGINSYSTEM, \ + origin = self) self._reporting.stop(level = PLUGIN, origin = self, message = plugin) return True diff --git a/pyfirstaidkit/utils/backup.py b/pyfirstaidkit/utils/backup.py index 2a11283..7c4537f 100644 --- a/pyfirstaidkit/utils/backup.py +++ b/pyfirstaidkit/utils/backup.py @@ -78,12 +78,14 @@ class FileBackupStore(BackupStoreInterface): self._metafile = "__meta.pickle" self._data = {} # name -> (stored as, origin) self._origin = {} # origin -> name + # Because the dir is suppose to be there when we are reverting. if not reverting: os.makedirs(self._path) def saveMeta(self): f = open(os.path.join(self._path, self._metafile), "wb") - pickle.dump((self._id, self._data, self._origin), f, pickle.HIGHEST_PROTOCOL) + pickle.dump((self._id, self._data, self._origin), f, \ + pickle.HIGHEST_PROTOCOL) f.close() return True @@ -96,7 +98,8 @@ class FileBackupStore(BackupStoreInterface): self._data = data self._origin = origin else: - raise BackupException("Loading metadata for different Backup (ID mismatch: '%s' and '%s')" % (self._id, id)) + raise BackupException("Loading metadata for different Backup " \ + "(ID mismatch: '%s' and '%s')" % (self._id, id)) return True |