Colin Copeland avatar Colin Copeland committed 05edc18

add reset_local_media example

Comments (0)

Files changed (2)

example-django-project/caktus_website/fabfile.py

     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))

mallet/client_vm.py

 
 
 class Postgres(lenny.Postgres):
-    packages = ['postgresql', 'postgresql-server-dev-8.4']
+    packages = ['postgresql', 'postgresql-server-dev-8.4', 'pwgen']
 
     def post_install(self, node_wrapper):
         call(['locale-gen', 'en_US.UTF-8'])
 
 class Python(PackageGroup):
     packages = ['ipython', 'python-setuptools', 'python-dev', 'libpq-dev',
-                'libapache2-mod-wsgi']
+                'libapache2-mod-wsgi', 'python-imaging']
 
     def post_install(self, node_wrapper):
         call(['easy_install', '-U', 'pip'])
         call(['pip', 'install', '-U', 'virtualenv'])
         call(['pip', 'install', '-U', 'distribute'])
+        call(['pip', 'install', '-U', 'distribute'])
+        call(['pip', 'install', '-U', 'psycopg2'])
 
 
 class Apache(lenny.Apache):
             logger.info('Creating database user')
             call(['sudo', '-u', 'postgres', 'createuser', '--no-superuser',
                   '--createdb', '--no-createrole', name])
+            call(['sudo', '-u', 'postgres', 'createdb', name, '-O', name])
 
             # TODO add configuration option for apache
             logger.info('Adding Apache configuration')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.