* bir debug seysi ekle ui interface'ine
* ui code'unu basitlestir * run_batch code'unu ui'lastir
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ from archive import Archive
|
||||
|
||||
# import pisipackage
|
||||
import util
|
||||
import ui
|
||||
from ui import ui
|
||||
|
||||
class PisiBuildError(Exception):
|
||||
pass
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
from specfile import *
|
||||
from package import Package
|
||||
import util
|
||||
import ui
|
||||
from ui import ui
|
||||
import installdb
|
||||
import packagedb
|
||||
import dependency
|
||||
|
||||
+12
-12
@@ -3,28 +3,28 @@
|
||||
import sys
|
||||
from colors import colorize
|
||||
|
||||
# put the interface directly in the module
|
||||
# since the UI is _unique_
|
||||
|
||||
def register(_impl):
|
||||
""" Register a UI implementation"""
|
||||
impl = _impl
|
||||
|
||||
def info(msg):
|
||||
impl.info(msg)
|
||||
|
||||
def error(msg):
|
||||
impl.error(msg)
|
||||
ui = _impl
|
||||
|
||||
# default UI implementation
|
||||
class CLI:
|
||||
def __init__(self, debuggy = True):
|
||||
self.showDebug = debuggy
|
||||
|
||||
def info(self, msg):
|
||||
sys.stdout.write(colorize(msg, 'blue'))
|
||||
sys.stdout.flush()
|
||||
|
||||
def debug(self, msg):
|
||||
if showDebug:
|
||||
sys.stdout.write(msg)
|
||||
sys.stdout.flush()
|
||||
|
||||
def error(self,msg):
|
||||
sys.stdout.write(colorize(msg, 'red'))
|
||||
sys.stdout.flush()
|
||||
# default UI is CLI
|
||||
impl = CLI()
|
||||
|
||||
# default UI is CLI
|
||||
ui = CLI()
|
||||
|
||||
|
||||
+4
-11
@@ -5,6 +5,7 @@
|
||||
import os
|
||||
import sys
|
||||
import md5
|
||||
from ui import ui
|
||||
|
||||
class FileError(Exception):
|
||||
pass
|
||||
@@ -21,14 +22,6 @@ def check_dir(dir):
|
||||
dir = dir.strip().rstrip("/")
|
||||
if not os.access(dir, os.F_OK):
|
||||
os.makedirs(dir)
|
||||
# does the parent exist?
|
||||
## (parent_dir, curr_dir) = os.path.split(dir)
|
||||
## if parent_dir != "/":
|
||||
## check_dir(parent_dir)
|
||||
## try:
|
||||
## os.mkdir(dir)
|
||||
## except OSError, e:
|
||||
## raise UtilError("%s" % e)
|
||||
|
||||
def purge_dir(top):
|
||||
"""Remove all content of a directory (top)"""
|
||||
@@ -59,14 +52,14 @@ def md5_file(filename):
|
||||
|
||||
# run a command non-interactively
|
||||
def run_batch(cmd):
|
||||
print 'running ', cmd
|
||||
ui.info('running ' + cmd)
|
||||
a = os.popen(cmd)
|
||||
lines = a.readlines()
|
||||
ret = a.close()
|
||||
print 'return value ', ret
|
||||
ui.debug('return value ' + ret)
|
||||
successful = ret == None
|
||||
if not successful:
|
||||
print 'ERROR: executing command', cmd
|
||||
ui.error('ERROR: executing command: ' + cmd)
|
||||
for x in lines:
|
||||
print x
|
||||
return (successful,lines)
|
||||
|
||||
Reference in New Issue
Block a user