From 90d104d94289f6de28a39d4bc1f1a125a494a1d7 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Tue, 6 Oct 2015 19:24:15 +0300
Subject: [PATCH] Use Fabric's module instead of rsync manually.

---
 README.rst |  1 -
 fabfile.py | 15 +++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/README.rst b/README.rst
index 670d154..b19a028 100644
--- a/README.rst
+++ b/README.rst
@@ -6,6 +6,5 @@ My Debian repository, minus the state (packages, db, etc.).
 todo
 ----
 
-- Use Fabric's module instead of rsync manually.
 - License.
 - Add GPG key.
diff --git a/fabfile.py b/fabfile.py
index 3dfecce..e66991e 100644
--- a/fabfile.py
+++ b/fabfile.py
@@ -1,12 +1,19 @@
 #!/usr/bin/env python
-from fabric.api import task, local
+from fabric.api import task, local, env, hosts
+from fabric.contrib.project import rsync_project
+from os import environ
+
+env.use_ssh_config = True
 
 
 @task
+@hosts('www.shore.co.il')
 def publish():
-    local('''rsync -az --del --exclude="conf/" --exclude="db/" \
-    --exclude="fabfile.*" --exclude="lists/" $REPREPRO_BASE_DIR\
-    www.shore.co.il:/var/www/htdocs/www.shore.co.il/repo/''')
+    rsync_project(remote_dir='''/var/www/htdocs/www.shore.co.il/repo''',
+                  exclude=['''fabfile.*''', 'lists/', 'conf/', 'db/'],
+                  local_dir=environ['REPREPRO_BASE_DIR'],
+                  delete=True,
+                  extra_ops='-z')
 
 
 @task
-- 
GitLab