add exception trace
authorymh <ymh.work@gmail.com>
Mon, 17 Nov 2014 14:34:16 +0100
changeset 21 57bbeb60c60b
parent 20 7fe7c089c1f2
child 22 89114c0a6ad7
add exception trace
src/fablib/core.py
--- a/src/fablib/core.py	Mon Nov 10 02:29:47 2014 +0100
+++ b/src/fablib/core.py	Mon Nov 17 14:34:16 2014 +0100
@@ -111,11 +111,15 @@
             print("Build source dist at %s : found setup" % path)
             setup_mod = imp.load_module("setup", f, pathname, description)
             print("Build source dist at %s : setup loaded" % path)
+        except:
+            e = sys.exc_info()[0]
+            print("Error when building %s : %s" % (path, str(e)))
+            raise
         finally:
             if f:
                 f.close()
             
-            setup_mod.launch_setup("setup.py", ['sdist'])
+        setup_mod.launch_setup("setup.py", ['sdist'])
     finally:
         os.chdir(current_path)
     print("Build source dist at %s done" % path)
@@ -208,19 +212,19 @@
                 run("pip uninstall -y %s" % module_to_uninstall)
         run("pip install \"%s\"" % remotepath)
 
-def collectstatic(remotepath, remotevirtualenvpath, platform_web_module):
+def collectstatic(remotepath, remotevirtualenvpath, platform_web_module, module_settings=""):
     print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath))
     remotestaticsitepath = get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, "STATIC_ROOT")
     activate_path = os.path.join(remotevirtualenvpath, "bin/activate")
     with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath):
-        #remocve old files optio -c of collect static fail !
+        #remove old files optio -c of collect static fail !
         run("rm -fr \"%s\"" % (remotestaticsitepath))
-        run("python manage.py collectstatic --noinput")
+        run("python manage.py collectstatic --noinput %s" % ("--settings="+module_settings if module_settings else ""))
 
-def syncdb(remotepath, remotevirtualenvpath):
+def syncdb(remotepath, remotevirtualenvpath, module_settings=""):
     activate_path = os.path.join(remotevirtualenvpath, "bin/activate")
     with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath):
-        run("python manage.py syncdb --migrate --noinput")
+        run("python manage.py syncdb --migrate --noinput %s" % ("--settings="+module_settings if module_settings else ""))
         
 def create_config(export_path):    
     print("Create config from %s" % (export_path,))
@@ -334,9 +338,9 @@
     if do_check_folder_access:
         check_folder_access()
     if do_syncdb:
-        syncdb(env.remote_path['src'], env.remote_path['virtualenv'])
+        syncdb(env.remote_path['src'], env.remote_path['virtualenv'], env.get('settings', ''))
     if do_collectstatic:
-        collectstatic(env.remote_path['src'], env.remote_path['virtualenv'], env.platform_web_module)
+        collectstatic(env.remote_path['src'], env.remote_path['virtualenv'], env.platform_web_module, env.get('settings', ''))
     sudo(env.web_relaunch_cmd, shell=False)