def setJsonFilename(self,applicationname): from leginon import version leginondir = version.getInstalledLocation() jsonpath = os.path.join(leginondir,'applications',applicationname+'_Settings.json') while not os.path.isfile(jsonpath): jsonpath = raw_input("Can not find the file from default path, Please specify: ") self.jsonfile = jsonpath
def getReleaseRevisionFromXML(self,module_path='.'): if not module_path: module_path = version.getInstalledLocation() module_path = os.path.abspath(module_path) pieces = module_path.split('/') xmlpathpieces = pieces[:-1] xmlpathpieces.extend(['myamiweb','xml','projectDefaultValues.xml']) xmlfilepath = '/'.join(xmlpathpieces) print '\033[35mGetting release revision from %s\033[0m' % xmlfilepath curkey = None installdata = {} try: xmlapp = dom.parse(xmlfilepath) except: raise ValueError('unable to parse XML file "%s"' % xmlfilepath) defaulttables = xmlapp.getElementsByTagName('defaulttables')[0] data = defaulttables.getElementsByTagName('data')[0] sqltables = defaulttables.getElementsByTagName('sqltable') for node in sqltables: if node.attributes['name'].value == 'install': for n in node.childNodes: if n.nodeName == 'field': if n.attributes['name'].value == 'key': curkey = n.firstChild.data if n.attributes['name'].value == 'value': installdata[curkey] = n.firstChild.data if 'revision' in installdata: return int(installdata['revision'])