[svn] r4797 - trunk/tools/yam

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Sun Oct 8 20:21:27 CEST 2006


Author: dag
Date: 2006-10-08 20:21:25 +0200 (Sun, 08 Oct 2006)
New Revision: 4797

Modified:
   trunk/tools/yam/rhnget
Log:
Small changes

Modified: trunk/tools/yam/rhnget
===================================================================
--- trunk/tools/yam/rhnget	2006-10-07 14:05:53 UTC (rev 4796)
+++ trunk/tools/yam/rhnget	2006-10-08 18:21:25 UTC (rev 4797)
@@ -15,7 +15,21 @@
 ### Copyright 2004-2006 Dag Wieers <dag at wieers.com>
 
 import os, sys, shutil, getopt, ConfigParser, urlparse, types
+import signal, xmlrpclib
 
+if os.path.exists('/usr/share/rhn/') and os.path.exists('/usr/share/rhn/up2date_client/'):
+	sys.path.insert(0, '/usr/share/rhn/')
+	sys.path.insert(1, '/usr/share/rhn/up2date_client/')
+else:
+	die(1,'up2date is not installed. Aborting execution')
+
+from up2date_client import config, rpcServer, wrapperUtils, up2dateErrors, repoDirector
+from rhn import rpclib
+
+cfg = {}
+loginInfo = {}
+rd = None
+
 __version__ = "$Revision: 4786 $"
 # $Source$
 
@@ -32,13 +46,14 @@
 		self.quiet = False
 		self.rhngetcleanup = False
 		self.rhngetdownloadall = False
+		self.rhngetsource = False
 		self.rhnrelease = None
 		self.systemid = '/etc/sysconfig/rhn/systemid'
 		self.verbose = 1
 
 		try:
 			opts, args = getopt.getopt (args, 'hnqr:s:v',
-				('delete', 'download-all', 'dryrun', 'help', 'quiet', 'release=', 'systemid=', 'verbose', 'version' ))
+				('delete', 'download-all', 'dryrun', 'help', 'quiet', 'release=', 'source', 'systemid=', 'verbose', 'version' ))
 		except getopt.error, exc:
 			print 'rhnget: %s, try rhnget -h for a list of all the options' % str(exc)
 			sys.exit(1)
@@ -59,6 +74,8 @@
 				self.quiet = True
 			elif opt in ('-r', '--release'):
 				self.rhnrelease = arg
+			elif opt in ('--source', ):
+				self.rhngetsource = True
 			elif opt in ('-s', '--systemid'):
 				self.systemid = os.path.abspath(arg)
 			elif opt in ('-v', '--verbose'):
@@ -70,6 +87,12 @@
 				print 'rhnget: the use of -x or --extras is deprecated, use -u and -r instead'
 				self.update = True
 
+		if len(args) < 2:
+			self.usage()
+			print
+			self.help()
+			sys.exit(1)
+
 		self.uri = args[0]
 		self.destination = args[1]
 
@@ -92,7 +115,7 @@
 		print 'usage: rhnget [options] rhns://server/channel destination-path'
 
 	def help(self):
-		print '''Set up a distribution server from ISO files
+		print '''Download packages from Red Hat Network (RHN)
 
 rhnget options:
       --delete            delete files that are not on the sender side
@@ -157,26 +180,6 @@
 	if not os.path.exists(path):
 		os.makedirs(path)
 
-def rhnreset():
-	"Clean up2date's global variables"
-	global cfg, loginInfo, rd, config, repoDirector, rpcServer
-#   global cfg, loginInfo, rd, server_list, channel_blacklist, selected_channels, lastPercent
-       
-	cfg = {}
-	loginInfo = {}
-	rd = None
-#   server_list = None
-#   channel_blacklist = None
-#   selected_channels = None
-#   lastPercent = None
-#   pkgSack = None
-    
-	### Does this help ?
-#	reload(config)
-#	reload(repoDirector)
-#	reload(rpcServer)
-
-
 def rhnlogin(url, path, force=False):
 	'Log on to RHN and return cfg, loginInfo and systemid'
 	global cfg, loginInfo, rd, config, rpcServer
@@ -194,11 +197,6 @@
 
 	systemid = open(systemidpath).read()
 
-	from up2date_client import config, rpcServer
-	from rhn import rpclib
-
-	rhnreset()
-
 	cfg['systemIdPath'] = systemidpath
 	cfg = config.initUp2dateConfig()
 	cfg['systemIdPath'] = systemidpath
@@ -269,16 +267,9 @@
 	'Mirror a channel from RHN'
 	global cfg, loginInfo, rd, repoDirector, rpcServer
 
-	sys.path.insert(0, '/usr/share/rhn/')
-	sys.path.insert(1, '/usr/share/rhn/up2date_client/')
-
 	t, t, label, t, t, t = urlparse.urlparse(url)
 	label = label.strip('/')
 
-	from up2date_client import rpcServer, wrapperUtils, up2dateErrors, repoDirector
-	from rhn import rpclib
-	import signal, xmlrpclib
-
 	### Log on to RHN
 	systemid = rhnlogin(url, path)
 	if not systemid:



More information about the svn-commits mailing list