Commits

Benoit C committed fee865f

fabulator is now a package

Comments (0)

Files changed (5)

src/decorators.py

-# -*- coding: latin-1 -*-
-"""
-
-
-
-"""
-import traceback
-
-
-from mexceptions import ImproperlyConfigured
-
-
-# how it sux !
-class Decorate(object):
-    def __init__(self):
-        pass
-        
-    def __call__(self, func):
-        pass
-
-
-class Permissions(Decorate):
-    def __init__(self, username, env):
-        self.username = username
-        self.env = env
-        
-    def __call__(self, func):
-        def _wrapper(*args, **kwargs):
-            try:
-                self.env.user = self.env.yaml.get('project').get(self.username)
-            except Exception, e:
-                raise ImproperlyConfigured("did you configured the 'project' part of your settings ?")
-            if not self.env.user:
-                raise ImproperlyConfigured("did you configured the 'project' part of your settings ?")
-            print func
-            return func(*args, **kwargs)
-
-        return _wrapper
-
-class ConfChecker(Decorate):
-    def __init__(self, conf, env):
-        self.conf = conf
-        self.env = env
-    
-    def __call__(self, func):
-        def _wrapper(*args, **kwargs):
-            conf = self.env.yaml
-            if not self.conf in conf:
-                raise ImproperlyConfigured("does %s exists in your configuration file ?" % self.conf)
-            return func(*args, **kwargs)
-
-        return _wrapper
 import datetime
 from fabric.api import *
 from fabric.contrib.files import exists, sed
-from decorators import Permissions, ConfChecker
+from fabulator.decorators import Permissions, ConfChecker
 
 import yaml
 import time
 @ConfChecker("database", env)
 def backup_database():
     conf = env.yaml.get("database")
-    print conf
     date = datetime.datetime.now()
     
     conf['backup_fname'] = "%s/backup-%s-%d-%d-%d-%s.sql" % \
     
     conf = env.yaml.get("database")
     django = env.yaml.get("django")
+    venv = env.yaml.get("virtualenv")
     
     with cd(django.get("src_dir")):
+        run("%(bin_dir)s/python manage.py migrate --all" % venv)
         pass
 
     

src/fabulator/decorators.py

+# -*- coding: latin-1 -*-
+"""
+
+
+
+"""
+import traceback
+
+from fabulator.exeptions import ImproperlyConfigured
+
+# how it sux !
+class Decorate(object):
+    def __init__(self):
+        pass
+        
+    def __call__(self, func):
+        pass
+
+
+class Permissions(Decorate):
+    def __init__(self, username, env):
+        self.username = username
+        self.env = env
+        
+    def __call__(self, func):
+        def _wrapper(*args, **kwargs):
+            try:
+                self.env.user = self.env.yaml.get('project').get(self.username)
+            except Exception, e:
+                raise ImproperlyConfigured("did you configured the 'project' part of your settings ?")
+            if not self.env.user:
+                raise ImproperlyConfigured("did you configured the 'project' part of your settings ?")
+            print func
+            return func(*args, **kwargs)
+
+        return _wrapper
+
+class ConfChecker(Decorate):
+    def __init__(self, conf, env):
+        self.conf = conf
+        self.env = env
+    
+    def __call__(self, func):
+        def _wrapper(*args, **kwargs):
+            conf = self.env.yaml
+            if not self.conf in conf:
+                raise ImproperlyConfigured("does %s exists in your configuration file ?" % self.conf)
+            return func(*args, **kwargs)
+
+        return _wrapper

src/fabulator/exceptions

+"""
+    Some exceptions \o/
+"""
+
+class ImproperlyConfigured(Exception):
+    # from django ;)
+    "fabulator is somehow improperly configured"
+    pass

src/mexceptions.py

-"""
-    Some exceptions \o/
-"""
-
-class ImproperlyConfigured(Exception):
-    # from django ;)
-    "fabulator is somehow improperly configured"
-    pass