[prev in list] [next in list] [prev in thread] [next in thread]
List: klik-devel
Subject: [klik-devel] [klikclient commit] r1471 - in
From: codesite-noreply () google ! com
Date: 2008-04-27 1:46:49
Message-ID: 0016e644d030ffeb07044bd0f8e6 () google ! com
[Download RAW message or body]
Author: KillerKiwi2005
Date: Sat Apr 26 18:45:53 2008
New Revision: 1471
Modified:
trunk/client/trunk/klikclient/bin/klik
trunk/client/trunk/klikclient/lib/klik/recipe.py
Log:
- Better prompt error message
- Fix in recipe for __readEnviroment (missing self)
Modified: trunk/client/trunk/klikclient/bin/klik
==============================================================================
--- trunk/client/trunk/klikclient/bin/klik (original)
+++ trunk/client/trunk/klikclient/bin/klik Sat Apr 26 18:45:53 2008
@@ -140,6 +140,8 @@
if __name__ == "__main__":
+
+
first_arg = None
result = False
@@ -147,13 +149,16 @@
# Check not root
xdg = XdgUtils()
-
- #if xdg.is_root():
- # print "Sorry, you should not run klik as root (or sudo)"
- # exit(1)
+ if xdg.is_root():
+ print "Sorry, you should not run klik as root (or sudo)"
+ exit(1)
klik = KlikBase(sys.path[0])
+ # Verbose... else it apears like we are spewing error messages all
the time
+ if klik.settings.debug:
+ print "WARNING: Debug mode is on!"
+
sanity = klik.is_system_sane()
"""if False in sanity:
print "System is not sane, aborting"
@@ -249,7 +254,12 @@
elif first_arg == "prompt":
cmg = KlikCmg( klik, args[0] )
- result, text = cmg.execute(args[1:], force_prompt=True)
+ if cmg.is_valid_cmg():
+ result, text = cmg.execute(args[1:], force_prompt=True)
+ else:
+
+ print "Error : No file found"
+ raise Exception("main.prompt")
elif first_arg == "get":
result, text = klik.download(args)
Modified: trunk/client/trunk/klikclient/lib/klik/recipe.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/recipe.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/recipe.py Sat Apr 26
18:45:53 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# klik2
+# klik2
# Copyright (C) 2008 Jason Taylor - killerkiwi2005@gmail.com
#
# This program is free software; you can redistribute it and/or modify
@@ -32,10 +32,10 @@
size = None
src = None
file_type = None
-
+
class Symlink (object):
pathFrom = None
- pathTo = None
+ pathTo = None
class Enviroment (object):
@@ -48,7 +48,7 @@
href = None
md5 = None
name = None
-
+
def __init__(self, href, name = None, md5 = None):
self.href = href
self.name = name
@@ -67,29 +67,29 @@
if p.startswith( base_path ):
return p
return None
-
+
class KlikTustredActionUnzip(KlikTustredAction):
def __init__(self, fileName):
self.fileName = fileName
-
+
def get_command(self, archivepath):
-
-
+
+
fn = self.clean_path(archivepath, self.fileName)
-
-
-
+
+
+
if fn.lower().endswith(".tgz") or fn.lower().endswith(".tar.gz"):
return ["tar", "zxvf", fn]
-
+
if fn.lower().endswith(".tbz") or fn.lower().endswith(".tar.bz2") or fn.lower().endswith(".tbz2"):
return ["bunzip2", "-c", fn]
-
+
if fn.lower().endswith(".zip"):
return ["unzip", fn]
-
+
return None
@@ -97,24 +97,24 @@
def __init__(self, source, destination):
self.source = source
self.destination = destination
-
+
def get_command(self, basepath):
pf = self.clean_path( basepath, self.source )
pt = self.clean_path( basepath, self.destination )
if pf != None and pt != None and os.path.exists(pf):
return ["mv", pf, pt]
return None
-
+
class KlikTustredActionDelete(KlikTustredAction):
def __init__(self, path):
self.path = path
-
+
def get_command(self, basepath):
p = self.clean_path( basepath, self.path)
if p != None and os.path.exists(p):
return ["rm", p]
return None
-
+
class KlikTustredActionSymLink(KlikTustredAction):
def __init__(self, source, destination):
self.source = source
@@ -125,14 +125,14 @@
if pf != None:
return ["ln", "-sf", self.destination, pf]
return None
-
+
class KlikTustredActionInformation(KlikTustredAction):
def __init__(self, text):
self.text = text
-
+
class KlikScript(object):
def __init__(self, script):
- self.script = script
+ self.script = script
class KlikTustredActionCollection(object):
def __init__(self):
@@ -142,7 +142,7 @@
self.information = []
self.script = []
self.unzip = []
-
+
class KlikRecipe (object):
def __init__(self, recipe_path=None):
@@ -157,14 +157,14 @@
self.description = ""
self.summary = ""
self.command = None
-
+
self.icon = None
self.packages = []
self.original_xml = None
self.size = None
self.source_uri = None
-
+
self.preflight = []
self.postflight = []
self.prerun = []
@@ -174,9 +174,9 @@
self.needs = []
self.debtags = { }
-
+
self.enviroment = []
-
+
if recipe_path:
if type(recipe_path) is file:
self.load_from_string( recipe_path.read() )
@@ -193,19 +193,19 @@
try:
stream, sigs = check_string( self.original_xml )
assert sigs
-
+
for sig in sigs:
signed_by = str(sig)
if isinstance(sig, ValidSig) == True :
- signed_by = sig.get_details()[1][9] # get the name of the person
who signed
+ signed_by = sig.get_details()[1][9] # get the name of the person
who signed
flag = True
break
except Exception, e:
print "recipe.is_trusted() - Error:", e
return [flag, signed_by]
-
-
+
+
def load_from_file(self, path):
try:
f = open(path, "r")
@@ -213,21 +213,21 @@
f.close()
self.load_from_string(xml)
except Exception, e:
- raise SafeException("Error recipe could not be loaded does not
appear to be valid XML (%s)" % e)
-
+ raise SafeException("Error recipe could not be loaded does not
appear to be valid XML (%s)" % e)
+
def load_from_string(self, xml):
try:
self.original_xml = xml
document = parseString(xml)
-
+
except Exception, e:
raise SafeException("Error recipe could not be loaded does not
appear to be valid XML (%s)" % e)
-
-
+
+
self.__load_from_document(document)
-
-
+
+
def print_details(self):
print "Application details"
print "==================="
@@ -239,39 +239,39 @@
print "Trusted Contact: %s" % text
else:
print "Trust Level: UNTRUSTED - This recipe has not been signed
by someone you trust"
-
+
print "Summary: %s" % self.summary
print "Description: %s" % self.description
-
-
+
+
def __load_from_document(self, document):
-
+
interface = self.__getFirstNode(document,"interface")
error = self.__getFirstNode(document,"error")
-
+
if interface != None:
self.source_uri = interface.getAttribute("uri")
-
+
name = self.__getFirstNode(interface, "name")
-
+
if name != None and name.firstChild != None:
self.name = self.__getNodeValue(name, "")
-
+
# default command is app name
self.command = self.name
-
+
description = self.__getFirstNode(interface,"description")
if description != None:
self.description = self.__getNodeValue( description, "")
-
+
summary = self.__getFirstNode(interface,"summary")
if summary != None:
self.summary = self.__getNodeValue( summary, "")
-
+
needs = self.__getFirstNode(interface,"needs")
if needs != None:
self.needs = self.__getNodeValue( needs, "").split("+")
-
+
icon = self.__getFirstNode(interface,"icon")
if icon != None:
self.icon = icon.getAttribute("href")
@@ -279,7 +279,7 @@
debtags = self.__getFirstNode(interface,"debtags")
if debtags != None:
nodes = interface.getElementsByTagName("tag")
-
+
if len(nodes) > 0:
self.require_terminal = False
for node in nodes:
@@ -290,14 +290,14 @@
value = value.split("::")
self.debtags[value[0]] = value[1]
-
+
group = self.__getFirstNode(interface,"group")
if group != None:
if group.attributes["main"] != None:
self.command = group.getAttribute("main")
implementation = self.__getFirstNode(group,"implementation")
-
+
if implementation != None:
self.version = implementation.getAttribute("version")
if implementation.attributes["downloadsize"] != None:
@@ -305,84 +305,84 @@
self.size = implementation.getAttribute("downloadsize")
except Exception, e:
print "recipe.__load_from_document() - Error:", e
-
+
for node in implementation.getElementsByTagName("environment"):
try:
- __readEnviroment( node )
+ self.__readEnviroment( node )
except Exception, e:
print "recipe.__load_from_document() - Error:", e
-
-
+
+
for node in implementation.getElementsByTagName("archive"):
try:
ki = KlikIngredientPackage(node.getAttribute( "href" ),
node.getAttribute( "name" ), node.getAttribute( "md5" ))
self.packages.append( ki )
except Exception, e:
print "recipe.__load_from_document() - Error:", e
-
-
+
+
preflight = self.__getFirstNode(implementation, "klik-preflight")
self.__readActions( preflight, self.preflight)
-
+
postflight = self.__getFirstNode(implementation, "klik-postflight")
self.__readActions( postflight, self.postflight)
-
+
prerun = self.__getFirstNode(implementation, "klik-prerun")
self.__readActions( prerun, self.prerun)
-
+
postrun = self.__getFirstNode(implementation, "klik-postrun")
self.__readActions( postrun, self.postrun)
- return
+ return
elif error != None:
# hack to trim quotes... why does this happen?
raise SafeException( self.__getNodeValue( error, "") )
return
-
+
raise Exception("XML document does not appear to be a valid recipe")
-
-
+
+
def __readEnviroment( self, node ):
name = node.getAttribute( "name" )
-
+
if name != None and name != "":
env = Enviroment()
env.name = name
env.insert = node.getAttribute( "insert" )
env.mode = node.getAttribute( "mode" )
env.default = node.getAttribute( "default" )
-
- self.enviroment.append(env)
+
+ self.enviroment.append(env)
def __readActions(self, parent_node, action_collection):
if parent_node != None:
-
+
for node in parent_node.childNodes:
-
+
if node.nodeType == 1:
if node.tagName == "move":
source = node.getAttribute("source")
destination = node.getAttribute("destination")
if source != None and destination != None:
action_collection.append( KlikTustredActionMove(source,
destination) )
-
+
if node.tagName == "delete":
path = node.getAttribute("path")
if path != None:
action_collection.append( KlikTustredActionDelete(path) )
-
+
if node.tagName == "symlink":
source = node.getAttribute("source")
destination = node.getAttribute("destination")
if source != None and destination != None:
action_collection.append( KlikTustredActionSymLink(source,
destination) )
-
+
if node.tagName == "information":
text = self. __getNodeValue( node, "" )
if text != "":
action_collection.append( KlikTustredActionInformation(text) )
-
+
if node.tagName == "script":
content = self. __getNodeValue( node, "" )
if content != "":
@@ -399,7 +399,7 @@
if len(nodes) > 0:
return nodes[0]
return None
-
+
def __getNodeValue(self, element, defaultValue):
node = element.firstChild
if node != None:
@@ -407,7 +407,4 @@
return node.nextSibling.nodeValue
else:
return node.nodeValue
- return defaultValue
-
-
-
+ return defaultValue
_______________________________________________
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