Skip to content

Instantly share code, notes, and snippets.

@vhata
Created November 20, 2011 19:09
Show Gist options
  • Save vhata/1380719 to your computer and use it in GitHub Desktop.
Save vhata/1380719 to your computer and use it in GitHub Desktop.
On the fly method-caller
try:
m = imp.load_source(f,'%s/%s/deploy/%s.py' % (workspace_path, self.application.name, f))
log.debug("Successfully imported module")
except IOError:
log.error("Could not find %s's deploy script" % self.application.name)
raise Exception('Could not import %s/%s/deploy/%s.py' % (workspace_path, self.application.name, f))
try:
func = getattr(m,f)
except:
log.error("Failed to call function %s" % f)
raise
# call the function, passing in the configuration
log.debug('Changing cwd to workspace')
os.chdir('%s/%s' % (workspace_path, self.application.name))
r = func(self.configuration)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment