Commit 8787716d authored by Nicolas Wavrant's avatar Nicolas Wavrant

librecipe: new function in GenericBaseRecipe to get value from previous buildout run

parent 203ffbfa
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import ConfigParser
import io import io
import logging import logging
import os import os
...@@ -280,3 +281,18 @@ class GenericBaseRecipe(object): ...@@ -280,3 +281,18 @@ class GenericBaseRecipe(object):
except: except:
shutil.rmtree(destination) shutil.rmtree(destination)
raise raise
def getValueFromPreviousRun(self, section, parameter):
"""
Returns the value of a parameter from a previous run, if it exists.
Otherwise, returns None
"""
if os.path.exists(self.buildout['buildout']['installed']):
with open(self.buildout['buildout']['installed']) as config_file:
try:
parser = ConfigParser.RawConfigParser()
parser.readfp(config_file)
return parser.get(section, parameter)
except:
pass
return None
\ No newline at end of file
  • NACK. Look at buildout source code to see how it does, but I doubt you can do it properly without using its API. buildout 2.x does not even use ConfigParser anymore. Revert or reimplement differently.

    /cc @vpelletier @rafael

Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment