From 4dc70a8f9736f92232ae3a5450ba06b1c506eb16 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 9 Oct 2010 10:45:24 -0600 Subject: [PATCH] Add a push command to setup.py so I can develop pn linux and seamlessly test on other platforms --- setup/commands.py | 5 +++-- setup/installer/__init__.py | 32 ++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/setup/commands.py b/setup/commands.py index d35e326ab1..a67c3e8633 100644 --- a/setup/commands.py +++ b/setup/commands.py @@ -19,7 +19,7 @@ __all__ = [ 'upload_user_manual', 'upload_to_mobileread', 'upload_demo', 'upload_to_sourceforge', 'upload_to_google_code', 'linux32', 'linux64', 'linux', 'linux_freeze', 'linux_freeze2', - 'osx32_freeze', 'osx32', 'osx', 'rsync', + 'osx32_freeze', 'osx32', 'osx', 'rsync', 'push', 'win32_freeze', 'win32', 'win', 'stage1', 'stage2', 'stage3', 'stage4', 'publish' ] @@ -68,8 +68,9 @@ upload_to_server = UploadToServer() upload_to_sourceforge = UploadToSourceForge() upload_to_google_code = UploadToGoogleCode() -from setup.installer import Rsync +from setup.installer import Rsync, Push rsync = Rsync() +push = Push() from setup.installer.linux import Linux, Linux32, Linux64 linux = Linux() diff --git a/setup/installer/__init__.py b/setup/installer/__init__.py index 39ca671f09..f38d175b4c 100644 --- a/setup/installer/__init__.py +++ b/setup/installer/__init__.py @@ -11,16 +11,21 @@ import subprocess, tempfile, os, time from setup import Command, installer_name from setup.build_environment import HOST, PROJECT +BASE_RSYNC = 'rsync -avz --delete'.split() +EXCLUDES = [] +for x in [ + 'src/calibre/plugins', 'src/calibre/manual', 'src/calibre/trac', + '.bzr', '.build', '.svn', 'build', 'dist', 'imgsrc', '*.pyc', '*.pyo', '*.swp', + '*.swo']: + EXCLUDES.extend(['--exclude', x]) +SAFE_EXCLUDES = ['"%s"'%x if '*' in x else x for x in EXCLUDES] + class Rsync(Command): description = 'Sync source tree from development machine' - SYNC_CMD = ('rsync -avz --delete --exclude src/calibre/plugins ' - '--exclude src/calibre/manual --exclude src/calibre/trac ' - '--exclude .bzr --exclude .build --exclude .svn --exclude build --exclude dist ' - '--exclude imgsrc ' - '--exclude "*.pyc" --exclude "*.pyo" --exclude "*.swp" --exclude "*.swo" ' - 'rsync://{host}/work/{project} ..') + SYNC_CMD = ' '.join(BASE_RSYNC+SAFE_EXCLUDES+ + ['rsync://{host}/work/{project}', '..']) def run(self, opts): cmd = self.SYNC_CMD.format(host=HOST, project=PROJECT) @@ -28,6 +33,21 @@ class Rsync(Command): subprocess.check_call(cmd, shell=True) +class Push(Command): + + description = 'Push code to another host' + + def run(self, opts): + for host in ( + r'Owner@winxp:/cygdrive/c/Documents\ and\ Settings/Owner/calibre', + 'kovid@ox:calibre' + ): + rcmd = BASE_RSYNC + EXCLUDES + ['.', host] + print '\n\nPushing to:', host, '\n' + subprocess.check_call(rcmd) + + + class VMInstaller(Command): EXTRA_SLEEP = 5