def _dumpRegsitry(self): out = '%s-reg.pkl' % self.name if os.path.exists(out): raise RuntimeError, 'dump registry: path %s already exists' % out from pyre.applications.Application import retrieveConfiguration reg = self.createRegistry() retrieveConfiguration(self.inventory, reg) from RegistryToDict import Renderer renderer = Renderer() reg = renderer.render(reg) import pickle pickle.dump(reg, open(out, 'w')) return
def _dumpRegsitry(self): out = '%s-reg.pkl' % self.name import os if os.path.exists(out): raise RuntimeError, 'dump registry: path %s already exists' % out from pyre.applications.Application import retrieveConfiguration reg = self.createRegistry() retrieveConfiguration(self.inventory, reg) from RegistryToDict import Renderer renderer = Renderer() reg = renderer.render(reg) import pickle pickle.dump(reg, open(out, 'w')) return
def _saveConfiguration(self): # the default configuration filename default_filename = '%s.pml' % self.name # the given filename dumppml = self.inventory.dumppml if dumppml in ['yes', 'on', 'true']: outfile = default_filename else: outfile = dumppml # make sure the output path does not exist import os if os.path.exists(outfile): # save the old configuration timeformat = '%m-%d-%Y--%H-%M-%S' import time, shutil timestr = time.strftime(timeformat) newfilename = '%s.saved-%s' % (outfile, timestr) shutil.copyfile(outfile, newfilename) # get registry registry = self.createRegistry() exclude_props = [ 'weaver', 'typos', 'dumpconfiguration', 'dumpconfiguration-output', 'help-properties', 'help', 'help-persistence', 'help-components', 'dump-pml', 'buffer_size', 'mode', ] from pyre.applications.Application import retrieveConfiguration registry = retrieveConfiguration( self.inventory, registry, excludes=exclude_props) # the output stream stream = open(outfile, 'w') # weave self.weaver.weave( registry, stream ) # footer stream.write('<!-- \n automatically created by the following command:\n') cmd = _getCmdStr() stream.write(' $ %s\n' % cmd) stream.write('-->\n\n') # give a warning when use non-default config filename import os, sys base = os.path.basename(outfile) if base != default_filename: print '*'*70 print "Warning: you will need to rename file %s to %s, otherwise this file won't be used by the simulation application %s" % ( outfile, default_filename, os.path.basename(sys.argv[0])) print '*'*70 return
def _saveConfiguration(self): # the default configuration filename default_filename = '%s.pml' % self.name # the given filename dumppml = self.inventory.dumppml if dumppml in ['yes', 'on', 'true']: outfile = default_filename else: outfile = dumppml # make sure the output path does not exist import os if os.path.exists(outfile): # save the old configuration timeformat = '%m-%d-%Y--%H-%M-%S' import time, shutil timestr = time.strftime(timeformat) newfilename = '%s.saved-%s' % (outfile, timestr) shutil.copyfile(outfile, newfilename) # get registry registry = self.createRegistry() exclude_props = [ 'weaver', 'typos', 'dumpconfiguration', 'dumpconfiguration-output', 'help-properties', 'help', 'help-persistence', 'help-components', 'dump-pml', 'buffer_size', 'mode', ] from pyre.applications.Application import retrieveConfiguration registry = retrieveConfiguration(self.inventory, registry, excludes=exclude_props) # the output stream stream = open(outfile, 'w') # weave self.weaver.weave(registry, stream) # footer stream.write( '<!-- \n automatically created by the following command:\n') cmd = _getCmdStr() stream.write(' $ %s\n' % cmd) stream.write('-->\n\n') # give a warning when use non-default config filename import os, sys base = os.path.basename(outfile) if base != default_filename: print '*' * 70 print "Warning: you will need to rename file %s to %s, otherwise this file won't be used by the simulation application %s" % ( outfile, default_filename, os.path.basename(sys.argv[0])) print '*' * 70 return