* 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:
Eray Özkural
2005-08-08 00:25:37 +00:00
parent 6dec65ebe5
commit e0119064ed
5 changed files with 44 additions and 8 deletions
+15 -2
View File
@@ -14,8 +14,12 @@
# Standart Python Modules
import os.path
# PISI Modules
from pisi.ui import ui
# ActionsAPI Modules
from variables import glb
from shelltools import exists_binary
env = glb.env
dirs = glb.dirs
@@ -86,8 +90,17 @@ def defaultprefixDIR():
# Binutils Variables
def getBinutilsInfo(needed):
return '%s-%s' % (HOST(), needed)
def getBinutilsInfo(util):
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():
return getBinutilsInfo('ar')
+10
View File
@@ -82,6 +82,7 @@ def export(key, value):
os.environ[key] = value
def system(command):
ui.debug('executing ' + command)
p = os.popen(command)
while 1:
line = p.readline()
@@ -90,3 +91,12 @@ def system(command):
ui.debug(line)
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
+3
View File
@@ -45,6 +45,9 @@ class PisiCLI(object):
#if len(parser.rargs)==0:
# self.die()
cmd = args[0]
cli = pisi.ui.CLI(options.debug)
pisi.ui.ui = cli
except IndexError:
self.die()
except ParserError:
+15 -5
View File
@@ -22,15 +22,25 @@ def register(_impl):
# default UI implementation
class CLI:
def __init__(self, debuggy = True):
self.showDebug = debuggy
def __init__(self, debuggy = False, verbose = False):
self.show_debug = debuggy
self.show_verbose = verbose
def info(self, msg):
sys.stdout.write(colorize(msg, 'blue'))
def set_verbose(self, flag):
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()
def debug(self, msg):
if self.showDebug:
if self.show_debug:
sys.stdout.write(msg)
sys.stdout.flush()
+1 -1
View File
@@ -2,7 +2,7 @@
pwd
PATH=$PATH:.
set -x
set -x -e
pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml
pisi-cli index .
pisi-cli add-repo repo1 pisi-index.xml