fabfile.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from fabric.api import *
  2. import fabric.contrib.project as project
  3. import os
  4. # Local path configuration (can be absolute or relative to fabfile)
  5. env.deploy_path = 'output'
  6. DEPLOY_PATH = env.deploy_path
  7. # Remote server configuration
  8. production = 'guilmour@localhost:22'
  9. dest_path = '/var/www/'
  10. # Rackspace Cloud Files configuration settings
  11. env.cloudfiles_username = 'my_rackspace_username'
  12. env.cloudfiles_api_key = 'my_rackspace_api_key'
  13. env.cloudfiles_container = 'my_cloudfiles_container'
  14. def clean():
  15. if os.path.isdir(DEPLOY_PATH):
  16. local('rm -rf {deploy_path}'.format(**env))
  17. local('mkdir {deploy_path}'.format(**env))
  18. def build():
  19. local('pelican -s pelicanconf.py')
  20. def rebuild():
  21. clean()
  22. build()
  23. def regenerate():
  24. local('pelican -r -s pelicanconf.py')
  25. def serve():
  26. local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
  27. def reserve():
  28. build()
  29. serve()
  30. def preview():
  31. local('pelican -s publishconf.py')
  32. def cf_upload():
  33. rebuild()
  34. local('cd {deploy_path} && '
  35. 'swift -v -A https://auth.api.rackspacecloud.com/v1.0 '
  36. '-U {cloudfiles_username} '
  37. '-K {cloudfiles_api_key} '
  38. 'upload -c {cloudfiles_container} .'.format(**env))
  39. @hosts(production)
  40. def publish():
  41. local('pelican -s publishconf.py')
  42. project.rsync_project(
  43. remote_dir=dest_path,
  44. exclude=".DS_Store",
  45. local_dir=DEPLOY_PATH.rstrip('/') + '/',
  46. delete=True
  47. )