1. Colin Copeland
  2. caktus-deployment

Source

caktus-deployment / example-django-project / caktus_website / fabfile.py

Diff from to

File example-django-project/caktus_website/fabfile.py

  • Ignore whitespace
     apache_reload()
 
 
-def configtest():
+def configtest():    
     """ test Apache configuration """
+    require('root', provided_by=('staging', 'production'))
     run('apache2ctl configtest')
 
 
-def apache_reload():
+def apache_reload():    
     """ reload Apache on remote host """
+    require('root', provided_by=('staging', 'production'))
     run('sudo /etc/init.d/apache2 reload')
 
 
-def apache_restart():
+def apache_restart():    
     """ restart Apache on remote host """
+    require('root', provided_by=('staging', 'production'))
     run('sudo /etc/init.d/apache2 restart')
 
 
-def symlink_django():
+def symlink_django():    
     """ create symbolic link so Apache can serve django admin media """
+    require('root', provided_by=('staging', 'production'))
     admin_media = os.path.join(env.virtualenv_root,
                                'src/django/django/contrib/admin/media/')
     media = os.path.join(env.code_root, 'media/admin')
     if not files.exists(media):
         run('ln -s %s %s' % (admin_media, media))
+
+
+def reset_local_media():
+    """ Reset local media from remote host """
+    require('root', provided_by=('staging', 'production'))
+    media = os.path.join(env.code_root, 'media', 'upload')
+    local('rsync -rvaz %s@%s:%s media/' % (env.user, env.hosts[0], media))