|
From: Oscar H. <osc...@us...> - 2005-08-15 22:15:18
|
Update of /cvsroot/mnet/darcs-mnet/mnetlib/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24538 Modified Files: startup.py Log Message: A file called mtlist.txt in the conf directory is now read for bootpages. If no such file exists it reads the default bootpages. Index: startup.py =================================================================== RCS file: /cvsroot/mnet/darcs-mnet/mnetlib/scripts/startup.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- startup.py 14 Mar 2005 19:51:51 -0000 1.3 +++ startup.py 15 Aug 2005 22:15:08 -0000 1.4 @@ -73,16 +73,69 @@ REALLY_SLOW_DEBUG_MODE = False -# mnet-specific default-URL-list +# HOME_DIR is a "home directory" such as /home/johndoe on unix systems. It is +# dictated here for flexibility's sake. +if os.environ.has_key('HOME'): + HOME_DIR = os.environ['HOME'] +else: + # The environment variable wasn't set, so start guessing. + if sys.platform in ("linux", "bsd", "irix", "sunos", "darwin",): + HOME_DIR = os.path.normpath("/var/tmp/mnet") + # If we are running in win32 use "My Documents" + # AAAAAAARNOOOOOOO! + #elif sys.platform in ("win32", ): + # from win32comext.shell import shell, shellcon + # HOME_DIR = str(shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_PERSONAL)) + else: + HOME_DIR = os.getcwd() + +# What if our guesses or the given HOME environment variable refs a non-existent dir? +if not os.path.exists(HOME_DIR): + HOME_DIR = os.getcwd() +if os.environ.has_key('MNETCONFDIR'): + NODE_DIR = os.path.normpath( + os.environ.get('MNETCONFDIR') + ) +elif sys.platform in ("win32",): + import _winreg # XXX PLATFORM NOTE + # Requires Python >= 2.0, but anyone using MN with Python < 2.0 on win32 + # is an idiot who should be mocked ruthlessly... (okay, next person to touch + # this file gets to remove this comment) -jim + # XXX + # This lookup should be changed to use HKEY_LOCAL_MACHINE for system-wide keys + # + # The installer should put the MNETCONFDIR into Software\\MN\\MN_NODE\\NODE_DIR + regroot = "Software\\MN\\MN_NODE" + try: + regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, regroot) + NODE_DIR = str(_winreg.QueryValue(regkey, "NODE_DIR")) + except EnvironmentError: + NODE_DIR = os.path.normpath(os.path.join(HOME_DIR, ".mnet")) +else: + # The environment variable wasn't set, so use this hardcoded constant: + NODE_DIR = os.path.normpath( + os.path.join(HOME_DIR, ".mnet") + ) + # !X! Note: Make sure all platforms can have directory names beginning with ".". + +# Once again, we need to deal with MNETCONFDIRs that do not exist... +if not os.path.exists(NODE_DIR): + os.makedirs(NODE_DIR, 700) + + +# mnet-specific default-URL-list +if (NODE_DIR + "mtlist.txt"): + #DEFAULT_BOOTPAGE_URLS = [] + DEFAULT_BOOTPAGE_URLS = file(NODE_DIR + "/mtlist.txt").readlines() + DEFAULT_BOOTPAGE_URLS = map(string.strip,DEFAULT_BOOTPAGE_URLS) +else: DEFAULT_BOOTPAGE_URLS = [ 'http://poro.maski.org:4242/bootpage/', 'http://81.231.230.175:22088/bootpage/', 'http://baka.no-ip.biz:3335/bootpage/', 'http://130.89.169.95:34297/bootpage/',] - - # load MV from env if present if os.environ.has_key('MAX_VERBOSITY'): mv = int(os.environ.get('MAX_VERBOSITY')) |