Exemplo n.º 1
0
def loadRealm(self,fn):
  global config
  global worldList
  status.push(0,"Destroying menus...")
  clearMenus()
  status.push(0,"Clearing worldList...")
  worldList = {} # clear worldList
  status.push(0,"Reloading config...")
  backends.killRealmOpts()
  status.push(0,"Loading realm...")
  config.update(backends.loadRealm(fn))
  status.push(0,"Populating realm...")
  common.updateTitle()
  backends.populateWorld()
  status.push(0,"Building menus...")
  doMenus(self)
  pass
Exemplo n.º 2
0
def mkRealm(caller,self,fileid,name,rdir):
  global config
  realms = backends.listRealms()
  (e,f,g) = getmod.listSelectBox("?",realms,title="Choose a realm to mimic",abort="None")
  if f is None or f == "":
    print "cancel"
  else:
    print "Creating %s from %s"% (fileid,f)
    old = backends.loadRealm(f)
    config.update(old)
  config['realmname'] = name # "New Realm"
  config['realmdir'] = rdir # "realms/default/"
  config['realmfile'] = fileid
  backends.saveRealm(fileid)
  loadRealm(self,"realms/%s.rlm" % fileid)
  options.optionSetter(caller,self.window,False)
  saveRealm(fileid)
Exemplo n.º 3
0
def loadConfig(fn = None,recursion = 0):
  """Returns a dict containing the config options in the Minette config file."""
  maxrecursion = 3
  lines = []
  global config
  global defaults
  if fn is None:
    fn = "default.cfg" # using 3-letter extension for MSWin compatibility, I hope.
  (found,fn) = findFile(lineno(),fn)
  if not found:
    print " [W] Config %s not loaded." % fn
    if not defaults.get("set",False):
      setDefaults()
    config.update(defaults)
    return config
  lines = readfile(fn)
  for line in lines:
    try:
      line = line.strip()
      if line:
        values = [x.strip() for x in line.split('=')]
        if values[0] != "loadconfig":
          if not config.get(values[0]): config[values[0]] = values[1] # existing options will not be clobbered
        elif recursion < maxrecursion and os.path.exists(values[1]): # loadconfig must be first option, or its options may be ignored.
          recursion += 1
          loadConfig(values[1],recursion)
    except Exception as e:
      print " [E] There was an error in the configuration file: %s" % e
  config['file'] = fn
  config = validateConfig(config)
  config['realmfile'] = ""
  if len(config.get("loadrealm","")) > 0 and recursion <= maxrecursion:
    rf = "realms/%s.rlm" % config['loadrealm']
    realm = loadRealm(rf)
    config.update(realm)
  else:
    config['realmloaded'] = False
  config.update(criticalDefaults())
  return config
Exemplo n.º 4
0
def copyOpts(o):
  global config
  config.update(o)