* 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 pisipackage
|
||||||
import util
|
import util
|
||||||
import ui
|
from ui import ui
|
||||||
|
|
||||||
class PisiBuildError(Exception):
|
class PisiBuildError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
from specfile import *
|
from specfile import *
|
||||||
from package import Package
|
from package import Package
|
||||||
import util
|
import util
|
||||||
import ui
|
from ui import ui
|
||||||
import installdb
|
import installdb
|
||||||
import packagedb
|
import packagedb
|
||||||
import dependency
|
import dependency
|
||||||
|
|||||||
+12
-12
@@ -3,28 +3,28 @@
|
|||||||
import sys
|
import sys
|
||||||
from colors import colorize
|
from colors import colorize
|
||||||
|
|
||||||
# put the interface directly in the module
|
|
||||||
# since the UI is _unique_
|
|
||||||
|
|
||||||
def register(_impl):
|
def register(_impl):
|
||||||
""" Register a UI implementation"""
|
""" Register a UI implementation"""
|
||||||
impl = _impl
|
ui = _impl
|
||||||
|
|
||||||
def info(msg):
|
|
||||||
impl.info(msg)
|
|
||||||
|
|
||||||
def error(msg):
|
|
||||||
impl.error(msg)
|
|
||||||
|
|
||||||
# default UI implementation
|
# default UI implementation
|
||||||
class CLI:
|
class CLI:
|
||||||
|
def __init__(self, debuggy = True):
|
||||||
|
self.showDebug = debuggy
|
||||||
|
|
||||||
def info(self, msg):
|
def info(self, msg):
|
||||||
sys.stdout.write(colorize(msg, 'blue'))
|
sys.stdout.write(colorize(msg, 'blue'))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
def debug(self, msg):
|
||||||
|
if showDebug:
|
||||||
|
sys.stdout.write(msg)
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
def error(self,msg):
|
def error(self,msg):
|
||||||
sys.stdout.write(colorize(msg, 'red'))
|
sys.stdout.write(colorize(msg, 'red'))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
# default UI is CLI
|
|
||||||
impl = CLI()
|
# default UI is CLI
|
||||||
|
ui = CLI()
|
||||||
|
|
||||||
|
|||||||
+4
-11
@@ -5,6 +5,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import md5
|
import md5
|
||||||
|
from ui import ui
|
||||||
|
|
||||||
class FileError(Exception):
|
class FileError(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -21,14 +22,6 @@ def check_dir(dir):
|
|||||||
dir = dir.strip().rstrip("/")
|
dir = dir.strip().rstrip("/")
|
||||||
if not os.access(dir, os.F_OK):
|
if not os.access(dir, os.F_OK):
|
||||||
os.makedirs(dir)
|
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):
|
def purge_dir(top):
|
||||||
"""Remove all content of a directory (top)"""
|
"""Remove all content of a directory (top)"""
|
||||||
@@ -59,14 +52,14 @@ def md5_file(filename):
|
|||||||
|
|
||||||
# run a command non-interactively
|
# run a command non-interactively
|
||||||
def run_batch(cmd):
|
def run_batch(cmd):
|
||||||
print 'running ', cmd
|
ui.info('running ' + cmd)
|
||||||
a = os.popen(cmd)
|
a = os.popen(cmd)
|
||||||
lines = a.readlines()
|
lines = a.readlines()
|
||||||
ret = a.close()
|
ret = a.close()
|
||||||
print 'return value ', ret
|
ui.debug('return value ' + ret)
|
||||||
successful = ret == None
|
successful = ret == None
|
||||||
if not successful:
|
if not successful:
|
||||||
print 'ERROR: executing command', cmd
|
ui.error('ERROR: executing command: ' + cmd)
|
||||||
for x in lines:
|
for x in lines:
|
||||||
print x
|
print x
|
||||||
return (successful,lines)
|
return (successful,lines)
|
||||||
|
|||||||
Reference in New Issue
Block a user