Viewing file: config.py (3.8 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# # config.py - config fileand default argument handling # # Copyright 2002, 2003 Red Hat, Inc. # # This software may be freely redistributed under the terms of the GNU # General Public License. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
import os
PROGNAME='system-config-packages' GLADEDIR='/usr/share/system-config-packages/glade/' PIXMAPSDIR='/usr/share/pixmaps/' RHCPIXMAPSDIR='/usr/share/pixmaps/system-config-packages/' MAX_PACKAGE_REMOVE_WARN=200 COMPS_BLACK_LIST = ['base-x', 'gnome-desktop', 'kde-desktop', 'printing']
install_pkgs = [ "kernel", "kernel-unsupported", "kernel-smp", "kernel-bigmem", "kernel-hugemem", "kernel-smp-unsupported", "kernel-bigmem-unsupported", "kernel-hugemem-unsupported" ]
# takes an argument of a list of (arg, val) tuples from getopt.getopt def get_method(args = []): import method import urlmethod
tree = None isodir = None url = None do_help = 0 for (arg, val) in args: if arg in ('-t', '--tree'): if val.startswith("file://"): tree = val[9:] elif val.startswith("dir://"): tree = val[8:] elif val.startswith("ftp://") or val.startswith("http://"): url = val else: tree = val elif (arg == '--isodir'): isodir = val elif (arg == "--url"): url = val
if tree is not None: return method.TreeInstallMethod(tree) elif isodir is not None: return method.LoopbackIsoInstallMethod(isodir) elif url is not None: return urlmethod.UrlInstallMethod(url)
# they didn't specify a method -- fall back to the default behavior
# note: this is completely unsupported. this file is highly likely to # go away in the future. do not count on its existence. it is mainly # a convenience to people who like reading source code ;-) try: if os.access("/etc/system-config-packages.method", os.O_RDONLY): f = open("/etc/system-config-packages.method", "r") lines = f.readlines() f.close()
for line in lines: if line.startswith("TREE="): tree = line[5:] return method.TreeInstallMethod(tree) elif line.startswith("ISODIR="): isodir = line[7:] return method.LoopbackIsoInstallMethod(isodir) elif line.startswith("DEVICE="): device = line[7:] return method.RedHatCdromInstallMethod(device) elif line.startswith("URL="): url = line[4:] return urlmethod.UrlInstallMethod(url)
except: pass
return method.RedHatCdromInstallMethod()
def default_short_args(): return "t:"
def default_long_args(): return ["tree=", "isodir=", "help"]
def default_args_help(): return "[--help] [--tree=PATH] [--isodir=PATH]"
def get_fallback_mountpoint(): # note: this is completely unsupported. this file is highly likely to # go away in the future. do not count on its existence. it is mainly # a convenience to people who like reading source code ;-) try: for fn in ("/etc/system-config-packages.method", "/etc/redhat-config-packages.method"): if os.access(fn, os.O_RDONLY): f = open(fn, "r") lines = f.readlines() f.close()
for line in lines: if line.startswith("MOUNTPOINT="): return line[11:] break except: pass
return "/media/cdrom"
|