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

List:       klik-devel
Subject:    [klik-devel] [klikclient commit] r1260 - in
From:       codesite-noreply () google ! com
Date:       2008-02-28 8:29:46
Message-ID: 0016364c5add044733b9652f1c3de85f () google ! com
[Download RAW message or body]

Author: razielmine
Date: Thu Feb 28 00:29:18 2008
New Revision: 1260

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/integration.py

Log:
Cleanup and various fixes

Modified: trunk/client/trunk/klikclient/bin/klik
==============================================================================
--- trunk/client/trunk/klikclient/bin/klik	(original)
+++ trunk/client/trunk/klikclient/bin/klik	Thu Feb 28 00:29:18 2008
@@ -157,13 +157,16 @@
 		
 		if len(sys.argv) == 1:
 			usage()
-		
+			
 		else:
 			first_arg = sys.argv[1]
 			args = sys.argv[2:]
-			cmg = KlikCmg( klik, args[0] )
+				
+			if os.path.exists( first_arg ):
+				cmg = KlikCmg( klik, first_arg )
+				result, text = cmg.execute(None, args)

-			if first_arg == "unpack":
+			elif first_arg == "unpack":
 				if len(args) == 1:
 					klik.unpack_cmg( args[0], args[0][:-4] )
 				else:
@@ -173,6 +176,7 @@
 				result = klik.extract_file(args[0], args[1], args[2])

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

 			elif first_arg == "shell":
-				klik.execute_cmg_shell(args[0])
+				cmg = KlikCmg( klik, args[0] )
+				cmg.execute_shell()

 			elif first_arg == "pack":
-				klik.pack_cmg(args[0], args[1])
+				cmg = KlikCmg( klik, args[0] )
+				cmg.pack_cmg(args[0], args[1])

 			elif first_arg == "merge":
 				klik.merge(args[0], args[1], args[2])
@@ -207,15 +213,18 @@
 				#cProfile.run("klik.sync(args)")
 				integration.sync(args)

-			elif first_arg == "setup":
-				print "setup"
-
 			elif first_arg == "run":
-				if args[0].lower().endswith(".cmg"):
+				# No executable option provided
+				cmg = KlikCmg( klik, args[0] )
+				if cmg.is_valid_cmg():
 					result, text = cmg.execute(None, args)
 				else:
+					# Executable option provided as argv[0]
 					cmg = KlikCmg( klik, args[1] )
-					result, text = cmg.execute(args[0], args[1:])
+					if cmg.is_valid_cmg():
+						result, text = cmg.execute(args[0], args[1:])
+					else:
+						raise Exception("main.run")

 			elif first_arg == "jail":
 				if len(args) > 2:
@@ -223,12 +232,14 @@
 				elif os.path.isfile(args[0]):
 					klik.create_jailed_cmg(args[0])
 				else:
-					raise Exception("jail exception")
+					raise Exception("main.jail")

 			elif first_arg == "exec":
+				cmg = KlikCmg( klik, args[0] )
 				result, text = cmg.execute(args[1], args[1:])

 			elif first_arg == "prompt":
+				cmg = KlikCmg( klik, args[0] )
 				result, text = cmg.execute(None, args[1:], False, True)

 			elif first_arg == "get":
@@ -239,10 +250,6 @@
 				
 			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)
@@ -253,5 +260,6 @@
 		if klik.settings.debug:
 			print "DEBUG - Error occurred:", inst
 			traceback.print_exc()
+		exit(1)
 			
-	sys.exit(1-int(result))
+	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:29:18 2008
@@ -400,64 +400,7 @@
 		self.clean_up()


-	def is_valid_cmg(self, cmg_path):
-		cmg = KlikCmg(self, cmg_path)
-		return cmg.is_valid_cmg()
-
-
 	# Private methods
 	def __download_progress(self, percentage, text):
 		self.events.on_download_progress( percentage, text )
-		
-	## OBSOLETE ##
-		
-	# MOVE TO cmg.py
-	def find_sub_directories(self, path, cmg_path):
-		print "ERROR find_sub_directories moved to cmg.py"
-		return
-
-	# MOVE TO cmg.py
-	# Return all the files in a given CMG that match pre and post text
-	def find_files(self, cmg_path, pre_text=None, post_text=None, omit_extension=False):
-		print "ERROR  find_files moved to cmg.py"
-		return
-		
-	# MOVE TO cmg.py
-	def scan_cmg_icons(self, cmg_path, do):
-		print "ERROR  scan_cmg_icons moved to cmg.py"
-		return
-
-	# MOVE TO cmg.py
-	# Get desktop objects set to execute cmg
-	def get_desktop_objects(self, cmg_path, fix_exec=True):
-		print "ERROR  get_desktop_objects moved to cmg.py"
-		return
-
-
-	# MOVE TO cmg.py
-	def is_klik2_cmg(self, path):
-		print "ERROR is_klik2_cmg moved to cmg.py"
-		return
-	
-	# MOVE TO cmg.py
-	def is_klik1_cmg(self, path):
-		print "ERROR is_klik1_cmg moved to cmg.py"
-		return
-		
-	# MOVE TO cmg.py
-	def extract_recipe(self, cmg_path):
-		print "ERROR extract_recipe moved to cmg.py"
-		return
-	
-	# MOVE TO cmg.py
-	def extract_file(self, cmg_path, file_path_from, file_path_to):
-		print "ERROR extract_file moved to cmg.py"
-		return
-		
-
-		
-
-	# MOVE TO cmg.py
-	def check_for_missing_library(self, command, cmg_path):
-		print "ERROR check_for_missiong_library moved to cmg.py"
-
+		
\ No newline at end of file

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:29:18 2008
@@ -201,6 +201,7 @@
 							# this should really mount and check for recipe not seek(22)
 					f.seek(0)
 					magic = str(f.read(4)).strip()
+					# FIXME: this breaks with IndexError: string index out of range (RazZziel)
  					if ord(magic[0])==69 and ord(magic[1])==61 and ord(magic[2])==205 
and ord(magic[3])==40:
 						# cramfs
 						f.close()

Modified: trunk/client/trunk/klikclient/lib/klik/integration.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/integration.py	(original)
+++ trunk/client/trunk/klikclient/lib/klik/integration.py	Thu Feb 28 
00:29:18 2008
@@ -29,6 +29,7 @@
 from klik.cmg import KlikCmg
 from gettext import ngettext

+import klik.utils.images
 from klik.utils.xdg import XdgUtils
 from klik.utils.notify import Notify

@@ -187,7 +188,7 @@
 			if cmg.extract_file( icon_path, temp_icon_path ):
 				if not extension:
 					# Guess image type
-					extension = "." + images.guess_type( temp_icon_path )
+					extension = "." + klik.utils.images.guess_type( temp_icon_path )
 					shutil.move( temp_icon_path, temp_icon_path + extension )
 					temp_icon_path += extension

@@ -228,7 +229,7 @@
 		apps_to_notify = set()
 		notify_icon = None

-		cmg_list = filter( self.base.is_valid_cmg, cmg_list )
+		cmg_list = filter( lambda x: KlikCmg(self.base,x).is_valid_cmg(), 
cmg_list )

 		for cmg_path in cmg_list:

@@ -325,7 +326,7 @@
 	def __is_valid_cmg_name(self, path):
 		# If the file exists, returns true if it's a valid CMG
 		# Otherwise, returns true if the name is valid
-		return self.base.is_valid_cmg( path ) or 
path.lower().endswith( ".cmg" )
+		return KlikCmg(self.base,path).is_valid_cmg() or 
path.lower().endswith( ".cmg" )
 	
 	def unregister(self, cmg_list):

@@ -388,7 +389,7 @@
 		# List of valid CMGs in all Applications directories.
  		registered_cmgs = map( lambda x : glob.glob(x+"/*"), apps_dirs )    
# list of lists
  		registered_cmgs = reduce( list.__add__, registered_cmgs )           
# flat list
-		registered_cmgs = filter( self.base.is_valid_cmg, registered_cmgs ) 
# list of valid CMGs
+		registered_cmgs = filter( lambda x: 
KlikCmg(self.base,x).is_valid_cmg, registered_cmgs ) # list of valid CMGs
  		registered_cmgs = set( registered_cmgs )                            
# for faster lookups


_______________________________________________
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