Skip to content

Commit

Permalink
Merge pull request #10 from mariotux/master
Browse files Browse the repository at this point in the history
If you have configured more than one target to deploy scrapy project,…
  • Loading branch information
jayzeng committed Aug 28, 2015
2 parents 7687200 + c8ea755 commit 47a7c7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ To save yourself from having to specify the target and project, you can set the
password = secret
project = yourproject


You can now deploy your project with just the following::

scrapyd-deploy
If you have more than one target to deploy, you can deploy your project in all targets with one command::

scrapyd-deploy -a -p <project>

.. _versioning:

Expand All @@ -81,6 +86,10 @@ By default, ``scrapyd-deploy`` uses the current timestamp for generating the pro

scrapyd-deploy <target> -p <project> --version <version>

Or for all targets::

scrapyd-deploy -a -p <project> --version <version>

The version must be comparable with `LooseVersion <http://epydoc.sourceforge.net/stdlib/distutils.version.LooseVersion-class.html>`_. Scrapyd will use the greatest version unless specified.

If you use Mercurial or Git, you can use ``HG`` or ``GIT`` respectively as the argument supplied to ``--version`` to use the current revision as the version. You can save yourself having to specify the version parameter by adding it to your target's entry in ``scrapy.cfg``::
Expand Down
28 changes: 19 additions & 9 deletions scrapyd-client/scrapyd-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def parse_opts():
help="the version to deploy. Defaults to current timestamp")
parser.add_option("-l", "--list-targets", action="store_true", \
help="list available targets")
parser.add_option("-a", "--deploy-all-targets",action="store_true", help="deploy all targets")
parser.add_option("-d", "--debug", action="store_true",
help="debug mode (do not remove build dir)")
parser.add_option("-L", "--list-projects", metavar="TARGET", \
Expand Down Expand Up @@ -82,19 +83,17 @@ def main():
egg, tmpdir = _build_egg()
_log("Writing egg to %s" % opts.build_egg)
shutil.copyfile(egg, opts.build_egg)
elif opts.deploy_all_targets:
version = None
for name, target in _get_targets().items():
if version is None:
version = _get_version(target, opts)
_build_egg_and_deploy_target(target, version, opts)
else: # buld egg and deploy
target_name = _get_target_name(args)
target = _get_target(target_name)
project = _get_project(target, opts)
version = _get_version(target, opts)
if opts.egg:
_log("Using egg: %s" % opts.egg)
egg = opts.egg
else:
_log("Packing version %s" % version)
egg, tmpdir = _build_egg()
if not _upload_egg(target, egg, project, version):
exitcode = 1
_build_egg_and_deploy_target(target, version, opts)

if tmpdir:
if opts.debug:
Expand All @@ -104,6 +103,17 @@ def main():

sys.exit(exitcode)

def _build_egg_and_deploy_target(target, version, opts):
project = _get_project(target, opts)
if opts.egg:
_log("Using egg: %s" % opts.egg)
egg = opts.egg
else:
_log("Packing version %s" % version)
egg, tmpdir = _build_egg()
if not _upload_egg(target, egg, project, version):
exitcode = 1

def _log(message):
sys.stderr.write(message + os.linesep)

Expand Down

0 comments on commit 47a7c7a

Please sign in to comment.