* alpha-light: stop on error
* shellutils: - implement a function to detect a binary (exists_binary) - system: debug output to show command * ui: verbose mode for info * cli: set debug flag from options * workaround: for non-pardus development systems, fall back to plain utility name if cross-platform name doesn't exist, and warn user with a debug output
This commit is contained in:
+15
-2
@@ -14,8 +14,12 @@
|
|||||||
# Standart Python Modules
|
# Standart Python Modules
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
# PISI Modules
|
||||||
|
from pisi.ui import ui
|
||||||
|
|
||||||
# ActionsAPI Modules
|
# ActionsAPI Modules
|
||||||
from variables import glb
|
from variables import glb
|
||||||
|
from shelltools import exists_binary
|
||||||
|
|
||||||
env = glb.env
|
env = glb.env
|
||||||
dirs = glb.dirs
|
dirs = glb.dirs
|
||||||
@@ -86,8 +90,17 @@ def defaultprefixDIR():
|
|||||||
|
|
||||||
# Binutils Variables
|
# Binutils Variables
|
||||||
|
|
||||||
def getBinutilsInfo(needed):
|
def getBinutilsInfo(util):
|
||||||
return '%s-%s' % (HOST(), needed)
|
cross_build_name = '%s-%s' % (HOST(), util)
|
||||||
|
if not exists_binary(cross_build_name):
|
||||||
|
if not exists_binary(util):
|
||||||
|
ui.error('Error: util %s cannot be found' % util)
|
||||||
|
else:
|
||||||
|
ui.debug('Warning: %s does not exist, using plain name %s'
|
||||||
|
% (cross_build_name, util))
|
||||||
|
return util
|
||||||
|
else:
|
||||||
|
return cross_build_name
|
||||||
|
|
||||||
def AR():
|
def AR():
|
||||||
return getBinutilsInfo('ar')
|
return getBinutilsInfo('ar')
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ def export(key, value):
|
|||||||
os.environ[key] = value
|
os.environ[key] = value
|
||||||
|
|
||||||
def system(command):
|
def system(command):
|
||||||
|
ui.debug('executing ' + command)
|
||||||
p = os.popen(command)
|
p = os.popen(command)
|
||||||
while 1:
|
while 1:
|
||||||
line = p.readline()
|
line = p.readline()
|
||||||
@@ -90,3 +91,12 @@ def system(command):
|
|||||||
ui.debug(line)
|
ui.debug(line)
|
||||||
|
|
||||||
return p.close()
|
return p.close()
|
||||||
|
|
||||||
|
def exists_binary(bin):
|
||||||
|
# determine if path has binary
|
||||||
|
from os.path import exists, join
|
||||||
|
path = os.environ['PATH'].split(':')
|
||||||
|
for directory in path:
|
||||||
|
if exists( join(directory, bin) ):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ class PisiCLI(object):
|
|||||||
#if len(parser.rargs)==0:
|
#if len(parser.rargs)==0:
|
||||||
# self.die()
|
# self.die()
|
||||||
cmd = args[0]
|
cmd = args[0]
|
||||||
|
cli = pisi.ui.CLI(options.debug)
|
||||||
|
pisi.ui.ui = cli
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self.die()
|
self.die()
|
||||||
except ParserError:
|
except ParserError:
|
||||||
|
|||||||
+15
-5
@@ -22,15 +22,25 @@ def register(_impl):
|
|||||||
|
|
||||||
# default UI implementation
|
# default UI implementation
|
||||||
class CLI:
|
class CLI:
|
||||||
def __init__(self, debuggy = True):
|
def __init__(self, debuggy = False, verbose = False):
|
||||||
self.showDebug = debuggy
|
self.show_debug = debuggy
|
||||||
|
self.show_verbose = verbose
|
||||||
|
|
||||||
def info(self, msg):
|
def set_verbose(self, flag):
|
||||||
sys.stdout.write(colorize(msg, 'blue'))
|
self.show_verbose = flag
|
||||||
|
|
||||||
|
def set_debug(self, flag):
|
||||||
|
self.show_debug = flag
|
||||||
|
|
||||||
|
def info(self, msg, verbose = False):
|
||||||
|
if verbose and self.show_verbose:
|
||||||
|
sys.stdout.write(colorize(msg, 'blue'))
|
||||||
|
elif not verbose:
|
||||||
|
sys.stdout.write(colorize(msg, 'blue'))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
def debug(self, msg):
|
def debug(self, msg):
|
||||||
if self.showDebug:
|
if self.show_debug:
|
||||||
sys.stdout.write(msg)
|
sys.stdout.write(msg)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
pwd
|
pwd
|
||||||
PATH=$PATH:.
|
PATH=$PATH:.
|
||||||
set -x
|
set -x -e
|
||||||
pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml
|
pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml
|
||||||
pisi-cli index .
|
pisi-cli index .
|
||||||
pisi-cli add-repo repo1 pisi-index.xml
|
pisi-cli add-repo repo1 pisi-index.xml
|
||||||
|
|||||||
Reference in New Issue
Block a user