Add '-cmd' syntax to ignore errors, drop copyif/moveif
Makefile-style "-cmd" syntax lets us run a command and ignore any resulting errors. This is a more general version of what copyif/moveif were trying to accomplish, so we can drop those commands.
This commit is contained in:
parent
fe98d6c921
commit
0e64f08ff8
@ -22,13 +22,13 @@ configdir = configdir + "/common"
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
## create_screenfont()
|
## create_screenfont()
|
||||||
moveif ${SCREENFONT} etc/screenfont.gz
|
-move ${SCREENFONT} etc/screenfont.gz
|
||||||
|
|
||||||
## move_stubs()
|
## move_stubs()
|
||||||
move usr/share/anaconda/restart-anaconda usr/bin
|
move usr/share/anaconda/restart-anaconda usr/bin
|
||||||
move ${PYTHONDIR}/site-packages/pyanaconda/sitecustomize.py ${PYTHONDIR}/site-packages
|
move ${PYTHONDIR}/site-packages/pyanaconda/sitecustomize.py ${PYTHONDIR}/site-packages
|
||||||
%for stub in stubs:
|
%for stub in stubs:
|
||||||
moveif usr/share/anaconda/${stub}-stub usr/bin/${stub}
|
-move usr/share/anaconda/${stub}-stub usr/bin/${stub}
|
||||||
%endfor
|
%endfor
|
||||||
|
|
||||||
## move_repos()
|
## move_repos()
|
||||||
|
@ -140,7 +140,13 @@ class LoraxTemplateRunner(object):
|
|||||||
logger.info("running %s", self.templatefile)
|
logger.info("running %s", self.templatefile)
|
||||||
for (num, line) in enumerate(parsed_template,1):
|
for (num, line) in enumerate(parsed_template,1):
|
||||||
logger.debug("template line %i: %s", num, " ".join(line))
|
logger.debug("template line %i: %s", num, " ".join(line))
|
||||||
|
skiperror = False
|
||||||
(cmd, args) = (line[0], line[1:])
|
(cmd, args) = (line[0], line[1:])
|
||||||
|
# Following Makefile convention, if the command is prefixed with
|
||||||
|
# a dash ('-'), we'll ignore any errors on that line.
|
||||||
|
if cmd.startswith('-'):
|
||||||
|
cmd = cmd[1:]
|
||||||
|
skiperror = True
|
||||||
try:
|
try:
|
||||||
# grab the method named in cmd and pass it the given arguments
|
# grab the method named in cmd and pass it the given arguments
|
||||||
f = getattr(self, cmd, None)
|
f = getattr(self, cmd, None)
|
||||||
@ -148,6 +154,10 @@ class LoraxTemplateRunner(object):
|
|||||||
raise ValueError, "unknown command %s" % cmd
|
raise ValueError, "unknown command %s" % cmd
|
||||||
f(*args)
|
f(*args)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
if skiperror:
|
||||||
|
logger.error("template command error in %s (ignored):", self.templatefile)
|
||||||
|
logger.error(" %s", " ".join(line))
|
||||||
|
continue
|
||||||
logger.error("template command error in %s:", self.templatefile)
|
logger.error("template command error in %s:", self.templatefile)
|
||||||
logger.error(" %s", " ".join(line))
|
logger.error(" %s", " ".join(line))
|
||||||
# format the exception traceback
|
# format the exception traceback
|
||||||
@ -283,14 +293,6 @@ class LoraxTemplateRunner(object):
|
|||||||
'''
|
'''
|
||||||
cpfile(self._out(src), self._out(dest))
|
cpfile(self._out(src), self._out(dest))
|
||||||
|
|
||||||
def copyif(self, src, dest):
|
|
||||||
'''
|
|
||||||
copyif SRC DEST
|
|
||||||
Copy SRC to DEST, but only if SRC exists.
|
|
||||||
'''
|
|
||||||
if rexists(self._out(src)):
|
|
||||||
self.copy(src, dest)
|
|
||||||
|
|
||||||
def move(self, src, dest):
|
def move(self, src, dest):
|
||||||
'''
|
'''
|
||||||
move SRC DEST
|
move SRC DEST
|
||||||
@ -298,18 +300,11 @@ class LoraxTemplateRunner(object):
|
|||||||
'''
|
'''
|
||||||
mvfile(self._out(src), self._out(dest))
|
mvfile(self._out(src), self._out(dest))
|
||||||
|
|
||||||
def moveif(self, src, dest):
|
|
||||||
'''
|
|
||||||
moveif SRC DEST
|
|
||||||
Move SRC to DEST, but only if SRC exists.
|
|
||||||
'''
|
|
||||||
if rexists(self._out(src)):
|
|
||||||
self.move(src, dest)
|
|
||||||
|
|
||||||
def remove(self, *fileglobs):
|
def remove(self, *fileglobs):
|
||||||
'''
|
'''
|
||||||
remove FILEGLOB [FILEGLOB ...]
|
remove FILEGLOB [FILEGLOB ...]
|
||||||
Remove all the named files or directories.
|
Remove all the named files or directories.
|
||||||
|
Will *not* raise exceptions if the file(s) are not found.
|
||||||
'''
|
'''
|
||||||
for g in fileglobs:
|
for g in fileglobs:
|
||||||
for f in rglob(self._out(g)):
|
for f in rglob(self._out(g)):
|
||||||
|
Loading…
Reference in New Issue
Block a user