COMAR didnt like exec, so just compile it :P

This commit is contained in:
S.Çağlar Onur
2006-10-10 07:26:44 +00:00
parent 4a11476a36
commit 4354f6eaf9
+12 -10
View File
@@ -357,26 +357,22 @@ class Builder:
return abandoned_files return abandoned_files
def compile_script(self, fname): def compile_action_script(self):
"""Compiles given string to check syntax error in it and sets the actionLocals and actionGlobals""" """Compiles given actions.py to check syntax error in it and sets the actionLocals and actionGlobals"""
fname = util.join_path(self.specdir, ctx.const.actions_file)
try: try:
localSymbols = globalSymbols = {} localSymbols = globalSymbols = {}
buf = open(fname).read() buf = open(fname).read()
exec compile(buf, "error", "exec") in localSymbols, globalSymbols exec compile(buf, "error", "exec") in localSymbols, globalSymbols
except IOError, e: except IOError, e:
raise Error(_("Unable to read file (%s): %s") %(fname,e)) raise Error(_("Unable to read Actions Script (%s): %s") %(fname,e))
except SyntaxError, e: except SyntaxError, e:
raise Error(_("SyntaxError in file (%s): %s") %(fname,e)) raise Error(_("SyntaxError in Actions Script (%s): %s") %(fname,e))
self.actionLocals = localSymbols self.actionLocals = localSymbols
self.actionGlobals = globalSymbols self.actionGlobals = globalSymbols
self.srcDir = self.pkg_src_dir() self.srcDir = self.pkg_src_dir()
def compile_action_script(self):
"""Compiles actions.py to check syntax errors"""
fname = util.join_path(self.specdir, ctx.const.actions_file)
self.compile_script(fname)
def compile_comar_script(self): def compile_comar_script(self):
"""Compiles comar scripts to check syntax errors""" """Compiles comar scripts to check syntax errors"""
for package in self.spec.packages: for package in self.spec.packages:
@@ -384,7 +380,13 @@ class Builder:
fname = util.join_path(ctx.const.comar_dir, fname = util.join_path(ctx.const.comar_dir,
pcomar.script) pcomar.script)
self.compile_script(fname) try:
buf = open(fname).read()
compile(buf, "error", "exec")
except IOError, e:
raise Error(_("Unable to read COMAR script (%s): %s") %(fname,e))
except SyntaxError, e:
raise Error(_("SyntaxError in COMAR file (%s): %s") %(fname,e))
def pkg_src_dir(self): def pkg_src_dir(self):
"""Returns the real path of WorkDir for an unpacked archive.""" """Returns the real path of WorkDir for an unpacked archive."""