FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Packaging

 
 
LinkBack Thread Tools
 
Old 05-23-2012, 02:28 PM
Martin Sivak
 
Default Improve the runspoke.py tool and make it callable from make

make runspoke SPOKE_MODULE=source

or

make runspoke SPOKE_MODULE=source SPOKE_CLASS=InstallSource

- runspoke now accepts the name of the module containing
the spoke the user wants to run on command line and
will find the spoke automatically

- as an optional second argument, the script accepts the
name of the spoke class

- install classes and gi introspection files are looked for
in anaconda sources first, so there is no need to install
the anaconda-widgets package to the system

- there was a circular dependency between yuminstall,
backend and kickstart modules, which caused import yuminstall
to fail, because:

yuminstall called backend, which called kickstart, which
requested NoSuchGroup from yuminstall. NoSuchGroup was
present in the source, but much later, so it hadn't been
evaluated yet and the import failed with missing symbol error.
---
Makefile.am | 4 +++
pyanaconda/installclass.py | 8 +++++-
pyanaconda/ui/gui/tools/run-spoke.py | 45 +++++++++++++++++++++++++++++-----
pyanaconda/yuminstall.py | 11 ++++-----
4 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1798740..41f7d27 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,3 +102,7 @@ unittest:

unittests-logpicker:
PYTHONPATH=tests/:.:utils/ nosetests tests/logpicker_test
+
+# GUI TESTING
+runspoke:
+ ANACONDA_INSTALL_CLASSES=${PWD}/pyanaconda/installclasses PYTHONPATH=.yanaconda/isys/.libs:widgets/python/:widgets/src/.libs/ LD_LIBRARY_PATH=widgets/src/.libs UIPATH=pyanaconda/ui/gui/ GI_TYPELIB_PATH=widgets/src/ pyanaconda/ui/gui/tools/run-spoke.py ${SPOKE_MODULE} ${SPOKE}
diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py
index 7e8aca1..15dbe20 100644
--- a/pyanaconda/installclass.py
+++ b/pyanaconda/installclass.py
@@ -245,7 +245,11 @@ def availableClasses(showHidden=0):

path = []

- for dir in ["installclasses",
+ env_path = []
+ if "ANACONDA_INSTALL_CLASSES" in os.environ:
+ env_path += os.environ["ANACONDA_INSTALL_CLASSES"].split(":")
+
+ for dir in env_path + ["installclasses",
"/tmp/updates/pyanaconda/installclasses",
"/tmp/product/pyanaconda/installclasses",
"%s/pyanaconda/installclasses" % get_python_lib(plat_specific=1) ]:
@@ -297,6 +301,7 @@ def availableClasses(showHidden=0):
list.append(((obj.name, obj, obj.pixmap), sortOrder))
except ImportError as e:
log.warning ("module import of %s failed: %s" % (mainName, sys.exc_type))
+ raise
if flags.debug: raise
else: continue

@@ -316,6 +321,7 @@ def getBaseInstallClass():
# figure out what installclass we should base on.
allavail = availableClasses(showHidden = 1)
avail = availableClasses(showHidden = 0)
+
if len(avail) == 1:
(cname, cobject, clogo) = avail[0]
log.info("using only installclass %s" %(cname,))
diff --git a/pyanaconda/ui/gui/tools/run-spoke.py b/pyanaconda/ui/gui/tools/run-spoke.py
index aef62db..45a6e8c 100755
--- a/pyanaconda/ui/gui/tools/run-spoke.py
+++ b/pyanaconda/ui/gui/tools/run-spoke.py
@@ -3,6 +3,11 @@
from gi.repository import AnacondaWidgets, Gtk
import ctypes, sys

+# Check command line arguments
+if len(sys.argv)<2:
+ print "Usage: $0 <spoke module name> [<spoke widget class>]"
+ sys.exit(1)
+
# This is a hack to make sure the AnacondaWidgets library gets loaded
ctypes.CDLL("libAnacondaWidgets.so.0", ctypes.RTLD_GLOBAL)

@@ -24,14 +29,42 @@ flags.testing = True

initThreading()

-# NOTE: To run your spoke, you need to do the proper import here (may need to
-# set $PYTHONPATH as well) and set spokeClass to be the class from that import.
-# I suppose this could be done automatically somehow, but that's hard and this
-# is a development testing tool.
-#from pyanaconda.ui.gui.spokes.software import SoftwareSelectionSpoke
-#spokeClass = SoftwareSelectionSpoke
+# Figure out the name of spoke module entered on command line
+spokeModuleName = "pyanaconda.ui.gui.spokes.%s" % sys.argv[1]
+
+# Set default spoke class
spokeClass = None

+# Load spoke specified on the command line
+# If the spoke module was specified, but the spoke class was not,
+# try to find it using class hierarchy
+try:
+ spokeClassName = sys.argv[2]
+ __import__(spokeModuleName, names = [spokeClassName])
+ spokeModule = sys.modules[spokeModuleName]
+except IndexError:
+ __import__(spokeModuleName)
+ spokeModule = sys.modules[spokeModuleName]
+ from pyanaconda.ui.gui.spokes import NormalSpoke
+ for k,v in vars(spokeModule).iteritems():
+ try:
+ if issubclass(v, NormalSpoke):
+ spokeClassName = k
+ spokeClass = v
+ break
+ except TypeError:
+ pass
+
+if not spokeClass:
+ try:
+ spokeClass = getattr(spokeModule, spokeClassName)
+ except KeyError:
+ print "Spoke %s could not be found in %s" % (spokeClassName, spokeModuleName)
+ sys.exit(1)
+
+
+print "Running spoke %s from %s" % (spokeClass, spokeModule)
+
platform = getPlatform()
ksdata = makeVersion()
storage = Storage(data=ksdata, platform=platform)
diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py
index d895e27..d8761ea 100644
--- a/pyanaconda/yuminstall.py
+++ b/pyanaconda/yuminstall.py
@@ -17,8 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

-from flags import flags
-
import ConfigParser
import sys
import os
@@ -32,6 +30,10 @@ import tempfile
import itertools
import re

+class NoSuchGroup(Exception):
+ pass
+
+from flags import flags

import anaconda_log
import rpm
@@ -45,12 +47,12 @@ from yum.constants import *
from yum.Errors import *
from yum.misc import to_unicode
from yum.yumRepo import YumRepository
-from backend import AnacondaBackend
from product import isFinal, productName, productVersion, productStamp
from constants import *
from image import *
from compssort import *
import packages
+from backend import AnacondaBackend

import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -72,9 +74,6 @@ urlgrabber.grabber.default_grabber.opts.user_agent = "%s (anaconda)/%s" %(produc
import iutil
import isys

-class NoSuchGroup(Exception):
- pass
-
def size_string (size):
def number_format(s):
return locale.format("%s", s, 1)
--
1.7.10.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:03 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org