#!/usr/bin/env python
+import warnings
+warnings.filterwarnings("ignore", "", DeprecationWarning)
+
import xmllib
import sys, os, string, re
# define xml file -----------------
if (xml_file is None) :
xml_file_name = "config.xml"
- if os.path.exists("/proc/version"):
- data = open("/proc/version").readline()
- res = re.search(r'Red\s+Hat\s+\w+(\s+)?(\d[.]\d)', data)
+ if os.path.exists("/etc/redhat-release"):
+ data = open("/etc/redhat-release").readline()
+ res = re.search(r'Red\s+Hat\s+Linux\s+release\s+([\d.]*)', data)
if res is not None:
- num = re.sub("[.]", "_", (res.groups())[1])
+ num = re.sub("[.]", "_", (res.groups())[0])
filename = "config_RedHat" + num+ ".xml"
if (os.path.exists(cur_dir + filename)):
xml_file_name = filename
-
+ else:
+ res = re.search(r'Mandrakelinux\s+release\s+([\d.]*)', data)
+ if res is not None:
+ num = re.sub("[.]", "_", (res.groups())[0])
+ filename = "config_Mandrake" + num+ ".xml"
+ if (os.path.exists(cur_dir + filename)):
+ xml_file_name = filename
xml_file = cur_dir + xml_file_name
+
if xml_file is None or not os.path.exists(xml_file):
error_exit("No xml file is found, try to run with options -f <xmlfile>")