Author: dmeyer
Date: Mon Jan 29 20:09:34 2007
New Revision: 9076

Removed:
   trunk/ui/src/config/configfile.py
Modified:
   trunk/ui/src/config/__init__.py

Log:
merge config code back into one file

Modified: trunk/ui/src/config/__init__.py
==============================================================================
--- trunk/ui/src/config/__init__.py     (original)
+++ trunk/ui/src/config/__init__.py     Mon Jan 29 20:09:34 2007
@@ -141,33 +141,65 @@
         setattr(CONF, valname, '')
 
 #
-# fall back to x11 if display is mga or fb and DISPLAY ist set
-# or switch to fbdev if we have no DISPLAY and x11 or dga is used
+# Load freevo_config.py:
 #
-if os.environ.has_key('DISPLAY') and os.environ['DISPLAY']:
-    if CONF.display in ('mga', 'fbdev'):
-        print
-        print 'Warning: display is set to %s, but the environment ' % \
-              CONF.display + \
-              'has DISPLAY=%s.' % os.environ['DISPLAY']
-        print 'this could mess up your X display, setting display to x11.'
-        print 'If you really want to do this, start \'DISPLAY="" freevo\''
-        print
-        CONF.display='x11'
+FREEVO_CONFIG = os.path.join(freevo.conf.SHAREDIR, 'freevo_config.py')
+if os.path.isfile(FREEVO_CONFIG):
+    log.info('Loading cfg: %s' % FREEVO_CONFIG)
+    execfile(FREEVO_CONFIG, globals(), locals())
+    
 else:
-    if CONF.display == 'x11':
-        print
-        print 'Warning: display is set to %s, but the environment ' % \
-              CONF.display + \
-              'has no DISPLAY set. Setting display to fbdev.'
-        print
-        CONF.display='fbdev'
+    log.critical("Error: %s: no such file" % FREEVO_CONFIG)
+    sys.exit(1)
 
 
 #
-# load the config file
+# Search for local_conf.py:
 #
-execfile(os.path.join(os.path.dirname(__file__), 'configfile.py'))
+
+has_config = False
+for a in sys.argv:
+    if has_config == True:
+        has_config = a
+    if a == '-c':
+        has_config = True
+    
+for dirname in freevo.conf.cfgfilepath:
+    if isinstance(has_config, str):
+        overridefile = has_config
+    else:
+        overridefile = dirname + '/local_conf.py'
+    if os.path.isfile(overridefile):
+        log.info('Loading cfg overrides: %s' % overridefile)
+        execfile(overridefile, globals(), locals())
+        break
+
+else:
+    locations = ''
+    for dirname in freevo.conf.cfgfilepath:
+        locations += '  %s\n' % dirname
+    log.critical("""local_conf.py not found
+Freevo is not completely configured to start
+
+The configuration is based on three files. This may sound oversized, but this
+way it's easier to configure. First Freevo loads a file called 'freevo.conf'.
+This file will be generated by 'freevo setup'. Use 'freevo setup --help' to get
+information about the parameter. Based on the informations in that file, Freevo
+will guess some settings for your system. This takes place in a file called
+'freevo_config.py'. Since this file may change from time to time, you should
+not edit this file. After freevo_config.py is loaded, Freevo will look for a
+file called 'local_conf.py'. You can overwrite the variables from
+'freevo_config.py' in here. There is an example for 'local_conf.py' called
+'local_conf.py.example' in the Freevo distribution.
+    
+The location of freevo_config.py is %s
+Freevo searches for freevo.conf and local_conf.py in the following locations:
+%s
+
+Since it's highly unlikly you want to start Freevo without further
+configuration, Freevo will exit now.
+"""  % (FREEVO_CONFIG, locations))
+    sys.exit(0)
 
 #
 # force fullscreen when freevo is it's own windowmanager
@@ -261,32 +293,8 @@
                                      VIDEO_SHOW_REGEXP + "[\.\- ]*").split
 
 
-# auto detect function
-def detect(*what):
-    for module in what:
-        exec('import %s' % module)
-
-
 # make sure USER and HOME are set
 os.environ['USER'] = pwd.getpwuid(os.getuid())[0]
 os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
 
-
-#
-# Some code for users converting from older versions of Freevo
-#
-
-try:
-    LOCALE
-    log.critical('LOCALE is deprecated.')
-    sys.exit(0)
-except NameError, e:
-    pass
-    
-try:
-    OVERLAY_DIR
-    log.critical('OVERLAY_DIR is deprecated. Set overlay dir on beacon' +\
-                 '  startup to change the location of the virtual file system')
-    sys.exit(0)
-except NameError, e:
-    pass
+cfgfilepath = freevo.conf.cfgfilepath

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to