Commits

Marko Loparic  committed 4ca4dc5

[launch] workaround to make the launcher work with execfile

  • Participants
  • Parent commits 7b7f23e

Comments (0)

Files changed (1)

File launch_console.py

 
 script_path = os.path.abspath(sys.argv[0])
 sys.path.insert(0, os.path.dirname(os.path.dirname(script_path)))
-#print 'sys.path =', sys.path
+print 'sys.path =', sys.path
 
 from limma.main import main
 from limma.launch_defaults import SHAREDDRIVE_DIR, DEFAULT_CONFIG
 LOCAL_SUBDIR = 'Limma'
 CONFIG_FNAME = 'limma.ini'
 
-def launch_console():
+# XX: don't use functions here!
+# - the code is called with execfile, global names don't work as expected
+#   inside functions!
 
-    # TODO: test receipt for "-u" in http://stackoverflow.com/questions/881696
-    # - perhaps better: http://stackoverflow.com/questions/107705
+# TODO: test receipt for "-u" in http://stackoverflow.com/questions/881696
+# - perhaps better: http://stackoverflow.com/questions/107705
 
-    # get default config and tell that the console is to be used
-    config = DEFAULT_CONFIG
-    config['interface'] = 'console'
+# get default config and tell that the console is to be used
+config = DEFAULT_CONFIG
+config['interface'] = 'console'
 
-    # look for local config file
-    config_found = False
-    appdata_dir = os.environ.get('APPDATA')
-    if appdata_dir:
-        config_fname = os.path.join(appdata_dir, LOCAL_SUBDIR, CONFIG_FNAME)
-        if os.path.exists(config_fname):
-            config_found = True
+# look for local config file
+config_found = False
+appdata_dir = os.environ.get('APPDATA')
+if appdata_dir:
+    config_fname = os.path.join(appdata_dir, LOCAL_SUBDIR, CONFIG_FNAME)
+    if os.path.exists(config_fname):
+        config_found = True
 
-    # look for config file in the shared drive (if no local config file)
-    if not config_found:
-        config_fname = os.path.join(SHAREDDRIVE_DIR, CONFIG_FNAME)
-        if os.path.exists(config_fname):
-            config_found = True
+# look for config file in the shared drive (if no local config file)
+if not config_found:
+    config_fname = os.path.join(SHAREDDRIVE_DIR, CONFIG_FNAME)
+    if os.path.exists(config_fname):
+        config_found = True
 
-    # override default config with config from file
-    if config_found:
-        # using print, since no logger activated at this point
-        print("Found configuration file in %s" % config_fname)
-        config.update(ConfigObj(config_fname))
-        
-    args = []
-    main(config, args)
+# override default config with config from file
+if config_found:
+    # using print, since no logger activated at this point
+    print("Found configuration file in %s" % config_fname)
+    config.update(ConfigObj(config_fname))
 
-if __name__ == '__main__':
-    # no command-line parameters allowed
-    launch_console()
+args = []
+main(config, args)
+