Hi,
I've recentely started with spacewalk and I'm slowly rolling...
I've registered some clients the 'hard way' just to get acquainted with
the system.
Trying the 'bootstrap.sh' script I stumbled over:
    "ImportError: No module named spacewalk.common.fileutils"

This list (and other sources) told me I was missing some stuff which I
installed:
     "yum install rhn-setup yum-rhnplugin python-dmidecode \
          spacewalk-backend-libs python-crypto"
However, the third time I decided to have a look at
'client_config_update.py'...

Suprised I observed the line:
    "from spacewalk.common.fileutils import cleanupAbsPath, make_temp_file"

So, all this trouble for 'just' two functions???

I copied them from 'spacewalk.common.fileutils' (three actually, see att.)
and the script performs nicely....

also on Centos 4...
osad won't start because of a missing 'python-hashlib' (not for Centos 4,
python-2.4). So I installed it from source
(http://code.krypto.org/python/hashlib/).

I never see an OSA status, however....

Ideas??? Anyone...

--
               Andre van der Vlies <[email protected]>
               Certifiable Linux/UNIX engineer (CLUE)
               Sip: (+31)878751928
               Homepage: http://vandervlies.xs4all.nl/~andre
               Books: http://www.lulu.com/andre14
Key fingerprint = 397C 7479 67DB 9306 23DC B423 7B58 CD5A 6EFF 5CF8
--
    "Programming isn't a craft, it's an art."
    ()  ascii ribbon campaign - against html e-mail
    /\                        - against microsoft attachments
                              ^[^#]
--
*** ORIG-client_config_update.py	2010-04-09 11:42:13.000000000 +0200
--- client_config_update.py	2010-04-09 11:46:03.000000000 +0200
***************
*** 66,78 ****
  import sys
  import time
  import string
! from spacewalk.common.fileutils import cleanupAbsPath, make_temp_file
  
  DEFAULT_CLIENT_CONFIG_OVERRIDES = 'client-config-overrides.txt'
  
  RHN_REGISTER = "/etc/sysconfig/rhn/rhn_register"
  UP2DATE = "/etc/sysconfig/rhn/up2date"
  
  def _parseConfigLine(line):
      """parse a line from a config file. Format can be either "key=value\n"
         or "whatever text\n"
--- 66,130 ----
  import sys
  import time
  import string
! #from spacewalk.common.fileutils import cleanupAbsPath, make_temp_file
  
  DEFAULT_CLIENT_CONFIG_OVERRIDES = 'client-config-overrides.txt'
  
  RHN_REGISTER = "/etc/sysconfig/rhn/rhn_register"
  UP2DATE = "/etc/sysconfig/rhn/up2date"
  
+ def cleanupAbsPath(path):
+     """ take ~taw/../some/path/$MOUNT_POINT/blah and make it sensible.
+ 
+ 	Path returned is absolute.
+ 	NOTE: python 2.2 fixes a number of bugs with this and eliminates
+ 		the need for os.path.expanduser
+     """
+ 
+     if path is None:
+ 	return None
+     return os.path.abspath(
+ 		os.path.expanduser(
+ 		os.path.expandvars(path)))
+ 
+ def maketemp(prefix):
+     """ Creates a temporary file (guaranteed to be new), using the
+ 	specified prefix.
+ 	Returns the filename and an open file descriptor (low-level)
+     """
+ 
+     filename = "%s-%s-%.8f" % (prefix, os.getpid(), time.time())
+     tries = 10
+     while tries > 0:
+ 	tries = tries - 1
+ 	try:
+ 	    fd = os.open(filename, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0600)
+ 	except OSError, e:
+ 	    if e.errno != 17:
+ 		raise e
+ 	    # File already exists
+ 	    filename = "%s-%.8f" % (filename, time.time())
+ 	else:
+ 	    break
+     else:
+ 	raise OSError("Could not create temp file")
+ 
+     return filename, fd
+ 
+ def make_temp_file(prefix):
+     """Creates a temporary file stream (returns an open file object)
+ 
+     Returns a read/write stream pointing to a file that goes away once the
+     stream is closed
+     """
+ 
+     filename, fd = maketemp(prefix)
+ 
+     os.unlink(filename)
+     # Since maketemp returns a freshly created file, we can skip the truncation
+     # part (w+); r+ should do just fine
+     return os.fdopen(fd, "r+b")
+ 
  def _parseConfigLine(line):
      """parse a line from a config file. Format can be either "key=value\n"
         or "whatever text\n"
_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to