Mercurial > piecrust2
annotate piecrust/publishing/rsync.py @ 885:13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 20 Jun 2017 21:12:35 -0700 |
parents | f6a13dba38d6 |
children |
rev | line source |
---|---|
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
1 from piecrust.publishing.shell import ShellCommandPublisherBase |
622
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 class RsyncPublisher(ShellCommandPublisherBase): |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 PUBLISHER_NAME = 'rsync' |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 PUBLISHER_SCHEME = 'rsync' |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
8 def parseUrlTarget(self, url): |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
9 self.config = { |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
10 'destination': (url.netloc + url.path) |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
11 } |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
12 |
622
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 def _getCommandArgs(self, ctx): |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
14 orig = self.config.get('source', ctx.bake_out_dir) |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
15 dest = self.config.get('destination') |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
16 if not dest: |
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
17 raise Exception("No destination specified.") |
622
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 |
885
13e8b50a2113
publish: Fix publishers API and add a simple "copy" publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
763
diff
changeset
|
19 rsync_options = self.config.get('options') |
622
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 if rsync_options is None: |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 rsync_options = ['-avc', '--delete'] |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 args = ['rsync'] + rsync_options |
624
b45fb2137a07
publish: Add option to change the source for the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
622
diff
changeset
|
24 args += [orig, dest] |
622
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 return args |
5d8e0c8cdb5f
publish: Add the `rsync` publisher.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 |