[prev in list] [next in list] [prev in thread] [next in thread] 

List:       klik-devel
Subject:    [klik-devel] [klikclient commit] r1259 - in
From:       codesite-noreply () google ! com
Date:       2008-02-28 8:07:35
Message-ID: 000e0cd296b40447336a136af4a203c () google ! com
[Download RAW message or body]

Author: razielmine
Date: Thu Feb 28 00:06:38 2008
New Revision: 1259

Modified:
   trunk/client/trunk/klikclient/bin/klik
   trunk/client/trunk/klikclient/lib/klik/base.py
   trunk/client/trunk/klikclient/lib/klik/cmg.py
   trunk/client/trunk/klikclient/lib/klik/gtk/multiple.py

Log:
Pretty but useless way of organizing help, just commiting if it happens 
to be useful later. Probably b0rken.

Modified: trunk/client/trunk/klikclient/bin/klik
==============================================================================
--- trunk/client/trunk/klikclient/bin/klik	(original)
+++ trunk/client/trunk/klikclient/bin/klik	Thu Feb 28 00:06:38 2008
@@ -40,58 +40,74 @@

 help_text = {}

-help_text["_default_"]=(
-"klik foo [args]				- Downloads and executes foo")
-help_text["_cmg_"]=(
-"klik /path/to/foo.cmg [args]			- Short for \"klik run /path/to/foo.cmg\"")
-help_text["get"]=(
-"klik get foo [bar...]				- Download a recipe and create a cmg\n"
-"						  file for the applications foo, bar...")
-help_text["_klik_url_"]=(
-"klik klik2://foo				- Download a recipe and create a cmg\n"+
-"						  file for the application foo")
-help_text["_recipe_"]=(
-"klik /path/to/foo.recipe			- Create a cmg file for the application\n"+
-"						  moo from the given recipe")
-
-help_text["run"]=(
-"klik run [executable] foo.cmg [args]		- Run application foo.cmg, executable\n"+
-"						  is an optional command to start")
-help_text["exec"]=(
-"klik exec foo.cmg executable [args]		- Run application foo.cmg, executable\n"+
-"						  is NOT optional")
-help_text["jail"]=(
-"klik jail [jail_type] foo.cmg [args]		- Create a jail folder for foo.cmg\n"+
-"						  Types:\n"+
-"							data	  - <TODO:description>\n"+
-"							home	  - <TODO:description>\n"+
-"							portable  - <TODO:description>\n")
-help_text["prompt"]=(
-"klik prompt foo.cmg executable			- force a dialogue to select application")
-help_text["shell"]=(
-"klik shell foo.cmg				- Start a shell with cmg union mounted")
-help_text["unpack"]=(
-"klik unpack foo.cmg /foo/			- Unpack an application")
-help_text["extract"]=(
-"klik extract foo.cmg /foo.cfg foo.cfg		- Extract a single file from a cmg")
-help_text["icon"]=(
-"klik icon foo.cmg output [size]		- Extract the icon for the CMG into output\n"+
-"						  If size is specified, resizes the icon")
-help_text["pack"]=(
-"klik pack /foo/ foo.cmg			- Repack an application")
-help_text["merge"]=(
-"klik merge main.cmg add.cmg output.cmg	- <TODO>")
-help_text["register"]=(
-"klik (un)register foo.cmg [bar.cmg...]	- (Un)register given CMGs with 
the desktop\n"+
-"						  Options:\n"+
-"							-f	  - Force registration")
-help_text["sync"]=(
-"klik sync dir1 [dir2...]			- Synchronize application directories,\n"+
-"						  looking for non-registered packages\n"+
-"						  and packages registered but no longer\n"+
-"						  existing")
+help_text["_default_"] = (0,
+	"klik foo [args]",
+	"Downloads and executes foo")
+help_text["_cmg_"] = (1,
+	"klik /path/to/foo.cmg [args]",
+	 "Short for \"klik run /path/to/foo.cmg\"")
+help_text["get"] = (2,
+	"klik get foo [bar...]",
+	"Download a recipe and create a cmg file for the applications foo, bar...")
+help_text["_klik_url_"] = (3,
+	"klik klik2://foo",
+	"Download a recipe and create a cmg file for the application foo")
+help_text["_recipe_"] = (4,
+	"klik /path/to/foo.recipe",
+	"Create a cmg file for the application foo from the given recipe")
+
+help_text["run"] = (5,
+	"klik run [executable] foo.cmg [args]",
+	"Run application foo.cmg, executable is an optional command to start")
+help_text["exec"] = (6,
+	"klik exec foo.cmg executable [args]",
+	"Run application foo.cmg, executable is NOT optional")
+help_text["jail"] = (7,
+	"klik jail [jail_type] foo.cmg [args]",
+	"Create a jail folder for foo.cmg",
+	["Types",
+	 ("data", "<TODO:description>"),
+	 ("home", "<TODO:description>"),
+	 ("portable", "<TODO:description>")])
+help_text["prompt"] = (8,
+	"klik prompt foo.cmg executable",
+	"force a dialogue to select application")
+help_text["shell"] = (9,
+	"klik shell foo.cmg",
+	"Start a shell with cmg union mounted")
+help_text["unpack"] = (10,
+	"klik unpack foo.cmg /foo/",
+	"Unpack an application")
+help_text["extract"] = (11,
+	"klik extract foo.cmg /foo.cfg foo.cfg",
+	"Extract a single file from a cmg")
+help_text["icon"] = (12,
+	"klik icon foo.cmg output [size]",
+	"Extract the icon for the CMG into output If size is specified, 
resizes the icon")
+help_text["pack"] = (13,
+	"klik pack /foo/ foo.cmg",
+	"Repack an application")
+help_text["merge"] = (14,
+	"klik merge main.cmg add.cmg output.cmg",
+	"<TODO>")
+help_text["register"] = (15,
+	"klik register foo.cmg [bar.cmg...]",
+	"Register given CMGs with the desktop",
+	["Options:",
+	 ("-f", "Force registration")])
+help_text["register"] = (16,
+	"klik unregister foo.cmg [bar.cmg...]",
+	"Unregister given CMGs with the desktop",
+	"Options:\n"+
+	"-f	  - Force registration")
+help_text["sync"] = (17,
+	"klik sync dir1 [dir2...]",
+	"Synchronize application directories, looking for non-registered 
packages and packages registered but no longer existing")

 def usage(mode=None):
+	
+	if not help_text.has_key(mode):
+		mode = None

 	if not mode:
 		print "Klik - Web based software installer"
@@ -99,10 +115,10 @@
 	print "Usage:"
 	
 	if mode:
-		print "  " + help_text[mode]
+		print " ", help_text[mode]
 	else:
-		for mode in help_text:
-			print "  " + help_text[mode]
+		for mode in help_text.values():
+			print " ", mode

 		s = KlikSettings()
 	
@@ -120,6 +136,8 @@
 if __name__ == "__main__":
 	
 	first_arg = None
+	result = False
+	
 	try:

 		# Check not root
@@ -136,136 +154,104 @@
 		integration = KlikIntegration(klik)
 		
 		command_options = set()
-
-		if len(sys.argv) > 2:
-
-			first_arg = sys.argv[1].lower()
-			second_arg = sys.argv[2]
-			args = sys.argv[3:]
+		
+		if len(sys.argv) == 1:
+			usage()
+		
+		else:
+			first_arg = sys.argv[1]
+			args = sys.argv[2:]
+			cmg = KlikCmg( klik, args[0] )

 			if first_arg == "unpack":
-			
-				if len(args) == 0:
-					klik.unpack_cmg( second_arg, second_arg[:-4])
-				elif len(args) > 0:
-					klik.unpack_cmg( second_arg, args[0])
+				if len(args) == 1:
+					klik.unpack_cmg( args[0], args[0][:-4] )
 				else:
-					usage()
+					klik.unpack_cmg( args[0], args[1] )

 			elif first_arg == "extract":
-				if len(args) > 1:
-					result = klik.extract_file(second_arg, args[0], args[1])
-					if result:
-						sys.exit(0)
-					else:
-						sys.exit(1)
-				else:
-					usage()
+				result = klik.extract_file(args[0], args[1], args[2])

 			elif first_arg == "icon":
-				cmg = KlikCmg( klik, second_arg )
-				if len(args) > 1:
-					result = cmg.extract_icon(args[0], resize=int(args[1]))
+				if len(args) > 2:
+					result = cmg.extract_icon(args[1], resize=int(args[2]))
 				else:
-					result = cmg.extract_icon(args[0])
+					result = cmg.extract_icon(args[1])
 				if not result:
 					print "Error: Could not extract icon"
-				sys.exit(int(result))

 			elif first_arg == "shell":
-				klik.execute_cmg_shell(second_arg)
+				klik.execute_cmg_shell(args[0])

 			elif first_arg == "pack":
-				if len(args) > 0:
-					klik.pack_cmg(second_arg, args[0])
-				else:
-					usage()
+				klik.pack_cmg(args[0], args[1])

 			elif first_arg == "merge":
-				if len(args) > 0:
-					klik.merge(second_arg, args[0], args[1])
-				else:
-					usage()
+				klik.merge(args[0], args[1], args[2])

 			elif first_arg == "register":
 				#import cProfile
-				#cProfile.run("integration.register(sys.argv[2:])")
+				#cProfile.run("integration.register(args)")
 				if "-f" in sys.argv:
 					sys.argv.remove("-f")
 					command_options.add("f")
-				integration.register(sys.argv[2:], command_options)
+				integration.register(args, command_options)

 			elif first_arg == "unregister":
 				#import cProfile
-				#cProfile.run("integration.unregister(sys.argv[2:])")
-				integration.unregister(sys.argv[2:])
+				#cProfile.run("integration.unregister(args)")
+				integration.unregister(args)

 			elif first_arg == "sync":
 				#import cProfile
-				#cProfile.run("klik.sync(sys.argv[2:])")
-				integration.sync(sys.argv[2:])
+				#cProfile.run("klik.sync(args)")
+				integration.sync(args)

 			elif first_arg == "setup":
 				print "setup"

 			elif first_arg == "run":
-				if os.path.isfile(second_arg):
-					result, text = klik.execute_cmg(None, second_arg, args)
-					sys.exit(result)
-				elif len(args) > 0:
-					third_arg = sys.argv[3]
-					args = sys.argv[4:]
-					result, text = klik.execute_cmg(second_arg, third_arg, args)
-					sys.exit(result)
+				if args[0].lower().endswith(".cmg"):
+					result, text = cmg.execute(None, args)
 				else:
-					usage()
+					cmg = KlikCmg( klik, args[1] )
+					result, text = cmg.execute(args[0], args[1:])

 			elif first_arg == "jail":
-				if len(args) > 1:
-					third_arg = sys.argv[3]
-					klik.create_jailed_cmg(second_arg, third_arg)
-					sys.exit()
-				elif os.path.isfile(second_arg):
-					klik.create_jailed_cmg(second_arg)
-					sys.exit()
+				if len(args) > 2:
+					klik.create_jailed_cmg(args[0], args[1])
+				elif os.path.isfile(args[0]):
+					klik.create_jailed_cmg(args[0])
 				else:
-					usage()
+					raise Exception("jail exception")

 			elif first_arg == "exec":
-				if len(args) > 0:
-					third_arg = sys.argv[3]
-					args = sys.argv[4:]
-					result, text = klik.execute_cmg(third_arg, second_arg, args)
-					sys.exit(result)
-				else:
-					usage()
+				result, text = cmg.execute(args[1], args[1:])

 			elif first_arg == "prompt":
-				result, text = klik.execute_cmg(None, second_arg, args, False, True)
-				sys.exit(result)
+				result, text = cmg.execute(None, args[1:], False, True)

 			elif first_arg == "get":
-				result, text = klik.download_and_execute(second_arg, args)
+				result, text = klik.download_and_execute(args[0], args[1:])

 			elif first_arg == "settings":
-				klik.settings.print_settings( sys.argv[2:] )
+				klik.settings.print_settings( args )
 				
-			else:
-				usage()
-
-		elif len(sys.argv) > 1:
-			first_arg = sys.argv[1]
-			args = sys.argv[2:]
-
-			if first_arg in ("--help","-h"):
+			elif first_arg in ("help", "--help", "-h"):
 				usage()
+			
+   			elif os.path.exists( first_arg ):
+				cmg = KlikCmg( klik, first_arg )
+				result, text = cmg.execute(None, args)
+				
 			else:
-				result, text = klik.download_and_execute(first_arg, args )
-		else:
-			usage()
+				result, text = klik.download_and_execute(first_arg, args)
+

 	except Exception, inst:
 		usage( first_arg )
 		if klik.settings.debug:
 			print "DEBUG - Error occurred:", inst
 			traceback.print_exc()
+			
+	sys.exit(1-int(result))

Modified: trunk/client/trunk/klikclient/lib/klik/base.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/base.py	(original)
+++ trunk/client/trunk/klikclient/lib/klik/base.py	Thu Feb 28 00:06:38 2008
@@ -399,9 +399,6 @@
 		# Cleanup temp files
 		self.clean_up()

-	def execute_cmg(self, command, cmg_path, args):
-		cmg = KlikCmg(self, cmg_path)
-		return cmg.execute(command, args)

 	def is_valid_cmg(self, cmg_path):
 		cmg = KlikCmg(self, cmg_path)

Modified: trunk/client/trunk/klikclient/lib/klik/cmg.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/cmg.py	(original)
+++ trunk/client/trunk/klikclient/lib/klik/cmg.py	Thu Feb 28 00:06:38 2008
@@ -100,7 +100,7 @@
 					desktop_object = None

 					# if self.xdg.get_desktop_enviroment() == "GNOME" and :
-					if self.xdg.get_is_gtk_installed():
+					if self.klik.xdg.get_is_gtk_installed():
 						# this dialouge will return the selected desktop object
 						from klik.gtk.multiple import MultipleApplications
 						ma = MultipleApplications(self)

Modified: trunk/client/trunk/klikclient/lib/klik/gtk/multiple.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/gtk/multiple.py	(original)
+++ trunk/client/trunk/klikclient/lib/klik/gtk/multiple.py	Thu Feb 28 
00:06:38 2008
@@ -44,6 +44,7 @@
 import gobject
 import utils

+from klik.cmg import KlikCmg


 class MultipleApplications( object ):
@@ -119,18 +120,19 @@
 	def load_items(self, desktop_files):
 		self.item_store.clear()
 		for item in desktop_files:
-
+			
+			cmg = KlikCmg( self.klik, item.get("X-CMG") )
 			name = item.get("Name").strip()
 			if item.get("Comment") != None:
  				name = xml.sax.saxutils.escape(name) + '\n<small><i>' + 
xml.sax.saxutils.escape(item.get("Comment").strip()) + '</i></small>'
 			else:
 				name = xml.sax.saxutils.escape(name) + '\n<small><i></i></small>'

-			icon = self.klik.scan_cmg_icons(item.get("X-CMG"), item)[0]
+			icon = cmg.scan_cmg_icons(item)[0]
 			
 			if icon[0] == "/":
 				temp_path = tempfile.mktemp()
-				self.klik.extract_file( item.get("X-CMG"), icon, temp_path)
+				cmg.extract_file(icon, temp_path)
 				icon = temp_path
 				
 			pixbuf = utils.getIcon(icon)
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic