#!/usr/bin/env python3 import html import cgi import os import funct from configparser import ConfigParser, ExtendedInterpolation import glob form = cgi.FieldStorage() serv = form.getvalue('serv') funct.head("Old Versions HAproxy config") funct.check_config() funct.check_login() path_config = "haproxy-webintarface.config" config = ConfigParser(interpolation=ExtendedInterpolation()) config.read(path_config) hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir') funct.page_for_admin() funct.chooseServer("delver.py", "Delete Versions HAproxy config", "n") if serv is not None and form.getvalue('open') is not None: print('

Choose old version

') print('
' '' '
') os.chdir(hap_configs_dir) for files in sorted(glob.glob('*.cfg')): ip = files.split("-") if serv == ip[0]: print('
' % (files, files, files, files, files)) print('' % serv) print('') print('') print('

') funct.get_button("Delete") print('

') Select = form.getvalue('del') if Select is not None: os.chdir(hap_configs_dir) print("The following files were deleted:
") for get in form: if "cfg" in get: try: os.remove(form.getvalue(get)) print(form.getvalue(get) + "
") funct.logging(serv, "delver.py deleted config: %s" % form.getvalue(get)) except OSError: print ("Error: %s - %s." % (e.filename,e.strerror)) print('' % form.getvalue('serv')) funct.footer()