A fork of hyde, the static site generation. Some patches will be pushed upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

59 lines
1.7 KiB

  1. """
  2. SSH publisher
  3. =============
  4. Contains classes and utilities that help publishing a hyde website
  5. via ssh/rsync.
  6. Usage
  7. -----
  8. In site.yaml, add the following lines
  9. publisher:
  10. ssh:
  11. type: hyde.ext.publishers.ssh.SSH
  12. username: username
  13. server: ssh.server.com
  14. target: /www/username/mysite/
  15. command: rsync
  16. opts: -r -e ssh
  17. Note that the final two settings (command and opts) are optional, and the
  18. values shown are the default. With this set, generate and publish the site
  19. as follows:
  20. >$ hyde gen
  21. >$ hyde publish -p ssh
  22. For the above options, this will lead to execution of the following command
  23. within the ``deploy/`` directory:
  24. rsync -r -e ssh ./ username@ssh.server.com:/www/username/mysite/
  25. """
  26. from hyde.publisher import Publisher
  27. from subprocess import Popen, PIPE
  28. class SSH(Publisher):
  29. def initialize(self, settings):
  30. self.settings = settings
  31. self.username = settings.username
  32. self.server = settings.server
  33. self.target = settings.target
  34. self.command = getattr(settings, 'command', 'rsync')
  35. self.opts = getattr(settings, 'opts', '-r -e ssh')
  36. def publish(self):
  37. command = "{command} {opts} ./ {username}@{server}:{target}".format(
  38. command=self.command,
  39. opts=self.opts,
  40. username=self.username,
  41. server=self.server,
  42. target=self.target)
  43. deploy_path = self.site.config.deploy_root_path.path
  44. cmd = Popen(command, cwd=unicode(deploy_path), stdout=PIPE, shell=True)
  45. cmdresult = cmd.communicate()[0]
  46. if cmd.returncode:
  47. raise Exception(cmdresult)