[prev in list] [next in list] [prev in thread] [next in thread]
List: klik-devel
Subject: [klik-devel] [klikclient commit] r1258 - in
From: codesite-noreply () google ! com
Date: 2008-02-28 6:18:18
Message-ID: 000e0cd1574e044731e33e7f101b6d0 () google ! com
[Download RAW message or body]
Author: razielmine
Date: Wed Feb 27 22:17:41 2008
New Revision: 1258
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
trunk/client/trunk/klikclient/lib/klik/settings.py
trunk/client/trunk/klikclient/lib/klik/utils/images.py
Log:
Started overhauling klik arguments and ended up fixing klik icon
function... funny night.
Modified: trunk/client/trunk/klikclient/bin/klik
==============================================================================
--- trunk/client/trunk/klikclient/bin/klik (original)
+++ trunk/client/trunk/klikclient/bin/klik Wed Feb 27 22:17:41 2008
@@ -34,75 +34,92 @@
from klik.settings import KlikSettings
from klik.integration import KlikIntegration
from klik.utils.xdg import XdgUtils
+from klik.cmg import KlikCmg
gettext.install( 'klikclient' )
-def usage():
+help_text = {}
- print """
-Usage:
-
-klik foo - Short for "klik get foo"
-
-klik /path/to/foo.cmg - Short for "klik run /path/to/foo.cmg"
-
-klik get foo - Download a recipe and create a cmg
- file for the application foo
-
-klik klik2://foo - Download a recipe and create a cmg
- file for the application foo
-
-klik /path/to/foo.recipe - Create a cmg file for the application
- moo from the given recipe
-
-klik run [executable] foo.cmg [args] - Run application foo.cmg, executable
- is an optional command to start
-
-klik jail foo.cmg [jail_type] - Create a jail folder for foo.cmg
- (types - data, home, portable)
-
-klik exec foo.cmg executable [args] - Run application foo.cmg, executable
- is NOT optional
-
-klik prompt foo.cmg executable - force a dialogue to select application
-
-klik shell foo.cmg - Start a shell with cmg union mounted
-
-klik unpack foo.cmg /foo/ - Unpack an application
-
-klik extract foo.cmg /foo.cfg foo.cfg - Extract a single file from a cmg
-
-klik icon foo.cmg output.ico - Extract the icon for the cmg (resizes icon)
-
-klik pack /foo/ foo.cmg - Repack an application
-
-klik merge main.cmg add.cmg output.cmg
-
-klik (un)register foo.cmg [bar.cmg...] - (un)register cmg list into
desktop menu
- Options:
- -f - Force registration
+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")
+
+def usage(mode=None):
+
+ if not mode:
+ print "Klik - Web based software installer"
+ print
+ print "Usage:"
+
+ if mode:
+ print " " + help_text[mode]
+ else:
+ for mode in help_text:
+ print " " + help_text[mode]
-klik sync dir1 [dir2...] - Synchronize application directories, looking
- for non-registered packages and packages
- registered but no longer existing
-"""
- s = KlikSettings()
+ s = KlikSettings()
- print ""
- print "Documentation by :"
- print "\n".join(s.documenters)
+ print "Documentation by :"
+ print "\n".join(s.documenters)
- print ""
- print "Created by :"
- print "\n".join(s.authors)
+ print ""
+ print "Created by :"
+ print "\n".join(s.authors)
- print ""
- print "Website : " + s.website
-
+ print ""
+ print "Website : " + s.website
-# klik jail foo.cmg - Run application moo.cmg
if __name__ == "__main__":
+
+ first_arg = None
try:
# Check not root
@@ -146,15 +163,14 @@
usage()
elif first_arg == "icon":
- result = True
+ cmg = KlikCmg( klik, second_arg )
if len(args) > 1:
- result = klik.extract_icon(second_arg, args[0], args[1])
- else:
- result = klik.extract_icon(second_arg, args[0], -1)
- if result:
- sys.exit(0)
+ result = cmg.extract_icon(args[0], resize=int(args[1]))
else:
- sys.exit(1)
+ result = cmg.extract_icon(args[0])
+ if not result:
+ print "Error: Could not extract icon"
+ sys.exit(int(result))
elif first_arg == "shell":
klik.execute_cmg_shell(second_arg)
@@ -249,5 +265,7 @@
usage()
except Exception, inst:
- print ("Error occurred: %s" % inst)
- traceback.print_exc()
+ usage( first_arg )
+ if klik.settings.debug:
+ print "DEBUG - Error occurred:", inst
+ traceback.print_exc()
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 Wed Feb 27 22:17:41 2008
@@ -436,12 +436,6 @@
print "ERROR get_desktop_objects moved to cmg.py"
return
- # MOVE TO cmg.py
- def extract_icon(self, cmg_path, file_path_to, image_size):
- cmg = KlikCmg(self, cmg_path)
- return cmg.extract_icon(file_path_to, image_size )
-
-
# MOVE TO cmg.py
def is_klik2_cmg(self, 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 Wed Feb 27 22:17:41 2008
@@ -29,8 +29,9 @@
import shutil
import re
-from klik.fuse import KlikExecute
+import klik.utils.images
import klik.utils.freedesktop
+from klik.fuse import KlikExecute
from klik.utils.freedesktop import DesktopParser
from klik.utils.debian import MenuParser
from klik.sandbox import KlikSandBox
@@ -396,19 +397,16 @@
return desktop_objects
- def extract_icon(self, file_path_to, image_size=24):
+ def extract_icon(self, file_path_to, resize=None):
if self.extract_file("/.DirIcon", file_path_to):
-
- # Check image size
- if image_size > -1:
- try:
- from klik.utils.images import Images
- img = Images()
- # NOTE : image_size is the thumbnail size NOT the icon size....
- img.check_image_size(file_path_to, self.klik.settings.desktop_icon_size)
-
- except Exception, text:
- pass
+ # Resize image if needed
+ if resize:
+ if resize < 0:
+ resize = self.klik.settings.desktop_icon_size # TODO: review this behaviour
+ klik.utils.images.resize(file_path_to, resize)
+ else:
+ shutil.move( file_path_to,
+ os.path.splitext(file_path_to)[0] +"."+
klik.utils.images.guess_type(file_path_to) )
return True
return False
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 Wed Feb 27
22:17:41 2008
@@ -187,8 +187,7 @@
if cmg.extract_file( icon_path, temp_icon_path ):
if not extension:
# Guess image type
- import imghdr # TODO: svg? ---> add entry to 'tests' list
- extension = "." + ( imghdr.what( temp_icon_path ) or "xpm" )
+ extension = "." + images.guess_type( temp_icon_path )
shutil.move( temp_icon_path, temp_icon_path + extension )
temp_icon_path += extension
Modified: trunk/client/trunk/klikclient/lib/klik/settings.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/settings.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/settings.py Wed Feb 27
22:17:41 2008
@@ -33,10 +33,10 @@
version = "1.9.2"
config_path = "~/.klik"
- authors = ["Simon Peter <probono@myrealbox.com>",
- "Kurt Pfeifle <pfeifle@kde.org>",
- "Jason Taylor <killerkiwi2005@gmail.com>",
- "Lionel Tricon <lionel.tricon@free.fr>",
+ authors = ["Simon Peter <probono@myrealbox.com>",
+ "Kurt Pfeifle <pfeifle@kde.org>",
+ "Jason Taylor <killerkiwi2005@gmail.com>",
+ "Lionel Tricon <lionel.tricon@free.fr>",
"Niall Walsh <niallw@gmail.com>",
"Ismael Barros <razielmine@gmail.com>",
"",
Modified: trunk/client/trunk/klikclient/lib/klik/utils/images.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/utils/images.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/utils/images.py Wed Feb 27
22:17:41 2008
@@ -18,13 +18,25 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-class Images (object):
+import os
- def check_image_size(self, file_path, default_size):
- try:
- import gtk
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_path,
default_size, default_size)
- pixbuf.save(file_path, "png")
+def resize(file_path, size):
+ try:
+ # TODO: What about using PIL here?
+ # more portable, more poserful
+ # http://www.pythonware.com/library/pil/handbook/index.htm
+ # (RazZziel)
+ import gtk
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_path, size, size)
+ os.remove(file_path)
+ pixbuf.save(os.path.splitext(file_path)[0] + ".png", "png")
+ except Exception, text:
+ print "Image resize failed:", text
- except Exception, text:
- print "Image Resize Failed : %s" % text
+
+def guess_type(file_path):
+ try:
+ import imghdr # TODO: svg? ---> add entry to 'tests' list
+ return imghdr.what( file_path ) or "xpm"
+ except Exception, text:
+ print "Image guess failed:", text
_______________________________________________
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