Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you have configured more than one target to deploy scrapy project,… #10

Merged
merged 2 commits into from
Aug 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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