Source

fabulator / src / fabfile.py

Diff from to

File src/fabfile.py

 from fabulator.core.http import http_factory
 from fabulator.core.system import os_factory
 from fabulator.core.virtualenv import VirtualEnv
+from fabulator.core.django import Django
 
 import yaml
 import time
     # we can be more magic here
     if "vc" in conf:
         env.vc = vc_factory(conf["vc"].get("type"), conf.get("vc"), env)
-    if "database" in conf:
-        env.db = database_factory(conf["database"].get("type"), conf.get("database"), env)
+    if "db" in conf:
+        env.db = database_factory(conf["db"].get("type"), conf.get("db"), env)
     if "httpd" in conf:
         env.httpd = http_factory(conf["httpd"].get("type"), conf.get("httpd"), env)
     if "virtualenv" in conf:
         env.virtualenv = VirtualEnv(conf.get("virtualenv"), env)
-    if "os" in conf:
-        
-        env.os = os_factory(conf["os"].get("type"), conf.get("os"), env)
-    else:
-        print "fu"
+    if "distro" in conf:
+        env.os = os_factory(conf["distro"].get("name"), conf.get("distro"), env)
+    if "django" in conf:
+        env.django = Django(conf.get("django"), env)
+
 
 def preprod(conf="conf.yaml"):
     """Preprod tasks"""
     build(env.yaml)
 
 
-@Permissions("sudo_user", env)
-@ConfChecker("services", env)
-def services_reload():
-    """Reloads your services"""
-    services = env.yaml.get('services').get('reload')
-    for service in services:
-        sudo("/etc/init.d/%s reload" % service)
-    print services
-
-@Permissions("sudo_user", env)
-@ConfChecker("services", env)
-def services_restart():
-    """Restarts your services"""
-    services = env.yaml.get('services').get('restart')
-    for service in services:
-        sudo("/etc/init.d/%s restart" % service)
-
-    
-
 def update():
     """updates the code and everything else"""
-    distro_install()
-
-    update_hg()
-    
-    virtualenv()
-
-    install_httpd_vhost()
-
-    # install django configuration
-    django_settings()
-
-    update_database()
- 
-
-    # start/restart the wsgi/fcgi process
-    wsgi_restart()
-
-    # restart other services
-    services_reload()
-    services_restart()
-
-
+    env.vc.update_repository()
 
 
 def install():
     """for the first install onto the machines"""
-
-    print env.os
-    print env.httpd
-    print env.db
-    print env.vc
-    
-    env.os.install_packages()
+    #env.os.install_packages()
     env.vc.clone_repository()
+    env.vc.switch_branch(env.vc.conf.get("branch"))
     env.virtualenv.create_virtualenv()
     env.virtualenv.install_requirements(False)
     
-    env.db.create_database()
+    #env.db.create_database
+    #env.django.configure()
+    #env.django.syncdb()
+    #env.django.runserver()
 
 
-
-#    # install required packages 
-#    distro_install()
-#
-#    # update the hg repos
-#    update_hg()
-#    
-#    # install or update the virtualenv
-#    virtualenv()
-#
-#    # install the vhost required for the django application
-#    install_httpd_vhost()
-#
-#
-#    # install django configuration
-#    django_settings()
-#    
-#    # install the database schema
-#    install_database()
-#
-#    # start/restart the wsgi/fcgi process
-#    wsgi_restart()
-#
-#    # restart other services
-#    services_reload()
-#    services_restart()
-
 def reset():
     env.vc.remove_repository()
-    env.db.drop_database()
-
-@Permissions("sudo_user", env)
-def nginx_logs():
-    sudo("sudo tail -f /var/log/nginx/*.log")
-
-
-@Permissions("sudo_user", env)
-@ConfChecker("distro", env)
-def distro_install():
-    """Installs required packages"""
-    # install packages specified in the yaml conf
-    dist_conf = env.yaml.get('distro')
-    if dist_conf.get('name') in ('ubuntu', 'debian'):
-        for package in dist_conf.get('packages'):
-            sudo("apt-get install %s" % package)
-
-@Permissions("sudo_user", env)
-@ConfChecker("distro", env)
-def delete_database():
-    db = env.yaml.get('database')
-    mysql.drop_database(db)
-
-@Permissions("sudo_user", env)
-@ConfChecker("distro", env)
-def delete_repos():
-    conf = env.yaml.get('project')
-    run("rm -Rf %(doc_root)s" % conf)
-
-
-
-
-@Permissions("normal_user", env)
-@ConfChecker("database", env)
-def install_database():
-    """Install your database schema"""
-    conf = env.yaml.get("database")
-    django = env.yaml.get("django")
-    venv = env.yaml.get("virtualenv")
-
-    mysql.create_database(conf)
-    if django.get('south'):
-        south.install_south(env)
-
-    with cd("%(src_dir)s" % django):
-        if django.get('south'):
-            run("%(bin_dir)s/python manage.py migrate --all" % venv)
-        else:
-            run("%(bin_dir)s/python manage.py syncdb --noinput" % venv)
+    #env.db.drop_database()
 
 
 @Permissions("normal_user", env)