libv8 7.3.492.27.1 → 8.4.255.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +11 -14
- data/CHANGELOG.md +10 -0
- data/README.md +10 -11
- data/Rakefile +30 -36
- data/ext/libv8/builder.rb +1 -1
- data/lib/libv8/version.rb +1 -1
- data/libv8.gemspec +1 -3
- data/vendor/depot_tools/{cipd.ps1 → .cipd_impl.ps1} +0 -0
- data/vendor/depot_tools/.gitattributes +1 -1
- data/vendor/depot_tools/.gitignore +7 -2
- data/vendor/depot_tools/.style.yapf +3 -1
- data/vendor/depot_tools/.vpython +55 -0
- data/vendor/depot_tools/.vpython3 +23 -0
- data/vendor/depot_tools/CROS_OWNERS +3 -1
- data/vendor/depot_tools/GOMA_OWNERS +9 -0
- data/vendor/depot_tools/LUCI_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +21 -6
- data/vendor/depot_tools/PRESUBMIT.py +35 -18
- data/vendor/depot_tools/README.git-cl.md +0 -14
- data/vendor/depot_tools/README.md +1 -1
- data/vendor/depot_tools/WATCHLISTS +2 -2
- data/vendor/depot_tools/auth.py +60 -772
- data/vendor/depot_tools/autoninja +12 -6
- data/vendor/depot_tools/autoninja.bat +14 -6
- data/vendor/depot_tools/autoninja.py +64 -27
- data/vendor/depot_tools/bb +1 -1
- data/vendor/depot_tools/bootstrap/{win/README.md → README.md} +28 -14
- data/vendor/depot_tools/bootstrap/{win/win_tools.py → bootstrap.py} +60 -43
- data/vendor/depot_tools/bootstrap/{win/git-bash.template.sh → git-bash.template.sh} +1 -1
- data/vendor/depot_tools/bootstrap/{win/git.template.bat → git.template.bat} +0 -0
- data/vendor/depot_tools/bootstrap/manifest.txt +27 -0
- data/vendor/depot_tools/bootstrap/manifest_bleeding_edge.txt +27 -0
- data/vendor/depot_tools/bootstrap/{win/profile.d.python.sh → profile.d.python.sh} +0 -0
- data/vendor/depot_tools/bootstrap/{win/python27.bleeding_edge.bat → python27.bat} +0 -0
- data/vendor/depot_tools/bootstrap/{win/python27.new.bat → python3.bat} +3 -3
- data/vendor/depot_tools/bootstrap/{win/win_tools.bat → win_tools.bat} +21 -16
- data/vendor/depot_tools/bootstrap_python3 +35 -0
- data/vendor/depot_tools/cbuildbot +1 -1
- data/vendor/depot_tools/chrome_set_ver +1 -1
- data/vendor/depot_tools/cipd +43 -39
- data/vendor/depot_tools/cipd.bat +2 -2
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +15 -14
- data/vendor/depot_tools/cipd_manifest.txt +31 -8
- data/vendor/depot_tools/cipd_manifest.versions +278 -158
- data/vendor/depot_tools/cit.py +9 -7
- data/vendor/depot_tools/clang_format.py +4 -1
- data/vendor/depot_tools/clang_format_merge_driver.py +10 -8
- data/vendor/depot_tools/compile_single_file.py +7 -2
- data/vendor/depot_tools/cpplint.py +51 -45
- data/vendor/depot_tools/cros +87 -0
- data/vendor/depot_tools/cros_sdk +1 -1
- data/vendor/depot_tools/crosjobs +13 -0
- data/vendor/depot_tools/detect_host_arch.py +0 -1
- data/vendor/depot_tools/dirmd +12 -0
- data/vendor/depot_tools/dirmd.bat +7 -0
- data/vendor/depot_tools/download_from_google_storage.py +47 -27
- data/vendor/depot_tools/ensure_bootstrap +14 -0
- data/vendor/depot_tools/fetch +14 -1
- data/vendor/depot_tools/fetch.bat +14 -1
- data/vendor/depot_tools/fetch.py +5 -7
- data/vendor/depot_tools/fetch_configs/chromium.py +6 -4
- data/vendor/depot_tools/fetch_configs/devtools-frontend.py +44 -0
- data/vendor/depot_tools/fetch_configs/ios_internal.py +10 -19
- data/vendor/depot_tools/fix_encoding.py +19 -5
- data/vendor/depot_tools/gclient +28 -12
- data/vendor/depot_tools/gclient-new-workdir.py +2 -0
- data/vendor/depot_tools/gclient.bat +18 -1
- data/vendor/depot_tools/gclient.py +160 -119
- data/vendor/depot_tools/gclient_eval.py +119 -107
- data/vendor/depot_tools/gclient_paths.py +67 -57
- data/vendor/depot_tools/gclient_scm.py +181 -159
- data/vendor/depot_tools/gclient_utils.py +177 -124
- data/vendor/depot_tools/gerrit_client.py +21 -13
- data/vendor/depot_tools/gerrit_util.py +188 -228
- data/vendor/depot_tools/git-cache +1 -1
- data/vendor/depot_tools/git-cl +1 -1
- data/vendor/depot_tools/git-drover +1 -1
- data/vendor/depot_tools/git-find-releases +1 -1
- data/vendor/depot_tools/git-footers +1 -1
- data/vendor/depot_tools/git-freeze +1 -1
- data/vendor/depot_tools/git-hyper-blame +1 -1
- data/vendor/depot_tools/git-map +1 -1
- data/vendor/depot_tools/git-map-branches +1 -1
- data/vendor/depot_tools/git-mark-merge-base +1 -1
- data/vendor/depot_tools/git-nav-downstream +1 -1
- data/vendor/depot_tools/git-new-branch +1 -1
- data/vendor/depot_tools/git-number +1 -1
- data/vendor/depot_tools/git-rebase-update +1 -1
- data/vendor/depot_tools/git-rename-branch +1 -1
- data/vendor/depot_tools/git-reparent-branch +1 -1
- data/vendor/depot_tools/git-retry +1 -1
- data/vendor/depot_tools/git-squash-branch +1 -1
- data/vendor/depot_tools/git-thaw +1 -1
- data/vendor/depot_tools/git-upstream-diff +1 -1
- data/vendor/depot_tools/git_cache.py +255 -360
- data/vendor/depot_tools/git_cl.py +1562 -2059
- data/vendor/depot_tools/git_cl_completion.sh +16 -2
- data/vendor/depot_tools/git_common.py +77 -32
- data/vendor/depot_tools/git_drover.py +17 -8
- data/vendor/depot_tools/git_find_releases.py +11 -9
- data/vendor/depot_tools/git_footers.py +13 -9
- data/vendor/depot_tools/git_freezer.py +3 -1
- data/vendor/depot_tools/git_hyper_blame.py +25 -32
- data/vendor/depot_tools/git_map.py +115 -93
- data/vendor/depot_tools/git_map_branches.py +11 -10
- data/vendor/depot_tools/git_mark_merge_base.py +8 -6
- data/vendor/depot_tools/git_nav_downstream.py +9 -6
- data/vendor/depot_tools/git_new_branch.py +39 -33
- data/vendor/depot_tools/git_number.py +28 -17
- data/vendor/depot_tools/git_rebase_update.py +50 -49
- data/vendor/depot_tools/git_rename_branch.py +2 -2
- data/vendor/depot_tools/git_reparent_branch.py +8 -6
- data/vendor/depot_tools/git_upstream_diff.py +4 -2
- data/vendor/depot_tools/gn.py +6 -4
- data/vendor/depot_tools/goma_auth +12 -0
- data/vendor/depot_tools/goma_auth.bat +8 -0
- data/vendor/depot_tools/goma_ctl +12 -0
- data/vendor/depot_tools/goma_ctl.bat +8 -0
- data/vendor/depot_tools/gsutil.py +5 -2
- data/vendor/depot_tools/gsutil.py.bat +8 -0
- data/vendor/depot_tools/gsutil.vpython +3 -1
- data/vendor/depot_tools/infra/config/OWNERS +2 -2
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/led +1 -1
- data/vendor/depot_tools/lockfile.py +116 -0
- data/vendor/depot_tools/luci-auth +1 -1
- data/vendor/depot_tools/lucicfg +1 -1
- data/vendor/depot_tools/mac_toolchain +1 -1
- data/vendor/depot_tools/man/html/depot_tools.html +1 -1
- data/vendor/depot_tools/man/html/depot_tools_tutorial.html +31 -25
- data/vendor/depot_tools/man/html/git-cl.html +1 -1
- data/vendor/depot_tools/man/html/git-drover.html +18 -18
- data/vendor/depot_tools/man/html/git-footers.html +1 -1
- data/vendor/depot_tools/man/html/git-freeze.html +3 -3
- data/vendor/depot_tools/man/html/git-hyper-blame.html +1 -1
- data/vendor/depot_tools/man/html/git-map-branches.html +2 -2
- data/vendor/depot_tools/man/html/git-map.html +1 -1
- data/vendor/depot_tools/man/html/git-mark-merge-base.html +1 -1
- data/vendor/depot_tools/man/html/git-nav-downstream.html +3 -3
- data/vendor/depot_tools/man/html/git-nav-upstream.html +12 -6
- data/vendor/depot_tools/man/html/git-new-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-rebase-update.html +20 -1
- data/vendor/depot_tools/man/html/git-rename-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-reparent-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-retry.html +1 -1
- data/vendor/depot_tools/man/html/git-squash-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-thaw.html +1 -1
- data/vendor/depot_tools/man/html/git-upstream-diff.html +10 -6
- data/vendor/depot_tools/man/man1/git-cl.1 +4 -4
- data/vendor/depot_tools/man/man1/git-drover.1 +21 -21
- data/vendor/depot_tools/man/man1/git-footers.1 +4 -4
- data/vendor/depot_tools/man/man1/git-freeze.1 +6 -6
- data/vendor/depot_tools/man/man1/git-hyper-blame.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map-branches.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map.1 +4 -4
- data/vendor/depot_tools/man/man1/git-mark-merge-base.1 +4 -4
- data/vendor/depot_tools/man/man1/git-nav-downstream.1 +6 -6
- data/vendor/depot_tools/man/man1/git-nav-upstream.1 +15 -9
- data/vendor/depot_tools/man/man1/git-new-branch.1 +3 -3
- data/vendor/depot_tools/man/man1/git-rebase-update.1 +14 -4
- data/vendor/depot_tools/man/man1/git-rename-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-reparent-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-retry.1 +4 -4
- data/vendor/depot_tools/man/man1/git-squash-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-thaw.1 +4 -4
- data/vendor/depot_tools/man/man1/git-upstream-diff.1 +7 -13
- data/vendor/depot_tools/man/man7/depot_tools.7 +4 -4
- data/vendor/depot_tools/man/man7/depot_tools_tutorial.7 +31 -25
- data/vendor/depot_tools/man/src/common_demo_functions.sh +2 -2
- data/vendor/depot_tools/man/src/depot_tools_tutorial.txt +3 -3
- data/vendor/depot_tools/man/src/filter_demo_output.py +4 -2
- data/vendor/depot_tools/man/src/git-new-branch.txt +2 -1
- data/vendor/depot_tools/man/src/git-rebase-update.txt +8 -1
- data/vendor/depot_tools/metrics.README.md +8 -5
- data/vendor/depot_tools/metrics.py +7 -6
- data/vendor/depot_tools/metrics_utils.py +4 -14
- data/vendor/depot_tools/my_activity.py +85 -251
- data/vendor/depot_tools/ninja +1 -0
- data/vendor/depot_tools/ninja-mac +0 -0
- data/vendor/depot_tools/ninjalog_uploader.py +146 -145
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +69 -60
- data/vendor/depot_tools/owners.py +156 -43
- data/vendor/depot_tools/owners_finder.py +28 -14
- data/vendor/depot_tools/post_build_ninja_summary.py +76 -48
- data/vendor/depot_tools/presubmit_canned_checks.py +293 -106
- data/vendor/depot_tools/presubmit_support.py +527 -333
- data/vendor/depot_tools/prpc +1 -1
- data/vendor/depot_tools/pylint +2 -12
- data/vendor/depot_tools/pylint-1.5 +78 -0
- data/vendor/depot_tools/pylint-1.6 +78 -0
- data/vendor/depot_tools/pylint-1.7 +78 -0
- data/vendor/depot_tools/pylint-1.8 +78 -0
- data/vendor/depot_tools/pylint-1.9 +78 -0
- data/vendor/depot_tools/{depot-tools-auth.bat → pylint.bat} +2 -2
- data/vendor/depot_tools/pylint_main.py +45 -0
- data/vendor/depot_tools/pylintrc +14 -1
- data/vendor/depot_tools/python-bin/python3 +7 -0
- data/vendor/depot_tools/python_runner.sh +13 -8
- data/vendor/depot_tools/rdb +12 -0
- data/vendor/depot_tools/rdb.bat +7 -0
- data/vendor/depot_tools/recipes/OWNERS +0 -1
- data/vendor/depot_tools/recipes/README.recipes.md +218 -151
- data/vendor/depot_tools/recipes/recipe_modules/OWNERS +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +17 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +127 -78
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +19 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +18 -3
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +19 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +28 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/input_commit_with_id_without_repo.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{with_manifest_name.json → no_cp_checkout_HEAD.json} +25 -15
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_branch_head.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_specific_commit.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_master.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/refs.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/resolve_chromium_fixed_version.json +117 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +17 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +41 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +24 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +38 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +36 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +95 -22
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +187 -114
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py +42 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/__init__.py +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +2 -4
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +26 -6
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/test_api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +3 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +82 -13
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +23 -11
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +3 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +3 -6
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +3 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +7 -7
- data/vendor/depot_tools/recipes/recipe_modules/gclient/resources/diff_deps.py +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/test_api.py +4 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/basic.json +55 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json +84 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/windows.json +55 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.py +88 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +9 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/sync_failure.py +24 -0
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +7 -12
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +0 -2
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +9 -17
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +3 -13
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +4 -12
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +2 -10
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +1 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +1 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +0 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +3 -10
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +3 -11
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +3 -13
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/__init__.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +7 -13
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +21 -16
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +23 -8
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +52 -1
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.py +15 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +32 -8
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/ancient_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/automatic_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/explicit_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +5 -4
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +21 -2
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +20 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +235 -3
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +13 -5
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.py +5 -1
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/properties.proto +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/test_api.py +19 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/execute.py +247 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/prepare.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +33 -45
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +64 -21
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +64 -21
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +1 -22
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +1 -22
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +5 -32
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_fetch_ref_timeout.py +29 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.expected/basic.json +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.py +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_target_ref.py +32 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +1 -6
- data/vendor/depot_tools/recipes/recipes.py +49 -28
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +11 -6
- data/vendor/depot_tools/repo +698 -540
- data/vendor/depot_tools/roll-dep +14 -1
- data/vendor/depot_tools/roll-dep.bat +10 -1
- data/vendor/depot_tools/roll_dep.py +15 -10
- data/vendor/depot_tools/scm.py +95 -75
- data/vendor/depot_tools/setup_color.py +36 -2
- data/vendor/depot_tools/split_cl.py +44 -32
- data/vendor/depot_tools/subcommand.py +6 -6
- data/vendor/depot_tools/subprocess2.py +38 -322
- data/vendor/depot_tools/third_party/colorama/LICENSE.txt +0 -1
- data/vendor/depot_tools/third_party/colorama/README.chromium +4 -5
- data/vendor/depot_tools/third_party/colorama/README.rst +346 -0
- data/vendor/depot_tools/third_party/colorama/__init__.py +3 -4
- data/vendor/depot_tools/third_party/colorama/ansi.py +82 -30
- data/vendor/depot_tools/third_party/colorama/ansitowin32.py +105 -37
- data/vendor/depot_tools/third_party/colorama/initialise.py +39 -15
- data/vendor/depot_tools/third_party/colorama/win32.py +46 -28
- data/vendor/depot_tools/third_party/colorama/winterm.py +80 -31
- data/vendor/depot_tools/update_depot_tools +18 -8
- data/vendor/depot_tools/update_depot_tools.bat +19 -15
- data/vendor/depot_tools/upload_metrics.py +7 -6
- data/vendor/depot_tools/upload_to_google_storage.py +23 -16
- data/vendor/depot_tools/vpython +4 -4
- data/vendor/depot_tools/vpython.bat +1 -1
- data/vendor/depot_tools/vpython3 +55 -0
- data/vendor/depot_tools/vpython3.bat +12 -0
- data/vendor/depot_tools/watchlists.py +14 -11
- data/vendor/depot_tools/weekly +4 -2
- data/vendor/depot_tools/win32imports.py +61 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +49 -41
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +142 -149
- data/vendor/depot_tools/wtf +5 -3
- data/vendor/depot_tools/yapf +5 -1
- metadata +68 -343
- data/vendor/depot_tools/README.testing +0 -23
- data/vendor/depot_tools/annotated_gclient.py +0 -89
- data/vendor/depot_tools/appengine_mapper.py +0 -23
- data/vendor/depot_tools/bootstrap/win/manifest.txt +0 -20
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +0 -20
- data/vendor/depot_tools/bootstrap/win/pylint.new.bat +0 -7
- data/vendor/depot_tools/buildbucket.py +0 -186
- data/vendor/depot_tools/checkout.py +0 -431
- data/vendor/depot_tools/cros +0 -1
- data/vendor/depot_tools/dart_format.py +0 -58
- data/vendor/depot_tools/depot-tools-auth +0 -8
- data/vendor/depot_tools/depot-tools-auth.py +0 -102
- data/vendor/depot_tools/my_reviews.py +0 -396
- data/vendor/depot_tools/patch.py +0 -548
- data/vendor/depot_tools/pylint.py +0 -30
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +0 -239
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +0 -222
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/__init__.py +0 -4
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/api.py +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.py +0 -33
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +0 -66
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +0 -11
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +0 -45
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +0 -45
- data/vendor/depot_tools/rietveld.py +0 -779
- data/vendor/depot_tools/roll-dep-svn +0 -8
- data/vendor/depot_tools/roll-dep-svn.bat +0 -12
- data/vendor/depot_tools/roll_dep_svn.py +0 -430
- data/vendor/depot_tools/support/chromite_wrapper +0 -96
- data/vendor/depot_tools/third_party/boto/LICENSE +0 -18
- data/vendor/depot_tools/third_party/boto/README.chromium +0 -43
- data/vendor/depot_tools/third_party/boto/README.rst +0 -163
- data/vendor/depot_tools/third_party/boto/__init__.py +0 -793
- data/vendor/depot_tools/third_party/boto/auth.py +0 -682
- data/vendor/depot_tools/third_party/boto/auth_handler.py +0 -58
- data/vendor/depot_tools/third_party/boto/cacerts/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/cacerts/cacerts.txt +0 -2183
- data/vendor/depot_tools/third_party/boto/compat.py +0 -28
- data/vendor/depot_tools/third_party/boto/connection.py +0 -1081
- data/vendor/depot_tools/third_party/boto/contrib/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/contrib/ymlmessage.py +0 -52
- data/vendor/depot_tools/third_party/boto/core/README +0 -58
- data/vendor/depot_tools/third_party/boto/core/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/core/auth.py +0 -78
- data/vendor/depot_tools/third_party/boto/core/credentials.py +0 -154
- data/vendor/depot_tools/third_party/boto/core/dictresponse.py +0 -178
- data/vendor/depot_tools/third_party/boto/core/service.py +0 -67
- data/vendor/depot_tools/third_party/boto/datapipeline/__init__.py +0 -0
- data/vendor/depot_tools/third_party/boto/datapipeline/exceptions.py +0 -42
- data/vendor/depot_tools/third_party/boto/datapipeline/layer1.py +0 -546
- data/vendor/depot_tools/third_party/boto/ecs/__init__.py +0 -90
- data/vendor/depot_tools/third_party/boto/ecs/item.py +0 -153
- data/vendor/depot_tools/third_party/boto/exception.py +0 -476
- data/vendor/depot_tools/third_party/boto/file/README +0 -49
- data/vendor/depot_tools/third_party/boto/file/__init__.py +0 -28
- data/vendor/depot_tools/third_party/boto/file/bucket.py +0 -112
- data/vendor/depot_tools/third_party/boto/file/connection.py +0 -33
- data/vendor/depot_tools/third_party/boto/file/key.py +0 -199
- data/vendor/depot_tools/third_party/boto/file/simpleresultset.py +0 -30
- data/vendor/depot_tools/third_party/boto/fps/__init__.py +0 -21
- data/vendor/depot_tools/third_party/boto/fps/connection.py +0 -369
- data/vendor/depot_tools/third_party/boto/fps/exception.py +0 -344
- data/vendor/depot_tools/third_party/boto/fps/response.py +0 -175
- data/vendor/depot_tools/third_party/boto/gs/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/gs/acl.py +0 -304
- data/vendor/depot_tools/third_party/boto/gs/bucket.py +0 -870
- data/vendor/depot_tools/third_party/boto/gs/bucketlistresultset.py +0 -64
- data/vendor/depot_tools/third_party/boto/gs/connection.py +0 -103
- data/vendor/depot_tools/third_party/boto/gs/cors.py +0 -169
- data/vendor/depot_tools/third_party/boto/gs/key.py +0 -704
- data/vendor/depot_tools/third_party/boto/gs/resumable_upload_handler.py +0 -659
- data/vendor/depot_tools/third_party/boto/gs/user.py +0 -54
- data/vendor/depot_tools/third_party/boto/handler.py +0 -44
- data/vendor/depot_tools/third_party/boto/https_connection.py +0 -124
- data/vendor/depot_tools/third_party/boto/jsonresponse.py +0 -163
- data/vendor/depot_tools/third_party/boto/manage/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/manage/cmdshell.py +0 -241
- data/vendor/depot_tools/third_party/boto/manage/propget.py +0 -64
- data/vendor/depot_tools/third_party/boto/manage/server.py +0 -556
- data/vendor/depot_tools/third_party/boto/manage/task.py +0 -175
- data/vendor/depot_tools/third_party/boto/manage/test_manage.py +0 -34
- data/vendor/depot_tools/third_party/boto/manage/volume.py +0 -420
- data/vendor/depot_tools/third_party/boto/mashups/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/mashups/interactive.py +0 -97
- data/vendor/depot_tools/third_party/boto/mashups/iobject.py +0 -115
- data/vendor/depot_tools/third_party/boto/mashups/order.py +0 -211
- data/vendor/depot_tools/third_party/boto/mashups/server.py +0 -395
- data/vendor/depot_tools/third_party/boto/plugin.py +0 -90
- data/vendor/depot_tools/third_party/boto/provider.py +0 -337
- data/vendor/depot_tools/third_party/boto/pyami/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/pyami/bootstrap.py +0 -134
- data/vendor/depot_tools/third_party/boto/pyami/config.py +0 -229
- data/vendor/depot_tools/third_party/boto/pyami/copybot.cfg +0 -60
- data/vendor/depot_tools/third_party/boto/pyami/copybot.py +0 -97
- data/vendor/depot_tools/third_party/boto/pyami/helloworld.py +0 -28
- data/vendor/depot_tools/third_party/boto/pyami/launch_ami.py +0 -178
- data/vendor/depot_tools/third_party/boto/pyami/scriptbase.py +0 -44
- data/vendor/depot_tools/third_party/boto/pyami/startup.py +0 -60
- data/vendor/depot_tools/third_party/boto/regioninfo.py +0 -63
- data/vendor/depot_tools/third_party/boto/resultset.py +0 -169
- data/vendor/depot_tools/third_party/boto/roboto/__init__.py +0 -1
- data/vendor/depot_tools/third_party/boto/roboto/awsqueryrequest.py +0 -504
- data/vendor/depot_tools/third_party/boto/roboto/awsqueryservice.py +0 -121
- data/vendor/depot_tools/third_party/boto/roboto/param.py +0 -147
- data/vendor/depot_tools/third_party/boto/s3/__init__.py +0 -84
- data/vendor/depot_tools/third_party/boto/s3/acl.py +0 -164
- data/vendor/depot_tools/third_party/boto/s3/bucket.py +0 -1634
- data/vendor/depot_tools/third_party/boto/s3/bucketlistresultset.py +0 -139
- data/vendor/depot_tools/third_party/boto/s3/bucketlogging.py +0 -83
- data/vendor/depot_tools/third_party/boto/s3/connection.py +0 -540
- data/vendor/depot_tools/third_party/boto/s3/cors.py +0 -210
- data/vendor/depot_tools/third_party/boto/s3/deletemarker.py +0 -55
- data/vendor/depot_tools/third_party/boto/s3/key.py +0 -1712
- data/vendor/depot_tools/third_party/boto/s3/keyfile.py +0 -134
- data/vendor/depot_tools/third_party/boto/s3/lifecycle.py +0 -231
- data/vendor/depot_tools/third_party/boto/s3/multidelete.py +0 -138
- data/vendor/depot_tools/third_party/boto/s3/multipart.py +0 -315
- data/vendor/depot_tools/third_party/boto/s3/prefix.py +0 -42
- data/vendor/depot_tools/third_party/boto/s3/resumable_download_handler.py +0 -339
- data/vendor/depot_tools/third_party/boto/s3/tagging.py +0 -71
- data/vendor/depot_tools/third_party/boto/s3/user.py +0 -49
- data/vendor/depot_tools/third_party/boto/s3/website.py +0 -237
- data/vendor/depot_tools/third_party/boto/services/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/services/bs.py +0 -179
- data/vendor/depot_tools/third_party/boto/services/message.py +0 -58
- data/vendor/depot_tools/third_party/boto/services/result.py +0 -136
- data/vendor/depot_tools/third_party/boto/services/service.py +0 -161
- data/vendor/depot_tools/third_party/boto/services/servicedef.py +0 -91
- data/vendor/depot_tools/third_party/boto/services/sonofmmm.cfg +0 -43
- data/vendor/depot_tools/third_party/boto/services/sonofmmm.py +0 -81
- data/vendor/depot_tools/third_party/boto/services/submit.py +0 -88
- data/vendor/depot_tools/third_party/boto/ses/__init__.py +0 -54
- data/vendor/depot_tools/third_party/boto/ses/connection.py +0 -521
- data/vendor/depot_tools/third_party/boto/ses/exceptions.py +0 -77
- data/vendor/depot_tools/third_party/boto/storage_uri.py +0 -835
- data/vendor/depot_tools/third_party/boto/sts/__init__.py +0 -55
- data/vendor/depot_tools/third_party/boto/sts/connection.py +0 -207
- data/vendor/depot_tools/third_party/boto/sts/credentials.py +0 -215
- data/vendor/depot_tools/third_party/boto/utils.py +0 -927
- data/vendor/depot_tools/third_party/colorama/README.txt +0 -304
- data/vendor/depot_tools/third_party/fancy_urllib/README +0 -22
- data/vendor/depot_tools/third_party/fancy_urllib/__init__.py +0 -460
- data/vendor/depot_tools/third_party/logilab/README.chromium +0 -6
- data/vendor/depot_tools/third_party/logilab/__init__.py +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/LICENSE.txt +0 -340
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +0 -136
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +0 -42
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +0 -233
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +0 -548
- data/vendor/depot_tools/third_party/logilab/astroid/astpeephole.py +0 -86
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +0 -636
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_builtin_inference.py +0 -336
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +0 -15
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_gi.py +0 -195
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_mechanize.py +0 -18
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_nose.py +0 -82
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +0 -62
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +0 -76
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +0 -44
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_six.py +0 -288
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +0 -65
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +0 -473
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +0 -263
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +0 -81
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +0 -75
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +0 -71
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +0 -359
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +0 -267
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +0 -147
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +0 -741
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +0 -1053
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +0 -87
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +0 -186
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +0 -470
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +0 -390
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +0 -989
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +0 -1716
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +0 -201
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +0 -96
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +0 -89
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +0 -19
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +0 -20
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +0 -1421
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +0 -9
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +0 -246
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +0 -414
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +0 -13
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +0 -24
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +0 -19
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +0 -2729
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +0 -96
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +0 -512
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +0 -228
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +0 -901
- data/vendor/depot_tools/third_party/mock/LICENSE.txt +0 -26
- data/vendor/depot_tools/third_party/mock/README.chromium +0 -24
- data/vendor/depot_tools/third_party/mock/__init__.py +0 -2366
- data/vendor/depot_tools/third_party/oauth2client/LICENSE +0 -202
- data/vendor/depot_tools/third_party/oauth2client/MODIFICATIONS.diff +0 -66
- data/vendor/depot_tools/third_party/oauth2client/README.chromium +0 -15
- data/vendor/depot_tools/third_party/oauth2client/__init__.py +0 -5
- data/vendor/depot_tools/third_party/oauth2client/anyjson.py +0 -32
- data/vendor/depot_tools/third_party/oauth2client/appengine.py +0 -963
- data/vendor/depot_tools/third_party/oauth2client/client.py +0 -1363
- data/vendor/depot_tools/third_party/oauth2client/clientsecrets.py +0 -153
- data/vendor/depot_tools/third_party/oauth2client/crypt.py +0 -377
- data/vendor/depot_tools/third_party/oauth2client/django_orm.py +0 -134
- data/vendor/depot_tools/third_party/oauth2client/file.py +0 -124
- data/vendor/depot_tools/third_party/oauth2client/gce.py +0 -90
- data/vendor/depot_tools/third_party/oauth2client/keyring_storage.py +0 -109
- data/vendor/depot_tools/third_party/oauth2client/locked_file.py +0 -373
- data/vendor/depot_tools/third_party/oauth2client/multistore_file.py +0 -465
- data/vendor/depot_tools/third_party/oauth2client/old_run.py +0 -160
- data/vendor/depot_tools/third_party/oauth2client/tools.py +0 -243
- data/vendor/depot_tools/third_party/oauth2client/util.py +0 -196
- data/vendor/depot_tools/third_party/oauth2client/xsrfutil.py +0 -113
- data/vendor/depot_tools/third_party/protobuf26/README.chromium +0 -23
- data/vendor/depot_tools/third_party/protobuf26/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/compiler/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/compiler/plugin_pb2.py +0 -184
- data/vendor/depot_tools/third_party/protobuf26/descriptor.py +0 -849
- data/vendor/depot_tools/third_party/protobuf26/descriptor_database.py +0 -137
- data/vendor/depot_tools/third_party/protobuf26/descriptor_pb2.py +0 -1522
- data/vendor/depot_tools/third_party/protobuf26/descriptor_pool.py +0 -643
- data/vendor/depot_tools/third_party/protobuf26/internal/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/internal/api_implementation.py +0 -89
- data/vendor/depot_tools/third_party/protobuf26/internal/containers.py +0 -269
- data/vendor/depot_tools/third_party/protobuf26/internal/cpp_message.py +0 -663
- data/vendor/depot_tools/third_party/protobuf26/internal/decoder.py +0 -831
- data/vendor/depot_tools/third_party/protobuf26/internal/encoder.py +0 -788
- data/vendor/depot_tools/third_party/protobuf26/internal/enum_type_wrapper.py +0 -89
- data/vendor/depot_tools/third_party/protobuf26/internal/message_listener.py +0 -78
- data/vendor/depot_tools/third_party/protobuf26/internal/python_message.py +0 -1247
- data/vendor/depot_tools/third_party/protobuf26/internal/type_checkers.py +0 -328
- data/vendor/depot_tools/third_party/protobuf26/internal/wire_format.py +0 -268
- data/vendor/depot_tools/third_party/protobuf26/message.py +0 -284
- data/vendor/depot_tools/third_party/protobuf26/message_factory.py +0 -155
- data/vendor/depot_tools/third_party/protobuf26/reflection.py +0 -205
- data/vendor/depot_tools/third_party/protobuf26/service.py +0 -226
- data/vendor/depot_tools/third_party/protobuf26/service_reflection.py +0 -284
- data/vendor/depot_tools/third_party/protobuf26/symbol_database.py +0 -185
- data/vendor/depot_tools/third_party/protobuf26/text_encoding.py +0 -110
- data/vendor/depot_tools/third_party/protobuf26/text_format.py +0 -873
- data/vendor/depot_tools/third_party/pylint.py +0 -37
- data/vendor/depot_tools/third_party/pylint/LICENSE.txt +0 -340
- data/vendor/depot_tools/third_party/pylint/README.chromium +0 -30
- data/vendor/depot_tools/third_party/pylint/__init__.py +0 -46
- data/vendor/depot_tools/third_party/pylint/__main__.py +0 -3
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +0 -80
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +0 -123
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +0 -82
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +0 -2010
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +0 -1120
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +0 -348
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +0 -369
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +0 -993
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +0 -654
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +0 -258
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +0 -105
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +0 -169
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +0 -591
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +0 -129
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +0 -371
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +0 -264
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +0 -280
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +0 -618
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +0 -974
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +0 -741
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +0 -1191
- data/vendor/depot_tools/third_party/pylint/config.py +0 -820
- data/vendor/depot_tools/third_party/pylint/epylint.py +0 -181
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +0 -311
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +0 -62
- data/vendor/depot_tools/third_party/pylint/graph.py +0 -179
- data/vendor/depot_tools/third_party/pylint/gui.py +0 -531
- data/vendor/depot_tools/third_party/pylint/interfaces.py +0 -102
- data/vendor/depot_tools/third_party/pylint/lint.py +0 -1381
- data/vendor/depot_tools/third_party/pylint/pyreverse/__init__.py +0 -5
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +0 -230
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +0 -258
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +0 -372
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +0 -147
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +0 -210
- data/vendor/depot_tools/third_party/pylint/pyreverse/vcgutils.py +0 -198
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +0 -198
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +0 -149
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +0 -27
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +0 -108
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +0 -64
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +0 -237
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +0 -106
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/html_writer.py +0 -93
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/nodes.py +0 -181
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/text_writer.py +0 -99
- data/vendor/depot_tools/third_party/pylint/testutils.py +0 -414
- data/vendor/depot_tools/third_party/pylint/utils.py +0 -1148
- data/vendor/depot_tools/third_party/pymox/COPYING +0 -202
- data/vendor/depot_tools/third_party/pymox/MANIFEST.in +0 -5
- data/vendor/depot_tools/third_party/pymox/README +0 -56
- data/vendor/depot_tools/third_party/pymox/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pymox/mox.py +0 -1643
- data/vendor/depot_tools/third_party/pymox/mox_test.py +0 -1708
- data/vendor/depot_tools/third_party/pymox/mox_test_helper.py +0 -76
- data/vendor/depot_tools/third_party/pymox/setup.py +0 -14
- data/vendor/depot_tools/third_party/pymox/stubout.py +0 -142
- data/vendor/depot_tools/third_party/pymox/stubout_test.py +0 -47
- data/vendor/depot_tools/third_party/pymox/stubout_testee.py +0 -2
- data/vendor/depot_tools/third_party/simplejson/LICENSE.txt +0 -19
- data/vendor/depot_tools/third_party/simplejson/PKG-INFO +0 -29
- data/vendor/depot_tools/third_party/simplejson/__init__.py +0 -437
- data/vendor/depot_tools/third_party/simplejson/decoder.py +0 -421
- data/vendor/depot_tools/third_party/simplejson/encoder.py +0 -501
- data/vendor/depot_tools/third_party/simplejson/ordered_dict.py +0 -119
- data/vendor/depot_tools/third_party/simplejson/scanner.py +0 -77
- data/vendor/depot_tools/third_party/simplejson/tool.py +0 -39
- data/vendor/depot_tools/third_party/upload.py +0 -2565
@@ -1,210 +0,0 @@
|
|
1
|
-
# Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
|
2
|
-
# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
5
|
-
# copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish, dis-
|
8
|
-
# tribute, sublicense, and/or sell copies of the Software, and to permit
|
9
|
-
# persons to whom the Software is furnished to do so, subject to the fol-
|
10
|
-
# lowing conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included
|
13
|
-
# in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16
|
-
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
17
|
-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
18
|
-
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
19
|
-
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
21
|
-
# IN THE SOFTWARE.
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
class CORSRule(object):
|
26
|
-
"""
|
27
|
-
CORS rule for a bucket.
|
28
|
-
|
29
|
-
:ivar id: A unique identifier for the rule. The ID value can be
|
30
|
-
up to 255 characters long. The IDs help you find a rule in
|
31
|
-
the configuration.
|
32
|
-
|
33
|
-
:ivar allowed_methods: An HTTP method that you want to allow the
|
34
|
-
origin to execute. Each CORSRule must identify at least one
|
35
|
-
origin and one method. Valid values are:
|
36
|
-
GET|PUT|HEAD|POST|DELETE
|
37
|
-
|
38
|
-
:ivar allowed_origin: An origin that you want to allow cross-domain
|
39
|
-
requests from. This can contain at most one * wild character.
|
40
|
-
Each CORSRule must identify at least one origin and one method.
|
41
|
-
The origin value can include at most one '*' wild character.
|
42
|
-
For example, "http://*.example.com". You can also specify
|
43
|
-
only * as the origin value allowing all origins cross-domain access.
|
44
|
-
|
45
|
-
:ivar allowed_header: Specifies which headers are allowed in a
|
46
|
-
pre-flight OPTIONS request via the
|
47
|
-
Access-Control-Request-Headers header. Each header name
|
48
|
-
specified in the Access-Control-Request-Headers header must
|
49
|
-
have a corresponding entry in the rule. Amazon S3 will send
|
50
|
-
only the allowed headers in a response that were requested.
|
51
|
-
This can contain at most one * wild character.
|
52
|
-
|
53
|
-
:ivar max_age_seconds: The time in seconds that your browser is to
|
54
|
-
cache the preflight response for the specified resource.
|
55
|
-
|
56
|
-
:ivar expose_header: One or more headers in the response that you
|
57
|
-
want customers to be able to access from their applications
|
58
|
-
(for example, from a JavaScript XMLHttpRequest object). You
|
59
|
-
add one ExposeHeader element in the rule for each header.
|
60
|
-
"""
|
61
|
-
|
62
|
-
def __init__(self, allowed_method=None, allowed_origin=None,
|
63
|
-
id=None, allowed_header=None, max_age_seconds=None,
|
64
|
-
expose_header=None):
|
65
|
-
if allowed_method is None:
|
66
|
-
allowed_method = []
|
67
|
-
self.allowed_method = allowed_method
|
68
|
-
if allowed_origin is None:
|
69
|
-
allowed_origin = []
|
70
|
-
self.allowed_origin = allowed_origin
|
71
|
-
self.id = id
|
72
|
-
if allowed_header is None:
|
73
|
-
allowed_header = []
|
74
|
-
self.allowed_header = allowed_header
|
75
|
-
self.max_age_seconds = max_age_seconds
|
76
|
-
if expose_header is None:
|
77
|
-
expose_header = []
|
78
|
-
self.expose_header = expose_header
|
79
|
-
|
80
|
-
def __repr__(self):
|
81
|
-
return '<Rule: %s>' % self.id
|
82
|
-
|
83
|
-
def startElement(self, name, attrs, connection):
|
84
|
-
return None
|
85
|
-
|
86
|
-
def endElement(self, name, value, connection):
|
87
|
-
if name == 'ID':
|
88
|
-
self.id = value
|
89
|
-
elif name == 'AllowedMethod':
|
90
|
-
self.allowed_method.append(value)
|
91
|
-
elif name == 'AllowedOrigin':
|
92
|
-
self.allowed_origin.append(value)
|
93
|
-
elif name == 'AllowedHeader':
|
94
|
-
self.allowed_header.append(value)
|
95
|
-
elif name == 'MaxAgeSeconds':
|
96
|
-
self.max_age_seconds = int(value)
|
97
|
-
elif name == 'ExposeHeader':
|
98
|
-
self.expose_header.append(value)
|
99
|
-
else:
|
100
|
-
setattr(self, name, value)
|
101
|
-
|
102
|
-
def to_xml(self):
|
103
|
-
s = '<CORSRule>'
|
104
|
-
for allowed_method in self.allowed_method:
|
105
|
-
s += '<AllowedMethod>%s</AllowedMethod>' % allowed_method
|
106
|
-
for allowed_origin in self.allowed_origin:
|
107
|
-
s += '<AllowedOrigin>%s</AllowedOrigin>' % allowed_origin
|
108
|
-
for allowed_header in self.allowed_header:
|
109
|
-
s += '<AllowedHeader>%s</AllowedHeader>' % allowed_header
|
110
|
-
for expose_header in self.expose_header:
|
111
|
-
s += '<ExposeHeader>%s</ExposeHeader>' % expose_header
|
112
|
-
if self.max_age_seconds:
|
113
|
-
s += '<MaxAgeSeconds>%d</MaxAgeSeconds>' % self.max_age_seconds
|
114
|
-
if self.id:
|
115
|
-
s += '<ID>%s</ID>' % self.id
|
116
|
-
s += '</CORSRule>'
|
117
|
-
return s
|
118
|
-
|
119
|
-
|
120
|
-
class CORSConfiguration(list):
|
121
|
-
"""
|
122
|
-
A container for the rules associated with a CORS configuration.
|
123
|
-
"""
|
124
|
-
|
125
|
-
def startElement(self, name, attrs, connection):
|
126
|
-
if name == 'CORSRule':
|
127
|
-
rule = CORSRule()
|
128
|
-
self.append(rule)
|
129
|
-
return rule
|
130
|
-
return None
|
131
|
-
|
132
|
-
def endElement(self, name, value, connection):
|
133
|
-
setattr(self, name, value)
|
134
|
-
|
135
|
-
def to_xml(self):
|
136
|
-
"""
|
137
|
-
Returns a string containing the XML version of the Lifecycle
|
138
|
-
configuration as defined by S3.
|
139
|
-
"""
|
140
|
-
s = '<CORSConfiguration>'
|
141
|
-
for rule in self:
|
142
|
-
s += rule.to_xml()
|
143
|
-
s += '</CORSConfiguration>'
|
144
|
-
return s
|
145
|
-
|
146
|
-
def add_rule(self, allowed_method, allowed_origin,
|
147
|
-
id=None, allowed_header=None, max_age_seconds=None,
|
148
|
-
expose_header=None):
|
149
|
-
"""
|
150
|
-
Add a rule to this CORS configuration. This only adds
|
151
|
-
the rule to the local copy. To install the new rule(s) on
|
152
|
-
the bucket, you need to pass this CORS config object
|
153
|
-
to the set_cors method of the Bucket object.
|
154
|
-
|
155
|
-
:type allowed_methods: list of str
|
156
|
-
:param allowed_methods: An HTTP method that you want to allow the
|
157
|
-
origin to execute. Each CORSRule must identify at least one
|
158
|
-
origin and one method. Valid values are:
|
159
|
-
GET|PUT|HEAD|POST|DELETE
|
160
|
-
|
161
|
-
:type allowed_origin: list of str
|
162
|
-
:param allowed_origin: An origin that you want to allow cross-domain
|
163
|
-
requests from. This can contain at most one * wild character.
|
164
|
-
Each CORSRule must identify at least one origin and one method.
|
165
|
-
The origin value can include at most one '*' wild character.
|
166
|
-
For example, "http://*.example.com". You can also specify
|
167
|
-
only * as the origin value allowing all origins
|
168
|
-
cross-domain access.
|
169
|
-
|
170
|
-
:type id: str
|
171
|
-
:param id: A unique identifier for the rule. The ID value can be
|
172
|
-
up to 255 characters long. The IDs help you find a rule in
|
173
|
-
the configuration.
|
174
|
-
|
175
|
-
:type allowed_header: list of str
|
176
|
-
:param allowed_header: Specifies which headers are allowed in a
|
177
|
-
pre-flight OPTIONS request via the
|
178
|
-
Access-Control-Request-Headers header. Each header name
|
179
|
-
specified in the Access-Control-Request-Headers header must
|
180
|
-
have a corresponding entry in the rule. Amazon S3 will send
|
181
|
-
only the allowed headers in a response that were requested.
|
182
|
-
This can contain at most one * wild character.
|
183
|
-
|
184
|
-
:type max_age_seconds: int
|
185
|
-
:param max_age_seconds: The time in seconds that your browser is to
|
186
|
-
cache the preflight response for the specified resource.
|
187
|
-
|
188
|
-
:type expose_header: list of str
|
189
|
-
:param expose_header: One or more headers in the response that you
|
190
|
-
want customers to be able to access from their applications
|
191
|
-
(for example, from a JavaScript XMLHttpRequest object). You
|
192
|
-
add one ExposeHeader element in the rule for each header.
|
193
|
-
"""
|
194
|
-
if not isinstance(allowed_method, (list, tuple)):
|
195
|
-
allowed_method = [allowed_method]
|
196
|
-
if not isinstance(allowed_origin, (list, tuple)):
|
197
|
-
allowed_origin = [allowed_origin]
|
198
|
-
if not isinstance(allowed_origin, (list, tuple)):
|
199
|
-
if allowed_origin is None:
|
200
|
-
allowed_origin = []
|
201
|
-
else:
|
202
|
-
allowed_origin = [allowed_origin]
|
203
|
-
if not isinstance(expose_header, (list, tuple)):
|
204
|
-
if expose_header is None:
|
205
|
-
expose_header = []
|
206
|
-
else:
|
207
|
-
expose_header = [expose_header]
|
208
|
-
rule = CORSRule(allowed_method, allowed_origin, id, allowed_header,
|
209
|
-
max_age_seconds, expose_header)
|
210
|
-
self.append(rule)
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
-
# copy of this software and associated documentation files (the
|
5
|
-
# "Software"), to deal in the Software without restriction, including
|
6
|
-
# without limitation the rights to use, copy, modify, merge, publish, dis-
|
7
|
-
# tribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
-
# persons to whom the Software is furnished to do so, subject to the fol-
|
9
|
-
# lowing conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included
|
12
|
-
# in all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
-
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
16
|
-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
17
|
-
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
18
|
-
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
20
|
-
# IN THE SOFTWARE.
|
21
|
-
|
22
|
-
from boto.s3.user import User
|
23
|
-
|
24
|
-
class DeleteMarker:
|
25
|
-
def __init__(self, bucket=None, name=None):
|
26
|
-
self.bucket = bucket
|
27
|
-
self.name = name
|
28
|
-
self.version_id = None
|
29
|
-
self.is_latest = False
|
30
|
-
self.last_modified = None
|
31
|
-
self.owner = None
|
32
|
-
|
33
|
-
def startElement(self, name, attrs, connection):
|
34
|
-
if name == 'Owner':
|
35
|
-
self.owner = User(self)
|
36
|
-
return self.owner
|
37
|
-
else:
|
38
|
-
return None
|
39
|
-
|
40
|
-
def endElement(self, name, value, connection):
|
41
|
-
if name == 'Key':
|
42
|
-
self.name = value
|
43
|
-
elif name == 'IsLatest':
|
44
|
-
if value == 'true':
|
45
|
-
self.is_latest = True
|
46
|
-
else:
|
47
|
-
self.is_latest = False
|
48
|
-
elif name == 'LastModified':
|
49
|
-
self.last_modified = value
|
50
|
-
elif name == 'Owner':
|
51
|
-
pass
|
52
|
-
elif name == 'VersionId':
|
53
|
-
self.version_id = value
|
54
|
-
else:
|
55
|
-
setattr(self, name, value)
|
@@ -1,1712 +0,0 @@
|
|
1
|
-
# Copyright (c) 2006-2012 Mitch Garnaat http://garnaat.org/
|
2
|
-
# Copyright (c) 2011, Nexenta Systems Inc.
|
3
|
-
# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
6
|
-
# copy of this software and associated documentation files (the
|
7
|
-
# "Software"), to deal in the Software without restriction, including
|
8
|
-
# without limitation the rights to use, copy, modify, merge, publish, dis-
|
9
|
-
# tribute, sublicense, and/or sell copies of the Software, and to permit
|
10
|
-
# persons to whom the Software is furnished to do so, subject to the fol-
|
11
|
-
# lowing conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included
|
14
|
-
# in all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
17
|
-
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
18
|
-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
19
|
-
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
-
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
-
# IN THE SOFTWARE.
|
23
|
-
|
24
|
-
import mimetypes
|
25
|
-
import os
|
26
|
-
import re
|
27
|
-
import rfc822
|
28
|
-
import StringIO
|
29
|
-
import base64
|
30
|
-
import binascii
|
31
|
-
import math
|
32
|
-
import urllib
|
33
|
-
import boto.utils
|
34
|
-
from boto.exception import BotoClientError
|
35
|
-
from boto.provider import Provider
|
36
|
-
from boto.s3.keyfile import KeyFile
|
37
|
-
from boto.s3.user import User
|
38
|
-
from boto import UserAgent
|
39
|
-
from boto.utils import compute_md5
|
40
|
-
try:
|
41
|
-
from hashlib import md5
|
42
|
-
except ImportError:
|
43
|
-
from md5 import md5
|
44
|
-
|
45
|
-
|
46
|
-
class Key(object):
|
47
|
-
"""
|
48
|
-
Represents a key (object) in an S3 bucket.
|
49
|
-
|
50
|
-
:ivar bucket: The parent :class:`boto.s3.bucket.Bucket`.
|
51
|
-
:ivar name: The name of this Key object.
|
52
|
-
:ivar metadata: A dictionary containing user metadata that you
|
53
|
-
wish to store with the object or that has been retrieved from
|
54
|
-
an existing object.
|
55
|
-
:ivar cache_control: The value of the `Cache-Control` HTTP header.
|
56
|
-
:ivar content_type: The value of the `Content-Type` HTTP header.
|
57
|
-
:ivar content_encoding: The value of the `Content-Encoding` HTTP header.
|
58
|
-
:ivar content_disposition: The value of the `Content-Disposition` HTTP
|
59
|
-
header.
|
60
|
-
:ivar content_language: The value of the `Content-Language` HTTP header.
|
61
|
-
:ivar etag: The `etag` associated with this object.
|
62
|
-
:ivar last_modified: The string timestamp representing the last
|
63
|
-
time this object was modified in S3.
|
64
|
-
:ivar owner: The ID of the owner of this object.
|
65
|
-
:ivar storage_class: The storage class of the object. Currently, one of:
|
66
|
-
STANDARD | REDUCED_REDUNDANCY | GLACIER
|
67
|
-
:ivar md5: The MD5 hash of the contents of the object.
|
68
|
-
:ivar size: The size, in bytes, of the object.
|
69
|
-
:ivar version_id: The version ID of this object, if it is a versioned
|
70
|
-
object.
|
71
|
-
:ivar encrypted: Whether the object is encrypted while at rest on
|
72
|
-
the server.
|
73
|
-
"""
|
74
|
-
|
75
|
-
DefaultContentType = 'application/octet-stream'
|
76
|
-
|
77
|
-
RestoreBody = """<?xml version="1.0" encoding="UTF-8"?>
|
78
|
-
<RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01">
|
79
|
-
<Days>%s</Days>
|
80
|
-
</RestoreRequest>"""
|
81
|
-
|
82
|
-
|
83
|
-
BufferSize = 8192
|
84
|
-
|
85
|
-
# The object metadata fields a user can set, other than custom metadata
|
86
|
-
# fields (i.e., those beginning with a provider-specific prefix like
|
87
|
-
# x-amz-meta).
|
88
|
-
base_user_settable_fields = set(["cache-control", "content-disposition",
|
89
|
-
"content-encoding", "content-language",
|
90
|
-
"content-md5", "content-type"])
|
91
|
-
_underscore_base_user_settable_fields = set()
|
92
|
-
for f in base_user_settable_fields:
|
93
|
-
_underscore_base_user_settable_fields.add(f.replace('-', '_'))
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
def __init__(self, bucket=None, name=None):
|
98
|
-
self.bucket = bucket
|
99
|
-
self.name = name
|
100
|
-
self.metadata = {}
|
101
|
-
self.cache_control = None
|
102
|
-
self.content_type = self.DefaultContentType
|
103
|
-
self.content_encoding = None
|
104
|
-
self.content_disposition = None
|
105
|
-
self.content_language = None
|
106
|
-
self.filename = None
|
107
|
-
self.etag = None
|
108
|
-
self.is_latest = False
|
109
|
-
self.last_modified = None
|
110
|
-
self.owner = None
|
111
|
-
self.storage_class = 'STANDARD'
|
112
|
-
self.md5 = None
|
113
|
-
self.base64md5 = None
|
114
|
-
self.path = None
|
115
|
-
self.resp = None
|
116
|
-
self.mode = None
|
117
|
-
self.size = None
|
118
|
-
self.version_id = None
|
119
|
-
self.source_version_id = None
|
120
|
-
self.delete_marker = False
|
121
|
-
self.encrypted = None
|
122
|
-
# If the object is being restored, this attribute will be set to True.
|
123
|
-
# If the object is restored, it will be set to False. Otherwise this
|
124
|
-
# value will be None. If the restore is completed (ongoing_restore =
|
125
|
-
# False), the expiry_date will be populated with the expiry date of the
|
126
|
-
# restored object.
|
127
|
-
self.ongoing_restore = None
|
128
|
-
self.expiry_date = None
|
129
|
-
|
130
|
-
def __repr__(self):
|
131
|
-
if self.bucket:
|
132
|
-
return '<Key: %s,%s>' % (self.bucket.name, self.name)
|
133
|
-
else:
|
134
|
-
return '<Key: None,%s>' % self.name
|
135
|
-
|
136
|
-
def __getattr__(self, name):
|
137
|
-
if name == 'key':
|
138
|
-
return self.name
|
139
|
-
else:
|
140
|
-
raise AttributeError
|
141
|
-
|
142
|
-
def __setattr__(self, name, value):
|
143
|
-
if name == 'key':
|
144
|
-
self.__dict__['name'] = value
|
145
|
-
else:
|
146
|
-
self.__dict__[name] = value
|
147
|
-
|
148
|
-
def __iter__(self):
|
149
|
-
return self
|
150
|
-
|
151
|
-
@property
|
152
|
-
def provider(self):
|
153
|
-
provider = None
|
154
|
-
if self.bucket and self.bucket.connection:
|
155
|
-
provider = self.bucket.connection.provider
|
156
|
-
return provider
|
157
|
-
|
158
|
-
def get_md5_from_hexdigest(self, md5_hexdigest):
|
159
|
-
"""
|
160
|
-
A utility function to create the 2-tuple (md5hexdigest, base64md5)
|
161
|
-
from just having a precalculated md5_hexdigest.
|
162
|
-
"""
|
163
|
-
digest = binascii.unhexlify(md5_hexdigest)
|
164
|
-
base64md5 = base64.encodestring(digest)
|
165
|
-
if base64md5[-1] == '\n':
|
166
|
-
base64md5 = base64md5[0:-1]
|
167
|
-
return (md5_hexdigest, base64md5)
|
168
|
-
|
169
|
-
def handle_encryption_headers(self, resp):
|
170
|
-
provider = self.bucket.connection.provider
|
171
|
-
if provider.server_side_encryption_header:
|
172
|
-
self.encrypted = resp.getheader(provider.server_side_encryption_header, None)
|
173
|
-
else:
|
174
|
-
self.encrypted = None
|
175
|
-
|
176
|
-
def handle_version_headers(self, resp, force=False):
|
177
|
-
provider = self.bucket.connection.provider
|
178
|
-
# If the Key object already has a version_id attribute value, it
|
179
|
-
# means that it represents an explicit version and the user is
|
180
|
-
# doing a get_contents_*(version_id=<foo>) to retrieve another
|
181
|
-
# version of the Key. In that case, we don't really want to
|
182
|
-
# overwrite the version_id in this Key object. Comprende?
|
183
|
-
if self.version_id is None or force:
|
184
|
-
self.version_id = resp.getheader(provider.version_id, None)
|
185
|
-
self.source_version_id = resp.getheader(provider.copy_source_version_id,
|
186
|
-
None)
|
187
|
-
if resp.getheader(provider.delete_marker, 'false') == 'true':
|
188
|
-
self.delete_marker = True
|
189
|
-
else:
|
190
|
-
self.delete_marker = False
|
191
|
-
|
192
|
-
def handle_restore_headers(self, response):
|
193
|
-
header = response.getheader('x-amz-restore')
|
194
|
-
if header is None:
|
195
|
-
return
|
196
|
-
parts = header.split(',', 1)
|
197
|
-
for part in parts:
|
198
|
-
key, val = [i.strip() for i in part.split('=')]
|
199
|
-
val = val.replace('"', '')
|
200
|
-
if key == 'ongoing-request':
|
201
|
-
self.ongoing_restore = True if val.lower() == 'true' else False
|
202
|
-
elif key == 'expiry-date':
|
203
|
-
self.expiry_date = val
|
204
|
-
|
205
|
-
def open_read(self, headers=None, query_args='',
|
206
|
-
override_num_retries=None, response_headers=None):
|
207
|
-
"""
|
208
|
-
Open this key for reading
|
209
|
-
|
210
|
-
:type headers: dict
|
211
|
-
:param headers: Headers to pass in the web request
|
212
|
-
|
213
|
-
:type query_args: string
|
214
|
-
:param query_args: Arguments to pass in the query string
|
215
|
-
(ie, 'torrent')
|
216
|
-
|
217
|
-
:type override_num_retries: int
|
218
|
-
:param override_num_retries: If not None will override configured
|
219
|
-
num_retries parameter for underlying GET.
|
220
|
-
|
221
|
-
:type response_headers: dict
|
222
|
-
:param response_headers: A dictionary containing HTTP
|
223
|
-
headers/values that will override any headers associated
|
224
|
-
with the stored object in the response. See
|
225
|
-
http://goo.gl/EWOPb for details.
|
226
|
-
"""
|
227
|
-
if self.resp == None:
|
228
|
-
self.mode = 'r'
|
229
|
-
|
230
|
-
provider = self.bucket.connection.provider
|
231
|
-
self.resp = self.bucket.connection.make_request(
|
232
|
-
'GET', self.bucket.name, self.name, headers,
|
233
|
-
query_args=query_args,
|
234
|
-
override_num_retries=override_num_retries)
|
235
|
-
if self.resp.status < 199 or self.resp.status > 299:
|
236
|
-
body = self.resp.read()
|
237
|
-
raise provider.storage_response_error(self.resp.status,
|
238
|
-
self.resp.reason, body)
|
239
|
-
response_headers = self.resp.msg
|
240
|
-
self.metadata = boto.utils.get_aws_metadata(response_headers,
|
241
|
-
provider)
|
242
|
-
for name, value in response_headers.items():
|
243
|
-
# To get correct size for Range GETs, use Content-Range
|
244
|
-
# header if one was returned. If not, use Content-Length
|
245
|
-
# header.
|
246
|
-
if (name.lower() == 'content-length' and
|
247
|
-
'Content-Range' not in response_headers):
|
248
|
-
self.size = int(value)
|
249
|
-
elif name.lower() == 'content-range':
|
250
|
-
end_range = re.sub('.*/(.*)', '\\1', value)
|
251
|
-
self.size = int(end_range)
|
252
|
-
elif name.lower() == 'etag':
|
253
|
-
self.etag = value
|
254
|
-
elif name.lower() == 'content-type':
|
255
|
-
self.content_type = value
|
256
|
-
elif name.lower() == 'content-encoding':
|
257
|
-
self.content_encoding = value
|
258
|
-
elif name.lower() == 'content-language':
|
259
|
-
self.content_language = value
|
260
|
-
elif name.lower() == 'last-modified':
|
261
|
-
self.last_modified = value
|
262
|
-
elif name.lower() == 'cache-control':
|
263
|
-
self.cache_control = value
|
264
|
-
elif name.lower() == 'content-disposition':
|
265
|
-
self.content_disposition = value
|
266
|
-
self.handle_version_headers(self.resp)
|
267
|
-
self.handle_encryption_headers(self.resp)
|
268
|
-
|
269
|
-
def open_write(self, headers=None, override_num_retries=None):
|
270
|
-
"""
|
271
|
-
Open this key for writing.
|
272
|
-
Not yet implemented
|
273
|
-
|
274
|
-
:type headers: dict
|
275
|
-
:param headers: Headers to pass in the write request
|
276
|
-
|
277
|
-
:type override_num_retries: int
|
278
|
-
:param override_num_retries: If not None will override configured
|
279
|
-
num_retries parameter for underlying PUT.
|
280
|
-
"""
|
281
|
-
raise BotoClientError('Not Implemented')
|
282
|
-
|
283
|
-
def open(self, mode='r', headers=None, query_args=None,
|
284
|
-
override_num_retries=None):
|
285
|
-
if mode == 'r':
|
286
|
-
self.mode = 'r'
|
287
|
-
self.open_read(headers=headers, query_args=query_args,
|
288
|
-
override_num_retries=override_num_retries)
|
289
|
-
elif mode == 'w':
|
290
|
-
self.mode = 'w'
|
291
|
-
self.open_write(headers=headers,
|
292
|
-
override_num_retries=override_num_retries)
|
293
|
-
else:
|
294
|
-
raise BotoClientError('Invalid mode: %s' % mode)
|
295
|
-
|
296
|
-
closed = False
|
297
|
-
|
298
|
-
def close(self, fast=False):
|
299
|
-
"""
|
300
|
-
Close this key.
|
301
|
-
|
302
|
-
:type fast: bool
|
303
|
-
:param fast: True if you want the connection to be closed without first
|
304
|
-
reading the content. This should only be used in cases where subsequent
|
305
|
-
calls don't need to return the content from the open HTTP connection.
|
306
|
-
Note: As explained at
|
307
|
-
http://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.getresponse,
|
308
|
-
callers must read the whole response before sending a new request to the
|
309
|
-
server. Calling Key.close(fast=True) and making a subsequent request to
|
310
|
-
the server will work because boto will get an httplib exception and
|
311
|
-
close/reopen the connection.
|
312
|
-
|
313
|
-
"""
|
314
|
-
if self.resp and not fast:
|
315
|
-
self.resp.read()
|
316
|
-
self.resp = None
|
317
|
-
self.mode = None
|
318
|
-
self.closed = True
|
319
|
-
|
320
|
-
def next(self):
|
321
|
-
"""
|
322
|
-
By providing a next method, the key object supports use as an iterator.
|
323
|
-
For example, you can now say:
|
324
|
-
|
325
|
-
for bytes in key:
|
326
|
-
write bytes to a file or whatever
|
327
|
-
|
328
|
-
All of the HTTP connection stuff is handled for you.
|
329
|
-
"""
|
330
|
-
self.open_read()
|
331
|
-
data = self.resp.read(self.BufferSize)
|
332
|
-
if not data:
|
333
|
-
self.close()
|
334
|
-
raise StopIteration
|
335
|
-
return data
|
336
|
-
|
337
|
-
def read(self, size=0):
|
338
|
-
self.open_read()
|
339
|
-
if size == 0:
|
340
|
-
data = self.resp.read()
|
341
|
-
else:
|
342
|
-
data = self.resp.read(size)
|
343
|
-
if not data:
|
344
|
-
self.close()
|
345
|
-
return data
|
346
|
-
|
347
|
-
def change_storage_class(self, new_storage_class, dst_bucket=None,
|
348
|
-
validate_dst_bucket=True):
|
349
|
-
"""
|
350
|
-
Change the storage class of an existing key.
|
351
|
-
Depending on whether a different destination bucket is supplied
|
352
|
-
or not, this will either move the item within the bucket, preserving
|
353
|
-
all metadata and ACL info bucket changing the storage class or it
|
354
|
-
will copy the item to the provided destination bucket, also
|
355
|
-
preserving metadata and ACL info.
|
356
|
-
|
357
|
-
:type new_storage_class: string
|
358
|
-
:param new_storage_class: The new storage class for the Key.
|
359
|
-
Possible values are:
|
360
|
-
* STANDARD
|
361
|
-
* REDUCED_REDUNDANCY
|
362
|
-
|
363
|
-
:type dst_bucket: string
|
364
|
-
:param dst_bucket: The name of a destination bucket. If not
|
365
|
-
provided the current bucket of the key will be used.
|
366
|
-
|
367
|
-
:type validate_dst_bucket: bool
|
368
|
-
:param validate_dst_bucket: If True, will validate the dst_bucket
|
369
|
-
by using an extra list request.
|
370
|
-
"""
|
371
|
-
if new_storage_class == 'STANDARD':
|
372
|
-
return self.copy(self.bucket.name, self.name,
|
373
|
-
reduced_redundancy=False, preserve_acl=True,
|
374
|
-
validate_dst_bucket=validate_dst_bucket)
|
375
|
-
elif new_storage_class == 'REDUCED_REDUNDANCY':
|
376
|
-
return self.copy(self.bucket.name, self.name,
|
377
|
-
reduced_redundancy=True, preserve_acl=True,
|
378
|
-
validate_dst_bucket=validate_dst_bucket)
|
379
|
-
else:
|
380
|
-
raise BotoClientError('Invalid storage class: %s' %
|
381
|
-
new_storage_class)
|
382
|
-
|
383
|
-
def copy(self, dst_bucket, dst_key, metadata=None,
|
384
|
-
reduced_redundancy=False, preserve_acl=False,
|
385
|
-
encrypt_key=False, validate_dst_bucket=True):
|
386
|
-
"""
|
387
|
-
Copy this Key to another bucket.
|
388
|
-
|
389
|
-
:type dst_bucket: string
|
390
|
-
:param dst_bucket: The name of the destination bucket
|
391
|
-
|
392
|
-
:type dst_key: string
|
393
|
-
:param dst_key: The name of the destination key
|
394
|
-
|
395
|
-
:type metadata: dict
|
396
|
-
:param metadata: Metadata to be associated with new key. If
|
397
|
-
metadata is supplied, it will replace the metadata of the
|
398
|
-
source key being copied. If no metadata is supplied, the
|
399
|
-
source key's metadata will be copied to the new key.
|
400
|
-
|
401
|
-
:type reduced_redundancy: bool
|
402
|
-
:param reduced_redundancy: If True, this will force the
|
403
|
-
storage class of the new Key to be REDUCED_REDUNDANCY
|
404
|
-
regardless of the storage class of the key being copied.
|
405
|
-
The Reduced Redundancy Storage (RRS) feature of S3,
|
406
|
-
provides lower redundancy at lower storage cost.
|
407
|
-
|
408
|
-
:type preserve_acl: bool
|
409
|
-
:param preserve_acl: If True, the ACL from the source key will
|
410
|
-
be copied to the destination key. If False, the
|
411
|
-
destination key will have the default ACL. Note that
|
412
|
-
preserving the ACL in the new key object will require two
|
413
|
-
additional API calls to S3, one to retrieve the current
|
414
|
-
ACL and one to set that ACL on the new object. If you
|
415
|
-
don't care about the ACL, a value of False will be
|
416
|
-
significantly more efficient.
|
417
|
-
|
418
|
-
:type encrypt_key: bool
|
419
|
-
:param encrypt_key: If True, the new copy of the object will
|
420
|
-
be encrypted on the server-side by S3 and will be stored
|
421
|
-
in an encrypted form while at rest in S3.
|
422
|
-
|
423
|
-
:type validate_dst_bucket: bool
|
424
|
-
:param validate_dst_bucket: If True, will validate the dst_bucket
|
425
|
-
by using an extra list request.
|
426
|
-
|
427
|
-
:rtype: :class:`boto.s3.key.Key` or subclass
|
428
|
-
:returns: An instance of the newly created key object
|
429
|
-
"""
|
430
|
-
dst_bucket = self.bucket.connection.lookup(dst_bucket,
|
431
|
-
validate_dst_bucket)
|
432
|
-
if reduced_redundancy:
|
433
|
-
storage_class = 'REDUCED_REDUNDANCY'
|
434
|
-
else:
|
435
|
-
storage_class = self.storage_class
|
436
|
-
return dst_bucket.copy_key(dst_key, self.bucket.name,
|
437
|
-
self.name, metadata,
|
438
|
-
storage_class=storage_class,
|
439
|
-
preserve_acl=preserve_acl,
|
440
|
-
encrypt_key=encrypt_key)
|
441
|
-
|
442
|
-
def startElement(self, name, attrs, connection):
|
443
|
-
if name == 'Owner':
|
444
|
-
self.owner = User(self)
|
445
|
-
return self.owner
|
446
|
-
else:
|
447
|
-
return None
|
448
|
-
|
449
|
-
def endElement(self, name, value, connection):
|
450
|
-
if name == 'Key':
|
451
|
-
self.name = value
|
452
|
-
elif name == 'ETag':
|
453
|
-
self.etag = value
|
454
|
-
elif name == 'IsLatest':
|
455
|
-
if value == 'true':
|
456
|
-
self.is_latest = True
|
457
|
-
else:
|
458
|
-
self.is_latest = False
|
459
|
-
elif name == 'LastModified':
|
460
|
-
self.last_modified = value
|
461
|
-
elif name == 'Size':
|
462
|
-
self.size = int(value)
|
463
|
-
elif name == 'StorageClass':
|
464
|
-
self.storage_class = value
|
465
|
-
elif name == 'Owner':
|
466
|
-
pass
|
467
|
-
elif name == 'VersionId':
|
468
|
-
self.version_id = value
|
469
|
-
else:
|
470
|
-
setattr(self, name, value)
|
471
|
-
|
472
|
-
def exists(self):
|
473
|
-
"""
|
474
|
-
Returns True if the key exists
|
475
|
-
|
476
|
-
:rtype: bool
|
477
|
-
:return: Whether the key exists on S3
|
478
|
-
"""
|
479
|
-
return bool(self.bucket.lookup(self.name))
|
480
|
-
|
481
|
-
def delete(self):
|
482
|
-
"""
|
483
|
-
Delete this key from S3
|
484
|
-
"""
|
485
|
-
return self.bucket.delete_key(self.name, version_id=self.version_id)
|
486
|
-
|
487
|
-
def get_metadata(self, name):
|
488
|
-
return self.metadata.get(name)
|
489
|
-
|
490
|
-
def set_metadata(self, name, value):
|
491
|
-
self.metadata[name] = value
|
492
|
-
|
493
|
-
def update_metadata(self, d):
|
494
|
-
self.metadata.update(d)
|
495
|
-
|
496
|
-
# convenience methods for setting/getting ACL
|
497
|
-
def set_acl(self, acl_str, headers=None):
|
498
|
-
if self.bucket != None:
|
499
|
-
self.bucket.set_acl(acl_str, self.name, headers=headers)
|
500
|
-
|
501
|
-
def get_acl(self, headers=None):
|
502
|
-
if self.bucket != None:
|
503
|
-
return self.bucket.get_acl(self.name, headers=headers)
|
504
|
-
|
505
|
-
def get_xml_acl(self, headers=None):
|
506
|
-
if self.bucket != None:
|
507
|
-
return self.bucket.get_xml_acl(self.name, headers=headers)
|
508
|
-
|
509
|
-
def set_xml_acl(self, acl_str, headers=None):
|
510
|
-
if self.bucket != None:
|
511
|
-
return self.bucket.set_xml_acl(acl_str, self.name, headers=headers)
|
512
|
-
|
513
|
-
def set_canned_acl(self, acl_str, headers=None):
|
514
|
-
return self.bucket.set_canned_acl(acl_str, self.name, headers)
|
515
|
-
|
516
|
-
def get_redirect(self):
|
517
|
-
"""Return the redirect location configured for this key.
|
518
|
-
|
519
|
-
If no redirect is configured (via set_redirect), then None
|
520
|
-
will be returned.
|
521
|
-
|
522
|
-
"""
|
523
|
-
response = self.bucket.connection.make_request(
|
524
|
-
'HEAD', self.bucket.name, self.name)
|
525
|
-
if response.status == 200:
|
526
|
-
return response.getheader('x-amz-website-redirect-location')
|
527
|
-
else:
|
528
|
-
raise self.provider.storage_response_error(
|
529
|
-
response.status, response.reason, response.read())
|
530
|
-
|
531
|
-
def set_redirect(self, redirect_location):
|
532
|
-
"""Configure this key to redirect to another location.
|
533
|
-
|
534
|
-
When the bucket associated with this key is accessed from the website
|
535
|
-
endpoint, a 301 redirect will be issued to the specified
|
536
|
-
`redirect_location`.
|
537
|
-
|
538
|
-
:type redirect_location: string
|
539
|
-
:param redirect_location: The location to redirect.
|
540
|
-
|
541
|
-
"""
|
542
|
-
headers = {'x-amz-website-redirect-location': redirect_location}
|
543
|
-
response = self.bucket.connection.make_request('PUT', self.bucket.name,
|
544
|
-
self.name, headers)
|
545
|
-
if response.status == 200:
|
546
|
-
return True
|
547
|
-
else:
|
548
|
-
raise self.provider.storage_response_error(
|
549
|
-
response.status, response.reason, response.read())
|
550
|
-
|
551
|
-
def make_public(self, headers=None):
|
552
|
-
return self.bucket.set_canned_acl('public-read', self.name, headers)
|
553
|
-
|
554
|
-
def generate_url(self, expires_in, method='GET', headers=None,
|
555
|
-
query_auth=True, force_http=False, response_headers=None,
|
556
|
-
expires_in_absolute=False, version_id=None,
|
557
|
-
policy=None, reduced_redundancy=False, encrypt_key=False):
|
558
|
-
"""
|
559
|
-
Generate a URL to access this key.
|
560
|
-
|
561
|
-
:type expires_in: int
|
562
|
-
:param expires_in: How long the url is valid for, in seconds
|
563
|
-
|
564
|
-
:type method: string
|
565
|
-
:param method: The method to use for retrieving the file
|
566
|
-
(default is GET)
|
567
|
-
|
568
|
-
:type headers: dict
|
569
|
-
:param headers: Any headers to pass along in the request
|
570
|
-
|
571
|
-
:type query_auth: bool
|
572
|
-
:param query_auth:
|
573
|
-
|
574
|
-
:type force_http: bool
|
575
|
-
:param force_http: If True, http will be used instead of https.
|
576
|
-
|
577
|
-
:type response_headers: dict
|
578
|
-
:param response_headers: A dictionary containing HTTP
|
579
|
-
headers/values that will override any headers associated
|
580
|
-
with the stored object in the response. See
|
581
|
-
http://goo.gl/EWOPb for details.
|
582
|
-
|
583
|
-
:type expires_in_absolute: bool
|
584
|
-
:param expires_in_absolute:
|
585
|
-
|
586
|
-
:type version_id: string
|
587
|
-
:param version_id: The version_id of the object to GET. If specified
|
588
|
-
this overrides any value in the key.
|
589
|
-
|
590
|
-
:type policy: :class:`boto.s3.acl.CannedACLStrings`
|
591
|
-
:param policy: A canned ACL policy that will be applied to the
|
592
|
-
new key in S3.
|
593
|
-
|
594
|
-
:type reduced_redundancy: bool
|
595
|
-
:param reduced_redundancy: If True, this will set the storage
|
596
|
-
class of the new Key to be REDUCED_REDUNDANCY. The Reduced
|
597
|
-
Redundancy Storage (RRS) feature of S3, provides lower
|
598
|
-
redundancy at lower storage cost.
|
599
|
-
|
600
|
-
:type encrypt_key: bool
|
601
|
-
:param encrypt_key: If True, the new copy of the object will
|
602
|
-
be encrypted on the server-side by S3 and will be stored
|
603
|
-
in an encrypted form while at rest in S3.
|
604
|
-
|
605
|
-
:rtype: string
|
606
|
-
:return: The URL to access the key
|
607
|
-
"""
|
608
|
-
provider = self.bucket.connection.provider
|
609
|
-
version_id = version_id or self.version_id
|
610
|
-
if headers is None:
|
611
|
-
headers = {}
|
612
|
-
else:
|
613
|
-
headers = headers.copy()
|
614
|
-
|
615
|
-
# add headers accordingly (usually PUT case)
|
616
|
-
if policy:
|
617
|
-
headers[provider.acl_header] = policy
|
618
|
-
if reduced_redundancy:
|
619
|
-
self.storage_class = 'REDUCED_REDUNDANCY'
|
620
|
-
if provider.storage_class_header:
|
621
|
-
headers[provider.storage_class_header] = self.storage_class
|
622
|
-
if encrypt_key:
|
623
|
-
headers[provider.server_side_encryption_header] = 'AES256'
|
624
|
-
headers = boto.utils.merge_meta(headers, self.metadata, provider)
|
625
|
-
|
626
|
-
return self.bucket.connection.generate_url(expires_in, method,
|
627
|
-
self.bucket.name, self.name,
|
628
|
-
headers, query_auth,
|
629
|
-
force_http,
|
630
|
-
response_headers,
|
631
|
-
expires_in_absolute,
|
632
|
-
version_id)
|
633
|
-
|
634
|
-
def send_file(self, fp, headers=None, cb=None, num_cb=10,
|
635
|
-
query_args=None, chunked_transfer=False, size=None):
|
636
|
-
"""
|
637
|
-
Upload a file to a key into a bucket on S3.
|
638
|
-
|
639
|
-
:type fp: file
|
640
|
-
:param fp: The file pointer to upload. The file pointer must
|
641
|
-
point point at the offset from which you wish to upload.
|
642
|
-
ie. if uploading the full file, it should point at the
|
643
|
-
start of the file. Normally when a file is opened for
|
644
|
-
reading, the fp will point at the first byte. See the
|
645
|
-
bytes parameter below for more info.
|
646
|
-
|
647
|
-
:type headers: dict
|
648
|
-
:param headers: The headers to pass along with the PUT request
|
649
|
-
|
650
|
-
:type cb: function
|
651
|
-
:param cb: a callback function that will be called to report
|
652
|
-
progress on the upload. The callback should accept two
|
653
|
-
integer parameters, the first representing the number of
|
654
|
-
bytes that have been successfully transmitted to S3 and
|
655
|
-
the second representing the size of the to be transmitted
|
656
|
-
object.
|
657
|
-
|
658
|
-
:type num_cb: int
|
659
|
-
:param num_cb: (optional) If a callback is specified with the
|
660
|
-
cb parameter this parameter determines the granularity of
|
661
|
-
the callback by defining the maximum number of times the
|
662
|
-
callback will be called during the file
|
663
|
-
transfer. Providing a negative integer will cause your
|
664
|
-
callback to be called with each buffer read.
|
665
|
-
|
666
|
-
:type size: int
|
667
|
-
:param size: (optional) The Maximum number of bytes to read
|
668
|
-
from the file pointer (fp). This is useful when uploading
|
669
|
-
a file in multiple parts where you are splitting the file
|
670
|
-
up into different ranges to be uploaded. If not specified,
|
671
|
-
the default behaviour is to read all bytes from the file
|
672
|
-
pointer. Less bytes may be available.
|
673
|
-
"""
|
674
|
-
provider = self.bucket.connection.provider
|
675
|
-
try:
|
676
|
-
spos = fp.tell()
|
677
|
-
except IOError:
|
678
|
-
spos = None
|
679
|
-
self.read_from_stream = False
|
680
|
-
|
681
|
-
def sender(http_conn, method, path, data, headers):
|
682
|
-
# This function is called repeatedly for temporary retries
|
683
|
-
# so we must be sure the file pointer is pointing at the
|
684
|
-
# start of the data.
|
685
|
-
if spos is not None and spos != fp.tell():
|
686
|
-
fp.seek(spos)
|
687
|
-
elif spos is None and self.read_from_stream:
|
688
|
-
# if seek is not supported, and we've read from this
|
689
|
-
# stream already, then we need to abort retries to
|
690
|
-
# avoid setting bad data.
|
691
|
-
raise provider.storage_data_error(
|
692
|
-
'Cannot retry failed request. fp does not support seeking.')
|
693
|
-
|
694
|
-
http_conn.putrequest(method, path)
|
695
|
-
for key in headers:
|
696
|
-
http_conn.putheader(key, headers[key])
|
697
|
-
http_conn.endheaders()
|
698
|
-
|
699
|
-
# Calculate all MD5 checksums on the fly, if not already computed
|
700
|
-
if not self.base64md5:
|
701
|
-
m = md5()
|
702
|
-
else:
|
703
|
-
m = None
|
704
|
-
|
705
|
-
save_debug = self.bucket.connection.debug
|
706
|
-
self.bucket.connection.debug = 0
|
707
|
-
# If the debuglevel < 4 we don't want to show connection
|
708
|
-
# payload, so turn off HTTP connection-level debug output (to
|
709
|
-
# be restored below).
|
710
|
-
# Use the getattr approach to allow this to work in AppEngine.
|
711
|
-
if getattr(http_conn, 'debuglevel', 0) < 4:
|
712
|
-
http_conn.set_debuglevel(0)
|
713
|
-
|
714
|
-
data_len = 0
|
715
|
-
if cb:
|
716
|
-
if size:
|
717
|
-
cb_size = size
|
718
|
-
elif self.size:
|
719
|
-
cb_size = self.size
|
720
|
-
else:
|
721
|
-
cb_size = 0
|
722
|
-
if chunked_transfer and cb_size == 0:
|
723
|
-
# For chunked Transfer, we call the cb for every 1MB
|
724
|
-
# of data transferred, except when we know size.
|
725
|
-
cb_count = (1024 * 1024) / self.BufferSize
|
726
|
-
elif num_cb > 1:
|
727
|
-
cb_count = int(math.ceil(cb_size / self.BufferSize / (num_cb - 1.0)))
|
728
|
-
elif num_cb < 0:
|
729
|
-
cb_count = -1
|
730
|
-
else:
|
731
|
-
cb_count = 0
|
732
|
-
i = 0
|
733
|
-
cb(data_len, cb_size)
|
734
|
-
|
735
|
-
bytes_togo = size
|
736
|
-
if bytes_togo and bytes_togo < self.BufferSize:
|
737
|
-
chunk = fp.read(bytes_togo)
|
738
|
-
else:
|
739
|
-
chunk = fp.read(self.BufferSize)
|
740
|
-
if spos is None:
|
741
|
-
# read at least something from a non-seekable fp.
|
742
|
-
self.read_from_stream = True
|
743
|
-
while chunk:
|
744
|
-
chunk_len = len(chunk)
|
745
|
-
data_len += chunk_len
|
746
|
-
if chunked_transfer:
|
747
|
-
http_conn.send('%x;\r\n' % chunk_len)
|
748
|
-
http_conn.send(chunk)
|
749
|
-
http_conn.send('\r\n')
|
750
|
-
else:
|
751
|
-
http_conn.send(chunk)
|
752
|
-
if m:
|
753
|
-
m.update(chunk)
|
754
|
-
if bytes_togo:
|
755
|
-
bytes_togo -= chunk_len
|
756
|
-
if bytes_togo <= 0:
|
757
|
-
break
|
758
|
-
if cb:
|
759
|
-
i += 1
|
760
|
-
if i == cb_count or cb_count == -1:
|
761
|
-
cb(data_len, cb_size)
|
762
|
-
i = 0
|
763
|
-
if bytes_togo and bytes_togo < self.BufferSize:
|
764
|
-
chunk = fp.read(bytes_togo)
|
765
|
-
else:
|
766
|
-
chunk = fp.read(self.BufferSize)
|
767
|
-
|
768
|
-
self.size = data_len
|
769
|
-
|
770
|
-
if m:
|
771
|
-
# Use the chunked trailer for the digest
|
772
|
-
hd = m.hexdigest()
|
773
|
-
self.md5, self.base64md5 = self.get_md5_from_hexdigest(hd)
|
774
|
-
|
775
|
-
if chunked_transfer:
|
776
|
-
http_conn.send('0\r\n')
|
777
|
-
# http_conn.send("Content-MD5: %s\r\n" % self.base64md5)
|
778
|
-
http_conn.send('\r\n')
|
779
|
-
|
780
|
-
if cb and (cb_count <= 1 or i > 0) and data_len > 0:
|
781
|
-
cb(data_len, cb_size)
|
782
|
-
|
783
|
-
http_conn.set_debuglevel(save_debug)
|
784
|
-
self.bucket.connection.debug = save_debug
|
785
|
-
response = http_conn.getresponse()
|
786
|
-
body = response.read()
|
787
|
-
if ((response.status == 500 or response.status == 503 or
|
788
|
-
response.getheader('location')) and not chunked_transfer):
|
789
|
-
# we'll try again.
|
790
|
-
return response
|
791
|
-
elif response.status >= 200 and response.status <= 299:
|
792
|
-
self.etag = response.getheader('etag')
|
793
|
-
if self.etag != '"%s"' % self.md5:
|
794
|
-
raise provider.storage_data_error(
|
795
|
-
'ETag from S3 did not match computed MD5')
|
796
|
-
return response
|
797
|
-
else:
|
798
|
-
raise provider.storage_response_error(
|
799
|
-
response.status, response.reason, body)
|
800
|
-
|
801
|
-
if not headers:
|
802
|
-
headers = {}
|
803
|
-
else:
|
804
|
-
headers = headers.copy()
|
805
|
-
headers['User-Agent'] = UserAgent
|
806
|
-
if self.storage_class != 'STANDARD':
|
807
|
-
headers[provider.storage_class_header] = self.storage_class
|
808
|
-
if 'Content-Encoding' in headers:
|
809
|
-
self.content_encoding = headers['Content-Encoding']
|
810
|
-
if 'Content-Language' in headers:
|
811
|
-
self.content_encoding = headers['Content-Language']
|
812
|
-
if 'Content-Type' in headers:
|
813
|
-
# Some use cases need to suppress sending of the Content-Type
|
814
|
-
# header and depend on the receiving server to set the content
|
815
|
-
# type. This can be achieved by setting headers['Content-Type']
|
816
|
-
# to None when calling this method.
|
817
|
-
if headers['Content-Type'] is None:
|
818
|
-
# Delete null Content-Type value to skip sending that header.
|
819
|
-
del headers['Content-Type']
|
820
|
-
else:
|
821
|
-
self.content_type = headers['Content-Type']
|
822
|
-
elif self.path:
|
823
|
-
self.content_type = mimetypes.guess_type(self.path)[0]
|
824
|
-
if self.content_type == None:
|
825
|
-
self.content_type = self.DefaultContentType
|
826
|
-
headers['Content-Type'] = self.content_type
|
827
|
-
else:
|
828
|
-
headers['Content-Type'] = self.content_type
|
829
|
-
if self.base64md5:
|
830
|
-
headers['Content-MD5'] = self.base64md5
|
831
|
-
if chunked_transfer:
|
832
|
-
headers['Transfer-Encoding'] = 'chunked'
|
833
|
-
#if not self.base64md5:
|
834
|
-
# headers['Trailer'] = "Content-MD5"
|
835
|
-
else:
|
836
|
-
headers['Content-Length'] = str(self.size)
|
837
|
-
headers['Expect'] = '100-Continue'
|
838
|
-
headers = boto.utils.merge_meta(headers, self.metadata, provider)
|
839
|
-
resp = self.bucket.connection.make_request('PUT', self.bucket.name,
|
840
|
-
self.name, headers,
|
841
|
-
sender=sender,
|
842
|
-
query_args=query_args)
|
843
|
-
self.handle_version_headers(resp, force=True)
|
844
|
-
|
845
|
-
def compute_md5(self, fp, size=None):
|
846
|
-
"""
|
847
|
-
:type fp: file
|
848
|
-
:param fp: File pointer to the file to MD5 hash. The file
|
849
|
-
pointer will be reset to the same position before the
|
850
|
-
method returns.
|
851
|
-
|
852
|
-
:type size: int
|
853
|
-
:param size: (optional) The Maximum number of bytes to read
|
854
|
-
from the file pointer (fp). This is useful when uploading
|
855
|
-
a file in multiple parts where the file is being split
|
856
|
-
inplace into different parts. Less bytes may be available.
|
857
|
-
|
858
|
-
:rtype: tuple
|
859
|
-
:return: A tuple containing the hex digest version of the MD5
|
860
|
-
hash as the first element and the base64 encoded version
|
861
|
-
of the plain digest as the second element.
|
862
|
-
"""
|
863
|
-
tup = compute_md5(fp, size=size)
|
864
|
-
# Returned values are MD5 hash, base64 encoded MD5 hash, and data size.
|
865
|
-
# The internal implementation of compute_md5() needs to return the
|
866
|
-
# data size but we don't want to return that value to the external
|
867
|
-
# caller because it changes the class interface (i.e. it might
|
868
|
-
# break some code) so we consume the third tuple value here and
|
869
|
-
# return the remainder of the tuple to the caller, thereby preserving
|
870
|
-
# the existing interface.
|
871
|
-
self.size = tup[2]
|
872
|
-
return tup[0:2]
|
873
|
-
|
874
|
-
def set_contents_from_stream(self, fp, headers=None, replace=True,
|
875
|
-
cb=None, num_cb=10, policy=None,
|
876
|
-
reduced_redundancy=False, query_args=None,
|
877
|
-
size=None):
|
878
|
-
"""
|
879
|
-
Store an object using the name of the Key object as the key in
|
880
|
-
cloud and the contents of the data stream pointed to by 'fp' as
|
881
|
-
the contents.
|
882
|
-
|
883
|
-
The stream object is not seekable and total size is not known.
|
884
|
-
This has the implication that we can't specify the
|
885
|
-
Content-Size and Content-MD5 in the header. So for huge
|
886
|
-
uploads, the delay in calculating MD5 is avoided but with a
|
887
|
-
penalty of inability to verify the integrity of the uploaded
|
888
|
-
data.
|
889
|
-
|
890
|
-
:type fp: file
|
891
|
-
:param fp: the file whose contents are to be uploaded
|
892
|
-
|
893
|
-
:type headers: dict
|
894
|
-
:param headers: additional HTTP headers to be sent with the
|
895
|
-
PUT request.
|
896
|
-
|
897
|
-
:type replace: bool
|
898
|
-
:param replace: If this parameter is False, the method will first check
|
899
|
-
to see if an object exists in the bucket with the same key. If it
|
900
|
-
does, it won't overwrite it. The default value is True which will
|
901
|
-
overwrite the object.
|
902
|
-
|
903
|
-
:type cb: function
|
904
|
-
:param cb: a callback function that will be called to report
|
905
|
-
progress on the upload. The callback should accept two integer
|
906
|
-
parameters, the first representing the number of bytes that have
|
907
|
-
been successfully transmitted to GS and the second representing the
|
908
|
-
total number of bytes that need to be transmitted.
|
909
|
-
|
910
|
-
:type num_cb: int
|
911
|
-
:param num_cb: (optional) If a callback is specified with the
|
912
|
-
cb parameter, this parameter determines the granularity of
|
913
|
-
the callback by defining the maximum number of times the
|
914
|
-
callback will be called during the file transfer.
|
915
|
-
|
916
|
-
:type policy: :class:`boto.gs.acl.CannedACLStrings`
|
917
|
-
:param policy: A canned ACL policy that will be applied to the new key
|
918
|
-
in GS.
|
919
|
-
|
920
|
-
:type reduced_redundancy: bool
|
921
|
-
:param reduced_redundancy: If True, this will set the storage
|
922
|
-
class of the new Key to be REDUCED_REDUNDANCY. The Reduced
|
923
|
-
Redundancy Storage (RRS) feature of S3, provides lower
|
924
|
-
redundancy at lower storage cost.
|
925
|
-
|
926
|
-
:type size: int
|
927
|
-
:param size: (optional) The Maximum number of bytes to read from
|
928
|
-
the file pointer (fp). This is useful when uploading a
|
929
|
-
file in multiple parts where you are splitting the file up
|
930
|
-
into different ranges to be uploaded. If not specified,
|
931
|
-
the default behaviour is to read all bytes from the file
|
932
|
-
pointer. Less bytes may be available.
|
933
|
-
"""
|
934
|
-
|
935
|
-
provider = self.bucket.connection.provider
|
936
|
-
if not provider.supports_chunked_transfer():
|
937
|
-
raise BotoClientError('%s does not support chunked transfer'
|
938
|
-
% provider.get_provider_name())
|
939
|
-
|
940
|
-
# Name of the Object should be specified explicitly for Streams.
|
941
|
-
if not self.name or self.name == '':
|
942
|
-
raise BotoClientError('Cannot determine the destination '
|
943
|
-
'object name for the given stream')
|
944
|
-
|
945
|
-
if headers is None:
|
946
|
-
headers = {}
|
947
|
-
if policy:
|
948
|
-
headers[provider.acl_header] = policy
|
949
|
-
|
950
|
-
if reduced_redundancy:
|
951
|
-
self.storage_class = 'REDUCED_REDUNDANCY'
|
952
|
-
if provider.storage_class_header:
|
953
|
-
headers[provider.storage_class_header] = self.storage_class
|
954
|
-
|
955
|
-
if self.bucket != None:
|
956
|
-
if not replace:
|
957
|
-
if self.bucket.lookup(self.name):
|
958
|
-
return
|
959
|
-
self.send_file(fp, headers, cb, num_cb, query_args,
|
960
|
-
chunked_transfer=True, size=size)
|
961
|
-
|
962
|
-
def set_contents_from_file(self, fp, headers=None, replace=True,
|
963
|
-
cb=None, num_cb=10, policy=None, md5=None,
|
964
|
-
reduced_redundancy=False, query_args=None,
|
965
|
-
encrypt_key=False, size=None, rewind=False):
|
966
|
-
"""
|
967
|
-
Store an object in S3 using the name of the Key object as the
|
968
|
-
key in S3 and the contents of the file pointed to by 'fp' as the
|
969
|
-
contents. The data is read from 'fp' from its current position until
|
970
|
-
'size' bytes have been read or EOF.
|
971
|
-
|
972
|
-
:type fp: file
|
973
|
-
:param fp: the file whose contents to upload
|
974
|
-
|
975
|
-
:type headers: dict
|
976
|
-
:param headers: Additional HTTP headers that will be sent with
|
977
|
-
the PUT request.
|
978
|
-
|
979
|
-
:type replace: bool
|
980
|
-
:param replace: If this parameter is False, the method will
|
981
|
-
first check to see if an object exists in the bucket with
|
982
|
-
the same key. If it does, it won't overwrite it. The
|
983
|
-
default value is True which will overwrite the object.
|
984
|
-
|
985
|
-
:type cb: function
|
986
|
-
:param cb: a callback function that will be called to report
|
987
|
-
progress on the upload. The callback should accept two
|
988
|
-
integer parameters, the first representing the number of
|
989
|
-
bytes that have been successfully transmitted to S3 and
|
990
|
-
the second representing the size of the to be transmitted
|
991
|
-
object.
|
992
|
-
|
993
|
-
:type cb: int
|
994
|
-
:param num_cb: (optional) If a callback is specified with the
|
995
|
-
cb parameter this parameter determines the granularity of
|
996
|
-
the callback by defining the maximum number of times the
|
997
|
-
callback will be called during the file transfer.
|
998
|
-
|
999
|
-
:type policy: :class:`boto.s3.acl.CannedACLStrings`
|
1000
|
-
:param policy: A canned ACL policy that will be applied to the
|
1001
|
-
new key in S3.
|
1002
|
-
|
1003
|
-
:type md5: A tuple containing the hexdigest version of the MD5
|
1004
|
-
checksum of the file as the first element and the
|
1005
|
-
Base64-encoded version of the plain checksum as the second
|
1006
|
-
element. This is the same format returned by the
|
1007
|
-
compute_md5 method.
|
1008
|
-
:param md5: If you need to compute the MD5 for any reason
|
1009
|
-
prior to upload, it's silly to have to do it twice so this
|
1010
|
-
param, if present, will be used as the MD5 values of the
|
1011
|
-
file. Otherwise, the checksum will be computed.
|
1012
|
-
|
1013
|
-
:type reduced_redundancy: bool
|
1014
|
-
:param reduced_redundancy: If True, this will set the storage
|
1015
|
-
class of the new Key to be REDUCED_REDUNDANCY. The Reduced
|
1016
|
-
Redundancy Storage (RRS) feature of S3, provides lower
|
1017
|
-
redundancy at lower storage cost.
|
1018
|
-
|
1019
|
-
:type encrypt_key: bool
|
1020
|
-
:param encrypt_key: If True, the new copy of the object will
|
1021
|
-
be encrypted on the server-side by S3 and will be stored
|
1022
|
-
in an encrypted form while at rest in S3.
|
1023
|
-
|
1024
|
-
:type size: int
|
1025
|
-
:param size: (optional) The Maximum number of bytes to read
|
1026
|
-
from the file pointer (fp). This is useful when uploading
|
1027
|
-
a file in multiple parts where you are splitting the file
|
1028
|
-
up into different ranges to be uploaded. If not specified,
|
1029
|
-
the default behaviour is to read all bytes from the file
|
1030
|
-
pointer. Less bytes may be available.
|
1031
|
-
|
1032
|
-
:type rewind: bool
|
1033
|
-
:param rewind: (optional) If True, the file pointer (fp) will
|
1034
|
-
be rewound to the start before any bytes are read from
|
1035
|
-
it. The default behaviour is False which reads from the
|
1036
|
-
current position of the file pointer (fp).
|
1037
|
-
|
1038
|
-
:rtype: int
|
1039
|
-
:return: The number of bytes written to the key.
|
1040
|
-
"""
|
1041
|
-
provider = self.bucket.connection.provider
|
1042
|
-
headers = headers or {}
|
1043
|
-
if policy:
|
1044
|
-
headers[provider.acl_header] = policy
|
1045
|
-
if encrypt_key:
|
1046
|
-
headers[provider.server_side_encryption_header] = 'AES256'
|
1047
|
-
|
1048
|
-
if rewind:
|
1049
|
-
# caller requests reading from beginning of fp.
|
1050
|
-
fp.seek(0, os.SEEK_SET)
|
1051
|
-
else:
|
1052
|
-
# The following seek/tell/seek logic is intended
|
1053
|
-
# to detect applications using the older interface to
|
1054
|
-
# set_contents_from_file(), which automatically rewound the
|
1055
|
-
# file each time the Key was reused. This changed with commit
|
1056
|
-
# 14ee2d03f4665fe20d19a85286f78d39d924237e, to support uploads
|
1057
|
-
# split into multiple parts and uploaded in parallel, and at
|
1058
|
-
# the time of that commit this check was added because otherwise
|
1059
|
-
# older programs would get a success status and upload an empty
|
1060
|
-
# object. Unfortuantely, it's very inefficient for fp's implemented
|
1061
|
-
# by KeyFile (used, for example, by gsutil when copying between
|
1062
|
-
# providers). So, we skip the check for the KeyFile case.
|
1063
|
-
# TODO: At some point consider removing this seek/tell/seek
|
1064
|
-
# logic, after enough time has passed that it's unlikely any
|
1065
|
-
# programs remain that assume the older auto-rewind interface.
|
1066
|
-
if not isinstance(fp, KeyFile):
|
1067
|
-
spos = fp.tell()
|
1068
|
-
fp.seek(0, os.SEEK_END)
|
1069
|
-
if fp.tell() == spos:
|
1070
|
-
fp.seek(0, os.SEEK_SET)
|
1071
|
-
if fp.tell() != spos:
|
1072
|
-
# Raise an exception as this is likely a programming
|
1073
|
-
# error whereby there is data before the fp but nothing
|
1074
|
-
# after it.
|
1075
|
-
fp.seek(spos)
|
1076
|
-
raise AttributeError('fp is at EOF. Use rewind option '
|
1077
|
-
'or seek() to data start.')
|
1078
|
-
# seek back to the correct position.
|
1079
|
-
fp.seek(spos)
|
1080
|
-
|
1081
|
-
if reduced_redundancy:
|
1082
|
-
self.storage_class = 'REDUCED_REDUNDANCY'
|
1083
|
-
if provider.storage_class_header:
|
1084
|
-
headers[provider.storage_class_header] = self.storage_class
|
1085
|
-
# TODO - What if provider doesn't support reduced reduncancy?
|
1086
|
-
# What if different providers provide different classes?
|
1087
|
-
if hasattr(fp, 'name'):
|
1088
|
-
self.path = fp.name
|
1089
|
-
if self.bucket != None:
|
1090
|
-
if not md5 and provider.supports_chunked_transfer():
|
1091
|
-
# defer md5 calculation to on the fly and
|
1092
|
-
# we don't know anything about size yet.
|
1093
|
-
chunked_transfer = True
|
1094
|
-
self.size = None
|
1095
|
-
else:
|
1096
|
-
chunked_transfer = False
|
1097
|
-
if isinstance(fp, KeyFile):
|
1098
|
-
# Avoid EOF seek for KeyFile case as it's very inefficient.
|
1099
|
-
key = fp.getkey()
|
1100
|
-
size = key.size - fp.tell()
|
1101
|
-
self.size = size
|
1102
|
-
# At present both GCS and S3 use MD5 for the etag for
|
1103
|
-
# non-multipart-uploaded objects. If the etag is 32 hex
|
1104
|
-
# chars use it as an MD5, to avoid having to read the file
|
1105
|
-
# twice while transferring.
|
1106
|
-
if (re.match('^"[a-fA-F0-9]{32}"$', key.etag)):
|
1107
|
-
etag = key.etag.strip('"')
|
1108
|
-
md5 = (etag, base64.b64encode(binascii.unhexlify(etag)))
|
1109
|
-
if not md5:
|
1110
|
-
# compute_md5() and also set self.size to actual
|
1111
|
-
# size of the bytes read computing the md5.
|
1112
|
-
md5 = self.compute_md5(fp, size)
|
1113
|
-
# adjust size if required
|
1114
|
-
size = self.size
|
1115
|
-
elif size:
|
1116
|
-
self.size = size
|
1117
|
-
else:
|
1118
|
-
# If md5 is provided, still need to size so
|
1119
|
-
# calculate based on bytes to end of content
|
1120
|
-
spos = fp.tell()
|
1121
|
-
fp.seek(0, os.SEEK_END)
|
1122
|
-
self.size = fp.tell() - spos
|
1123
|
-
fp.seek(spos)
|
1124
|
-
size = self.size
|
1125
|
-
self.md5 = md5[0]
|
1126
|
-
self.base64md5 = md5[1]
|
1127
|
-
|
1128
|
-
if self.name == None:
|
1129
|
-
self.name = self.md5
|
1130
|
-
if not replace:
|
1131
|
-
if self.bucket.lookup(self.name):
|
1132
|
-
return
|
1133
|
-
|
1134
|
-
self.send_file(fp, headers=headers, cb=cb, num_cb=num_cb,
|
1135
|
-
query_args=query_args,
|
1136
|
-
chunked_transfer=chunked_transfer, size=size)
|
1137
|
-
# return number of bytes written.
|
1138
|
-
return self.size
|
1139
|
-
|
1140
|
-
def set_contents_from_filename(self, filename, headers=None, replace=True,
|
1141
|
-
cb=None, num_cb=10, policy=None, md5=None,
|
1142
|
-
reduced_redundancy=False,
|
1143
|
-
encrypt_key=False):
|
1144
|
-
"""
|
1145
|
-
Store an object in S3 using the name of the Key object as the
|
1146
|
-
key in S3 and the contents of the file named by 'filename'.
|
1147
|
-
See set_contents_from_file method for details about the
|
1148
|
-
parameters.
|
1149
|
-
|
1150
|
-
:type filename: string
|
1151
|
-
:param filename: The name of the file that you want to put onto S3
|
1152
|
-
|
1153
|
-
:type headers: dict
|
1154
|
-
:param headers: Additional headers to pass along with the
|
1155
|
-
request to AWS.
|
1156
|
-
|
1157
|
-
:type replace: bool
|
1158
|
-
:param replace: If True, replaces the contents of the file
|
1159
|
-
if it already exists.
|
1160
|
-
|
1161
|
-
:type cb: function
|
1162
|
-
:param cb: a callback function that will be called to report
|
1163
|
-
progress on the upload. The callback should accept two
|
1164
|
-
integer parameters, the first representing the number of
|
1165
|
-
bytes that have been successfully transmitted to S3 and
|
1166
|
-
the second representing the size of the to be transmitted
|
1167
|
-
object.
|
1168
|
-
|
1169
|
-
:type cb: int
|
1170
|
-
:param num_cb: (optional) If a callback is specified with the
|
1171
|
-
cb parameter this parameter determines the granularity of
|
1172
|
-
the callback by defining the maximum number of times the
|
1173
|
-
callback will be called during the file transfer.
|
1174
|
-
|
1175
|
-
:type policy: :class:`boto.s3.acl.CannedACLStrings`
|
1176
|
-
:param policy: A canned ACL policy that will be applied to the
|
1177
|
-
new key in S3.
|
1178
|
-
|
1179
|
-
:type md5: A tuple containing the hexdigest version of the MD5
|
1180
|
-
checksum of the file as the first element and the
|
1181
|
-
Base64-encoded version of the plain checksum as the second
|
1182
|
-
element. This is the same format returned by the
|
1183
|
-
compute_md5 method.
|
1184
|
-
:param md5: If you need to compute the MD5 for any reason
|
1185
|
-
prior to upload, it's silly to have to do it twice so this
|
1186
|
-
param, if present, will be used as the MD5 values of the
|
1187
|
-
file. Otherwise, the checksum will be computed.
|
1188
|
-
|
1189
|
-
:type reduced_redundancy: bool
|
1190
|
-
:param reduced_redundancy: If True, this will set the storage
|
1191
|
-
class of the new Key to be REDUCED_REDUNDANCY. The Reduced
|
1192
|
-
Redundancy Storage (RRS) feature of S3, provides lower
|
1193
|
-
redundancy at lower storage cost. :type encrypt_key: bool
|
1194
|
-
:param encrypt_key: If True, the new copy of the object
|
1195
|
-
will be encrypted on the server-side by S3 and will be
|
1196
|
-
stored in an encrypted form while at rest in S3.
|
1197
|
-
"""
|
1198
|
-
fp = open(filename, 'rb')
|
1199
|
-
try:
|
1200
|
-
self.set_contents_from_file(fp, headers, replace, cb, num_cb,
|
1201
|
-
policy, md5, reduced_redundancy,
|
1202
|
-
encrypt_key=encrypt_key)
|
1203
|
-
finally:
|
1204
|
-
fp.close()
|
1205
|
-
|
1206
|
-
def set_contents_from_string(self, s, headers=None, replace=True,
|
1207
|
-
cb=None, num_cb=10, policy=None, md5=None,
|
1208
|
-
reduced_redundancy=False,
|
1209
|
-
encrypt_key=False):
|
1210
|
-
"""
|
1211
|
-
Store an object in S3 using the name of the Key object as the
|
1212
|
-
key in S3 and the string 's' as the contents.
|
1213
|
-
See set_contents_from_file method for details about the
|
1214
|
-
parameters.
|
1215
|
-
|
1216
|
-
:type headers: dict
|
1217
|
-
:param headers: Additional headers to pass along with the
|
1218
|
-
request to AWS.
|
1219
|
-
|
1220
|
-
:type replace: bool
|
1221
|
-
:param replace: If True, replaces the contents of the file if
|
1222
|
-
it already exists.
|
1223
|
-
|
1224
|
-
:type cb: function
|
1225
|
-
:param cb: a callback function that will be called to report
|
1226
|
-
progress on the upload. The callback should accept two
|
1227
|
-
integer parameters, the first representing the number of
|
1228
|
-
bytes that have been successfully transmitted to S3 and
|
1229
|
-
the second representing the size of the to be transmitted
|
1230
|
-
object.
|
1231
|
-
|
1232
|
-
:type cb: int
|
1233
|
-
:param num_cb: (optional) If a callback is specified with the
|
1234
|
-
cb parameter this parameter determines the granularity of
|
1235
|
-
the callback by defining the maximum number of times the
|
1236
|
-
callback will be called during the file transfer.
|
1237
|
-
|
1238
|
-
:type policy: :class:`boto.s3.acl.CannedACLStrings`
|
1239
|
-
:param policy: A canned ACL policy that will be applied to the
|
1240
|
-
new key in S3.
|
1241
|
-
|
1242
|
-
:type md5: A tuple containing the hexdigest version of the MD5
|
1243
|
-
checksum of the file as the first element and the
|
1244
|
-
Base64-encoded version of the plain checksum as the second
|
1245
|
-
element. This is the same format returned by the
|
1246
|
-
compute_md5 method.
|
1247
|
-
:param md5: If you need to compute the MD5 for any reason
|
1248
|
-
prior to upload, it's silly to have to do it twice so this
|
1249
|
-
param, if present, will be used as the MD5 values of the
|
1250
|
-
file. Otherwise, the checksum will be computed.
|
1251
|
-
|
1252
|
-
:type reduced_redundancy: bool
|
1253
|
-
:param reduced_redundancy: If True, this will set the storage
|
1254
|
-
class of the new Key to be REDUCED_REDUNDANCY. The Reduced
|
1255
|
-
Redundancy Storage (RRS) feature of S3, provides lower
|
1256
|
-
redundancy at lower storage cost.
|
1257
|
-
|
1258
|
-
:type encrypt_key: bool
|
1259
|
-
:param encrypt_key: If True, the new copy of the object will
|
1260
|
-
be encrypted on the server-side by S3 and will be stored
|
1261
|
-
in an encrypted form while at rest in S3.
|
1262
|
-
"""
|
1263
|
-
if isinstance(s, unicode):
|
1264
|
-
s = s.encode("utf-8")
|
1265
|
-
fp = StringIO.StringIO(s)
|
1266
|
-
r = self.set_contents_from_file(fp, headers, replace, cb, num_cb,
|
1267
|
-
policy, md5, reduced_redundancy,
|
1268
|
-
encrypt_key=encrypt_key)
|
1269
|
-
fp.close()
|
1270
|
-
return r
|
1271
|
-
|
1272
|
-
def get_file(self, fp, headers=None, cb=None, num_cb=10,
|
1273
|
-
torrent=False, version_id=None, override_num_retries=None,
|
1274
|
-
response_headers=None):
|
1275
|
-
"""
|
1276
|
-
Retrieves a file from an S3 Key
|
1277
|
-
|
1278
|
-
:type fp: file
|
1279
|
-
:param fp: File pointer to put the data into
|
1280
|
-
|
1281
|
-
:type headers: string
|
1282
|
-
:param: headers to send when retrieving the files
|
1283
|
-
|
1284
|
-
:type cb: function
|
1285
|
-
:param cb: a callback function that will be called to report
|
1286
|
-
progress on the upload. The callback should accept two
|
1287
|
-
integer parameters, the first representing the number of
|
1288
|
-
bytes that have been successfully transmitted to S3 and
|
1289
|
-
the second representing the size of the to be transmitted
|
1290
|
-
object.
|
1291
|
-
|
1292
|
-
:type cb: int
|
1293
|
-
:param num_cb: (optional) If a callback is specified with the
|
1294
|
-
cb parameter this parameter determines the granularity of
|
1295
|
-
the callback by defining the maximum number of times the
|
1296
|
-
callback will be called during the file transfer.
|
1297
|
-
|
1298
|
-
:type torrent: bool
|
1299
|
-
:param torrent: Flag for whether to get a torrent for the file
|
1300
|
-
|
1301
|
-
:type override_num_retries: int
|
1302
|
-
:param override_num_retries: If not None will override configured
|
1303
|
-
num_retries parameter for underlying GET.
|
1304
|
-
|
1305
|
-
:type response_headers: dict
|
1306
|
-
:param response_headers: A dictionary containing HTTP
|
1307
|
-
headers/values that will override any headers associated
|
1308
|
-
with the stored object in the response. See
|
1309
|
-
http://goo.gl/EWOPb for details.
|
1310
|
-
"""
|
1311
|
-
self._get_file_internal(fp, headers=headers, cb=cb, num_cb=num_cb,
|
1312
|
-
torrent=torrent, version_id=version_id,
|
1313
|
-
override_num_retries=override_num_retries,
|
1314
|
-
response_headers=response_headers,
|
1315
|
-
query_args=None)
|
1316
|
-
|
1317
|
-
def _get_file_internal(self, fp, headers=None, cb=None, num_cb=10,
|
1318
|
-
torrent=False, version_id=None, override_num_retries=None,
|
1319
|
-
response_headers=None, query_args=None):
|
1320
|
-
if headers is None:
|
1321
|
-
headers = {}
|
1322
|
-
save_debug = self.bucket.connection.debug
|
1323
|
-
if self.bucket.connection.debug == 1:
|
1324
|
-
self.bucket.connection.debug = 0
|
1325
|
-
|
1326
|
-
query_args = query_args or []
|
1327
|
-
if torrent:
|
1328
|
-
query_args.append('torrent')
|
1329
|
-
m = None
|
1330
|
-
else:
|
1331
|
-
m = md5()
|
1332
|
-
# If a version_id is passed in, use that. If not, check to see
|
1333
|
-
# if the Key object has an explicit version_id and, if so, use that.
|
1334
|
-
# Otherwise, don't pass a version_id query param.
|
1335
|
-
if version_id is None:
|
1336
|
-
version_id = self.version_id
|
1337
|
-
if version_id:
|
1338
|
-
query_args.append('versionId=%s' % version_id)
|
1339
|
-
if response_headers:
|
1340
|
-
for key in response_headers:
|
1341
|
-
query_args.append('%s=%s' % (key, urllib.quote(response_headers[key])))
|
1342
|
-
query_args = '&'.join(query_args)
|
1343
|
-
self.open('r', headers, query_args=query_args,
|
1344
|
-
override_num_retries=override_num_retries)
|
1345
|
-
|
1346
|
-
data_len = 0
|
1347
|
-
if cb:
|
1348
|
-
if self.size is None:
|
1349
|
-
cb_size = 0
|
1350
|
-
else:
|
1351
|
-
cb_size = self.size
|
1352
|
-
if self.size is None and num_cb != -1:
|
1353
|
-
# If size is not available due to chunked transfer for example,
|
1354
|
-
# we'll call the cb for every 1MB of data transferred.
|
1355
|
-
cb_count = (1024 * 1024) / self.BufferSize
|
1356
|
-
elif num_cb > 1:
|
1357
|
-
cb_count = int(math.ceil(cb_size/self.BufferSize/(num_cb-1.0)))
|
1358
|
-
elif num_cb < 0:
|
1359
|
-
cb_count = -1
|
1360
|
-
else:
|
1361
|
-
cb_count = 0
|
1362
|
-
i = 0
|
1363
|
-
cb(data_len, cb_size)
|
1364
|
-
for bytes in self:
|
1365
|
-
fp.write(bytes)
|
1366
|
-
data_len += len(bytes)
|
1367
|
-
if m:
|
1368
|
-
m.update(bytes)
|
1369
|
-
if cb:
|
1370
|
-
if cb_size > 0 and data_len >= cb_size:
|
1371
|
-
break
|
1372
|
-
i += 1
|
1373
|
-
if i == cb_count or cb_count == -1:
|
1374
|
-
cb(data_len, cb_size)
|
1375
|
-
i = 0
|
1376
|
-
if cb and (cb_count <= 1 or i > 0) and data_len > 0:
|
1377
|
-
cb(data_len, cb_size)
|
1378
|
-
if m:
|
1379
|
-
self.md5 = m.hexdigest()
|
1380
|
-
if self.size is None and not torrent and "Range" not in headers:
|
1381
|
-
self.size = data_len
|
1382
|
-
self.close()
|
1383
|
-
self.bucket.connection.debug = save_debug
|
1384
|
-
|
1385
|
-
def get_torrent_file(self, fp, headers=None, cb=None, num_cb=10):
|
1386
|
-
"""
|
1387
|
-
Get a torrent file (see to get_file)
|
1388
|
-
|
1389
|
-
:type fp: file
|
1390
|
-
:param fp: The file pointer of where to put the torrent
|
1391
|
-
|
1392
|
-
:type headers: dict
|
1393
|
-
:param headers: Headers to be passed
|
1394
|
-
|
1395
|
-
:type cb: function
|
1396
|
-
:param cb: a callback function that will be called to report
|
1397
|
-
progress on the upload. The callback should accept two
|
1398
|
-
integer parameters, the first representing the number of
|
1399
|
-
bytes that have been successfully transmitted to S3 and
|
1400
|
-
the second representing the size of the to be transmitted
|
1401
|
-
object.
|
1402
|
-
|
1403
|
-
:type cb: int
|
1404
|
-
:param num_cb: (optional) If a callback is specified with the
|
1405
|
-
cb parameter this parameter determines the granularity of
|
1406
|
-
the callback by defining the maximum number of times the
|
1407
|
-
callback will be called during the file transfer.
|
1408
|
-
|
1409
|
-
"""
|
1410
|
-
return self.get_file(fp, headers, cb, num_cb, torrent=True)
|
1411
|
-
|
1412
|
-
def get_contents_to_file(self, fp, headers=None,
|
1413
|
-
cb=None, num_cb=10,
|
1414
|
-
torrent=False,
|
1415
|
-
version_id=None,
|
1416
|
-
res_download_handler=None,
|
1417
|
-
response_headers=None):
|
1418
|
-
"""
|
1419
|
-
Retrieve an object from S3 using the name of the Key object as the
|
1420
|
-
key in S3. Write the contents of the object to the file pointed
|
1421
|
-
to by 'fp'.
|
1422
|
-
|
1423
|
-
:type fp: File -like object
|
1424
|
-
:param fp:
|
1425
|
-
|
1426
|
-
:type headers: dict
|
1427
|
-
:param headers: additional HTTP headers that will be sent with
|
1428
|
-
the GET request.
|
1429
|
-
|
1430
|
-
:type cb: function
|
1431
|
-
:param cb: a callback function that will be called to report
|
1432
|
-
progress on the upload. The callback should accept two
|
1433
|
-
integer parameters, the first representing the number of
|
1434
|
-
bytes that have been successfully transmitted to S3 and
|
1435
|
-
the second representing the size of the to be transmitted
|
1436
|
-
object.
|
1437
|
-
|
1438
|
-
:type cb: int
|
1439
|
-
:param num_cb: (optional) If a callback is specified with the
|
1440
|
-
cb parameter this parameter determines the granularity of
|
1441
|
-
the callback by defining the maximum number of times the
|
1442
|
-
callback will be called during the file transfer.
|
1443
|
-
|
1444
|
-
:type torrent: bool
|
1445
|
-
:param torrent: If True, returns the contents of a torrent
|
1446
|
-
file as a string.
|
1447
|
-
|
1448
|
-
:type res_upload_handler: ResumableDownloadHandler
|
1449
|
-
:param res_download_handler: If provided, this handler will
|
1450
|
-
perform the download.
|
1451
|
-
|
1452
|
-
:type response_headers: dict
|
1453
|
-
:param response_headers: A dictionary containing HTTP
|
1454
|
-
headers/values that will override any headers associated
|
1455
|
-
with the stored object in the response. See
|
1456
|
-
http://goo.gl/EWOPb for details.
|
1457
|
-
"""
|
1458
|
-
if self.bucket != None:
|
1459
|
-
if res_download_handler:
|
1460
|
-
res_download_handler.get_file(self, fp, headers, cb, num_cb,
|
1461
|
-
torrent=torrent,
|
1462
|
-
version_id=version_id)
|
1463
|
-
else:
|
1464
|
-
self.get_file(fp, headers, cb, num_cb, torrent=torrent,
|
1465
|
-
version_id=version_id,
|
1466
|
-
response_headers=response_headers)
|
1467
|
-
|
1468
|
-
def get_contents_to_filename(self, filename, headers=None,
|
1469
|
-
cb=None, num_cb=10,
|
1470
|
-
torrent=False,
|
1471
|
-
version_id=None,
|
1472
|
-
res_download_handler=None,
|
1473
|
-
response_headers=None):
|
1474
|
-
"""
|
1475
|
-
Retrieve an object from S3 using the name of the Key object as the
|
1476
|
-
key in S3. Store contents of the object to a file named by 'filename'.
|
1477
|
-
See get_contents_to_file method for details about the
|
1478
|
-
parameters.
|
1479
|
-
|
1480
|
-
:type filename: string
|
1481
|
-
:param filename: The filename of where to put the file contents
|
1482
|
-
|
1483
|
-
:type headers: dict
|
1484
|
-
:param headers: Any additional headers to send in the request
|
1485
|
-
|
1486
|
-
:type cb: function
|
1487
|
-
:param cb: a callback function that will be called to report
|
1488
|
-
progress on the upload. The callback should accept two
|
1489
|
-
integer parameters, the first representing the number of
|
1490
|
-
bytes that have been successfully transmitted to S3 and
|
1491
|
-
the second representing the size of the to be transmitted
|
1492
|
-
object.
|
1493
|
-
|
1494
|
-
:type cb: int
|
1495
|
-
:param num_cb: (optional) If a callback is specified with the
|
1496
|
-
cb parameter this parameter determines the granularity of
|
1497
|
-
the callback by defining the maximum number of times the
|
1498
|
-
callback will be called during the file transfer.
|
1499
|
-
|
1500
|
-
:type torrent: bool
|
1501
|
-
:param torrent: If True, returns the contents of a torrent file
|
1502
|
-
as a string.
|
1503
|
-
|
1504
|
-
:type res_upload_handler: ResumableDownloadHandler
|
1505
|
-
:param res_download_handler: If provided, this handler will
|
1506
|
-
perform the download.
|
1507
|
-
|
1508
|
-
:type response_headers: dict
|
1509
|
-
:param response_headers: A dictionary containing HTTP
|
1510
|
-
headers/values that will override any headers associated
|
1511
|
-
with the stored object in the response. See
|
1512
|
-
http://goo.gl/EWOPb for details.
|
1513
|
-
"""
|
1514
|
-
fp = open(filename, 'wb')
|
1515
|
-
try:
|
1516
|
-
self.get_contents_to_file(fp, headers, cb, num_cb, torrent=torrent,
|
1517
|
-
version_id=version_id,
|
1518
|
-
res_download_handler=res_download_handler,
|
1519
|
-
response_headers=response_headers)
|
1520
|
-
except Exception:
|
1521
|
-
os.remove(filename)
|
1522
|
-
raise
|
1523
|
-
finally:
|
1524
|
-
fp.close()
|
1525
|
-
# if last_modified date was sent from s3, try to set file's timestamp
|
1526
|
-
if self.last_modified != None:
|
1527
|
-
try:
|
1528
|
-
modified_tuple = rfc822.parsedate_tz(self.last_modified)
|
1529
|
-
modified_stamp = int(rfc822.mktime_tz(modified_tuple))
|
1530
|
-
os.utime(fp.name, (modified_stamp, modified_stamp))
|
1531
|
-
except Exception:
|
1532
|
-
pass
|
1533
|
-
|
1534
|
-
def get_contents_as_string(self, headers=None,
|
1535
|
-
cb=None, num_cb=10,
|
1536
|
-
torrent=False,
|
1537
|
-
version_id=None,
|
1538
|
-
response_headers=None):
|
1539
|
-
"""
|
1540
|
-
Retrieve an object from S3 using the name of the Key object as the
|
1541
|
-
key in S3. Return the contents of the object as a string.
|
1542
|
-
See get_contents_to_file method for details about the
|
1543
|
-
parameters.
|
1544
|
-
|
1545
|
-
:type headers: dict
|
1546
|
-
:param headers: Any additional headers to send in the request
|
1547
|
-
|
1548
|
-
:type cb: function
|
1549
|
-
:param cb: a callback function that will be called to report
|
1550
|
-
progress on the upload. The callback should accept two
|
1551
|
-
integer parameters, the first representing the number of
|
1552
|
-
bytes that have been successfully transmitted to S3 and
|
1553
|
-
the second representing the size of the to be transmitted
|
1554
|
-
object.
|
1555
|
-
|
1556
|
-
:type cb: int
|
1557
|
-
:param num_cb: (optional) If a callback is specified with the
|
1558
|
-
cb parameter this parameter determines the granularity of
|
1559
|
-
the callback by defining the maximum number of times the
|
1560
|
-
callback will be called during the file transfer.
|
1561
|
-
|
1562
|
-
:type torrent: bool
|
1563
|
-
:param torrent: If True, returns the contents of a torrent file
|
1564
|
-
as a string.
|
1565
|
-
|
1566
|
-
:type response_headers: dict
|
1567
|
-
:param response_headers: A dictionary containing HTTP
|
1568
|
-
headers/values that will override any headers associated
|
1569
|
-
with the stored object in the response. See
|
1570
|
-
http://goo.gl/EWOPb for details.
|
1571
|
-
|
1572
|
-
:rtype: string
|
1573
|
-
:returns: The contents of the file as a string
|
1574
|
-
"""
|
1575
|
-
fp = StringIO.StringIO()
|
1576
|
-
self.get_contents_to_file(fp, headers, cb, num_cb, torrent=torrent,
|
1577
|
-
version_id=version_id,
|
1578
|
-
response_headers=response_headers)
|
1579
|
-
return fp.getvalue()
|
1580
|
-
|
1581
|
-
def add_email_grant(self, permission, email_address, headers=None):
|
1582
|
-
"""
|
1583
|
-
Convenience method that provides a quick way to add an email grant
|
1584
|
-
to a key. This method retrieves the current ACL, creates a new
|
1585
|
-
grant based on the parameters passed in, adds that grant to the ACL
|
1586
|
-
and then PUT's the new ACL back to S3.
|
1587
|
-
|
1588
|
-
:type permission: string
|
1589
|
-
:param permission: The permission being granted. Should be one of:
|
1590
|
-
(READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL).
|
1591
|
-
|
1592
|
-
:type email_address: string
|
1593
|
-
:param email_address: The email address associated with the AWS
|
1594
|
-
account your are granting the permission to.
|
1595
|
-
|
1596
|
-
:type recursive: boolean
|
1597
|
-
:param recursive: A boolean value to controls whether the
|
1598
|
-
command will apply the grant to all keys within the bucket
|
1599
|
-
or not. The default value is False. By passing a True
|
1600
|
-
value, the call will iterate through all keys in the
|
1601
|
-
bucket and apply the same grant to each key. CAUTION: If
|
1602
|
-
you have a lot of keys, this could take a long time!
|
1603
|
-
"""
|
1604
|
-
policy = self.get_acl(headers=headers)
|
1605
|
-
policy.acl.add_email_grant(permission, email_address)
|
1606
|
-
self.set_acl(policy, headers=headers)
|
1607
|
-
|
1608
|
-
def add_user_grant(self, permission, user_id, headers=None,
|
1609
|
-
display_name=None):
|
1610
|
-
"""
|
1611
|
-
Convenience method that provides a quick way to add a canonical
|
1612
|
-
user grant to a key. This method retrieves the current ACL,
|
1613
|
-
creates a new grant based on the parameters passed in, adds that
|
1614
|
-
grant to the ACL and then PUT's the new ACL back to S3.
|
1615
|
-
|
1616
|
-
:type permission: string
|
1617
|
-
:param permission: The permission being granted. Should be one of:
|
1618
|
-
(READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL).
|
1619
|
-
|
1620
|
-
:type user_id: string
|
1621
|
-
:param user_id: The canonical user id associated with the AWS
|
1622
|
-
account your are granting the permission to.
|
1623
|
-
|
1624
|
-
:type display_name: string
|
1625
|
-
:param display_name: An option string containing the user's
|
1626
|
-
Display Name. Only required on Walrus.
|
1627
|
-
"""
|
1628
|
-
policy = self.get_acl(headers=headers)
|
1629
|
-
policy.acl.add_user_grant(permission, user_id,
|
1630
|
-
display_name=display_name)
|
1631
|
-
self.set_acl(policy, headers=headers)
|
1632
|
-
|
1633
|
-
def _normalize_metadata(self, metadata):
|
1634
|
-
if type(metadata) == set:
|
1635
|
-
norm_metadata = set()
|
1636
|
-
for k in metadata:
|
1637
|
-
norm_metadata.add(k.lower())
|
1638
|
-
else:
|
1639
|
-
norm_metadata = {}
|
1640
|
-
for k in metadata:
|
1641
|
-
norm_metadata[k.lower()] = metadata[k]
|
1642
|
-
return norm_metadata
|
1643
|
-
|
1644
|
-
def _get_remote_metadata(self, headers=None):
|
1645
|
-
"""
|
1646
|
-
Extracts metadata from existing URI into a dict, so we can
|
1647
|
-
overwrite/delete from it to form the new set of metadata to apply to a
|
1648
|
-
key.
|
1649
|
-
"""
|
1650
|
-
metadata = {}
|
1651
|
-
for underscore_name in self._underscore_base_user_settable_fields:
|
1652
|
-
if hasattr(self, underscore_name):
|
1653
|
-
value = getattr(self, underscore_name)
|
1654
|
-
if value:
|
1655
|
-
# Generate HTTP field name corresponding to "_" named field.
|
1656
|
-
field_name = underscore_name.replace('_', '-')
|
1657
|
-
metadata[field_name.lower()] = value
|
1658
|
-
# self.metadata contains custom metadata, which are all user-settable.
|
1659
|
-
prefix = self.provider.metadata_prefix
|
1660
|
-
for underscore_name in self.metadata:
|
1661
|
-
field_name = underscore_name.replace('_', '-')
|
1662
|
-
metadata['%s%s' % (prefix, field_name.lower())] = (
|
1663
|
-
self.metadata[underscore_name])
|
1664
|
-
return metadata
|
1665
|
-
|
1666
|
-
def set_remote_metadata(self, metadata_plus, metadata_minus, preserve_acl,
|
1667
|
-
headers=None):
|
1668
|
-
metadata_plus = self._normalize_metadata(metadata_plus)
|
1669
|
-
metadata_minus = self._normalize_metadata(metadata_minus)
|
1670
|
-
metadata = self._get_remote_metadata()
|
1671
|
-
metadata.update(metadata_plus)
|
1672
|
-
for h in metadata_minus:
|
1673
|
-
if h in metadata:
|
1674
|
-
del metadata[h]
|
1675
|
-
src_bucket = self.bucket
|
1676
|
-
# Boto prepends the meta prefix when adding headers, so strip prefix in
|
1677
|
-
# metadata before sending back in to copy_key() call.
|
1678
|
-
rewritten_metadata = {}
|
1679
|
-
for h in metadata:
|
1680
|
-
if (h.startswith('x-goog-meta-') or h.startswith('x-amz-meta-')):
|
1681
|
-
rewritten_h = (h.replace('x-goog-meta-', '')
|
1682
|
-
.replace('x-amz-meta-', ''))
|
1683
|
-
else:
|
1684
|
-
rewritten_h = h
|
1685
|
-
rewritten_metadata[rewritten_h] = metadata[h]
|
1686
|
-
metadata = rewritten_metadata
|
1687
|
-
src_bucket.copy_key(self.name, self.bucket.name, self.name,
|
1688
|
-
metadata=metadata, preserve_acl=preserve_acl,
|
1689
|
-
headers=headers)
|
1690
|
-
|
1691
|
-
def restore(self, days, headers=None):
|
1692
|
-
"""Restore an object from an archive.
|
1693
|
-
|
1694
|
-
:type days: int
|
1695
|
-
:param days: The lifetime of the restored object (must
|
1696
|
-
be at least 1 day). If the object is already restored
|
1697
|
-
then this parameter can be used to readjust the lifetime
|
1698
|
-
of the restored object. In this case, the days
|
1699
|
-
param is with respect to the initial time of the request.
|
1700
|
-
If the object has not been restored, this param is with
|
1701
|
-
respect to the completion time of the request.
|
1702
|
-
|
1703
|
-
"""
|
1704
|
-
response = self.bucket.connection.make_request(
|
1705
|
-
'POST', self.bucket.name, self.name,
|
1706
|
-
data=self.RestoreBody % days,
|
1707
|
-
headers=headers, query_args='restore')
|
1708
|
-
if response.status not in (200, 202):
|
1709
|
-
provider = self.bucket.connection.provider
|
1710
|
-
raise provider.storage_response_error(response.status,
|
1711
|
-
response.reason,
|
1712
|
-
response.read())
|