publish#
import userdir_publish.publish
Validate a built website and copy it to the web directory with rsync.
- exception PublishError[source]#
Bases:
RuntimeErrorRaised when the website cannot be published safely.
- validate_build(settings: Settings) None[source]#
Check that the build can be published.
The build must contain an
index.html. Ifhtaccess_sourceis set, every.htaccessfile under it must appear unchanged at the same relative path in the build. Hidden directories, the build itself, and files ignored by Git are not searched.- Raises:
PublishError – If a check fails.
- use_ssh(settings: Settings) bool[source]#
Decide whether to publish over SSH.
With
transport = "auto", SSH is used when a host is set and the target directory does not exist on this machine.
- rsync_command(settings: Settings, *, ssh: bool, dry_run: bool = False, progress: bool = False) list[str][source]#
Build the rsync command that mirrors the build to the target.
The command passes
--delete, so files in the target that are not in the build are removed, except those matched bykeep. Unless dry_run is set, a local target directory is created, and over SSH the remote target is created by the command itself. With progress, rsync reports the overall transfer progress.
- publish(settings: Settings, *, dry_run: bool = False, progress: bool = False) list[str][source]#
Copy the build to the target and return the rsync command that was run.
A dry run still validates the build and refuses a symlinked target, but copies nothing and creates no directories.
- Raises:
PublishError – If the build is invalid or the target is a symlink.
subprocess.CalledProcessError – If rsync fails.