def versioninfo_update(group, app, version): xml = get_versioninfo() dom = fromstring(xml) """ find group """ groupxml = None for node in dom: if node.attrib['name'] == group: groupxml = node if groupxml == None: groupxml = Element('group') groupxml.attrib['name'] = group dom.append(groupxml) for node in groupxml: if node.attrib['name'] == app: groupxml.remove(node) appxml = Element('application') appxml.attrib['name'] = app appxml.attrib['version'] = version groupxml.append(appxml) write_versioninfo(tostring(dom))
def info(): xml = get_versioninfo() dom = fromstring(xml) for group in dom: print "Group: " + group.attrib['name'] for app in group: print " - App: " + app.attrib['name'], 'Version: ' + app.attrib['version']
def compare_applications(): """ If true, we stopped the servers because of an change, so they need to be started again at the end """ group = settings.GROUP local = open(settings.APPS_LOCALINFO).read() remote = remote = get_versioninfo() """ Collect app list for local and remove """ localApps = get_app_list(local) remoteApps = get_app_list(remote, group) """ First, check for apps to remove """ for app, localVersion in localApps.items(): found = False for remoteApp, version in remoteApps.items(): if app == remoteApp: found = True if not found: uninstall(app) """ Now check for new apps """ for app, version in remoteApps.items(): found = False for localApp, localVersion in localApps.items(): if app == localApp: found = True if not found: install(app, version) """ Now check for apps to upgrade """ for app, version in remoteApps.items(): diff = False for localApp, localVersion in localApps.items(): if app == localApp and version != localVersion: diff = True if diff: upgrade(app, version) handle_webserver()