Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- data/conda_envs/evalclaw/lib/python3.11/site-packages/_soundfile_data/COPYING +503 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/_soundfile_data/__init__.py +3 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/INSTALLER +1 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/METADATA +100 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/RECORD +53 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/WHEEL +4 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/__init__.py +1 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/_constants.py +5 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/_endpoint_helpers.py +55 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/_helpers.py +16 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/args.py +224 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/awsrequest.py +41 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/client.py +644 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/config.py +96 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/configprovider.py +37 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/context.py +40 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/credentials.py +1168 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/discovery.py +87 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/endpoint.py +350 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/eventstream.py +51 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/handlers.py +97 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/hooks.py +93 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/httpchecksum.py +303 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/httpsession.py +286 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/httpxsession.py +275 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/paginate.py +199 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/parsers.py +207 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/regions.py +116 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/response.py +202 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/retryhandler.py +220 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/session.py +283 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/signers.py +551 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/stub.py +108 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/tokens.py +173 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/utils.py +794 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/waiter.py +146 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/INSTALLER +1 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/LICENSE +279 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/METADATA +123 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/RECORD +16 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/WHEEL +4 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/INSTALLER +1 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/METADATA +262 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/RECORD +138 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/WHEEL +7 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/top_level.txt +1 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/__init__.py +278 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/_cookie_helpers.py +338 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/_cparser.pxd +158 -0
- data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/_find_header.pxd +2 -0
data/conda_envs/evalclaw/lib/python3.11/site-packages/_soundfile_data/COPYING
ADDED
|
@@ -0,0 +1,503 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU LESSER GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 2.1, February 1999
|
| 3 |
+
|
| 4 |
+
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
| 5 |
+
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 7 |
+
of this license document, but changing it is not allowed.
|
| 8 |
+
|
| 9 |
+
[This is the first released version of the Lesser GPL. It also counts
|
| 10 |
+
as the successor of the GNU Library Public License, version 2, hence
|
| 11 |
+
the version number 2.1.]
|
| 12 |
+
|
| 13 |
+
Preamble
|
| 14 |
+
|
| 15 |
+
The licenses for most software are designed to take away your
|
| 16 |
+
freedom to share and change it. By contrast, the GNU General Public
|
| 17 |
+
Licenses are intended to guarantee your freedom to share and change
|
| 18 |
+
free software--to make sure the software is free for all its users.
|
| 19 |
+
|
| 20 |
+
This license, the Lesser General Public License, applies to some
|
| 21 |
+
specially designated software packages--typically libraries--of the
|
| 22 |
+
Free Software Foundation and other authors who decide to use it. You
|
| 23 |
+
can use it too, but we suggest you first think carefully about whether
|
| 24 |
+
this license or the ordinary General Public License is the better
|
| 25 |
+
strategy to use in any particular case, based on the explanations below.
|
| 26 |
+
|
| 27 |
+
When we speak of free software, we are referring to freedom of use,
|
| 28 |
+
not price. Our General Public Licenses are designed to make sure that
|
| 29 |
+
you have the freedom to distribute copies of free software (and charge
|
| 30 |
+
for this service if you wish); that you receive source code or can get
|
| 31 |
+
it if you want it; that you can change the software and use pieces of
|
| 32 |
+
it in new free programs; and that you are informed that you can do
|
| 33 |
+
these things.
|
| 34 |
+
|
| 35 |
+
To protect your rights, we need to make restrictions that forbid
|
| 36 |
+
distributors to deny you these rights or to ask you to surrender these
|
| 37 |
+
rights. These restrictions translate to certain responsibilities for
|
| 38 |
+
you if you distribute copies of the library or if you modify it.
|
| 39 |
+
|
| 40 |
+
For example, if you distribute copies of the library, whether gratis
|
| 41 |
+
or for a fee, you must give the recipients all the rights that we gave
|
| 42 |
+
you. You must make sure that they, too, receive or can get the source
|
| 43 |
+
code. If you link other code with the library, you must provide
|
| 44 |
+
complete object files to the recipients, so that they can relink them
|
| 45 |
+
with the library after making changes to the library and recompiling
|
| 46 |
+
it. And you must show them these terms so they know their rights.
|
| 47 |
+
|
| 48 |
+
We protect your rights with a two-step method: (1) we copyright the
|
| 49 |
+
library, and (2) we offer you this license, which gives you legal
|
| 50 |
+
permission to copy, distribute and/or modify the library.
|
| 51 |
+
|
| 52 |
+
To protect each distributor, we want to make it very clear that
|
| 53 |
+
there is no warranty for the free library. Also, if the library is
|
| 54 |
+
modified by someone else and passed on, the recipients should know
|
| 55 |
+
that what they have is not the original version, so that the original
|
| 56 |
+
author's reputation will not be affected by problems that might be
|
| 57 |
+
introduced by others.
|
| 58 |
+
|
| 59 |
+
Finally, software patents pose a constant threat to the existence of
|
| 60 |
+
any free program. We wish to make sure that a company cannot
|
| 61 |
+
effectively restrict the users of a free program by obtaining a
|
| 62 |
+
restrictive license from a patent holder. Therefore, we insist that
|
| 63 |
+
any patent license obtained for a version of the library must be
|
| 64 |
+
consistent with the full freedom of use specified in this license.
|
| 65 |
+
|
| 66 |
+
Most GNU software, including some libraries, is covered by the
|
| 67 |
+
ordinary GNU General Public License. This license, the GNU Lesser
|
| 68 |
+
General Public License, applies to certain designated libraries, and
|
| 69 |
+
is quite different from the ordinary General Public License. We use
|
| 70 |
+
this license for certain libraries in order to permit linking those
|
| 71 |
+
libraries into non-free programs.
|
| 72 |
+
|
| 73 |
+
When a program is linked with a library, whether statically or using
|
| 74 |
+
a shared library, the combination of the two is legally speaking a
|
| 75 |
+
combined work, a derivative of the original library. The ordinary
|
| 76 |
+
General Public License therefore permits such linking only if the
|
| 77 |
+
entire combination fits its criteria of freedom. The Lesser General
|
| 78 |
+
Public License permits more lax criteria for linking other code with
|
| 79 |
+
the library.
|
| 80 |
+
|
| 81 |
+
We call this license the "Lesser" General Public License because it
|
| 82 |
+
does Less to protect the user's freedom than the ordinary General
|
| 83 |
+
Public License. It also provides other free software developers Less
|
| 84 |
+
of an advantage over competing non-free programs. These disadvantages
|
| 85 |
+
are the reason we use the ordinary General Public License for many
|
| 86 |
+
libraries. However, the Lesser license provides advantages in certain
|
| 87 |
+
special circumstances.
|
| 88 |
+
|
| 89 |
+
For example, on rare occasions, there may be a special need to
|
| 90 |
+
encourage the widest possible use of a certain library, so that it becomes
|
| 91 |
+
a de-facto standard. To achieve this, non-free programs must be
|
| 92 |
+
allowed to use the library. A more frequent case is that a free
|
| 93 |
+
library does the same job as widely used non-free libraries. In this
|
| 94 |
+
case, there is little to gain by limiting the free library to free
|
| 95 |
+
software only, so we use the Lesser General Public License.
|
| 96 |
+
|
| 97 |
+
In other cases, permission to use a particular library in non-free
|
| 98 |
+
programs enables a greater number of people to use a large body of
|
| 99 |
+
free software. For example, permission to use the GNU C Library in
|
| 100 |
+
non-free programs enables many more people to use the whole GNU
|
| 101 |
+
operating system, as well as its variant, the GNU/Linux operating
|
| 102 |
+
system.
|
| 103 |
+
|
| 104 |
+
Although the Lesser General Public License is Less protective of the
|
| 105 |
+
users' freedom, it does ensure that the user of a program that is
|
| 106 |
+
linked with the Library has the freedom and the wherewithal to run
|
| 107 |
+
that program using a modified version of the Library.
|
| 108 |
+
|
| 109 |
+
The precise terms and conditions for copying, distribution and
|
| 110 |
+
modification follow. Pay close attention to the difference between a
|
| 111 |
+
"work based on the library" and a "work that uses the library". The
|
| 112 |
+
former contains code derived from the library, whereas the latter must
|
| 113 |
+
be combined with the library in order to run.
|
| 114 |
+
|
| 115 |
+
GNU LESSER GENERAL PUBLIC LICENSE
|
| 116 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
| 117 |
+
|
| 118 |
+
0. This License Agreement applies to any software library or other
|
| 119 |
+
program which contains a notice placed by the copyright holder or
|
| 120 |
+
other authorized party saying it may be distributed under the terms of
|
| 121 |
+
this Lesser General Public License (also called "this License").
|
| 122 |
+
Each licensee is addressed as "you".
|
| 123 |
+
|
| 124 |
+
A "library" means a collection of software functions and/or data
|
| 125 |
+
prepared so as to be conveniently linked with application programs
|
| 126 |
+
(which use some of those functions and data) to form executables.
|
| 127 |
+
|
| 128 |
+
The "Library", below, refers to any such software library or work
|
| 129 |
+
which has been distributed under these terms. A "work based on the
|
| 130 |
+
Library" means either the Library or any derivative work under
|
| 131 |
+
copyright law: that is to say, a work containing the Library or a
|
| 132 |
+
portion of it, either verbatim or with modifications and/or translated
|
| 133 |
+
straightforwardly into another language. (Hereinafter, translation is
|
| 134 |
+
included without limitation in the term "modification".)
|
| 135 |
+
|
| 136 |
+
"Source code" for a work means the preferred form of the work for
|
| 137 |
+
making modifications to it. For a library, complete source code means
|
| 138 |
+
all the source code for all modules it contains, plus any associated
|
| 139 |
+
interface definition files, plus the scripts used to control compilation
|
| 140 |
+
and installation of the library.
|
| 141 |
+
|
| 142 |
+
Activities other than copying, distribution and modification are not
|
| 143 |
+
covered by this License; they are outside its scope. The act of
|
| 144 |
+
running a program using the Library is not restricted, and output from
|
| 145 |
+
such a program is covered only if its contents constitute a work based
|
| 146 |
+
on the Library (independent of the use of the Library in a tool for
|
| 147 |
+
writing it). Whether that is true depends on what the Library does
|
| 148 |
+
and what the program that uses the Library does.
|
| 149 |
+
|
| 150 |
+
1. You may copy and distribute verbatim copies of the Library's
|
| 151 |
+
complete source code as you receive it, in any medium, provided that
|
| 152 |
+
you conspicuously and appropriately publish on each copy an
|
| 153 |
+
appropriate copyright notice and disclaimer of warranty; keep intact
|
| 154 |
+
all the notices that refer to this License and to the absence of any
|
| 155 |
+
warranty; and distribute a copy of this License along with the
|
| 156 |
+
Library.
|
| 157 |
+
|
| 158 |
+
You may charge a fee for the physical act of transferring a copy,
|
| 159 |
+
and you may at your option offer warranty protection in exchange for a
|
| 160 |
+
fee.
|
| 161 |
+
|
| 162 |
+
2. You may modify your copy or copies of the Library or any portion
|
| 163 |
+
of it, thus forming a work based on the Library, and copy and
|
| 164 |
+
distribute such modifications or work under the terms of Section 1
|
| 165 |
+
above, provided that you also meet all of these conditions:
|
| 166 |
+
|
| 167 |
+
a) The modified work must itself be a software library.
|
| 168 |
+
|
| 169 |
+
b) You must cause the files modified to carry prominent notices
|
| 170 |
+
stating that you changed the files and the date of any change.
|
| 171 |
+
|
| 172 |
+
c) You must cause the whole of the work to be licensed at no
|
| 173 |
+
charge to all third parties under the terms of this License.
|
| 174 |
+
|
| 175 |
+
d) If a facility in the modified Library refers to a function or a
|
| 176 |
+
table of data to be supplied by an application program that uses
|
| 177 |
+
the facility, other than as an argument passed when the facility
|
| 178 |
+
is invoked, then you must make a good faith effort to ensure that,
|
| 179 |
+
in the event an application does not supply such function or
|
| 180 |
+
table, the facility still operates, and performs whatever part of
|
| 181 |
+
its purpose remains meaningful.
|
| 182 |
+
|
| 183 |
+
(For example, a function in a library to compute square roots has
|
| 184 |
+
a purpose that is entirely well-defined independent of the
|
| 185 |
+
application. Therefore, Subsection 2d requires that any
|
| 186 |
+
application-supplied function or table used by this function must
|
| 187 |
+
be optional: if the application does not supply it, the square
|
| 188 |
+
root function must still compute square roots.)
|
| 189 |
+
|
| 190 |
+
These requirements apply to the modified work as a whole. If
|
| 191 |
+
identifiable sections of that work are not derived from the Library,
|
| 192 |
+
and can be reasonably considered independent and separate works in
|
| 193 |
+
themselves, then this License, and its terms, do not apply to those
|
| 194 |
+
sections when you distribute them as separate works. But when you
|
| 195 |
+
distribute the same sections as part of a whole which is a work based
|
| 196 |
+
on the Library, the distribution of the whole must be on the terms of
|
| 197 |
+
this License, whose permissions for other licensees extend to the
|
| 198 |
+
entire whole, and thus to each and every part regardless of who wrote
|
| 199 |
+
it.
|
| 200 |
+
|
| 201 |
+
Thus, it is not the intent of this section to claim rights or contest
|
| 202 |
+
your rights to work written entirely by you; rather, the intent is to
|
| 203 |
+
exercise the right to control the distribution of derivative or
|
| 204 |
+
collective works based on the Library.
|
| 205 |
+
|
| 206 |
+
In addition, mere aggregation of another work not based on the Library
|
| 207 |
+
with the Library (or with a work based on the Library) on a volume of
|
| 208 |
+
a storage or distribution medium does not bring the other work under
|
| 209 |
+
the scope of this License.
|
| 210 |
+
|
| 211 |
+
3. You may opt to apply the terms of the ordinary GNU General Public
|
| 212 |
+
License instead of this License to a given copy of the Library. To do
|
| 213 |
+
this, you must alter all the notices that refer to this License, so
|
| 214 |
+
that they refer to the ordinary GNU General Public License, version 2,
|
| 215 |
+
instead of to this License. (If a newer version than version 2 of the
|
| 216 |
+
ordinary GNU General Public License has appeared, then you can specify
|
| 217 |
+
that version instead if you wish.) Do not make any other change in
|
| 218 |
+
these notices.
|
| 219 |
+
|
| 220 |
+
Once this change is made in a given copy, it is irreversible for
|
| 221 |
+
that copy, so the ordinary GNU General Public License applies to all
|
| 222 |
+
subsequent copies and derivative works made from that copy.
|
| 223 |
+
|
| 224 |
+
This option is useful when you wish to copy part of the code of
|
| 225 |
+
the Library into a program that is not a library.
|
| 226 |
+
|
| 227 |
+
4. You may copy and distribute the Library (or a portion or
|
| 228 |
+
derivative of it, under Section 2) in object code or executable form
|
| 229 |
+
under the terms of Sections 1 and 2 above provided that you accompany
|
| 230 |
+
it with the complete corresponding machine-readable source code, which
|
| 231 |
+
must be distributed under the terms of Sections 1 and 2 above on a
|
| 232 |
+
medium customarily used for software interchange.
|
| 233 |
+
|
| 234 |
+
If distribution of object code is made by offering access to copy
|
| 235 |
+
from a designated place, then offering equivalent access to copy the
|
| 236 |
+
source code from the same place satisfies the requirement to
|
| 237 |
+
distribute the source code, even though third parties are not
|
| 238 |
+
compelled to copy the source along with the object code.
|
| 239 |
+
|
| 240 |
+
5. A program that contains no derivative of any portion of the
|
| 241 |
+
Library, but is designed to work with the Library by being compiled or
|
| 242 |
+
linked with it, is called a "work that uses the Library". Such a
|
| 243 |
+
work, in isolation, is not a derivative work of the Library, and
|
| 244 |
+
therefore falls outside the scope of this License.
|
| 245 |
+
|
| 246 |
+
However, linking a "work that uses the Library" with the Library
|
| 247 |
+
creates an executable that is a derivative of the Library (because it
|
| 248 |
+
contains portions of the Library), rather than a "work that uses the
|
| 249 |
+
library". The executable is therefore covered by this License.
|
| 250 |
+
Section 6 states terms for distribution of such executables.
|
| 251 |
+
|
| 252 |
+
When a "work that uses the Library" uses material from a header file
|
| 253 |
+
that is part of the Library, the object code for the work may be a
|
| 254 |
+
derivative work of the Library even though the source code is not.
|
| 255 |
+
Whether this is true is especially significant if the work can be
|
| 256 |
+
linked without the Library, or if the work is itself a library. The
|
| 257 |
+
threshold for this to be true is not precisely defined by law.
|
| 258 |
+
|
| 259 |
+
If such an object file uses only numerical parameters, data
|
| 260 |
+
structure layouts and accessors, and small macros and small inline
|
| 261 |
+
functions (ten lines or less in length), then the use of the object
|
| 262 |
+
file is unrestricted, regardless of whether it is legally a derivative
|
| 263 |
+
work. (Executables containing this object code plus portions of the
|
| 264 |
+
Library will still fall under Section 6.)
|
| 265 |
+
|
| 266 |
+
Otherwise, if the work is a derivative of the Library, you may
|
| 267 |
+
distribute the object code for the work under the terms of Section 6.
|
| 268 |
+
Any executables containing that work also fall under Section 6,
|
| 269 |
+
whether or not they are linked directly with the Library itself.
|
| 270 |
+
|
| 271 |
+
6. As an exception to the Sections above, you may also combine or
|
| 272 |
+
link a "work that uses the Library" with the Library to produce a
|
| 273 |
+
work containing portions of the Library, and distribute that work
|
| 274 |
+
under terms of your choice, provided that the terms permit
|
| 275 |
+
modification of the work for the customer's own use and reverse
|
| 276 |
+
engineering for debugging such modifications.
|
| 277 |
+
|
| 278 |
+
You must give prominent notice with each copy of the work that the
|
| 279 |
+
Library is used in it and that the Library and its use are covered by
|
| 280 |
+
this License. You must supply a copy of this License. If the work
|
| 281 |
+
during execution displays copyright notices, you must include the
|
| 282 |
+
copyright notice for the Library among them, as well as a reference
|
| 283 |
+
directing the user to the copy of this License. Also, you must do one
|
| 284 |
+
of these things:
|
| 285 |
+
|
| 286 |
+
a) Accompany the work with the complete corresponding
|
| 287 |
+
machine-readable source code for the Library including whatever
|
| 288 |
+
changes were used in the work (which must be distributed under
|
| 289 |
+
Sections 1 and 2 above); and, if the work is an executable linked
|
| 290 |
+
with the Library, with the complete machine-readable "work that
|
| 291 |
+
uses the Library", as object code and/or source code, so that the
|
| 292 |
+
user can modify the Library and then relink to produce a modified
|
| 293 |
+
executable containing the modified Library. (It is understood
|
| 294 |
+
that the user who changes the contents of definitions files in the
|
| 295 |
+
Library will not necessarily be able to recompile the application
|
| 296 |
+
to use the modified definitions.)
|
| 297 |
+
|
| 298 |
+
b) Use a suitable shared library mechanism for linking with the
|
| 299 |
+
Library. A suitable mechanism is one that (1) uses at run time a
|
| 300 |
+
copy of the library already present on the user's computer system,
|
| 301 |
+
rather than copying library functions into the executable, and (2)
|
| 302 |
+
will operate properly with a modified version of the library, if
|
| 303 |
+
the user installs one, as long as the modified version is
|
| 304 |
+
interface-compatible with the version that the work was made with.
|
| 305 |
+
|
| 306 |
+
c) Accompany the work with a written offer, valid for at
|
| 307 |
+
least three years, to give the same user the materials
|
| 308 |
+
specified in Subsection 6a, above, for a charge no more
|
| 309 |
+
than the cost of performing this distribution.
|
| 310 |
+
|
| 311 |
+
d) If distribution of the work is made by offering access to copy
|
| 312 |
+
from a designated place, offer equivalent access to copy the above
|
| 313 |
+
specified materials from the same place.
|
| 314 |
+
|
| 315 |
+
e) Verify that the user has already received a copy of these
|
| 316 |
+
materials or that you have already sent this user a copy.
|
| 317 |
+
|
| 318 |
+
For an executable, the required form of the "work that uses the
|
| 319 |
+
Library" must include any data and utility programs needed for
|
| 320 |
+
reproducing the executable from it. However, as a special exception,
|
| 321 |
+
the materials to be distributed need not include anything that is
|
| 322 |
+
normally distributed (in either source or binary form) with the major
|
| 323 |
+
components (compiler, kernel, and so on) of the operating system on
|
| 324 |
+
which the executable runs, unless that component itself accompanies
|
| 325 |
+
the executable.
|
| 326 |
+
|
| 327 |
+
It may happen that this requirement contradicts the license
|
| 328 |
+
restrictions of other proprietary libraries that do not normally
|
| 329 |
+
accompany the operating system. Such a contradiction means you cannot
|
| 330 |
+
use both them and the Library together in an executable that you
|
| 331 |
+
distribute.
|
| 332 |
+
|
| 333 |
+
7. You may place library facilities that are a work based on the
|
| 334 |
+
Library side-by-side in a single library together with other library
|
| 335 |
+
facilities not covered by this License, and distribute such a combined
|
| 336 |
+
library, provided that the separate distribution of the work based on
|
| 337 |
+
the Library and of the other library facilities is otherwise
|
| 338 |
+
permitted, and provided that you do these two things:
|
| 339 |
+
|
| 340 |
+
a) Accompany the combined library with a copy of the same work
|
| 341 |
+
based on the Library, uncombined with any other library
|
| 342 |
+
facilities. This must be distributed under the terms of the
|
| 343 |
+
Sections above.
|
| 344 |
+
|
| 345 |
+
b) Give prominent notice with the combined library of the fact
|
| 346 |
+
that part of it is a work based on the Library, and explaining
|
| 347 |
+
where to find the accompanying uncombined form of the same work.
|
| 348 |
+
|
| 349 |
+
8. You may not copy, modify, sublicense, link with, or distribute
|
| 350 |
+
the Library except as expressly provided under this License. Any
|
| 351 |
+
attempt otherwise to copy, modify, sublicense, link with, or
|
| 352 |
+
distribute the Library is void, and will automatically terminate your
|
| 353 |
+
rights under this License. However, parties who have received copies,
|
| 354 |
+
or rights, from you under this License will not have their licenses
|
| 355 |
+
terminated so long as such parties remain in full compliance.
|
| 356 |
+
|
| 357 |
+
9. You are not required to accept this License, since you have not
|
| 358 |
+
signed it. However, nothing else grants you permission to modify or
|
| 359 |
+
distribute the Library or its derivative works. These actions are
|
| 360 |
+
prohibited by law if you do not accept this License. Therefore, by
|
| 361 |
+
modifying or distributing the Library (or any work based on the
|
| 362 |
+
Library), you indicate your acceptance of this License to do so, and
|
| 363 |
+
all its terms and conditions for copying, distributing or modifying
|
| 364 |
+
the Library or works based on it.
|
| 365 |
+
|
| 366 |
+
10. Each time you redistribute the Library (or any work based on the
|
| 367 |
+
Library), the recipient automatically receives a license from the
|
| 368 |
+
original licensor to copy, distribute, link with or modify the Library
|
| 369 |
+
subject to these terms and conditions. You may not impose any further
|
| 370 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
| 371 |
+
You are not responsible for enforcing compliance by third parties with
|
| 372 |
+
this License.
|
| 373 |
+
|
| 374 |
+
11. If, as a consequence of a court judgment or allegation of patent
|
| 375 |
+
infringement or for any other reason (not limited to patent issues),
|
| 376 |
+
conditions are imposed on you (whether by court order, agreement or
|
| 377 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 378 |
+
excuse you from the conditions of this License. If you cannot
|
| 379 |
+
distribute so as to satisfy simultaneously your obligations under this
|
| 380 |
+
License and any other pertinent obligations, then as a consequence you
|
| 381 |
+
may not distribute the Library at all. For example, if a patent
|
| 382 |
+
license would not permit royalty-free redistribution of the Library by
|
| 383 |
+
all those who receive copies directly or indirectly through you, then
|
| 384 |
+
the only way you could satisfy both it and this License would be to
|
| 385 |
+
refrain entirely from distribution of the Library.
|
| 386 |
+
|
| 387 |
+
If any portion of this section is held invalid or unenforceable under any
|
| 388 |
+
particular circumstance, the balance of the section is intended to apply,
|
| 389 |
+
and the section as a whole is intended to apply in other circumstances.
|
| 390 |
+
|
| 391 |
+
It is not the purpose of this section to induce you to infringe any
|
| 392 |
+
patents or other property right claims or to contest validity of any
|
| 393 |
+
such claims; this section has the sole purpose of protecting the
|
| 394 |
+
integrity of the free software distribution system which is
|
| 395 |
+
implemented by public license practices. Many people have made
|
| 396 |
+
generous contributions to the wide range of software distributed
|
| 397 |
+
through that system in reliance on consistent application of that
|
| 398 |
+
system; it is up to the author/donor to decide if he or she is willing
|
| 399 |
+
to distribute software through any other system and a licensee cannot
|
| 400 |
+
impose that choice.
|
| 401 |
+
|
| 402 |
+
This section is intended to make thoroughly clear what is believed to
|
| 403 |
+
be a consequence of the rest of this License.
|
| 404 |
+
|
| 405 |
+
12. If the distribution and/or use of the Library is restricted in
|
| 406 |
+
certain countries either by patents or by copyrighted interfaces, the
|
| 407 |
+
original copyright holder who places the Library under this License may add
|
| 408 |
+
an explicit geographical distribution limitation excluding those countries,
|
| 409 |
+
so that distribution is permitted only in or among countries not thus
|
| 410 |
+
excluded. In such case, this License incorporates the limitation as if
|
| 411 |
+
written in the body of this License.
|
| 412 |
+
|
| 413 |
+
13. The Free Software Foundation may publish revised and/or new
|
| 414 |
+
versions of the Lesser General Public License from time to time.
|
| 415 |
+
Such new versions will be similar in spirit to the present version,
|
| 416 |
+
but may differ in detail to address new problems or concerns.
|
| 417 |
+
|
| 418 |
+
Each version is given a distinguishing version number. If the Library
|
| 419 |
+
specifies a version number of this License which applies to it and
|
| 420 |
+
"any later version", you have the option of following the terms and
|
| 421 |
+
conditions either of that version or of any later version published by
|
| 422 |
+
the Free Software Foundation. If the Library does not specify a
|
| 423 |
+
license version number, you may choose any version ever published by
|
| 424 |
+
the Free Software Foundation.
|
| 425 |
+
|
| 426 |
+
14. If you wish to incorporate parts of the Library into other free
|
| 427 |
+
programs whose distribution conditions are incompatible with these,
|
| 428 |
+
write to the author to ask for permission. For software which is
|
| 429 |
+
copyrighted by the Free Software Foundation, write to the Free
|
| 430 |
+
Software Foundation; we sometimes make exceptions for this. Our
|
| 431 |
+
decision will be guided by the two goals of preserving the free status
|
| 432 |
+
of all derivatives of our free software and of promoting the sharing
|
| 433 |
+
and reuse of software generally.
|
| 434 |
+
|
| 435 |
+
NO WARRANTY
|
| 436 |
+
|
| 437 |
+
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
| 438 |
+
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
| 439 |
+
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
| 440 |
+
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
| 441 |
+
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
| 442 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 443 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
| 444 |
+
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
| 445 |
+
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 446 |
+
|
| 447 |
+
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
| 448 |
+
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
| 449 |
+
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
| 450 |
+
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
| 451 |
+
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
| 452 |
+
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
| 453 |
+
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
| 454 |
+
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
| 455 |
+
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
| 456 |
+
DAMAGES.
|
| 457 |
+
|
| 458 |
+
END OF TERMS AND CONDITIONS
|
| 459 |
+
|
| 460 |
+
How to Apply These Terms to Your New Libraries
|
| 461 |
+
|
| 462 |
+
If you develop a new library, and you want it to be of the greatest
|
| 463 |
+
possible use to the public, we recommend making it free software that
|
| 464 |
+
everyone can redistribute and change. You can do so by permitting
|
| 465 |
+
redistribution under these terms (or, alternatively, under the terms of the
|
| 466 |
+
ordinary General Public License).
|
| 467 |
+
|
| 468 |
+
To apply these terms, attach the following notices to the library. It is
|
| 469 |
+
safest to attach them to the start of each source file to most effectively
|
| 470 |
+
convey the exclusion of warranty; and each file should have at least the
|
| 471 |
+
"copyright" line and a pointer to where the full notice is found.
|
| 472 |
+
|
| 473 |
+
<one line to give the library's name and a brief idea of what it does.>
|
| 474 |
+
Copyright (C) <year> <name of author>
|
| 475 |
+
|
| 476 |
+
This library is free software; you can redistribute it and/or
|
| 477 |
+
modify it under the terms of the GNU Lesser General Public
|
| 478 |
+
License as published by the Free Software Foundation; either
|
| 479 |
+
version 2.1 of the License, or (at your option) any later version.
|
| 480 |
+
|
| 481 |
+
This library is distributed in the hope that it will be useful,
|
| 482 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 483 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 484 |
+
Lesser General Public License for more details.
|
| 485 |
+
|
| 486 |
+
You should have received a copy of the GNU Lesser General Public
|
| 487 |
+
License along with this library; if not, write to the Free Software
|
| 488 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 489 |
+
|
| 490 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 491 |
+
|
| 492 |
+
You should also get your employer (if you work as a programmer) or your
|
| 493 |
+
school, if any, to sign a "copyright disclaimer" for the library, if
|
| 494 |
+
necessary. Here is a sample; alter the names:
|
| 495 |
+
|
| 496 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
| 497 |
+
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
| 498 |
+
|
| 499 |
+
<signature of Ty Coon>, 1 April 1990
|
| 500 |
+
Ty Coon, President of Vice
|
| 501 |
+
|
| 502 |
+
That's all there is to it!
|
| 503 |
+
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/_soundfile_data/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# this file makes _soundfile_data importable, so we can query its path
|
| 2 |
+
# when searching for the libsndfile binaries.
|
| 3 |
+
pass
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: absl-py
|
| 3 |
+
Version: 2.4.0
|
| 4 |
+
Summary: Abseil Python Common Libraries, see https://github.com/abseil/abseil-py.
|
| 5 |
+
Project-URL: Changelog, https://github.com/abseil/abseil-py/blob/main/CHANGELOG.md
|
| 6 |
+
Project-URL: Documentation, https://abseil.io/docs/python/
|
| 7 |
+
Project-URL: Issues, https://github.com/abseil/abseil-py/issues
|
| 8 |
+
Project-URL: Source, https://github.com/abseil/abseil-py
|
| 9 |
+
Author: The Abseil Authors
|
| 10 |
+
License-Expression: Apache-2.0
|
| 11 |
+
License-File: AUTHORS
|
| 12 |
+
License-File: LICENSE
|
| 13 |
+
Classifier: Intended Audience :: Developers
|
| 14 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 15 |
+
Classifier: Operating System :: OS Independent
|
| 16 |
+
Classifier: Programming Language :: Python
|
| 17 |
+
Classifier: Programming Language :: Python :: 3
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 23 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 24 |
+
Requires-Python: >=3.10
|
| 25 |
+
Description-Content-Type: text/markdown
|
| 26 |
+
|
| 27 |
+
[](https://pypi.org/project/absl-py)
|
| 28 |
+
[](https://pypi.org/project/absl-py)
|
| 29 |
+
[](https://github.com/abseil/abseil-py/blob/main/LICENSE)
|
| 30 |
+
[](https://github.com/abseil/abseil-py/actions)
|
| 31 |
+
[](https://pepy.tech/project/absl-py)
|
| 32 |
+
[](https://pepy.tech/project/absl-py)
|
| 33 |
+
|
| 34 |
+
# Abseil Python Common Libraries
|
| 35 |
+
|
| 36 |
+
This repository is a collection of Python library code for building Python
|
| 37 |
+
applications. The code is collected from Google's own Python code base, and has
|
| 38 |
+
been extensively tested and used in production.
|
| 39 |
+
|
| 40 |
+
## Features
|
| 41 |
+
|
| 42 |
+
* Simple application startup
|
| 43 |
+
* Distributed commandline flags system
|
| 44 |
+
* Custom logging module with additional features
|
| 45 |
+
* Testing utilities
|
| 46 |
+
|
| 47 |
+
## Getting Started
|
| 48 |
+
|
| 49 |
+
### Installation
|
| 50 |
+
|
| 51 |
+
To install the package, simply run:
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
pip install absl-py
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
Or install from source:
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
pip install .
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### Running Tests
|
| 64 |
+
|
| 65 |
+
To run Abseil tests, you can clone the git repo and run
|
| 66 |
+
[bazel](https://bazel.build/):
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
git clone https://github.com/abseil/abseil-py.git
|
| 70 |
+
cd abseil-py
|
| 71 |
+
bazel test absl/...
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
Please also validate the type annotations against the latest mypy:
|
| 75 |
+
|
| 76 |
+
```bash
|
| 77 |
+
pip install mypy
|
| 78 |
+
mypy absl
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Example Code
|
| 82 |
+
|
| 83 |
+
Please refer to
|
| 84 |
+
[smoke_tests/sample_app.py](https://github.com/abseil/abseil-py/blob/main/smoke_tests/sample_app.py)
|
| 85 |
+
as an example to get started.
|
| 86 |
+
|
| 87 |
+
## Documentation
|
| 88 |
+
|
| 89 |
+
See the [Abseil Python Developer Guide](https://abseil.io/docs/python/).
|
| 90 |
+
|
| 91 |
+
## Future Releases
|
| 92 |
+
|
| 93 |
+
The current repository includes an initial set of libraries for early adoption.
|
| 94 |
+
More components and interoperability with Abseil C++ Common Libraries
|
| 95 |
+
will come in future releases.
|
| 96 |
+
|
| 97 |
+
## License
|
| 98 |
+
|
| 99 |
+
The Abseil Python library is licensed under the terms of the Apache
|
| 100 |
+
license. See [LICENSE](LICENSE) for more information.
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
absl/__init__.py,sha256=tQJRn_5rbQ5gWoXdkGAV-fJSGFCOGH6fFBI1NxLx5ho,607
|
| 2 |
+
absl/__pycache__/__init__.cpython-311.pyc,,
|
| 3 |
+
absl/__pycache__/app.cpython-311.pyc,,
|
| 4 |
+
absl/__pycache__/command_name.cpython-311.pyc,,
|
| 5 |
+
absl/app.py,sha256=zC4tAKcK054F7kSrR7pzSCEDqNcJKLVb2AkvjIlmvl8,17065
|
| 6 |
+
absl/app.pyi,sha256=YTcQS7o1DBFyFNgMpdykmvP3g4OljSwp3BuX9sSSLIM,1814
|
| 7 |
+
absl/command_name.py,sha256=FgWUMHmlX0yQxEuMPXxFxn5ayWWZSLB0cq8Vx361TpU,2283
|
| 8 |
+
absl/flags/__init__.py,sha256=n_uLeSK-15_1DKLb0wXivmt6A8xvADDC87D1yoJdqVU,7665
|
| 9 |
+
absl/flags/__pycache__/__init__.cpython-311.pyc,,
|
| 10 |
+
absl/flags/__pycache__/_argument_parser.cpython-311.pyc,,
|
| 11 |
+
absl/flags/__pycache__/_defines.cpython-311.pyc,,
|
| 12 |
+
absl/flags/__pycache__/_exceptions.cpython-311.pyc,,
|
| 13 |
+
absl/flags/__pycache__/_flag.cpython-311.pyc,,
|
| 14 |
+
absl/flags/__pycache__/_flagvalues.cpython-311.pyc,,
|
| 15 |
+
absl/flags/__pycache__/_helpers.cpython-311.pyc,,
|
| 16 |
+
absl/flags/__pycache__/_validators.cpython-311.pyc,,
|
| 17 |
+
absl/flags/__pycache__/_validators_classes.cpython-311.pyc,,
|
| 18 |
+
absl/flags/__pycache__/argparse_flags.cpython-311.pyc,,
|
| 19 |
+
absl/flags/_argument_parser.py,sha256=XFIDxu1I8NjgBZhUdzSLUwDHhXFvOC-SbI8FsVmWZ_0,20531
|
| 20 |
+
absl/flags/_defines.py,sha256=P3DLHYAaSgXSBlRgBN6QOS6oRcNUYNtzeapL5EQJ5LA,52499
|
| 21 |
+
absl/flags/_exceptions.py,sha256=FZzlzhvkjqPImTxXqbS1pSPYKr_TvtOd5ellvoiVLDI,3619
|
| 22 |
+
absl/flags/_flag.py,sha256=fOv_KC7t1e-BoabTP3iYHR1dUkTf2yhgfAWonjhByEQ,19891
|
| 23 |
+
absl/flags/_flagvalues.py,sha256=QqCMTxHIJdwqYwlYhZ76nuXzsJQtF20RTzq-x0S_tPg,55319
|
| 24 |
+
absl/flags/_helpers.py,sha256=0cWFV4XFLkcHWu-du6es8sCsWl26k1dZ6fqCPsWZ68k,13301
|
| 25 |
+
absl/flags/_validators.py,sha256=VcsJtZzohliNxsI974NECYpeozD8rswHNHXggrQ4BLo,14140
|
| 26 |
+
absl/flags/_validators_classes.py,sha256=PGUWzO7v3wPOHb9leIKKzry3q-pPeKCoMB_O7prLdnY,6093
|
| 27 |
+
absl/flags/argparse_flags.py,sha256=usJudgMpy3P6Vvq7-LmJNa2Rj3ygHM3hwDTGd1mbAzc,14386
|
| 28 |
+
absl/logging/__init__.py,sha256=3quWtll8Cb949CYs-VOC1AnxdBqClX8ab55VB28knVs,43883
|
| 29 |
+
absl/logging/__init__.pyi,sha256=7yyq5rAJfkBFRaD8iqOTsLW-xhMAIDJ5ub4r3Has04U,5984
|
| 30 |
+
absl/logging/__pycache__/__init__.cpython-311.pyc,,
|
| 31 |
+
absl/logging/__pycache__/converter.cpython-311.pyc,,
|
| 32 |
+
absl/logging/converter.py,sha256=6eBymfv9UNkog0BGat4HPWlxC_oSqvHcQ46jnSdtaMg,6323
|
| 33 |
+
absl/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 34 |
+
absl/testing/__init__.py,sha256=7cM57swk2T1Hc5wxmt-JpcaR6xfdPJyL_lyRqgODvuM,584
|
| 35 |
+
absl/testing/__pycache__/__init__.cpython-311.pyc,,
|
| 36 |
+
absl/testing/__pycache__/_bazelize_command.cpython-311.pyc,,
|
| 37 |
+
absl/testing/__pycache__/_pretty_print_reporter.cpython-311.pyc,,
|
| 38 |
+
absl/testing/__pycache__/absltest.cpython-311.pyc,,
|
| 39 |
+
absl/testing/__pycache__/flagsaver.cpython-311.pyc,,
|
| 40 |
+
absl/testing/__pycache__/parameterized.cpython-311.pyc,,
|
| 41 |
+
absl/testing/__pycache__/xml_reporter.cpython-311.pyc,,
|
| 42 |
+
absl/testing/_bazelize_command.py,sha256=qpioV02ln2sBBJ9kdlHgNpKk8_wxdz2hJGKbG6EWZMI,2287
|
| 43 |
+
absl/testing/_pretty_print_reporter.py,sha256=PZh9NXSXBbXDi0FOk-BOmpse8LXa92Er16tgyBRogMs,3065
|
| 44 |
+
absl/testing/absltest.py,sha256=CkUgJ54S4LJ1RwjNISv4pEW_N9kZBrNDpnzQ1YGPOlc,104586
|
| 45 |
+
absl/testing/flagsaver.py,sha256=BeftLpNxJctYtd041tECgCSglQVFKSsQ4KBFT9D_m5k,13291
|
| 46 |
+
absl/testing/parameterized.py,sha256=TpTlWTUXjikGeUDE45AgubvnmHsPbFNj-wUtAwT-e6E,27817
|
| 47 |
+
absl/testing/xml_reporter.py,sha256=Q0keNHVOh3L9zXwNIzWCjXcWYlCM9ZJxdjMaYyHF3dw,21424
|
| 48 |
+
absl_py-2.4.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 49 |
+
absl_py-2.4.0.dist-info/METADATA,sha256=Eh8VboTinee1rj1-UDeBjw_KiicKBxJBi6H0zB1Sq0g,3283
|
| 50 |
+
absl_py-2.4.0.dist-info/RECORD,,
|
| 51 |
+
absl_py-2.4.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
| 52 |
+
absl_py-2.4.0.dist-info/licenses/AUTHORS,sha256=YoLudsylaQg7W5mLn4FroQMuEnuNx8RpQrhkd_xvv6U,296
|
| 53 |
+
absl_py-2.4.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: hatchling 1.28.0
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__version__ = '2.25.1'
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/_constants.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AWS has a 20 second idle timeout:
|
| 2 |
+
# https://web.archive.org/web/20150926192339/https://forums.aws.amazon.com/message.jspa?messageID=215367
|
| 3 |
+
# and aiohttp default timeout is 30s so we set it to something
|
| 4 |
+
# reasonable here
|
| 5 |
+
DEFAULT_KEEPALIVE_TIMEOUT = 12
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/_endpoint_helpers.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
|
| 3 |
+
import aiohttp.http_exceptions
|
| 4 |
+
import botocore.retryhandler
|
| 5 |
+
import wrapt
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
import httpx
|
| 9 |
+
except ImportError:
|
| 10 |
+
httpx = None
|
| 11 |
+
|
| 12 |
+
# Monkey patching: We need to insert the aiohttp exception equivalents
|
| 13 |
+
# The only other way to do this would be to have another config file :(
|
| 14 |
+
_aiohttp_retryable_exceptions = [
|
| 15 |
+
aiohttp.ClientConnectionError,
|
| 16 |
+
aiohttp.ClientPayloadError,
|
| 17 |
+
aiohttp.ServerDisconnectedError,
|
| 18 |
+
aiohttp.http_exceptions.HttpProcessingError,
|
| 19 |
+
asyncio.TimeoutError,
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
botocore.retryhandler.EXCEPTION_MAP['GENERAL_CONNECTION_ERROR'].extend(
|
| 24 |
+
_aiohttp_retryable_exceptions
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
if httpx is not None:
|
| 28 |
+
# See https://www.python-httpx.org/exceptions/#the-exception-hierarchy
|
| 29 |
+
# All child exceptions of TransportError, except ProxyError,
|
| 30 |
+
# UnsupportedProtocol and CloseError.
|
| 31 |
+
_httpx_retryable_exceptions = [
|
| 32 |
+
httpx.TimeoutException,
|
| 33 |
+
httpx.ProtocolError,
|
| 34 |
+
httpx.ConnectError,
|
| 35 |
+
httpx.ReadError,
|
| 36 |
+
httpx.WriteError,
|
| 37 |
+
]
|
| 38 |
+
botocore.retryhandler.EXCEPTION_MAP['GENERAL_CONNECTION_ERROR'].extend(
|
| 39 |
+
_httpx_retryable_exceptions
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _text(s, encoding='utf-8', errors='strict'):
|
| 44 |
+
if isinstance(s, bytes):
|
| 45 |
+
return s.decode(encoding, errors)
|
| 46 |
+
return s # pragma: no cover
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# Unfortunately aiohttp changed the behavior of streams:
|
| 50 |
+
# github.com/aio-libs/aiohttp/issues/1907
|
| 51 |
+
# We need this wrapper until we have a final resolution
|
| 52 |
+
class _IOBaseWrapper(wrapt.ObjectProxy):
|
| 53 |
+
def close(self):
|
| 54 |
+
# this stream should not be closed by aiohttp, like 1.x
|
| 55 |
+
pass
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/_helpers.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
async def resolve_awaitable(obj):
|
| 5 |
+
if inspect.isawaitable(obj):
|
| 6 |
+
return await obj
|
| 7 |
+
|
| 8 |
+
return obj
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
async def async_any(items):
|
| 12 |
+
for item in items:
|
| 13 |
+
if await resolve_awaitable(item):
|
| 14 |
+
return True
|
| 15 |
+
|
| 16 |
+
return False
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/args.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
|
| 3 |
+
import botocore.parsers
|
| 4 |
+
import botocore.serialize
|
| 5 |
+
from botocore.args import ClientArgsCreator, EPRBuiltins
|
| 6 |
+
|
| 7 |
+
from .config import AioConfig
|
| 8 |
+
from .endpoint import DEFAULT_HTTP_SESSION_CLS, AioEndpointCreator
|
| 9 |
+
from .parsers import create_parser
|
| 10 |
+
from .regions import AioEndpointRulesetResolver
|
| 11 |
+
from .signers import AioRequestSigner
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class AioClientArgsCreator(ClientArgsCreator):
|
| 15 |
+
# NOTE: we override this so we can pull out the custom AioConfig params and
|
| 16 |
+
# use an AioEndpointCreator
|
| 17 |
+
async def get_client_args(
|
| 18 |
+
self,
|
| 19 |
+
service_model,
|
| 20 |
+
region_name,
|
| 21 |
+
is_secure,
|
| 22 |
+
endpoint_url,
|
| 23 |
+
verify,
|
| 24 |
+
credentials,
|
| 25 |
+
scoped_config,
|
| 26 |
+
client_config,
|
| 27 |
+
endpoint_bridge,
|
| 28 |
+
auth_token=None,
|
| 29 |
+
endpoints_ruleset_data=None,
|
| 30 |
+
partition_data=None,
|
| 31 |
+
):
|
| 32 |
+
final_args = self.compute_client_args(
|
| 33 |
+
service_model,
|
| 34 |
+
client_config,
|
| 35 |
+
endpoint_bridge,
|
| 36 |
+
region_name,
|
| 37 |
+
endpoint_url,
|
| 38 |
+
is_secure,
|
| 39 |
+
scoped_config,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
service_name = final_args['service_name'] # noqa
|
| 43 |
+
parameter_validation = final_args['parameter_validation']
|
| 44 |
+
endpoint_config = final_args['endpoint_config']
|
| 45 |
+
protocol = final_args['protocol']
|
| 46 |
+
config_kwargs = final_args['config_kwargs']
|
| 47 |
+
s3_config = final_args['s3_config']
|
| 48 |
+
partition = endpoint_config['metadata'].get('partition', None)
|
| 49 |
+
socket_options = final_args['socket_options']
|
| 50 |
+
configured_endpoint_url = final_args['configured_endpoint_url']
|
| 51 |
+
signing_region = endpoint_config['signing_region']
|
| 52 |
+
endpoint_region_name = endpoint_config['region_name']
|
| 53 |
+
account_id_endpoint_mode = config_kwargs['account_id_endpoint_mode']
|
| 54 |
+
|
| 55 |
+
event_emitter = copy.copy(self._event_emitter)
|
| 56 |
+
signer = AioRequestSigner(
|
| 57 |
+
service_model.service_id,
|
| 58 |
+
signing_region,
|
| 59 |
+
endpoint_config['signing_name'],
|
| 60 |
+
endpoint_config['signature_version'],
|
| 61 |
+
credentials,
|
| 62 |
+
event_emitter,
|
| 63 |
+
auth_token,
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
config_kwargs['s3'] = s3_config
|
| 67 |
+
|
| 68 |
+
# aiobotocore addition
|
| 69 |
+
if isinstance(client_config, AioConfig):
|
| 70 |
+
connector_args = client_config.connector_args
|
| 71 |
+
http_session_cls = client_config.http_session_cls
|
| 72 |
+
else:
|
| 73 |
+
connector_args = None
|
| 74 |
+
http_session_cls = DEFAULT_HTTP_SESSION_CLS
|
| 75 |
+
|
| 76 |
+
new_config = AioConfig(connector_args, **config_kwargs)
|
| 77 |
+
endpoint_creator = AioEndpointCreator(event_emitter)
|
| 78 |
+
|
| 79 |
+
endpoint = endpoint_creator.create_endpoint(
|
| 80 |
+
service_model,
|
| 81 |
+
region_name=endpoint_region_name,
|
| 82 |
+
endpoint_url=endpoint_config['endpoint_url'],
|
| 83 |
+
verify=verify,
|
| 84 |
+
response_parser_factory=self._response_parser_factory,
|
| 85 |
+
timeout=(new_config.connect_timeout, new_config.read_timeout),
|
| 86 |
+
max_pool_connections=new_config.max_pool_connections,
|
| 87 |
+
http_session_cls=http_session_cls,
|
| 88 |
+
proxies=new_config.proxies,
|
| 89 |
+
socket_options=socket_options,
|
| 90 |
+
client_cert=new_config.client_cert,
|
| 91 |
+
proxies_config=new_config.proxies_config,
|
| 92 |
+
connector_args=new_config.connector_args,
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
# Emit event to allow service-specific or customer customization of serializer kwargs
|
| 96 |
+
event_name = f'creating-serializer.{service_name}'
|
| 97 |
+
serializer_kwargs = {
|
| 98 |
+
'timestamp_precision': botocore.serialize.TIMESTAMP_PRECISION_DEFAULT
|
| 99 |
+
}
|
| 100 |
+
await event_emitter.emit(
|
| 101 |
+
event_name,
|
| 102 |
+
protocol_name=protocol,
|
| 103 |
+
service_model=service_model,
|
| 104 |
+
serializer_kwargs=serializer_kwargs,
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
serializer = botocore.serialize.create_serializer(
|
| 108 |
+
protocol,
|
| 109 |
+
parameter_validation,
|
| 110 |
+
timestamp_precision=serializer_kwargs['timestamp_precision'],
|
| 111 |
+
)
|
| 112 |
+
response_parser = create_parser(protocol)
|
| 113 |
+
|
| 114 |
+
ruleset_resolver = self._build_endpoint_resolver(
|
| 115 |
+
endpoints_ruleset_data,
|
| 116 |
+
partition_data,
|
| 117 |
+
client_config,
|
| 118 |
+
service_model,
|
| 119 |
+
endpoint_region_name,
|
| 120 |
+
region_name,
|
| 121 |
+
configured_endpoint_url,
|
| 122 |
+
endpoint,
|
| 123 |
+
is_secure,
|
| 124 |
+
endpoint_bridge,
|
| 125 |
+
event_emitter,
|
| 126 |
+
credentials,
|
| 127 |
+
account_id_endpoint_mode,
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
# Copy the session's user agent factory and adds client configuration.
|
| 131 |
+
client_ua_creator = self._session_ua_creator.with_client_config(
|
| 132 |
+
new_config
|
| 133 |
+
)
|
| 134 |
+
supplied_ua = client_config.user_agent if client_config else None
|
| 135 |
+
new_config._supplied_user_agent = supplied_ua
|
| 136 |
+
|
| 137 |
+
return {
|
| 138 |
+
'serializer': serializer,
|
| 139 |
+
'endpoint': endpoint,
|
| 140 |
+
'response_parser': response_parser,
|
| 141 |
+
'event_emitter': event_emitter,
|
| 142 |
+
'request_signer': signer,
|
| 143 |
+
'service_model': service_model,
|
| 144 |
+
'loader': self._loader,
|
| 145 |
+
'client_config': new_config,
|
| 146 |
+
'partition': partition,
|
| 147 |
+
'exceptions_factory': self._exceptions_factory,
|
| 148 |
+
'endpoint_ruleset_resolver': ruleset_resolver,
|
| 149 |
+
'user_agent_creator': client_ua_creator,
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
def _build_endpoint_resolver(
|
| 153 |
+
self,
|
| 154 |
+
endpoints_ruleset_data,
|
| 155 |
+
partition_data,
|
| 156 |
+
client_config,
|
| 157 |
+
service_model,
|
| 158 |
+
endpoint_region_name,
|
| 159 |
+
region_name,
|
| 160 |
+
endpoint_url,
|
| 161 |
+
endpoint,
|
| 162 |
+
is_secure,
|
| 163 |
+
endpoint_bridge,
|
| 164 |
+
event_emitter,
|
| 165 |
+
credentials,
|
| 166 |
+
account_id_endpoint_mode,
|
| 167 |
+
):
|
| 168 |
+
if endpoints_ruleset_data is None:
|
| 169 |
+
return None
|
| 170 |
+
|
| 171 |
+
# The legacy EndpointResolver is global to the session, but
|
| 172 |
+
# EndpointRulesetResolver is service-specific. Builtins for
|
| 173 |
+
# EndpointRulesetResolver must not be derived from the legacy
|
| 174 |
+
# endpoint resolver's output, including final_args, s3_config,
|
| 175 |
+
# etc.
|
| 176 |
+
s3_config_raw = self.compute_s3_config(client_config) or {}
|
| 177 |
+
service_name_raw = service_model.endpoint_prefix
|
| 178 |
+
# Maintain complex logic for s3 and sts endpoints for backwards
|
| 179 |
+
# compatibility.
|
| 180 |
+
if service_name_raw in ['s3', 'sts'] or region_name is None:
|
| 181 |
+
eprv2_region_name = endpoint_region_name
|
| 182 |
+
else:
|
| 183 |
+
eprv2_region_name = region_name
|
| 184 |
+
resolver_builtins = self.compute_endpoint_resolver_builtin_defaults(
|
| 185 |
+
region_name=eprv2_region_name,
|
| 186 |
+
service_name=service_name_raw,
|
| 187 |
+
s3_config=s3_config_raw,
|
| 188 |
+
endpoint_bridge=endpoint_bridge,
|
| 189 |
+
client_endpoint_url=endpoint_url,
|
| 190 |
+
legacy_endpoint_url=endpoint.host,
|
| 191 |
+
credentials=credentials,
|
| 192 |
+
account_id_endpoint_mode=account_id_endpoint_mode,
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
# replace with async version
|
| 196 |
+
resolver_builtins[EPRBuiltins.ACCOUNT_ID] = (
|
| 197 |
+
credentials.get_account_id if credentials else None
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
# Client context params for s3 conflict with the available settings
|
| 201 |
+
# in the `s3` parameter on the `Config` object. If the same parameter
|
| 202 |
+
# is set in both places, the value in the `s3` parameter takes priority.
|
| 203 |
+
if client_config is not None:
|
| 204 |
+
client_context = client_config.client_context_params or {}
|
| 205 |
+
else:
|
| 206 |
+
client_context = {}
|
| 207 |
+
if self._is_s3_service(service_name_raw):
|
| 208 |
+
client_context.update(s3_config_raw)
|
| 209 |
+
|
| 210 |
+
sig_version = (
|
| 211 |
+
client_config.signature_version
|
| 212 |
+
if client_config is not None
|
| 213 |
+
else None
|
| 214 |
+
)
|
| 215 |
+
return AioEndpointRulesetResolver(
|
| 216 |
+
endpoint_ruleset_data=endpoints_ruleset_data,
|
| 217 |
+
partition_data=partition_data,
|
| 218 |
+
service_model=service_model,
|
| 219 |
+
builtins=resolver_builtins,
|
| 220 |
+
client_context=client_context,
|
| 221 |
+
event_emitter=event_emitter,
|
| 222 |
+
use_ssl=is_secure,
|
| 223 |
+
requested_auth_scheme=sig_version,
|
| 224 |
+
)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/awsrequest.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import botocore.utils
|
| 2 |
+
from botocore.awsrequest import AWSResponse
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class AioAWSResponse(AWSResponse):
|
| 6 |
+
# Unlike AWSResponse, these return awaitables
|
| 7 |
+
|
| 8 |
+
async def _content_prop(self):
|
| 9 |
+
"""Content of the response as bytes."""
|
| 10 |
+
|
| 11 |
+
if self._content is None:
|
| 12 |
+
# NOTE: this will cache the data in self.raw
|
| 13 |
+
self._content = await self.raw.read() or b''
|
| 14 |
+
|
| 15 |
+
return self._content
|
| 16 |
+
|
| 17 |
+
@property
|
| 18 |
+
def content(self):
|
| 19 |
+
return self._content_prop()
|
| 20 |
+
|
| 21 |
+
async def _text_prop(self):
|
| 22 |
+
encoding = botocore.utils.get_encoding_from_headers(self.headers)
|
| 23 |
+
if encoding:
|
| 24 |
+
return (await self.content).decode(encoding)
|
| 25 |
+
else:
|
| 26 |
+
return (await self.content).decode('utf-8')
|
| 27 |
+
|
| 28 |
+
@property
|
| 29 |
+
def text(self):
|
| 30 |
+
return self._text_prop()
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class HttpxAWSResponse(AioAWSResponse):
|
| 34 |
+
async def _content_prop(self):
|
| 35 |
+
"""Content of the response as bytes."""
|
| 36 |
+
|
| 37 |
+
if self._content is None:
|
| 38 |
+
# NOTE: this will cache the data in self.raw
|
| 39 |
+
self._content = await self.raw.aread() or b''
|
| 40 |
+
|
| 41 |
+
return self._content
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/client.py
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.auth import resolve_auth_type
|
| 2 |
+
from botocore.awsrequest import prepare_request_dict
|
| 3 |
+
from botocore.client import (
|
| 4 |
+
BaseClient,
|
| 5 |
+
ClientCreator,
|
| 6 |
+
ClientEndpointBridge,
|
| 7 |
+
PaginatorDocstring,
|
| 8 |
+
logger,
|
| 9 |
+
resolve_checksum_context,
|
| 10 |
+
)
|
| 11 |
+
from botocore.compress import maybe_compress_request
|
| 12 |
+
from botocore.discovery import block_endpoint_discovery_required_operations
|
| 13 |
+
from botocore.exceptions import OperationNotPageableError, UnknownServiceError
|
| 14 |
+
from botocore.history import get_global_history_recorder
|
| 15 |
+
from botocore.hooks import first_non_none_response
|
| 16 |
+
from botocore.useragent import register_feature_id
|
| 17 |
+
from botocore.utils import get_service_module_name
|
| 18 |
+
from botocore.waiter import xform_name
|
| 19 |
+
|
| 20 |
+
from . import waiter
|
| 21 |
+
from .args import AioClientArgsCreator
|
| 22 |
+
from .context import with_current_context
|
| 23 |
+
from .credentials import AioRefreshableCredentials
|
| 24 |
+
from .discovery import AioEndpointDiscoveryHandler, AioEndpointDiscoveryManager
|
| 25 |
+
from .httpchecksum import apply_request_checksum
|
| 26 |
+
from .paginate import AioPaginator
|
| 27 |
+
from .retries import adaptive, standard
|
| 28 |
+
from .utils import AioS3ExpressIdentityResolver, AioS3RegionRedirectorv2
|
| 29 |
+
|
| 30 |
+
history_recorder = get_global_history_recorder()
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class AioClientCreator(ClientCreator):
|
| 34 |
+
async def create_client(
|
| 35 |
+
self,
|
| 36 |
+
service_name,
|
| 37 |
+
region_name,
|
| 38 |
+
is_secure=True,
|
| 39 |
+
endpoint_url=None,
|
| 40 |
+
verify=None,
|
| 41 |
+
credentials=None,
|
| 42 |
+
scoped_config=None,
|
| 43 |
+
api_version=None,
|
| 44 |
+
client_config=None,
|
| 45 |
+
auth_token=None,
|
| 46 |
+
):
|
| 47 |
+
responses = await self._event_emitter.emit(
|
| 48 |
+
'choose-service-name', service_name=service_name
|
| 49 |
+
)
|
| 50 |
+
service_name = first_non_none_response(responses, default=service_name)
|
| 51 |
+
service_model = self._load_service_model(service_name, api_version)
|
| 52 |
+
try:
|
| 53 |
+
endpoints_ruleset_data = self._load_service_endpoints_ruleset(
|
| 54 |
+
service_name, api_version
|
| 55 |
+
)
|
| 56 |
+
partition_data = self._loader.load_data('partitions')
|
| 57 |
+
except UnknownServiceError:
|
| 58 |
+
endpoints_ruleset_data = None
|
| 59 |
+
partition_data = None
|
| 60 |
+
logger.info(
|
| 61 |
+
'No endpoints ruleset found for service %s, falling back to '
|
| 62 |
+
'legacy endpoint routing.',
|
| 63 |
+
service_name,
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
cls = await self._create_client_class(service_name, service_model)
|
| 67 |
+
region_name, client_config = self._normalize_fips_region(
|
| 68 |
+
region_name, client_config
|
| 69 |
+
)
|
| 70 |
+
if auth := service_model.metadata.get('auth'):
|
| 71 |
+
service_signature_version = resolve_auth_type(auth)
|
| 72 |
+
else:
|
| 73 |
+
service_signature_version = service_model.metadata.get(
|
| 74 |
+
'signatureVersion'
|
| 75 |
+
)
|
| 76 |
+
endpoint_bridge = ClientEndpointBridge(
|
| 77 |
+
self._endpoint_resolver,
|
| 78 |
+
scoped_config,
|
| 79 |
+
client_config,
|
| 80 |
+
service_signing_name=service_model.metadata.get('signingName'),
|
| 81 |
+
config_store=self._config_store,
|
| 82 |
+
service_signature_version=service_signature_version,
|
| 83 |
+
)
|
| 84 |
+
if token := self._evaluate_client_specific_token(
|
| 85 |
+
service_model.signing_name
|
| 86 |
+
):
|
| 87 |
+
auth_token = token
|
| 88 |
+
client_args = await self._get_client_args(
|
| 89 |
+
service_model,
|
| 90 |
+
region_name,
|
| 91 |
+
is_secure,
|
| 92 |
+
endpoint_url,
|
| 93 |
+
verify,
|
| 94 |
+
credentials,
|
| 95 |
+
scoped_config,
|
| 96 |
+
client_config,
|
| 97 |
+
endpoint_bridge,
|
| 98 |
+
auth_token,
|
| 99 |
+
endpoints_ruleset_data,
|
| 100 |
+
partition_data,
|
| 101 |
+
)
|
| 102 |
+
service_client = cls(**client_args)
|
| 103 |
+
self._register_retries(service_client)
|
| 104 |
+
self._register_s3_events(
|
| 105 |
+
client=service_client,
|
| 106 |
+
endpoint_bridge=None,
|
| 107 |
+
endpoint_url=None,
|
| 108 |
+
client_config=client_config,
|
| 109 |
+
scoped_config=scoped_config,
|
| 110 |
+
)
|
| 111 |
+
self._register_s3express_events(client=service_client)
|
| 112 |
+
self._register_s3_control_events(client=service_client)
|
| 113 |
+
self._register_importexport_events(client=service_client)
|
| 114 |
+
self._register_endpoint_discovery(
|
| 115 |
+
service_client, endpoint_url, client_config
|
| 116 |
+
)
|
| 117 |
+
return service_client
|
| 118 |
+
|
| 119 |
+
async def _create_client_class(self, service_name, service_model):
|
| 120 |
+
class_attributes = self._create_methods(service_model)
|
| 121 |
+
py_name_to_operation_name = self._create_name_mapping(service_model)
|
| 122 |
+
class_attributes['_PY_TO_OP_NAME'] = py_name_to_operation_name
|
| 123 |
+
bases = [AioBaseClient]
|
| 124 |
+
service_id = service_model.service_id.hyphenize()
|
| 125 |
+
await self._event_emitter.emit(
|
| 126 |
+
f'creating-client-class.{service_id}',
|
| 127 |
+
class_attributes=class_attributes,
|
| 128 |
+
base_classes=bases,
|
| 129 |
+
)
|
| 130 |
+
class_name = get_service_module_name(service_model)
|
| 131 |
+
cls = type(str(class_name), tuple(bases), class_attributes)
|
| 132 |
+
return cls
|
| 133 |
+
|
| 134 |
+
def _register_retries(self, client):
|
| 135 |
+
# botocore retry handlers may block. We add our own implementation here.
|
| 136 |
+
# botocore provides three implementations:
|
| 137 |
+
#
|
| 138 |
+
# 1) standard
|
| 139 |
+
# This one doesn't block. A threading.Lock is used in quota.RetryQuota,
|
| 140 |
+
# but it's only used to protect concurrent modifications of internal
|
| 141 |
+
# state inside multithreaded programs. When running under a single
|
| 142 |
+
# asyncio thread, this lock will be acquired and released in the same
|
| 143 |
+
# coroutine, and the coroutine will never block waiting for the lock.
|
| 144 |
+
# Thus, we don't need to redefine this strategy.
|
| 145 |
+
#
|
| 146 |
+
# 2) adaptive
|
| 147 |
+
# This one blocks when the client is applying self rate limiting.
|
| 148 |
+
# We override the corresponding definition to replace it with async
|
| 149 |
+
# objects.
|
| 150 |
+
#
|
| 151 |
+
# 3) legacy
|
| 152 |
+
# This one probably doesn't block.
|
| 153 |
+
#
|
| 154 |
+
# The code for this method comes directly from botocore. We could
|
| 155 |
+
# override `_register_v2_adaptive_retries` only. The override for
|
| 156 |
+
# `_register_retries` is only included for clarity.
|
| 157 |
+
retry_mode = client.meta.config.retries['mode']
|
| 158 |
+
if retry_mode == 'standard':
|
| 159 |
+
self._register_v2_standard_retries(client)
|
| 160 |
+
elif retry_mode == 'adaptive':
|
| 161 |
+
self._register_v2_standard_retries(client)
|
| 162 |
+
self._register_v2_adaptive_retries(client)
|
| 163 |
+
elif retry_mode == 'legacy':
|
| 164 |
+
self._register_legacy_retries(client)
|
| 165 |
+
else:
|
| 166 |
+
return
|
| 167 |
+
register_feature_id(f'RETRY_MODE_{retry_mode.upper()}')
|
| 168 |
+
|
| 169 |
+
def _register_v2_standard_retries(self, client):
|
| 170 |
+
max_attempts = client.meta.config.retries.get('total_max_attempts')
|
| 171 |
+
kwargs = {'client': client}
|
| 172 |
+
if max_attempts is not None:
|
| 173 |
+
kwargs['max_attempts'] = max_attempts
|
| 174 |
+
standard.register_retry_handler(**kwargs)
|
| 175 |
+
|
| 176 |
+
def _register_v2_adaptive_retries(self, client):
|
| 177 |
+
# See comment in `_register_retries`.
|
| 178 |
+
# Note that this `adaptive` module is an aiobotocore reimplementation.
|
| 179 |
+
adaptive.register_retry_handler(client)
|
| 180 |
+
|
| 181 |
+
def _register_legacy_retries(self, client):
|
| 182 |
+
endpoint_prefix = client.meta.service_model.endpoint_prefix
|
| 183 |
+
service_id = client.meta.service_model.service_id
|
| 184 |
+
service_event_name = service_id.hyphenize()
|
| 185 |
+
|
| 186 |
+
# First, we load the entire retry config for all services,
|
| 187 |
+
# then pull out just the information we need.
|
| 188 |
+
original_config = self._loader.load_data('_retry')
|
| 189 |
+
if not original_config:
|
| 190 |
+
return
|
| 191 |
+
|
| 192 |
+
retries = self._transform_legacy_retries(client.meta.config.retries)
|
| 193 |
+
retry_config = self._retry_config_translator.build_retry_config(
|
| 194 |
+
endpoint_prefix,
|
| 195 |
+
original_config.get('retry', {}),
|
| 196 |
+
original_config.get('definitions', {}),
|
| 197 |
+
retries,
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
logger.debug(
|
| 201 |
+
"Registering retry handlers for service: %s",
|
| 202 |
+
client.meta.service_model.service_name,
|
| 203 |
+
)
|
| 204 |
+
handler = self._retry_handler_factory.create_retry_handler(
|
| 205 |
+
retry_config, endpoint_prefix
|
| 206 |
+
)
|
| 207 |
+
unique_id = f'retry-config-{service_event_name}'
|
| 208 |
+
client.meta.events.register(
|
| 209 |
+
f"needs-retry.{service_event_name}", handler, unique_id=unique_id
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
def _register_endpoint_discovery(self, client, endpoint_url, config):
|
| 213 |
+
if endpoint_url is not None:
|
| 214 |
+
# Don't register any handlers in the case of a custom endpoint url
|
| 215 |
+
return
|
| 216 |
+
# Only attach handlers if the service supports discovery
|
| 217 |
+
if client.meta.service_model.endpoint_discovery_operation is None:
|
| 218 |
+
return
|
| 219 |
+
events = client.meta.events
|
| 220 |
+
service_id = client.meta.service_model.service_id.hyphenize()
|
| 221 |
+
enabled = False
|
| 222 |
+
if config and config.endpoint_discovery_enabled is not None:
|
| 223 |
+
enabled = config.endpoint_discovery_enabled
|
| 224 |
+
elif self._config_store:
|
| 225 |
+
enabled = self._config_store.get_config_variable(
|
| 226 |
+
'endpoint_discovery_enabled'
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
enabled = self._normalize_endpoint_discovery_config(enabled)
|
| 230 |
+
if enabled and self._requires_endpoint_discovery(client, enabled):
|
| 231 |
+
discover = enabled is True
|
| 232 |
+
manager = AioEndpointDiscoveryManager(
|
| 233 |
+
client, always_discover=discover
|
| 234 |
+
)
|
| 235 |
+
handler = AioEndpointDiscoveryHandler(manager)
|
| 236 |
+
handler.register(events, service_id)
|
| 237 |
+
else:
|
| 238 |
+
events.register(
|
| 239 |
+
'before-parameter-build',
|
| 240 |
+
block_endpoint_discovery_required_operations,
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
def _register_s3express_events(
|
| 244 |
+
self,
|
| 245 |
+
client,
|
| 246 |
+
endpoint_bridge=None,
|
| 247 |
+
endpoint_url=None,
|
| 248 |
+
client_config=None,
|
| 249 |
+
scoped_config=None,
|
| 250 |
+
):
|
| 251 |
+
if client.meta.service_model.service_name != 's3':
|
| 252 |
+
return
|
| 253 |
+
AioS3ExpressIdentityResolver(
|
| 254 |
+
client, AioRefreshableCredentials
|
| 255 |
+
).register()
|
| 256 |
+
|
| 257 |
+
def _register_s3_events(
|
| 258 |
+
self,
|
| 259 |
+
client,
|
| 260 |
+
endpoint_bridge,
|
| 261 |
+
endpoint_url,
|
| 262 |
+
client_config,
|
| 263 |
+
scoped_config,
|
| 264 |
+
):
|
| 265 |
+
if client.meta.service_model.service_name != 's3':
|
| 266 |
+
return
|
| 267 |
+
AioS3RegionRedirectorv2(None, client).register()
|
| 268 |
+
self._set_s3_presign_signature_version(
|
| 269 |
+
client.meta, client_config, scoped_config
|
| 270 |
+
)
|
| 271 |
+
client.meta.events.register(
|
| 272 |
+
'before-parameter-build.s3', self._inject_s3_input_parameters
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
async def _get_client_args(
|
| 276 |
+
self,
|
| 277 |
+
service_model,
|
| 278 |
+
region_name,
|
| 279 |
+
is_secure,
|
| 280 |
+
endpoint_url,
|
| 281 |
+
verify,
|
| 282 |
+
credentials,
|
| 283 |
+
scoped_config,
|
| 284 |
+
client_config,
|
| 285 |
+
endpoint_bridge,
|
| 286 |
+
auth_token,
|
| 287 |
+
endpoints_ruleset_data,
|
| 288 |
+
partition_data,
|
| 289 |
+
):
|
| 290 |
+
# This is a near copy of ClientCreator. What's replaced
|
| 291 |
+
# is ClientArgsCreator->AioClientArgsCreator
|
| 292 |
+
args_creator = AioClientArgsCreator(
|
| 293 |
+
self._event_emitter,
|
| 294 |
+
self._user_agent,
|
| 295 |
+
self._response_parser_factory,
|
| 296 |
+
self._loader,
|
| 297 |
+
self._exceptions_factory,
|
| 298 |
+
config_store=self._config_store,
|
| 299 |
+
user_agent_creator=self._user_agent_creator,
|
| 300 |
+
)
|
| 301 |
+
return await args_creator.get_client_args(
|
| 302 |
+
service_model,
|
| 303 |
+
region_name,
|
| 304 |
+
is_secure,
|
| 305 |
+
endpoint_url,
|
| 306 |
+
verify,
|
| 307 |
+
credentials,
|
| 308 |
+
scoped_config,
|
| 309 |
+
client_config,
|
| 310 |
+
endpoint_bridge,
|
| 311 |
+
auth_token,
|
| 312 |
+
endpoints_ruleset_data,
|
| 313 |
+
partition_data,
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
class AioBaseClient(BaseClient):
|
| 318 |
+
async def _async_getattr(self, item):
|
| 319 |
+
event_name = (
|
| 320 |
+
f'getattr.{self._service_model.service_id.hyphenize()}.{item}'
|
| 321 |
+
)
|
| 322 |
+
handler, event_response = await self.meta.events.emit_until_response(
|
| 323 |
+
event_name, client=self
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
return event_response
|
| 327 |
+
|
| 328 |
+
def __getattr__(self, item):
|
| 329 |
+
# NOTE: we can not reliably support this because if we were to make this a
|
| 330 |
+
# deferred attrgetter (See #803), it would resolve in hasattr always returning
|
| 331 |
+
# true. This ends up breaking ddtrace for example when it tries to set a pin.
|
| 332 |
+
raise AttributeError(
|
| 333 |
+
f"'{self.__class__.__name__}' object has no attribute '{item}'"
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
async def close(self):
|
| 337 |
+
"""Closes underlying endpoint connections."""
|
| 338 |
+
await self._endpoint.close()
|
| 339 |
+
|
| 340 |
+
@with_current_context()
|
| 341 |
+
async def _make_api_call(self, operation_name, api_params):
|
| 342 |
+
operation_model = self._service_model.operation_model(operation_name)
|
| 343 |
+
service_name = self._service_model.service_name
|
| 344 |
+
history_recorder.record(
|
| 345 |
+
'API_CALL',
|
| 346 |
+
{
|
| 347 |
+
'service': service_name,
|
| 348 |
+
'operation': operation_name,
|
| 349 |
+
'params': api_params,
|
| 350 |
+
},
|
| 351 |
+
)
|
| 352 |
+
if operation_model.deprecated:
|
| 353 |
+
logger.debug(
|
| 354 |
+
'Warning: %s.%s() is deprecated', service_name, operation_name
|
| 355 |
+
)
|
| 356 |
+
request_context = {
|
| 357 |
+
'client_region': self.meta.region_name,
|
| 358 |
+
'client_config': self.meta.config,
|
| 359 |
+
'has_streaming_input': operation_model.has_streaming_input,
|
| 360 |
+
'auth_type': operation_model.resolved_auth_type,
|
| 361 |
+
'unsigned_payload': operation_model.unsigned_payload,
|
| 362 |
+
'auth_options': self._service_model.metadata.get('auth'),
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
api_params = await self._emit_api_params(
|
| 366 |
+
api_params=api_params,
|
| 367 |
+
operation_model=operation_model,
|
| 368 |
+
context=request_context,
|
| 369 |
+
)
|
| 370 |
+
(
|
| 371 |
+
endpoint_url,
|
| 372 |
+
additional_headers,
|
| 373 |
+
properties,
|
| 374 |
+
) = await self._resolve_endpoint_ruleset(
|
| 375 |
+
operation_model, api_params, request_context
|
| 376 |
+
)
|
| 377 |
+
if properties:
|
| 378 |
+
# Pass arbitrary endpoint info with the Request
|
| 379 |
+
# for use during construction.
|
| 380 |
+
request_context['endpoint_properties'] = properties
|
| 381 |
+
request_dict = await self._convert_to_request_dict(
|
| 382 |
+
api_params=api_params,
|
| 383 |
+
operation_model=operation_model,
|
| 384 |
+
endpoint_url=endpoint_url,
|
| 385 |
+
context=request_context,
|
| 386 |
+
headers=additional_headers,
|
| 387 |
+
)
|
| 388 |
+
resolve_checksum_context(request_dict, operation_model, api_params)
|
| 389 |
+
|
| 390 |
+
service_id = self._service_model.service_id.hyphenize()
|
| 391 |
+
handler, event_response = await self.meta.events.emit_until_response(
|
| 392 |
+
f'before-call.{service_id}.{operation_name}',
|
| 393 |
+
model=operation_model,
|
| 394 |
+
params=request_dict,
|
| 395 |
+
request_signer=self._request_signer,
|
| 396 |
+
context=request_context,
|
| 397 |
+
)
|
| 398 |
+
|
| 399 |
+
if event_response is not None:
|
| 400 |
+
http, parsed_response = event_response
|
| 401 |
+
else:
|
| 402 |
+
maybe_compress_request(
|
| 403 |
+
self.meta.config, request_dict, operation_model
|
| 404 |
+
)
|
| 405 |
+
apply_request_checksum(request_dict)
|
| 406 |
+
http, parsed_response = await self._make_request(
|
| 407 |
+
operation_model, request_dict, request_context
|
| 408 |
+
)
|
| 409 |
+
|
| 410 |
+
await self.meta.events.emit(
|
| 411 |
+
f'after-call.{service_id}.{operation_name}',
|
| 412 |
+
http_response=http,
|
| 413 |
+
parsed=parsed_response,
|
| 414 |
+
model=operation_model,
|
| 415 |
+
context=request_context,
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
if http.status_code >= 300:
|
| 419 |
+
error_info = parsed_response.get("Error", {})
|
| 420 |
+
error_code = request_context.get(
|
| 421 |
+
'error_code_override'
|
| 422 |
+
) or error_info.get("Code")
|
| 423 |
+
error_class = self.exceptions.from_code(error_code)
|
| 424 |
+
raise error_class(parsed_response, operation_name)
|
| 425 |
+
else:
|
| 426 |
+
return parsed_response
|
| 427 |
+
|
| 428 |
+
async def _make_request(
|
| 429 |
+
self, operation_model, request_dict, request_context
|
| 430 |
+
):
|
| 431 |
+
try:
|
| 432 |
+
return await self._endpoint.make_request(
|
| 433 |
+
operation_model, request_dict
|
| 434 |
+
)
|
| 435 |
+
except Exception as e:
|
| 436 |
+
await self.meta.events.emit(
|
| 437 |
+
f'after-call-error.{self._service_model.service_id.hyphenize()}.{operation_model.name}',
|
| 438 |
+
exception=e,
|
| 439 |
+
context=request_context,
|
| 440 |
+
)
|
| 441 |
+
raise
|
| 442 |
+
|
| 443 |
+
async def _convert_to_request_dict(
|
| 444 |
+
self,
|
| 445 |
+
api_params,
|
| 446 |
+
operation_model,
|
| 447 |
+
endpoint_url,
|
| 448 |
+
context=None,
|
| 449 |
+
headers=None,
|
| 450 |
+
set_user_agent_header=True,
|
| 451 |
+
):
|
| 452 |
+
request_dict = self._serializer.serialize_to_request(
|
| 453 |
+
api_params, operation_model
|
| 454 |
+
)
|
| 455 |
+
if not self._client_config.inject_host_prefix:
|
| 456 |
+
request_dict.pop('host_prefix', None)
|
| 457 |
+
if headers is not None:
|
| 458 |
+
request_dict['headers'].update(headers)
|
| 459 |
+
if set_user_agent_header:
|
| 460 |
+
user_agent = self._user_agent_creator.to_string()
|
| 461 |
+
else:
|
| 462 |
+
user_agent = None
|
| 463 |
+
prepare_request_dict(
|
| 464 |
+
request_dict,
|
| 465 |
+
endpoint_url=endpoint_url,
|
| 466 |
+
user_agent=user_agent,
|
| 467 |
+
context=context,
|
| 468 |
+
)
|
| 469 |
+
return request_dict
|
| 470 |
+
|
| 471 |
+
async def _emit_api_params(self, api_params, operation_model, context):
|
| 472 |
+
# Given the API params provided by the user and the operation_model
|
| 473 |
+
# we can serialize the request to a request_dict.
|
| 474 |
+
operation_name = operation_model.name
|
| 475 |
+
|
| 476 |
+
# Emit an event that allows users to modify the parameters at the
|
| 477 |
+
# beginning of the method. It allows handlers to modify existing
|
| 478 |
+
# parameters or return a new set of parameters to use.
|
| 479 |
+
service_id = self._service_model.service_id.hyphenize()
|
| 480 |
+
responses = await self.meta.events.emit(
|
| 481 |
+
f'provide-client-params.{service_id}.{operation_name}',
|
| 482 |
+
params=api_params,
|
| 483 |
+
model=operation_model,
|
| 484 |
+
context=context,
|
| 485 |
+
)
|
| 486 |
+
api_params = first_non_none_response(responses, default=api_params)
|
| 487 |
+
|
| 488 |
+
await self.meta.events.emit(
|
| 489 |
+
f'before-parameter-build.{service_id}.{operation_name}',
|
| 490 |
+
params=api_params,
|
| 491 |
+
model=operation_model,
|
| 492 |
+
context=context,
|
| 493 |
+
)
|
| 494 |
+
return api_params
|
| 495 |
+
|
| 496 |
+
async def _resolve_endpoint_ruleset(
|
| 497 |
+
self,
|
| 498 |
+
operation_model,
|
| 499 |
+
params,
|
| 500 |
+
request_context,
|
| 501 |
+
ignore_signing_region=False,
|
| 502 |
+
):
|
| 503 |
+
"""Returns endpoint URL and list of additional headers returned from
|
| 504 |
+
EndpointRulesetResolver for the given operation and params. If the
|
| 505 |
+
ruleset resolver is not available, for example because the service has
|
| 506 |
+
no endpoints ruleset file, the legacy endpoint resolver's value is
|
| 507 |
+
returned.
|
| 508 |
+
|
| 509 |
+
Use ignore_signing_region for generating presigned URLs or any other
|
| 510 |
+
situation where the signing region information from the ruleset
|
| 511 |
+
resolver should be ignored.
|
| 512 |
+
|
| 513 |
+
Returns tuple of URL and headers dictionary. Additionally, the
|
| 514 |
+
request_context dict is modified in place with any signing information
|
| 515 |
+
returned from the ruleset resolver.
|
| 516 |
+
"""
|
| 517 |
+
if self._ruleset_resolver is None:
|
| 518 |
+
endpoint_url = self.meta.endpoint_url
|
| 519 |
+
additional_headers = {}
|
| 520 |
+
endpoint_properties = {}
|
| 521 |
+
else:
|
| 522 |
+
endpoint_info = await self._ruleset_resolver.construct_endpoint(
|
| 523 |
+
operation_model=operation_model,
|
| 524 |
+
call_args=params,
|
| 525 |
+
request_context=request_context,
|
| 526 |
+
)
|
| 527 |
+
endpoint_url = endpoint_info.url
|
| 528 |
+
additional_headers = endpoint_info.headers
|
| 529 |
+
endpoint_properties = endpoint_info.properties
|
| 530 |
+
# If authSchemes is present, overwrite default auth type and
|
| 531 |
+
# signing context derived from service model.
|
| 532 |
+
auth_schemes = endpoint_info.properties.get('authSchemes')
|
| 533 |
+
if auth_schemes is not None:
|
| 534 |
+
auth_info = self._ruleset_resolver.auth_schemes_to_signing_ctx(
|
| 535 |
+
auth_schemes
|
| 536 |
+
)
|
| 537 |
+
auth_type, signing_context = auth_info
|
| 538 |
+
request_context['auth_type'] = auth_type
|
| 539 |
+
if 'region' in signing_context and ignore_signing_region:
|
| 540 |
+
del signing_context['region']
|
| 541 |
+
if 'signing' in request_context:
|
| 542 |
+
request_context['signing'].update(signing_context)
|
| 543 |
+
else:
|
| 544 |
+
request_context['signing'] = signing_context
|
| 545 |
+
|
| 546 |
+
return endpoint_url, additional_headers, endpoint_properties
|
| 547 |
+
|
| 548 |
+
def get_paginator(self, operation_name):
|
| 549 |
+
"""Create a paginator for an operation.
|
| 550 |
+
|
| 551 |
+
:type operation_name: string
|
| 552 |
+
:param operation_name: The operation name. This is the same name
|
| 553 |
+
as the method name on the client. For example, if the
|
| 554 |
+
method name is ``create_foo``, and you'd normally invoke the
|
| 555 |
+
operation as ``client.create_foo(**kwargs)``, if the
|
| 556 |
+
``create_foo`` operation can be paginated, you can use the
|
| 557 |
+
call ``client.get_paginator("create_foo")``.
|
| 558 |
+
|
| 559 |
+
:raise OperationNotPageableError: Raised if the operation is not
|
| 560 |
+
pageable. You can use the ``client.can_paginate`` method to
|
| 561 |
+
check if an operation is pageable.
|
| 562 |
+
|
| 563 |
+
:rtype: ``botocore.paginate.Paginator``
|
| 564 |
+
:return: A paginator object.
|
| 565 |
+
|
| 566 |
+
"""
|
| 567 |
+
if not self.can_paginate(operation_name):
|
| 568 |
+
raise OperationNotPageableError(operation_name=operation_name)
|
| 569 |
+
else:
|
| 570 |
+
actual_operation_name = self._PY_TO_OP_NAME[operation_name]
|
| 571 |
+
|
| 572 |
+
# Create a new paginate method that will serve as a proxy to
|
| 573 |
+
# the underlying Paginator.paginate method. This is needed to
|
| 574 |
+
# attach a docstring to the method.
|
| 575 |
+
def paginate(self, **kwargs):
|
| 576 |
+
return AioPaginator.paginate(self, **kwargs)
|
| 577 |
+
|
| 578 |
+
paginator_config = self._cache['page_config'][
|
| 579 |
+
actual_operation_name
|
| 580 |
+
]
|
| 581 |
+
# Add the docstring for the paginate method.
|
| 582 |
+
paginate.__doc__ = PaginatorDocstring(
|
| 583 |
+
paginator_name=actual_operation_name,
|
| 584 |
+
event_emitter=self.meta.events,
|
| 585 |
+
service_model=self.meta.service_model,
|
| 586 |
+
paginator_config=paginator_config,
|
| 587 |
+
include_signature=False,
|
| 588 |
+
)
|
| 589 |
+
|
| 590 |
+
# Rename the paginator class based on the type of paginator.
|
| 591 |
+
service_module_name = get_service_module_name(
|
| 592 |
+
self.meta.service_model
|
| 593 |
+
)
|
| 594 |
+
paginator_class_name = (
|
| 595 |
+
f"{service_module_name}.Paginator.{actual_operation_name}"
|
| 596 |
+
)
|
| 597 |
+
|
| 598 |
+
# Create the new paginator class
|
| 599 |
+
documented_paginator_cls = type(
|
| 600 |
+
paginator_class_name, (AioPaginator,), {'paginate': paginate}
|
| 601 |
+
)
|
| 602 |
+
|
| 603 |
+
operation_model = self._service_model.operation_model(
|
| 604 |
+
actual_operation_name
|
| 605 |
+
)
|
| 606 |
+
paginator = documented_paginator_cls(
|
| 607 |
+
getattr(self, operation_name),
|
| 608 |
+
paginator_config,
|
| 609 |
+
operation_model,
|
| 610 |
+
)
|
| 611 |
+
return paginator
|
| 612 |
+
|
| 613 |
+
# NOTE: this method does not differ from botocore, however it's important to keep
|
| 614 |
+
# as the "waiter" value points to our own asyncio waiter module
|
| 615 |
+
def get_waiter(self, waiter_name):
|
| 616 |
+
"""Returns an object that can wait for some condition.
|
| 617 |
+
|
| 618 |
+
:type waiter_name: str
|
| 619 |
+
:param waiter_name: The name of the waiter to get. See the waiters
|
| 620 |
+
section of the service docs for a list of available waiters.
|
| 621 |
+
|
| 622 |
+
:returns: The specified waiter object.
|
| 623 |
+
:rtype: ``botocore.waiter.Waiter``
|
| 624 |
+
"""
|
| 625 |
+
config = self._get_waiter_config()
|
| 626 |
+
if not config:
|
| 627 |
+
raise ValueError(f"Waiter does not exist: {waiter_name}")
|
| 628 |
+
model = waiter.WaiterModel(config)
|
| 629 |
+
mapping = {}
|
| 630 |
+
for name in model.waiter_names:
|
| 631 |
+
mapping[xform_name(name)] = name
|
| 632 |
+
if waiter_name not in mapping:
|
| 633 |
+
raise ValueError(f"Waiter does not exist: {waiter_name}")
|
| 634 |
+
|
| 635 |
+
return waiter.create_waiter_with_client(
|
| 636 |
+
mapping[waiter_name], model, self
|
| 637 |
+
)
|
| 638 |
+
|
| 639 |
+
async def __aenter__(self):
|
| 640 |
+
await self._endpoint.http_session.__aenter__()
|
| 641 |
+
return self
|
| 642 |
+
|
| 643 |
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
| 644 |
+
await self._endpoint.http_session.__aexit__(exc_type, exc_val, exc_tb)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/config.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
|
| 3 |
+
import botocore.client
|
| 4 |
+
from botocore.exceptions import ParamValidationError
|
| 5 |
+
|
| 6 |
+
from ._constants import DEFAULT_KEEPALIVE_TIMEOUT
|
| 7 |
+
from .endpoint import DEFAULT_HTTP_SESSION_CLS
|
| 8 |
+
from .httpxsession import HttpxSession
|
| 9 |
+
|
| 10 |
+
TIMEOUT_ARGS = frozenset(
|
| 11 |
+
('keepalive_timeout', 'write_timeout', 'pool_timeout')
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class AioConfig(botocore.client.Config):
|
| 16 |
+
def __init__(
|
| 17 |
+
self,
|
| 18 |
+
connector_args=None,
|
| 19 |
+
http_session_cls=DEFAULT_HTTP_SESSION_CLS,
|
| 20 |
+
**kwargs,
|
| 21 |
+
):
|
| 22 |
+
super().__init__(**kwargs)
|
| 23 |
+
|
| 24 |
+
self._validate_connector_args(connector_args, http_session_cls)
|
| 25 |
+
self.connector_args = copy.copy(connector_args)
|
| 26 |
+
self.http_session_cls = http_session_cls
|
| 27 |
+
if not self.connector_args:
|
| 28 |
+
self.connector_args = dict()
|
| 29 |
+
|
| 30 |
+
if 'keepalive_timeout' not in self.connector_args:
|
| 31 |
+
self.connector_args['keepalive_timeout'] = (
|
| 32 |
+
DEFAULT_KEEPALIVE_TIMEOUT
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
def merge(self, other_config):
|
| 36 |
+
# Adapted from parent class
|
| 37 |
+
config_options = copy.copy(self._user_provided_options)
|
| 38 |
+
config_options.update(other_config._user_provided_options)
|
| 39 |
+
return AioConfig(self.connector_args, **config_options)
|
| 40 |
+
|
| 41 |
+
@staticmethod
|
| 42 |
+
def _validate_connector_args(connector_args, http_session_cls):
|
| 43 |
+
if connector_args is None:
|
| 44 |
+
return
|
| 45 |
+
|
| 46 |
+
for k, v in connector_args.items():
|
| 47 |
+
# verify_ssl is handled by verify parameter to create_client
|
| 48 |
+
if k == 'use_dns_cache':
|
| 49 |
+
if http_session_cls is HttpxSession:
|
| 50 |
+
raise ParamValidationError(
|
| 51 |
+
report='Httpx does not support dns caching. https://github.com/encode/httpx/discussions/2211'
|
| 52 |
+
)
|
| 53 |
+
if not isinstance(v, bool):
|
| 54 |
+
raise ParamValidationError(
|
| 55 |
+
report=f'{k} value must be a boolean'
|
| 56 |
+
)
|
| 57 |
+
elif k == 'ttl_dns_cache':
|
| 58 |
+
if v is not None and not isinstance(v, int):
|
| 59 |
+
raise ParamValidationError(
|
| 60 |
+
report=f'{k} value must be an int or None'
|
| 61 |
+
)
|
| 62 |
+
elif k in TIMEOUT_ARGS:
|
| 63 |
+
if v is not None and not isinstance(v, (float, int)):
|
| 64 |
+
raise ParamValidationError(
|
| 65 |
+
report=f'{k} value must be a float/int or None'
|
| 66 |
+
)
|
| 67 |
+
elif k == 'force_close':
|
| 68 |
+
if http_session_cls is HttpxSession:
|
| 69 |
+
raise ParamValidationError(
|
| 70 |
+
report=f'Httpx backend does not currently support {k}.'
|
| 71 |
+
)
|
| 72 |
+
if not isinstance(v, bool):
|
| 73 |
+
raise ParamValidationError(
|
| 74 |
+
report=f'{k} value must be a boolean'
|
| 75 |
+
)
|
| 76 |
+
# limit is handled by max_pool_connections
|
| 77 |
+
elif k == 'ssl_context':
|
| 78 |
+
import ssl
|
| 79 |
+
|
| 80 |
+
if not isinstance(v, ssl.SSLContext):
|
| 81 |
+
raise ParamValidationError(
|
| 82 |
+
report=f'{k} must be an SSLContext instance'
|
| 83 |
+
)
|
| 84 |
+
elif k == "resolver":
|
| 85 |
+
from aiohttp.abc import AbstractResolver
|
| 86 |
+
|
| 87 |
+
if http_session_cls is HttpxSession:
|
| 88 |
+
raise ParamValidationError(
|
| 89 |
+
report=f'Httpx backend does not support {k}.'
|
| 90 |
+
)
|
| 91 |
+
if not isinstance(v, AbstractResolver):
|
| 92 |
+
raise ParamValidationError(
|
| 93 |
+
report=f'{k} must be an instance of a AbstractResolver'
|
| 94 |
+
)
|
| 95 |
+
else:
|
| 96 |
+
raise ParamValidationError(report=f'invalid connector_arg:{k}')
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/configprovider.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.configprovider import SmartDefaultsConfigStoreFactory, os
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class AioSmartDefaultsConfigStoreFactory(SmartDefaultsConfigStoreFactory):
|
| 5 |
+
async def merge_smart_defaults(self, config_store, mode, region_name):
|
| 6 |
+
if mode == 'auto':
|
| 7 |
+
mode = await self.resolve_auto_mode(region_name)
|
| 8 |
+
default_configs = (
|
| 9 |
+
self._default_config_resolver.get_default_config_values(mode)
|
| 10 |
+
)
|
| 11 |
+
for config_var in default_configs:
|
| 12 |
+
config_value = default_configs[config_var]
|
| 13 |
+
method = getattr(self, f'_set_{config_var}', None)
|
| 14 |
+
if method:
|
| 15 |
+
method(config_store, config_value)
|
| 16 |
+
|
| 17 |
+
async def resolve_auto_mode(self, region_name):
|
| 18 |
+
current_region = None
|
| 19 |
+
if os.environ.get('AWS_EXECUTION_ENV'):
|
| 20 |
+
default_region = os.environ.get('AWS_DEFAULT_REGION')
|
| 21 |
+
current_region = os.environ.get('AWS_REGION', default_region)
|
| 22 |
+
if not current_region:
|
| 23 |
+
if self._instance_metadata_region:
|
| 24 |
+
current_region = self._instance_metadata_region
|
| 25 |
+
else:
|
| 26 |
+
try:
|
| 27 |
+
current_region = await self._imds_region_provider.provide()
|
| 28 |
+
self._instance_metadata_region = current_region
|
| 29 |
+
except Exception:
|
| 30 |
+
pass
|
| 31 |
+
|
| 32 |
+
if current_region:
|
| 33 |
+
if region_name == current_region:
|
| 34 |
+
return 'in-region'
|
| 35 |
+
else:
|
| 36 |
+
return 'cross-region'
|
| 37 |
+
return 'standard'
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/context.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from contextlib import asynccontextmanager
|
| 2 |
+
from copy import deepcopy
|
| 3 |
+
from functools import wraps
|
| 4 |
+
|
| 5 |
+
from botocore.context import (
|
| 6 |
+
ClientContext,
|
| 7 |
+
get_context,
|
| 8 |
+
reset_context,
|
| 9 |
+
set_context,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
from ._helpers import resolve_awaitable
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@asynccontextmanager
|
| 16 |
+
async def start_as_current_context(ctx=None):
|
| 17 |
+
current = ctx or get_context()
|
| 18 |
+
if current is None:
|
| 19 |
+
new = ClientContext()
|
| 20 |
+
else:
|
| 21 |
+
new = deepcopy(current)
|
| 22 |
+
token = set_context(new)
|
| 23 |
+
try:
|
| 24 |
+
yield
|
| 25 |
+
finally:
|
| 26 |
+
reset_context(token)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def with_current_context(hook=None):
|
| 30 |
+
def decorator(func):
|
| 31 |
+
@wraps(func)
|
| 32 |
+
async def wrapper(*args, **kwargs):
|
| 33 |
+
async with start_as_current_context():
|
| 34 |
+
if hook:
|
| 35 |
+
await resolve_awaitable(hook())
|
| 36 |
+
return await func(*args, **kwargs)
|
| 37 |
+
|
| 38 |
+
return wrapper
|
| 39 |
+
|
| 40 |
+
return decorator
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/credentials.py
ADDED
|
@@ -0,0 +1,1168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import subprocess
|
| 5 |
+
from copy import deepcopy
|
| 6 |
+
|
| 7 |
+
import botocore.compat
|
| 8 |
+
import dateutil.parser
|
| 9 |
+
from botocore import UNSIGNED
|
| 10 |
+
from botocore.compat import compat_shell_split, total_seconds
|
| 11 |
+
from botocore.config import Config
|
| 12 |
+
from botocore.credentials import (
|
| 13 |
+
_DEFAULT_ADVISORY_REFRESH_TIMEOUT,
|
| 14 |
+
AssumeRoleCredentialFetcher,
|
| 15 |
+
AssumeRoleProvider,
|
| 16 |
+
AssumeRoleWithWebIdentityProvider,
|
| 17 |
+
BaseAssumeRoleCredentialFetcher,
|
| 18 |
+
BotoProvider,
|
| 19 |
+
CachedCredentialFetcher,
|
| 20 |
+
CanonicalNameCredentialSourcer,
|
| 21 |
+
ConfigNotFound,
|
| 22 |
+
ConfigProvider,
|
| 23 |
+
ContainerMetadataFetcher,
|
| 24 |
+
ContainerProvider,
|
| 25 |
+
CredentialResolver,
|
| 26 |
+
CredentialRetrievalError,
|
| 27 |
+
Credentials,
|
| 28 |
+
DeferredRefreshableCredentials,
|
| 29 |
+
EnvProvider,
|
| 30 |
+
InstanceMetadataProvider,
|
| 31 |
+
InvalidConfigError,
|
| 32 |
+
MetadataRetrievalError,
|
| 33 |
+
OriginalEC2Provider,
|
| 34 |
+
PartialCredentialsError,
|
| 35 |
+
ProcessProvider,
|
| 36 |
+
ProfileProviderBuilder,
|
| 37 |
+
ReadOnlyCredentials,
|
| 38 |
+
RefreshableCredentials,
|
| 39 |
+
RefreshWithMFAUnsupportedError,
|
| 40 |
+
SharedCredentialProvider,
|
| 41 |
+
SSOCredentialFetcher,
|
| 42 |
+
SSOProvider,
|
| 43 |
+
SSOTokenLoader,
|
| 44 |
+
UnauthorizedSSOTokenError,
|
| 45 |
+
UnknownCredentialError,
|
| 46 |
+
_local_now,
|
| 47 |
+
_parse_if_needed,
|
| 48 |
+
_serialize_if_needed,
|
| 49 |
+
parse,
|
| 50 |
+
resolve_imds_endpoint_mode,
|
| 51 |
+
)
|
| 52 |
+
from botocore.useragent import register_feature_id, register_feature_ids
|
| 53 |
+
|
| 54 |
+
from aiobotocore._helpers import resolve_awaitable
|
| 55 |
+
from aiobotocore.config import AioConfig
|
| 56 |
+
from aiobotocore.tokens import AioSSOTokenProvider
|
| 57 |
+
from aiobotocore.utils import (
|
| 58 |
+
AioContainerMetadataFetcher,
|
| 59 |
+
AioInstanceMetadataFetcher,
|
| 60 |
+
create_nested_client,
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
logger = logging.getLogger(__name__)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def create_credential_resolver(session, cache=None, region_name=None):
|
| 67 |
+
"""Create a default credential resolver.
|
| 68 |
+
This creates a pre-configured credential resolver
|
| 69 |
+
that includes the default lookup chain for
|
| 70 |
+
credentials.
|
| 71 |
+
"""
|
| 72 |
+
profile_name = session.get_config_variable('profile') or 'default'
|
| 73 |
+
metadata_timeout = session.get_config_variable('metadata_service_timeout')
|
| 74 |
+
num_attempts = session.get_config_variable('metadata_service_num_attempts')
|
| 75 |
+
disable_env_vars = session.instance_variables().get('profile') is not None
|
| 76 |
+
|
| 77 |
+
imds_config = {
|
| 78 |
+
'ec2_metadata_service_endpoint': session.get_config_variable(
|
| 79 |
+
'ec2_metadata_service_endpoint'
|
| 80 |
+
),
|
| 81 |
+
'ec2_metadata_service_endpoint_mode': resolve_imds_endpoint_mode(
|
| 82 |
+
session
|
| 83 |
+
),
|
| 84 |
+
'ec2_credential_refresh_window': _DEFAULT_ADVISORY_REFRESH_TIMEOUT,
|
| 85 |
+
'ec2_metadata_v1_disabled': session.get_config_variable(
|
| 86 |
+
'ec2_metadata_v1_disabled'
|
| 87 |
+
),
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
if cache is None:
|
| 91 |
+
cache = {}
|
| 92 |
+
|
| 93 |
+
env_provider = AioEnvProvider()
|
| 94 |
+
container_provider = AioContainerProvider()
|
| 95 |
+
instance_metadata_provider = AioInstanceMetadataProvider(
|
| 96 |
+
iam_role_fetcher=AioInstanceMetadataFetcher(
|
| 97 |
+
timeout=metadata_timeout,
|
| 98 |
+
num_attempts=num_attempts,
|
| 99 |
+
user_agent=session.user_agent(),
|
| 100 |
+
config=imds_config,
|
| 101 |
+
)
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
profile_provider_builder = AioProfileProviderBuilder(
|
| 105 |
+
session, cache=cache, region_name=region_name
|
| 106 |
+
)
|
| 107 |
+
assume_role_provider = AioAssumeRoleProvider(
|
| 108 |
+
load_config=lambda: session.full_config,
|
| 109 |
+
client_creator=_get_client_creator(session, region_name),
|
| 110 |
+
cache=cache,
|
| 111 |
+
profile_name=profile_name,
|
| 112 |
+
credential_sourcer=AioCanonicalNameCredentialSourcer(
|
| 113 |
+
[env_provider, container_provider, instance_metadata_provider]
|
| 114 |
+
),
|
| 115 |
+
profile_provider_builder=profile_provider_builder,
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
pre_profile = [
|
| 119 |
+
env_provider,
|
| 120 |
+
assume_role_provider,
|
| 121 |
+
]
|
| 122 |
+
profile_providers = profile_provider_builder.providers(
|
| 123 |
+
profile_name=profile_name,
|
| 124 |
+
disable_env_vars=disable_env_vars,
|
| 125 |
+
)
|
| 126 |
+
post_profile = [
|
| 127 |
+
AioOriginalEC2Provider(),
|
| 128 |
+
AioBotoProvider(),
|
| 129 |
+
container_provider,
|
| 130 |
+
instance_metadata_provider,
|
| 131 |
+
]
|
| 132 |
+
providers = pre_profile + profile_providers + post_profile
|
| 133 |
+
|
| 134 |
+
if disable_env_vars:
|
| 135 |
+
# An explicitly provided profile will negate an EnvProvider.
|
| 136 |
+
# We will defer to providers that understand the "profile"
|
| 137 |
+
# concept to retrieve credentials.
|
| 138 |
+
# The one edge case if is all three values are provided via
|
| 139 |
+
# env vars:
|
| 140 |
+
# export AWS_ACCESS_KEY_ID=foo
|
| 141 |
+
# export AWS_SECRET_ACCESS_KEY=bar
|
| 142 |
+
# export AWS_PROFILE=baz
|
| 143 |
+
# Then, just like our client() calls, the explicit credentials
|
| 144 |
+
# will take precedence.
|
| 145 |
+
#
|
| 146 |
+
# This precedence is enforced by leaving the EnvProvider in the chain.
|
| 147 |
+
# This means that the only way a "profile" would win is if the
|
| 148 |
+
# EnvProvider does not return credentials, which is what we want
|
| 149 |
+
# in this scenario.
|
| 150 |
+
providers.remove(env_provider)
|
| 151 |
+
logger.debug(
|
| 152 |
+
'Skipping environment variable credential check'
|
| 153 |
+
' because profile name was explicitly set.'
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
resolver = AioCredentialResolver(providers=providers)
|
| 157 |
+
return resolver
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
class AioProfileProviderBuilder(ProfileProviderBuilder):
|
| 161 |
+
def _create_process_provider(self, profile_name):
|
| 162 |
+
return AioProcessProvider(
|
| 163 |
+
profile_name=profile_name,
|
| 164 |
+
load_config=lambda: self._session.full_config,
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
def _create_shared_credential_provider(self, profile_name):
|
| 168 |
+
credential_file = self._session.get_config_variable('credentials_file')
|
| 169 |
+
return AioSharedCredentialProvider(
|
| 170 |
+
profile_name=profile_name,
|
| 171 |
+
creds_filename=credential_file,
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
def _create_config_provider(self, profile_name):
|
| 175 |
+
config_file = self._session.get_config_variable('config_file')
|
| 176 |
+
return AioConfigProvider(
|
| 177 |
+
profile_name=profile_name,
|
| 178 |
+
config_filename=config_file,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
def _create_web_identity_provider(self, profile_name, disable_env_vars):
|
| 182 |
+
return AioAssumeRoleWithWebIdentityProvider(
|
| 183 |
+
load_config=lambda: self._session.full_config,
|
| 184 |
+
client_creator=_get_client_creator(
|
| 185 |
+
self._session, self._region_name
|
| 186 |
+
),
|
| 187 |
+
cache=self._cache,
|
| 188 |
+
profile_name=profile_name,
|
| 189 |
+
disable_env_vars=disable_env_vars,
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
def _create_sso_provider(self, profile_name):
|
| 193 |
+
return AioSSOProvider(
|
| 194 |
+
load_config=lambda: self._session.full_config,
|
| 195 |
+
client_creator=self._session.create_client,
|
| 196 |
+
profile_name=profile_name,
|
| 197 |
+
cache=self._cache,
|
| 198 |
+
token_cache=self._sso_token_cache,
|
| 199 |
+
token_provider=AioSSOTokenProvider(
|
| 200 |
+
self._session,
|
| 201 |
+
cache=self._sso_token_cache,
|
| 202 |
+
profile_name=profile_name,
|
| 203 |
+
),
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
async def get_credentials(session):
|
| 208 |
+
resolver = create_credential_resolver(session)
|
| 209 |
+
return await resolver.load_credentials()
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def create_assume_role_refresher(client, params):
|
| 213 |
+
async def refresh():
|
| 214 |
+
async with client as sts:
|
| 215 |
+
response = await sts.assume_role(**params)
|
| 216 |
+
credentials = response['Credentials']
|
| 217 |
+
# We need to normalize the credential names to
|
| 218 |
+
# the values expected by the refresh creds.
|
| 219 |
+
return {
|
| 220 |
+
'access_key': credentials['AccessKeyId'],
|
| 221 |
+
'secret_key': credentials['SecretAccessKey'],
|
| 222 |
+
'token': credentials['SessionToken'],
|
| 223 |
+
'expiry_time': _serialize_if_needed(credentials['Expiration']),
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
return refresh
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
def create_mfa_serial_refresher(actual_refresh):
|
| 230 |
+
class _Refresher:
|
| 231 |
+
def __init__(self, refresh):
|
| 232 |
+
self._refresh = refresh
|
| 233 |
+
self._has_been_called = False
|
| 234 |
+
|
| 235 |
+
async def call(self):
|
| 236 |
+
if self._has_been_called:
|
| 237 |
+
# We can explore an option in the future to support
|
| 238 |
+
# reprompting for MFA, but for now we just error out
|
| 239 |
+
# when the temp creds expire.
|
| 240 |
+
raise RefreshWithMFAUnsupportedError()
|
| 241 |
+
self._has_been_called = True
|
| 242 |
+
return await self._refresh()
|
| 243 |
+
|
| 244 |
+
return _Refresher(actual_refresh).call
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
# TODO: deprecate
|
| 248 |
+
create_aio_mfa_serial_refresher = create_mfa_serial_refresher
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class AioCredentials(Credentials):
|
| 252 |
+
# Overrides for property accessors
|
| 253 |
+
def get_account_id(self):
|
| 254 |
+
return self.account_id
|
| 255 |
+
|
| 256 |
+
def get_access_key(self):
|
| 257 |
+
return self.access_key
|
| 258 |
+
|
| 259 |
+
def get_secret_key(self):
|
| 260 |
+
return self.secret_key
|
| 261 |
+
|
| 262 |
+
def get_token(self):
|
| 263 |
+
return self.token
|
| 264 |
+
|
| 265 |
+
async def get_frozen_credentials(self):
|
| 266 |
+
return ReadOnlyCredentials(
|
| 267 |
+
self.access_key, self.secret_key, self.token, self.account_id
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
class AioRefreshableCredentials(RefreshableCredentials):
|
| 272 |
+
def __init__(self, *args, **kwargs):
|
| 273 |
+
super().__init__(*args, **kwargs)
|
| 274 |
+
self._refresh_lock = asyncio.Lock()
|
| 275 |
+
|
| 276 |
+
async def get_account_id(self):
|
| 277 |
+
await self._refresh()
|
| 278 |
+
return self._account_id
|
| 279 |
+
|
| 280 |
+
async def get_access_key(self):
|
| 281 |
+
await self._refresh()
|
| 282 |
+
return self._access_key
|
| 283 |
+
|
| 284 |
+
async def get_secret_key(self):
|
| 285 |
+
await self._refresh()
|
| 286 |
+
return self._secret_key
|
| 287 |
+
|
| 288 |
+
async def get_token(self):
|
| 289 |
+
await self._refresh()
|
| 290 |
+
return self._token
|
| 291 |
+
|
| 292 |
+
# Redeclaring the properties so it doesn't call refresh
|
| 293 |
+
# Have to redeclare setter as we're overriding the getter
|
| 294 |
+
@property
|
| 295 |
+
def access_key(self):
|
| 296 |
+
# TODO: this needs to be resolved
|
| 297 |
+
raise NotImplementedError(
|
| 298 |
+
"missing call to self._refresh. "
|
| 299 |
+
"Use get_frozen_credentials or get_access_key"
|
| 300 |
+
)
|
| 301 |
+
return self._access_key
|
| 302 |
+
|
| 303 |
+
@access_key.setter
|
| 304 |
+
def access_key(self, value):
|
| 305 |
+
self._access_key = value
|
| 306 |
+
|
| 307 |
+
@property
|
| 308 |
+
def secret_key(self):
|
| 309 |
+
# TODO: this needs to be resolved
|
| 310 |
+
raise NotImplementedError(
|
| 311 |
+
"missing call to self._refresh. "
|
| 312 |
+
"Use get_frozen_credentials or get_secret_key instead"
|
| 313 |
+
)
|
| 314 |
+
return self._secret_key
|
| 315 |
+
|
| 316 |
+
@secret_key.setter
|
| 317 |
+
def secret_key(self, value):
|
| 318 |
+
self._secret_key = value
|
| 319 |
+
|
| 320 |
+
@property
|
| 321 |
+
def token(self):
|
| 322 |
+
# TODO: this needs to be resolved
|
| 323 |
+
raise NotImplementedError(
|
| 324 |
+
"missing call to self._refresh. "
|
| 325 |
+
"Use get_frozen_credentials or get_token instead"
|
| 326 |
+
)
|
| 327 |
+
return self._token
|
| 328 |
+
|
| 329 |
+
@token.setter
|
| 330 |
+
def token(self, value):
|
| 331 |
+
self._token = value
|
| 332 |
+
|
| 333 |
+
@property
|
| 334 |
+
def account_id(self):
|
| 335 |
+
# TODO: this needs to be resolved
|
| 336 |
+
raise NotImplementedError(
|
| 337 |
+
"missing call to self._refresh. "
|
| 338 |
+
"Use get_frozen_credentials or get_account_id instead"
|
| 339 |
+
)
|
| 340 |
+
return self._account_id
|
| 341 |
+
|
| 342 |
+
@account_id.setter
|
| 343 |
+
def account_id(self, value):
|
| 344 |
+
self._account_id = value
|
| 345 |
+
|
| 346 |
+
async def _refresh(self):
|
| 347 |
+
if not self.refresh_needed(self._advisory_refresh_timeout):
|
| 348 |
+
return
|
| 349 |
+
|
| 350 |
+
# By this point we need a refresh but its not critical
|
| 351 |
+
if not self._refresh_lock.locked():
|
| 352 |
+
async with self._refresh_lock:
|
| 353 |
+
if not self.refresh_needed(self._advisory_refresh_timeout):
|
| 354 |
+
return
|
| 355 |
+
is_mandatory_refresh = self.refresh_needed(
|
| 356 |
+
self._mandatory_refresh_timeout
|
| 357 |
+
)
|
| 358 |
+
await self._protected_refresh(
|
| 359 |
+
is_mandatory=is_mandatory_refresh
|
| 360 |
+
)
|
| 361 |
+
return
|
| 362 |
+
elif self.refresh_needed(self._mandatory_refresh_timeout):
|
| 363 |
+
# If we're here, we absolutely need a refresh and the
|
| 364 |
+
# lock is held so wait for it
|
| 365 |
+
async with self._refresh_lock:
|
| 366 |
+
# Might have refreshed by now
|
| 367 |
+
if not self.refresh_needed(self._mandatory_refresh_timeout):
|
| 368 |
+
return
|
| 369 |
+
await self._protected_refresh(is_mandatory=True)
|
| 370 |
+
|
| 371 |
+
async def _protected_refresh(self, is_mandatory):
|
| 372 |
+
try:
|
| 373 |
+
# AioEnvProvider._create_credentials_fetcher is not and does not need async
|
| 374 |
+
metadata = await resolve_awaitable(self._refresh_using())
|
| 375 |
+
except Exception:
|
| 376 |
+
period_name = 'mandatory' if is_mandatory else 'advisory'
|
| 377 |
+
logger.warning(
|
| 378 |
+
"Refreshing temporary credentials failed "
|
| 379 |
+
"during %s refresh period.",
|
| 380 |
+
period_name,
|
| 381 |
+
exc_info=True,
|
| 382 |
+
)
|
| 383 |
+
if is_mandatory:
|
| 384 |
+
# If this is a mandatory refresh, then
|
| 385 |
+
# all errors that occur when we attempt to refresh
|
| 386 |
+
# credentials are propagated back to the user.
|
| 387 |
+
raise
|
| 388 |
+
# Otherwise we'll just return.
|
| 389 |
+
# The end result will be that we'll use the current
|
| 390 |
+
# set of temporary credentials we have.
|
| 391 |
+
return
|
| 392 |
+
self._set_from_data(metadata)
|
| 393 |
+
self._frozen_credentials = ReadOnlyCredentials(
|
| 394 |
+
self._access_key, self._secret_key, self._token, self._account_id
|
| 395 |
+
)
|
| 396 |
+
if self._is_expired():
|
| 397 |
+
msg = (
|
| 398 |
+
"Credentials were refreshed, but the "
|
| 399 |
+
"refreshed credentials are still expired."
|
| 400 |
+
)
|
| 401 |
+
logger.warning(msg)
|
| 402 |
+
raise RuntimeError(msg)
|
| 403 |
+
|
| 404 |
+
async def get_frozen_credentials(self):
|
| 405 |
+
await self._refresh()
|
| 406 |
+
return self._frozen_credentials
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
class AioDeferredRefreshableCredentials(
|
| 410 |
+
DeferredRefreshableCredentials, AioRefreshableCredentials
|
| 411 |
+
):
|
| 412 |
+
def __init__(self, refresh_using, method, time_fetcher=_local_now):
|
| 413 |
+
self._refresh_using = refresh_using
|
| 414 |
+
self._access_key = None
|
| 415 |
+
self._secret_key = None
|
| 416 |
+
self._token = None
|
| 417 |
+
self._account_id = None
|
| 418 |
+
self._expiry_time = None
|
| 419 |
+
self._time_fetcher = time_fetcher
|
| 420 |
+
self._refresh_lock = asyncio.Lock()
|
| 421 |
+
self.method = method
|
| 422 |
+
self._frozen_credentials = None
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
class AioCachedCredentialFetcher(CachedCredentialFetcher):
|
| 426 |
+
async def _get_credentials(self):
|
| 427 |
+
raise NotImplementedError('_get_credentials()')
|
| 428 |
+
|
| 429 |
+
async def fetch_credentials(self):
|
| 430 |
+
return await self._get_cached_credentials()
|
| 431 |
+
|
| 432 |
+
async def _get_cached_credentials(self):
|
| 433 |
+
"""Get up-to-date credentials.
|
| 434 |
+
|
| 435 |
+
This will check the cache for up-to-date credentials, calling assume
|
| 436 |
+
role if none are available.
|
| 437 |
+
"""
|
| 438 |
+
response = self._load_from_cache()
|
| 439 |
+
if response is None:
|
| 440 |
+
response = await self._get_credentials()
|
| 441 |
+
self._write_to_cache(response)
|
| 442 |
+
else:
|
| 443 |
+
logger.debug("Credentials for role retrieved from cache.")
|
| 444 |
+
|
| 445 |
+
creds = response['Credentials']
|
| 446 |
+
expiration = _serialize_if_needed(creds['Expiration'], iso=True)
|
| 447 |
+
credentials = {
|
| 448 |
+
'access_key': creds['AccessKeyId'],
|
| 449 |
+
'secret_key': creds['SecretAccessKey'],
|
| 450 |
+
'token': creds['SessionToken'],
|
| 451 |
+
'expiry_time': expiration,
|
| 452 |
+
'account_id': creds.get('AccountId'),
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
return credentials
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
class AioBaseAssumeRoleCredentialFetcher(
|
| 459 |
+
BaseAssumeRoleCredentialFetcher, AioCachedCredentialFetcher
|
| 460 |
+
):
|
| 461 |
+
pass
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
class AioAssumeRoleCredentialFetcher(
|
| 465 |
+
AssumeRoleCredentialFetcher, AioBaseAssumeRoleCredentialFetcher
|
| 466 |
+
):
|
| 467 |
+
async def _get_credentials(self):
|
| 468 |
+
"""Get credentials by calling assume role."""
|
| 469 |
+
register_feature_ids(self.feature_ids)
|
| 470 |
+
kwargs = self._assume_role_kwargs()
|
| 471 |
+
client = await self._create_client()
|
| 472 |
+
async with client as sts:
|
| 473 |
+
response = await sts.assume_role(**kwargs)
|
| 474 |
+
self._add_account_id_to_response(response)
|
| 475 |
+
return response
|
| 476 |
+
|
| 477 |
+
async def _create_client(self):
|
| 478 |
+
"""Create an STS client using the source credentials."""
|
| 479 |
+
frozen_credentials = (
|
| 480 |
+
await self._source_credentials.get_frozen_credentials()
|
| 481 |
+
)
|
| 482 |
+
return self._client_creator(
|
| 483 |
+
'sts',
|
| 484 |
+
aws_access_key_id=frozen_credentials.access_key,
|
| 485 |
+
aws_secret_access_key=frozen_credentials.secret_key,
|
| 486 |
+
aws_session_token=frozen_credentials.token,
|
| 487 |
+
)
|
| 488 |
+
|
| 489 |
+
|
| 490 |
+
class AioAssumeRoleWithWebIdentityCredentialFetcher(
|
| 491 |
+
AioBaseAssumeRoleCredentialFetcher
|
| 492 |
+
):
|
| 493 |
+
def __init__(
|
| 494 |
+
self,
|
| 495 |
+
client_creator,
|
| 496 |
+
web_identity_token_loader,
|
| 497 |
+
role_arn,
|
| 498 |
+
extra_args=None,
|
| 499 |
+
cache=None,
|
| 500 |
+
expiry_window_seconds=None,
|
| 501 |
+
):
|
| 502 |
+
self._web_identity_token_loader = web_identity_token_loader
|
| 503 |
+
|
| 504 |
+
super().__init__(
|
| 505 |
+
client_creator,
|
| 506 |
+
role_arn,
|
| 507 |
+
extra_args=extra_args,
|
| 508 |
+
cache=cache,
|
| 509 |
+
expiry_window_seconds=expiry_window_seconds,
|
| 510 |
+
)
|
| 511 |
+
|
| 512 |
+
async def _get_credentials(self):
|
| 513 |
+
"""Get credentials by calling assume role."""
|
| 514 |
+
register_feature_ids(self.feature_ids)
|
| 515 |
+
kwargs = self._assume_role_kwargs()
|
| 516 |
+
# Assume role with web identity does not require credentials other than
|
| 517 |
+
# the token, explicitly configure the client to not sign requests.
|
| 518 |
+
config = AioConfig(signature_version=UNSIGNED)
|
| 519 |
+
async with self._client_creator('sts', config=config) as client:
|
| 520 |
+
response = await client.assume_role_with_web_identity(**kwargs)
|
| 521 |
+
self._add_account_id_to_response(response)
|
| 522 |
+
return response
|
| 523 |
+
|
| 524 |
+
def _assume_role_kwargs(self):
|
| 525 |
+
"""Get the arguments for assume role based on current configuration."""
|
| 526 |
+
assume_role_kwargs = deepcopy(self._assume_kwargs)
|
| 527 |
+
identity_token = self._web_identity_token_loader()
|
| 528 |
+
assume_role_kwargs['WebIdentityToken'] = identity_token
|
| 529 |
+
|
| 530 |
+
return assume_role_kwargs
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
class AioProcessProvider(ProcessProvider):
|
| 534 |
+
def __init__(self, *args, popen=asyncio.create_subprocess_exec, **kwargs):
|
| 535 |
+
super().__init__(*args, **kwargs, popen=popen)
|
| 536 |
+
|
| 537 |
+
async def load(self):
|
| 538 |
+
credential_process = self._credential_process
|
| 539 |
+
if credential_process is None:
|
| 540 |
+
return
|
| 541 |
+
|
| 542 |
+
register_feature_id('CREDENTIALS_PROFILE_PROCESS')
|
| 543 |
+
creds_dict = await self._retrieve_credentials_using(credential_process)
|
| 544 |
+
register_feature_id('CREDENTIALS_PROCESS')
|
| 545 |
+
if creds_dict.get('expiry_time') is not None:
|
| 546 |
+
return AioRefreshableCredentials.create_from_metadata(
|
| 547 |
+
creds_dict,
|
| 548 |
+
lambda: self._retrieve_credentials_using(credential_process),
|
| 549 |
+
self.METHOD,
|
| 550 |
+
)
|
| 551 |
+
|
| 552 |
+
return AioCredentials(
|
| 553 |
+
access_key=creds_dict['access_key'],
|
| 554 |
+
secret_key=creds_dict['secret_key'],
|
| 555 |
+
token=creds_dict.get('token'),
|
| 556 |
+
method=self.METHOD,
|
| 557 |
+
account_id=creds_dict.get('account_id'),
|
| 558 |
+
)
|
| 559 |
+
|
| 560 |
+
async def _retrieve_credentials_using(self, credential_process):
|
| 561 |
+
# We're not using shell=True, so we need to pass the
|
| 562 |
+
# command and all arguments as a list.
|
| 563 |
+
process_list = compat_shell_split(credential_process)
|
| 564 |
+
p = await self._popen(
|
| 565 |
+
*process_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
| 566 |
+
)
|
| 567 |
+
stdout, stderr = await p.communicate()
|
| 568 |
+
if p.returncode != 0:
|
| 569 |
+
raise CredentialRetrievalError(
|
| 570 |
+
provider=self.METHOD, error_msg=stderr.decode('utf-8')
|
| 571 |
+
)
|
| 572 |
+
parsed = botocore.compat.json.loads(stdout.decode('utf-8'))
|
| 573 |
+
version = parsed.get('Version', '<Version key not provided>')
|
| 574 |
+
if version != 1:
|
| 575 |
+
raise CredentialRetrievalError(
|
| 576 |
+
provider=self.METHOD,
|
| 577 |
+
error_msg=(
|
| 578 |
+
f"Unsupported version '{version}' for credential process "
|
| 579 |
+
f"provider, supported versions: 1"
|
| 580 |
+
),
|
| 581 |
+
)
|
| 582 |
+
try:
|
| 583 |
+
return {
|
| 584 |
+
'access_key': parsed['AccessKeyId'],
|
| 585 |
+
'secret_key': parsed['SecretAccessKey'],
|
| 586 |
+
'token': parsed.get('SessionToken'),
|
| 587 |
+
'expiry_time': parsed.get('Expiration'),
|
| 588 |
+
'account_id': self._get_account_id(parsed),
|
| 589 |
+
}
|
| 590 |
+
except KeyError as e:
|
| 591 |
+
raise CredentialRetrievalError(
|
| 592 |
+
provider=self.METHOD,
|
| 593 |
+
error_msg=f"Missing required key in response: {e}",
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
class AioInstanceMetadataProvider(InstanceMetadataProvider):
|
| 598 |
+
async def load(self):
|
| 599 |
+
fetcher = self._role_fetcher
|
| 600 |
+
metadata = await fetcher.retrieve_iam_role_credentials()
|
| 601 |
+
if not metadata:
|
| 602 |
+
return None
|
| 603 |
+
register_feature_id('CREDENTIALS_IMDS')
|
| 604 |
+
logger.info(
|
| 605 |
+
'Found credentials from IAM Role: %s', metadata['role_name']
|
| 606 |
+
)
|
| 607 |
+
|
| 608 |
+
creds = AioRefreshableCredentials.create_from_metadata(
|
| 609 |
+
metadata,
|
| 610 |
+
method=self.METHOD,
|
| 611 |
+
refresh_using=fetcher.retrieve_iam_role_credentials,
|
| 612 |
+
)
|
| 613 |
+
return creds
|
| 614 |
+
|
| 615 |
+
|
| 616 |
+
class AioEnvProvider(EnvProvider):
|
| 617 |
+
async def load(self):
|
| 618 |
+
access_key = self.environ.get(self._mapping['access_key'], '')
|
| 619 |
+
|
| 620 |
+
if access_key:
|
| 621 |
+
logger.info('Found credentials in environment variables.')
|
| 622 |
+
fetcher = self._create_credentials_fetcher()
|
| 623 |
+
credentials = fetcher(require_expiry=False)
|
| 624 |
+
register_feature_id('CREDENTIALS_ENV_VARS')
|
| 625 |
+
|
| 626 |
+
expiry_time = credentials['expiry_time']
|
| 627 |
+
if expiry_time is not None:
|
| 628 |
+
expiry_time = parse(expiry_time)
|
| 629 |
+
return AioRefreshableCredentials(
|
| 630 |
+
credentials['access_key'],
|
| 631 |
+
credentials['secret_key'],
|
| 632 |
+
credentials['token'],
|
| 633 |
+
expiry_time,
|
| 634 |
+
refresh_using=fetcher,
|
| 635 |
+
method=self.METHOD,
|
| 636 |
+
account_id=credentials['account_id'],
|
| 637 |
+
)
|
| 638 |
+
|
| 639 |
+
return AioCredentials(
|
| 640 |
+
credentials['access_key'],
|
| 641 |
+
credentials['secret_key'],
|
| 642 |
+
credentials['token'],
|
| 643 |
+
method=self.METHOD,
|
| 644 |
+
account_id=credentials['account_id'],
|
| 645 |
+
)
|
| 646 |
+
else:
|
| 647 |
+
return None
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
class AioOriginalEC2Provider(OriginalEC2Provider):
|
| 651 |
+
async def load(self):
|
| 652 |
+
if 'AWS_CREDENTIAL_FILE' in self._environ:
|
| 653 |
+
full_path = os.path.expanduser(
|
| 654 |
+
self._environ['AWS_CREDENTIAL_FILE']
|
| 655 |
+
)
|
| 656 |
+
creds = self._parser(full_path)
|
| 657 |
+
if self.ACCESS_KEY in creds:
|
| 658 |
+
logger.info('Found credentials in AWS_CREDENTIAL_FILE.')
|
| 659 |
+
access_key = creds[self.ACCESS_KEY]
|
| 660 |
+
secret_key = creds[self.SECRET_KEY]
|
| 661 |
+
# EC2 creds file doesn't support session tokens.
|
| 662 |
+
return AioCredentials(
|
| 663 |
+
access_key, secret_key, method=self.METHOD
|
| 664 |
+
)
|
| 665 |
+
else:
|
| 666 |
+
return None
|
| 667 |
+
|
| 668 |
+
|
| 669 |
+
class AioSharedCredentialProvider(SharedCredentialProvider):
|
| 670 |
+
async def load(self):
|
| 671 |
+
try:
|
| 672 |
+
available_creds = self._ini_parser(self._creds_filename)
|
| 673 |
+
except ConfigNotFound:
|
| 674 |
+
return None
|
| 675 |
+
if self._profile_name in available_creds:
|
| 676 |
+
config = available_creds[self._profile_name]
|
| 677 |
+
if self.ACCESS_KEY in config:
|
| 678 |
+
logger.info(
|
| 679 |
+
"Found credentials in shared credentials file: %s",
|
| 680 |
+
self._creds_filename,
|
| 681 |
+
)
|
| 682 |
+
access_key, secret_key = self._extract_creds_from_mapping(
|
| 683 |
+
config, self.ACCESS_KEY, self.SECRET_KEY
|
| 684 |
+
)
|
| 685 |
+
token = self._get_session_token(config)
|
| 686 |
+
account_id = self._get_account_id(config)
|
| 687 |
+
register_feature_id('CREDENTIALS_PROFILE')
|
| 688 |
+
return AioCredentials(
|
| 689 |
+
access_key,
|
| 690 |
+
secret_key,
|
| 691 |
+
token,
|
| 692 |
+
method=self.METHOD,
|
| 693 |
+
account_id=account_id,
|
| 694 |
+
)
|
| 695 |
+
|
| 696 |
+
|
| 697 |
+
class AioConfigProvider(ConfigProvider):
|
| 698 |
+
async def load(self):
|
| 699 |
+
try:
|
| 700 |
+
full_config = self._config_parser(self._config_filename)
|
| 701 |
+
except ConfigNotFound:
|
| 702 |
+
return None
|
| 703 |
+
if self._profile_name in full_config['profiles']:
|
| 704 |
+
profile_config = full_config['profiles'][self._profile_name]
|
| 705 |
+
if self.ACCESS_KEY in profile_config:
|
| 706 |
+
logger.info(
|
| 707 |
+
"Credentials found in config file: %s",
|
| 708 |
+
self._config_filename,
|
| 709 |
+
)
|
| 710 |
+
access_key, secret_key = self._extract_creds_from_mapping(
|
| 711 |
+
profile_config, self.ACCESS_KEY, self.SECRET_KEY
|
| 712 |
+
)
|
| 713 |
+
token = self._get_session_token(profile_config)
|
| 714 |
+
account_id = self._get_account_id(profile_config)
|
| 715 |
+
register_feature_id('CREDENTIALS_PROFILE')
|
| 716 |
+
return AioCredentials(
|
| 717 |
+
access_key,
|
| 718 |
+
secret_key,
|
| 719 |
+
token,
|
| 720 |
+
method=self.METHOD,
|
| 721 |
+
account_id=account_id,
|
| 722 |
+
)
|
| 723 |
+
else:
|
| 724 |
+
return None
|
| 725 |
+
|
| 726 |
+
|
| 727 |
+
class AioBotoProvider(BotoProvider):
|
| 728 |
+
async def load(self):
|
| 729 |
+
if self.BOTO_CONFIG_ENV in self._environ:
|
| 730 |
+
potential_locations = [self._environ[self.BOTO_CONFIG_ENV]]
|
| 731 |
+
else:
|
| 732 |
+
potential_locations = self.DEFAULT_CONFIG_FILENAMES
|
| 733 |
+
for filename in potential_locations:
|
| 734 |
+
try:
|
| 735 |
+
config = self._ini_parser(filename)
|
| 736 |
+
except ConfigNotFound:
|
| 737 |
+
# Move on to the next potential config file name.
|
| 738 |
+
continue
|
| 739 |
+
if 'Credentials' in config:
|
| 740 |
+
credentials = config['Credentials']
|
| 741 |
+
if self.ACCESS_KEY in credentials:
|
| 742 |
+
logger.info(
|
| 743 |
+
"Found credentials in boto config file: %s", filename
|
| 744 |
+
)
|
| 745 |
+
access_key, secret_key = self._extract_creds_from_mapping(
|
| 746 |
+
credentials, self.ACCESS_KEY, self.SECRET_KEY
|
| 747 |
+
)
|
| 748 |
+
register_feature_id('CREDENTIALS_BOTO2_CONFIG_FILE')
|
| 749 |
+
return AioCredentials(
|
| 750 |
+
access_key, secret_key, method=self.METHOD
|
| 751 |
+
)
|
| 752 |
+
|
| 753 |
+
|
| 754 |
+
class AioAssumeRoleProvider(AssumeRoleProvider):
|
| 755 |
+
async def load(self):
|
| 756 |
+
self._loaded_config = self._load_config()
|
| 757 |
+
profiles = self._loaded_config.get('profiles', {})
|
| 758 |
+
profile = profiles.get(self._profile_name, {})
|
| 759 |
+
if self._has_assume_role_config_vars(profile):
|
| 760 |
+
return await self._load_creds_via_assume_role(self._profile_name)
|
| 761 |
+
|
| 762 |
+
async def _load_creds_via_assume_role(self, profile_name):
|
| 763 |
+
role_config = self._get_role_config(profile_name)
|
| 764 |
+
source_credentials = await self._resolve_source_credentials(
|
| 765 |
+
role_config, profile_name
|
| 766 |
+
)
|
| 767 |
+
|
| 768 |
+
extra_args = {}
|
| 769 |
+
role_session_name = role_config.get('role_session_name')
|
| 770 |
+
if role_session_name is not None:
|
| 771 |
+
extra_args['RoleSessionName'] = role_session_name
|
| 772 |
+
|
| 773 |
+
external_id = role_config.get('external_id')
|
| 774 |
+
if external_id is not None:
|
| 775 |
+
extra_args['ExternalId'] = external_id
|
| 776 |
+
|
| 777 |
+
mfa_serial = role_config.get('mfa_serial')
|
| 778 |
+
if mfa_serial is not None:
|
| 779 |
+
extra_args['SerialNumber'] = mfa_serial
|
| 780 |
+
|
| 781 |
+
duration_seconds = role_config.get('duration_seconds')
|
| 782 |
+
if duration_seconds is not None:
|
| 783 |
+
extra_args['DurationSeconds'] = duration_seconds
|
| 784 |
+
|
| 785 |
+
fetcher = AioAssumeRoleCredentialFetcher(
|
| 786 |
+
client_creator=self._client_creator,
|
| 787 |
+
source_credentials=source_credentials,
|
| 788 |
+
role_arn=role_config['role_arn'],
|
| 789 |
+
extra_args=extra_args,
|
| 790 |
+
mfa_prompter=self._prompter,
|
| 791 |
+
cache=self.cache,
|
| 792 |
+
)
|
| 793 |
+
fetcher.feature_ids = self._feature_ids.copy()
|
| 794 |
+
refresher = fetcher.fetch_credentials
|
| 795 |
+
if mfa_serial is not None:
|
| 796 |
+
refresher = create_mfa_serial_refresher(refresher)
|
| 797 |
+
|
| 798 |
+
self._feature_ids.add('CREDENTIALS_STS_ASSUME_ROLE')
|
| 799 |
+
register_feature_ids(self._feature_ids)
|
| 800 |
+
# The initial credentials are empty and the expiration time is set
|
| 801 |
+
# to now so that we can delay the call to assume role until it is
|
| 802 |
+
# strictly needed.
|
| 803 |
+
return AioDeferredRefreshableCredentials(
|
| 804 |
+
method=self.METHOD,
|
| 805 |
+
refresh_using=refresher,
|
| 806 |
+
time_fetcher=_local_now,
|
| 807 |
+
)
|
| 808 |
+
|
| 809 |
+
async def _resolve_source_credentials(self, role_config, profile_name):
|
| 810 |
+
credential_source = role_config.get('credential_source')
|
| 811 |
+
if credential_source is not None:
|
| 812 |
+
self._feature_ids.add('CREDENTIALS_PROFILE_NAMED_PROVIDER')
|
| 813 |
+
return await self._resolve_credentials_from_source(
|
| 814 |
+
credential_source, profile_name
|
| 815 |
+
)
|
| 816 |
+
|
| 817 |
+
source_profile = role_config['source_profile']
|
| 818 |
+
self._visited_profiles.append(source_profile)
|
| 819 |
+
self._feature_ids.add('CREDENTIALS_PROFILE_SOURCE_PROFILE')
|
| 820 |
+
return await self._resolve_credentials_from_profile(source_profile)
|
| 821 |
+
|
| 822 |
+
async def _resolve_credentials_from_profile(self, profile_name):
|
| 823 |
+
profiles = self._loaded_config.get('profiles', {})
|
| 824 |
+
profile = profiles[profile_name]
|
| 825 |
+
self._feature_ids.add('CREDENTIALS_PROFILE')
|
| 826 |
+
if (
|
| 827 |
+
self._has_static_credentials(profile)
|
| 828 |
+
and not self._profile_provider_builder
|
| 829 |
+
):
|
| 830 |
+
# This is only here for backwards compatibility. If this provider
|
| 831 |
+
# isn't given a profile provider builder we still want to be able
|
| 832 |
+
# to handle the basic static credential case as we would before the
|
| 833 |
+
# profile provider builder parameter was added.
|
| 834 |
+
return self._resolve_static_credentials_from_profile(profile)
|
| 835 |
+
elif self._has_static_credentials(
|
| 836 |
+
profile
|
| 837 |
+
) or not self._has_assume_role_config_vars(profile):
|
| 838 |
+
profile_providers = self._profile_provider_builder.providers(
|
| 839 |
+
profile_name=profile_name,
|
| 840 |
+
disable_env_vars=True,
|
| 841 |
+
)
|
| 842 |
+
profile_chain = AioCredentialResolver(profile_providers)
|
| 843 |
+
credentials = await profile_chain.load_credentials()
|
| 844 |
+
if credentials is None:
|
| 845 |
+
error_message = (
|
| 846 |
+
'The source profile "%s" must have credentials.'
|
| 847 |
+
)
|
| 848 |
+
raise InvalidConfigError(
|
| 849 |
+
error_msg=error_message % profile_name,
|
| 850 |
+
)
|
| 851 |
+
return credentials
|
| 852 |
+
return await self._load_creds_via_assume_role(profile_name)
|
| 853 |
+
|
| 854 |
+
def _resolve_static_credentials_from_profile(self, profile):
|
| 855 |
+
try:
|
| 856 |
+
return AioCredentials(
|
| 857 |
+
access_key=profile['aws_access_key_id'],
|
| 858 |
+
secret_key=profile['aws_secret_access_key'],
|
| 859 |
+
token=profile.get('aws_session_token'),
|
| 860 |
+
)
|
| 861 |
+
except KeyError as e:
|
| 862 |
+
raise PartialCredentialsError(
|
| 863 |
+
provider=self.METHOD, cred_var=str(e)
|
| 864 |
+
)
|
| 865 |
+
|
| 866 |
+
async def _resolve_credentials_from_source(
|
| 867 |
+
self, credential_source, profile_name
|
| 868 |
+
):
|
| 869 |
+
credentials = await self._credential_sourcer.source_credentials(
|
| 870 |
+
credential_source
|
| 871 |
+
)
|
| 872 |
+
if credentials is None:
|
| 873 |
+
raise CredentialRetrievalError(
|
| 874 |
+
provider=credential_source,
|
| 875 |
+
error_msg=(
|
| 876 |
+
'No credentials found in credential_source referenced '
|
| 877 |
+
f'in profile {profile_name}'
|
| 878 |
+
),
|
| 879 |
+
)
|
| 880 |
+
named_provider_feature_id = self.NAMED_PROVIDER_FEATURE_MAP.get(
|
| 881 |
+
credential_source
|
| 882 |
+
)
|
| 883 |
+
if named_provider_feature_id:
|
| 884 |
+
self._feature_ids.add(named_provider_feature_id)
|
| 885 |
+
return credentials
|
| 886 |
+
|
| 887 |
+
|
| 888 |
+
class AioAssumeRoleWithWebIdentityProvider(AssumeRoleWithWebIdentityProvider):
|
| 889 |
+
async def load(self):
|
| 890 |
+
return await self._assume_role_with_web_identity()
|
| 891 |
+
|
| 892 |
+
async def _assume_role_with_web_identity(self):
|
| 893 |
+
token_path = self._get_config('web_identity_token_file')
|
| 894 |
+
if not token_path:
|
| 895 |
+
return None
|
| 896 |
+
token_loader = self._token_loader_cls(token_path)
|
| 897 |
+
|
| 898 |
+
role_arn = self._get_config('role_arn')
|
| 899 |
+
if not role_arn:
|
| 900 |
+
error_msg = (
|
| 901 |
+
'The provided profile or the current environment is '
|
| 902 |
+
'configured to assume role with web identity but has no '
|
| 903 |
+
'role ARN configured. Ensure that the profile has the role_arn'
|
| 904 |
+
'configuration set or the AWS_ROLE_ARN env var is set.'
|
| 905 |
+
)
|
| 906 |
+
raise InvalidConfigError(error_msg=error_msg)
|
| 907 |
+
|
| 908 |
+
extra_args = {}
|
| 909 |
+
role_session_name = self._get_config('role_session_name')
|
| 910 |
+
if role_session_name is not None:
|
| 911 |
+
extra_args['RoleSessionName'] = role_session_name
|
| 912 |
+
|
| 913 |
+
fetcher = AioAssumeRoleWithWebIdentityCredentialFetcher(
|
| 914 |
+
client_creator=self._client_creator,
|
| 915 |
+
web_identity_token_loader=token_loader,
|
| 916 |
+
role_arn=role_arn,
|
| 917 |
+
extra_args=extra_args,
|
| 918 |
+
cache=self.cache,
|
| 919 |
+
)
|
| 920 |
+
fetcher.feature_ids = self._feature_ids.copy()
|
| 921 |
+
|
| 922 |
+
self._feature_ids.add('CREDENTIALS_STS_ASSUME_ROLE_WEB_ID')
|
| 923 |
+
register_feature_ids(self._feature_ids)
|
| 924 |
+
# The initial credentials are empty and the expiration time is set
|
| 925 |
+
# to now so that we can delay the call to assume role until it is
|
| 926 |
+
# strictly needed.
|
| 927 |
+
return AioDeferredRefreshableCredentials(
|
| 928 |
+
method=self.METHOD,
|
| 929 |
+
refresh_using=fetcher.fetch_credentials,
|
| 930 |
+
)
|
| 931 |
+
|
| 932 |
+
|
| 933 |
+
class AioCanonicalNameCredentialSourcer(CanonicalNameCredentialSourcer):
|
| 934 |
+
async def source_credentials(self, source_name):
|
| 935 |
+
"""Loads source credentials based on the provided configuration.
|
| 936 |
+
|
| 937 |
+
:type source_name: str
|
| 938 |
+
:param source_name: The value of credential_source in the config
|
| 939 |
+
file. This is the canonical name of the credential provider.
|
| 940 |
+
|
| 941 |
+
:rtype: Credentials
|
| 942 |
+
"""
|
| 943 |
+
source = self._get_provider(source_name)
|
| 944 |
+
if isinstance(source, AioCredentialResolver):
|
| 945 |
+
return await source.load_credentials()
|
| 946 |
+
return await source.load()
|
| 947 |
+
|
| 948 |
+
def _get_provider(self, canonical_name):
|
| 949 |
+
"""Return a credential provider by its canonical name.
|
| 950 |
+
|
| 951 |
+
:type canonical_name: str
|
| 952 |
+
:param canonical_name: The canonical name of the provider.
|
| 953 |
+
|
| 954 |
+
:raises UnknownCredentialError: Raised if no
|
| 955 |
+
credential provider by the provided name
|
| 956 |
+
is found.
|
| 957 |
+
"""
|
| 958 |
+
provider = self._get_provider_by_canonical_name(canonical_name)
|
| 959 |
+
|
| 960 |
+
# The AssumeRole provider should really be part of the SharedConfig
|
| 961 |
+
# provider rather than being its own thing, but it is not. It is
|
| 962 |
+
# effectively part of both the SharedConfig provider and the
|
| 963 |
+
# SharedCredentials provider now due to the way it behaves.
|
| 964 |
+
# Therefore if we want either of those providers we should return
|
| 965 |
+
# the AssumeRole provider with it.
|
| 966 |
+
if canonical_name.lower() in ['sharedconfig', 'sharedcredentials']:
|
| 967 |
+
assume_role_provider = self._get_provider_by_method('assume-role')
|
| 968 |
+
if assume_role_provider is not None:
|
| 969 |
+
# The SharedConfig or SharedCredentials provider may not be
|
| 970 |
+
# present if it was removed for some reason, but the
|
| 971 |
+
# AssumeRole provider could still be present. In that case,
|
| 972 |
+
# return the assume role provider by itself.
|
| 973 |
+
if provider is None:
|
| 974 |
+
return assume_role_provider
|
| 975 |
+
|
| 976 |
+
# If both are present, return them both as a
|
| 977 |
+
# CredentialResolver so that calling code can treat them as
|
| 978 |
+
# a single entity.
|
| 979 |
+
return AioCredentialResolver([assume_role_provider, provider])
|
| 980 |
+
|
| 981 |
+
if provider is None:
|
| 982 |
+
raise UnknownCredentialError(name=canonical_name)
|
| 983 |
+
|
| 984 |
+
return provider
|
| 985 |
+
|
| 986 |
+
|
| 987 |
+
class AioContainerProvider(ContainerProvider):
|
| 988 |
+
def __init__(self, *args, **kwargs):
|
| 989 |
+
super().__init__(*args, **kwargs)
|
| 990 |
+
|
| 991 |
+
# This will always run if no fetcher arg is provided
|
| 992 |
+
if isinstance(self._fetcher, ContainerMetadataFetcher):
|
| 993 |
+
self._fetcher = AioContainerMetadataFetcher()
|
| 994 |
+
|
| 995 |
+
async def load(self):
|
| 996 |
+
if self.ENV_VAR in self._environ or self.ENV_VAR_FULL in self._environ:
|
| 997 |
+
return await self._retrieve_or_fail()
|
| 998 |
+
|
| 999 |
+
async def _retrieve_or_fail(self):
|
| 1000 |
+
if self._provided_relative_uri():
|
| 1001 |
+
full_uri = self._fetcher.full_url(self._environ[self.ENV_VAR])
|
| 1002 |
+
else:
|
| 1003 |
+
full_uri = self._environ[self.ENV_VAR_FULL]
|
| 1004 |
+
fetcher = self._create_fetcher(full_uri)
|
| 1005 |
+
creds = await fetcher()
|
| 1006 |
+
return AioRefreshableCredentials(
|
| 1007 |
+
access_key=creds['access_key'],
|
| 1008 |
+
secret_key=creds['secret_key'],
|
| 1009 |
+
token=creds['token'],
|
| 1010 |
+
method=self.METHOD,
|
| 1011 |
+
expiry_time=_parse_if_needed(creds['expiry_time']),
|
| 1012 |
+
refresh_using=fetcher,
|
| 1013 |
+
account_id=creds.get('account_id'),
|
| 1014 |
+
)
|
| 1015 |
+
|
| 1016 |
+
def _create_fetcher(self, full_uri, *args, **kwargs):
|
| 1017 |
+
async def fetch_creds():
|
| 1018 |
+
try:
|
| 1019 |
+
headers = self._build_headers()
|
| 1020 |
+
response = await self._fetcher.retrieve_full_uri(
|
| 1021 |
+
full_uri, headers=headers
|
| 1022 |
+
)
|
| 1023 |
+
register_feature_id('CREDENTIALS_HTTP')
|
| 1024 |
+
except MetadataRetrievalError as e:
|
| 1025 |
+
logger.debug(
|
| 1026 |
+
"Error retrieving container metadata: %s", e, exc_info=True
|
| 1027 |
+
)
|
| 1028 |
+
raise CredentialRetrievalError(
|
| 1029 |
+
provider=self.METHOD, error_msg=str(e)
|
| 1030 |
+
)
|
| 1031 |
+
return {
|
| 1032 |
+
'access_key': response['AccessKeyId'],
|
| 1033 |
+
'secret_key': response['SecretAccessKey'],
|
| 1034 |
+
'token': response['Token'],
|
| 1035 |
+
'expiry_time': response['Expiration'],
|
| 1036 |
+
'account_id': response.get('AccountId'),
|
| 1037 |
+
}
|
| 1038 |
+
|
| 1039 |
+
return fetch_creds
|
| 1040 |
+
|
| 1041 |
+
|
| 1042 |
+
class AioCredentialResolver(CredentialResolver):
|
| 1043 |
+
async def load_credentials(self):
|
| 1044 |
+
"""
|
| 1045 |
+
Goes through the credentials chain, returning the first ``Credentials``
|
| 1046 |
+
that could be loaded.
|
| 1047 |
+
"""
|
| 1048 |
+
# First provider to return a non-None response wins.
|
| 1049 |
+
for provider in self.providers:
|
| 1050 |
+
logger.debug("Looking for credentials via: %s", provider.METHOD)
|
| 1051 |
+
creds = await provider.load()
|
| 1052 |
+
if creds is not None:
|
| 1053 |
+
return creds
|
| 1054 |
+
|
| 1055 |
+
# If we got here, no credentials could be found.
|
| 1056 |
+
# This feels like it should be an exception, but historically, ``None``
|
| 1057 |
+
# is returned.
|
| 1058 |
+
#
|
| 1059 |
+
# +1
|
| 1060 |
+
# -js
|
| 1061 |
+
return None
|
| 1062 |
+
|
| 1063 |
+
|
| 1064 |
+
class AioSSOCredentialFetcher(
|
| 1065 |
+
SSOCredentialFetcher, AioCachedCredentialFetcher
|
| 1066 |
+
):
|
| 1067 |
+
async def _get_credentials(self):
|
| 1068 |
+
"""Get credentials by calling SSO get role credentials."""
|
| 1069 |
+
config = Config(
|
| 1070 |
+
signature_version=UNSIGNED,
|
| 1071 |
+
region_name=self._sso_region,
|
| 1072 |
+
)
|
| 1073 |
+
async with self._client_creator('sso', config=config) as client:
|
| 1074 |
+
if self._token_provider:
|
| 1075 |
+
initial_token_data = self._token_provider.load_token()
|
| 1076 |
+
token = (await initial_token_data.get_frozen_token()).token
|
| 1077 |
+
else:
|
| 1078 |
+
token_dict = self._token_loader(self._start_url)
|
| 1079 |
+
token = token_dict['accessToken']
|
| 1080 |
+
|
| 1081 |
+
# raise an UnauthorizedSSOTokenError if the loaded legacy token
|
| 1082 |
+
# is expired to save a call to GetRoleCredentials with an
|
| 1083 |
+
# expired token.
|
| 1084 |
+
expiration = dateutil.parser.parse(token_dict['expiresAt'])
|
| 1085 |
+
remaining = total_seconds(expiration - self._time_fetcher())
|
| 1086 |
+
if remaining <= 0:
|
| 1087 |
+
raise UnauthorizedSSOTokenError()
|
| 1088 |
+
|
| 1089 |
+
kwargs = {
|
| 1090 |
+
'roleName': self._role_name,
|
| 1091 |
+
'accountId': self._account_id,
|
| 1092 |
+
'accessToken': token,
|
| 1093 |
+
}
|
| 1094 |
+
try:
|
| 1095 |
+
register_feature_ids(self.feature_ids)
|
| 1096 |
+
response = await client.get_role_credentials(**kwargs)
|
| 1097 |
+
except client.exceptions.UnauthorizedException:
|
| 1098 |
+
raise UnauthorizedSSOTokenError()
|
| 1099 |
+
credentials = response['roleCredentials']
|
| 1100 |
+
|
| 1101 |
+
credentials = {
|
| 1102 |
+
'ProviderType': 'sso',
|
| 1103 |
+
'Credentials': {
|
| 1104 |
+
'AccessKeyId': credentials['accessKeyId'],
|
| 1105 |
+
'SecretAccessKey': credentials['secretAccessKey'],
|
| 1106 |
+
'SessionToken': credentials['sessionToken'],
|
| 1107 |
+
'Expiration': self._parse_timestamp(
|
| 1108 |
+
credentials['expiration']
|
| 1109 |
+
),
|
| 1110 |
+
'AccountId': self._account_id,
|
| 1111 |
+
},
|
| 1112 |
+
}
|
| 1113 |
+
return credentials
|
| 1114 |
+
|
| 1115 |
+
|
| 1116 |
+
class AioSSOProvider(SSOProvider):
|
| 1117 |
+
async def load(self):
|
| 1118 |
+
sso_config = self._load_sso_config()
|
| 1119 |
+
if not sso_config:
|
| 1120 |
+
return None
|
| 1121 |
+
|
| 1122 |
+
fetcher_kwargs = {
|
| 1123 |
+
'start_url': sso_config['sso_start_url'],
|
| 1124 |
+
'sso_region': sso_config['sso_region'],
|
| 1125 |
+
'role_name': sso_config['sso_role_name'],
|
| 1126 |
+
'account_id': sso_config['sso_account_id'],
|
| 1127 |
+
'client_creator': self._client_creator,
|
| 1128 |
+
'token_loader': SSOTokenLoader(cache=self._token_cache),
|
| 1129 |
+
'cache': self.cache,
|
| 1130 |
+
}
|
| 1131 |
+
sso_session_in_config = 'sso_session' in sso_config
|
| 1132 |
+
if sso_session_in_config:
|
| 1133 |
+
fetcher_kwargs['sso_session_name'] = sso_config['sso_session']
|
| 1134 |
+
fetcher_kwargs['token_provider'] = self._token_provider
|
| 1135 |
+
self._feature_ids.add('CREDENTIALS_PROFILE_SSO')
|
| 1136 |
+
else:
|
| 1137 |
+
self._feature_ids.add('CREDENTIALS_PROFILE_SSO_LEGACY')
|
| 1138 |
+
|
| 1139 |
+
sso_fetcher = AioSSOCredentialFetcher(**fetcher_kwargs)
|
| 1140 |
+
sso_fetcher.feature_ids = self._feature_ids.copy()
|
| 1141 |
+
|
| 1142 |
+
if sso_session_in_config:
|
| 1143 |
+
self._feature_ids.add('CREDENTIALS_SSO')
|
| 1144 |
+
else:
|
| 1145 |
+
self._feature_ids.add('CREDENTIALS_SSO_LEGACY')
|
| 1146 |
+
|
| 1147 |
+
register_feature_ids(self._feature_ids)
|
| 1148 |
+
return AioDeferredRefreshableCredentials(
|
| 1149 |
+
method=self.METHOD,
|
| 1150 |
+
refresh_using=sso_fetcher.fetch_credentials,
|
| 1151 |
+
)
|
| 1152 |
+
|
| 1153 |
+
|
| 1154 |
+
def _get_client_creator(session, region_name):
|
| 1155 |
+
"""Create a client creator function for use in credential providers.
|
| 1156 |
+
|
| 1157 |
+
This is the async version of botocore.credentials._get_client_creator that
|
| 1158 |
+
uses aiobotocore's create_nested_client.
|
| 1159 |
+
"""
|
| 1160 |
+
|
| 1161 |
+
def client_creator(service_name, **kwargs):
|
| 1162 |
+
create_client_kwargs = {'region_name': region_name}
|
| 1163 |
+
create_client_kwargs.update(**kwargs)
|
| 1164 |
+
return create_nested_client(
|
| 1165 |
+
session, service_name, **create_client_kwargs
|
| 1166 |
+
)
|
| 1167 |
+
|
| 1168 |
+
return client_creator
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/discovery.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
|
| 3 |
+
from botocore.discovery import (
|
| 4 |
+
EndpointDiscoveryHandler,
|
| 5 |
+
EndpointDiscoveryManager,
|
| 6 |
+
EndpointDiscoveryRefreshFailed,
|
| 7 |
+
HTTPClientError,
|
| 8 |
+
logger,
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class AioEndpointDiscoveryManager(EndpointDiscoveryManager):
|
| 13 |
+
async def _refresh_current_endpoints(self, **kwargs):
|
| 14 |
+
cache_key = self._create_cache_key(**kwargs)
|
| 15 |
+
try:
|
| 16 |
+
response = self._describe_endpoints(**kwargs)
|
| 17 |
+
|
| 18 |
+
if inspect.isawaitable(response):
|
| 19 |
+
response = await response
|
| 20 |
+
|
| 21 |
+
endpoints = self._parse_endpoints(response)
|
| 22 |
+
self._cache[cache_key] = endpoints
|
| 23 |
+
self._failed_attempts.pop(cache_key, None)
|
| 24 |
+
return endpoints
|
| 25 |
+
except (ConnectionError, HTTPClientError):
|
| 26 |
+
self._failed_attempts[cache_key] = self._time() + 60
|
| 27 |
+
return None
|
| 28 |
+
|
| 29 |
+
async def describe_endpoint(self, **kwargs):
|
| 30 |
+
operation = kwargs['Operation']
|
| 31 |
+
discovery_required = self._model.discovery_required_for(operation)
|
| 32 |
+
|
| 33 |
+
if not self._always_discover and not discovery_required:
|
| 34 |
+
# Discovery set to only run on required operations
|
| 35 |
+
logger.debug(
|
| 36 |
+
'Optional discovery disabled. Skipping discovery for Operation: %s',
|
| 37 |
+
operation,
|
| 38 |
+
)
|
| 39 |
+
return None
|
| 40 |
+
|
| 41 |
+
# Get the endpoint for the provided operation and identifiers
|
| 42 |
+
cache_key = self._create_cache_key(**kwargs)
|
| 43 |
+
endpoints = self._get_current_endpoints(cache_key)
|
| 44 |
+
if endpoints:
|
| 45 |
+
return self._select_endpoint(endpoints)
|
| 46 |
+
# All known endpoints are stale
|
| 47 |
+
recently_failed = self._recently_failed(cache_key)
|
| 48 |
+
if not recently_failed:
|
| 49 |
+
# We haven't failed to discover recently, go ahead and refresh
|
| 50 |
+
endpoints = await self._refresh_current_endpoints(**kwargs)
|
| 51 |
+
if endpoints:
|
| 52 |
+
return self._select_endpoint(endpoints)
|
| 53 |
+
# Discovery has failed recently, do our best to get an endpoint
|
| 54 |
+
logger.debug('Endpoint Discovery has failed for: %s', kwargs)
|
| 55 |
+
stale_entries = self._cache.get(cache_key, None)
|
| 56 |
+
if stale_entries:
|
| 57 |
+
# We have stale entries, use those while discovery is failing
|
| 58 |
+
return self._select_endpoint(stale_entries)
|
| 59 |
+
if discovery_required:
|
| 60 |
+
# It looks strange to be checking recently_failed again but,
|
| 61 |
+
# this informs us as to whether or not we tried to refresh earlier
|
| 62 |
+
if recently_failed:
|
| 63 |
+
# Discovery is required and we haven't already refreshed
|
| 64 |
+
endpoints = await self._refresh_current_endpoints(**kwargs)
|
| 65 |
+
if endpoints:
|
| 66 |
+
return self._select_endpoint(endpoints)
|
| 67 |
+
# No endpoints even refresh, raise hard error
|
| 68 |
+
raise EndpointDiscoveryRefreshFailed()
|
| 69 |
+
# Discovery is optional, just use the default endpoint for now
|
| 70 |
+
return None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
class AioEndpointDiscoveryHandler(EndpointDiscoveryHandler):
|
| 74 |
+
async def discover_endpoint(self, request, operation_name, **kwargs):
|
| 75 |
+
ids = request.context.get('discovery', {}).get('identifiers')
|
| 76 |
+
if ids is None:
|
| 77 |
+
return
|
| 78 |
+
endpoint = await self._manager.describe_endpoint(
|
| 79 |
+
Operation=operation_name, Identifiers=ids
|
| 80 |
+
)
|
| 81 |
+
if endpoint is None:
|
| 82 |
+
logger.debug('Failed to discover and inject endpoint')
|
| 83 |
+
return
|
| 84 |
+
if not endpoint.startswith('http'):
|
| 85 |
+
endpoint = 'https://' + endpoint
|
| 86 |
+
logger.debug('Injecting discovered endpoint: %s', endpoint)
|
| 87 |
+
request.url = endpoint
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/endpoint.py
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
|
| 3 |
+
from botocore.endpoint import (
|
| 4 |
+
DEFAULT_TIMEOUT,
|
| 5 |
+
MAX_POOL_CONNECTIONS,
|
| 6 |
+
Endpoint,
|
| 7 |
+
EndpointCreator,
|
| 8 |
+
HTTPClientError,
|
| 9 |
+
create_request_object,
|
| 10 |
+
history_recorder,
|
| 11 |
+
is_valid_endpoint_url,
|
| 12 |
+
is_valid_ipv6_endpoint_url,
|
| 13 |
+
logger,
|
| 14 |
+
)
|
| 15 |
+
from botocore.hooks import first_non_none_response
|
| 16 |
+
|
| 17 |
+
from aiobotocore.httpchecksum import handle_checksum_body
|
| 18 |
+
from aiobotocore.httpsession import AIOHTTPSession
|
| 19 |
+
from aiobotocore.parsers import AioResponseParserFactory
|
| 20 |
+
from aiobotocore.response import HttpxStreamingBody, StreamingBody
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
import httpx
|
| 24 |
+
except ImportError:
|
| 25 |
+
httpx = None
|
| 26 |
+
|
| 27 |
+
DEFAULT_HTTP_SESSION_CLS = AIOHTTPSession
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
async def convert_to_response_dict(http_response, operation_model):
|
| 31 |
+
"""Convert an HTTP response object to a request dict.
|
| 32 |
+
|
| 33 |
+
This converts the HTTP response object to a dictionary.
|
| 34 |
+
|
| 35 |
+
:type http_response: botocore.awsrequest.AWSResponse
|
| 36 |
+
:param http_response: The HTTP response from an AWS service request.
|
| 37 |
+
|
| 38 |
+
:rtype: dict
|
| 39 |
+
:return: A response dictionary which will contain the following keys:
|
| 40 |
+
* headers (dict)
|
| 41 |
+
* status_code (int)
|
| 42 |
+
* body (string or file-like object)
|
| 43 |
+
|
| 44 |
+
"""
|
| 45 |
+
response_dict = {
|
| 46 |
+
'headers': http_response.headers,
|
| 47 |
+
'status_code': http_response.status_code,
|
| 48 |
+
'context': {
|
| 49 |
+
'operation_name': operation_model.name,
|
| 50 |
+
},
|
| 51 |
+
}
|
| 52 |
+
if response_dict['status_code'] >= 300:
|
| 53 |
+
response_dict['body'] = await http_response.content
|
| 54 |
+
elif operation_model.has_event_stream_output:
|
| 55 |
+
response_dict['body'] = http_response.raw
|
| 56 |
+
elif operation_model.has_streaming_output:
|
| 57 |
+
if httpx and isinstance(http_response.raw, httpx.Response):
|
| 58 |
+
response_dict['body'] = HttpxStreamingBody(http_response.raw)
|
| 59 |
+
else:
|
| 60 |
+
length = response_dict['headers'].get('content-length')
|
| 61 |
+
response_dict['body'] = StreamingBody(http_response.raw, length)
|
| 62 |
+
else:
|
| 63 |
+
response_dict['body'] = await http_response.content
|
| 64 |
+
return response_dict
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class AioEndpoint(Endpoint):
|
| 68 |
+
def __init__(
|
| 69 |
+
self,
|
| 70 |
+
host,
|
| 71 |
+
endpoint_prefix,
|
| 72 |
+
event_emitter,
|
| 73 |
+
response_parser_factory=None,
|
| 74 |
+
http_session=None,
|
| 75 |
+
):
|
| 76 |
+
if response_parser_factory is None:
|
| 77 |
+
response_parser_factory = AioResponseParserFactory()
|
| 78 |
+
|
| 79 |
+
if http_session is None:
|
| 80 |
+
raise ValueError('http_session must be provided')
|
| 81 |
+
|
| 82 |
+
super().__init__(
|
| 83 |
+
host=host,
|
| 84 |
+
endpoint_prefix=endpoint_prefix,
|
| 85 |
+
event_emitter=event_emitter,
|
| 86 |
+
response_parser_factory=response_parser_factory,
|
| 87 |
+
http_session=http_session,
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
async def close(self):
|
| 91 |
+
await self.http_session.close()
|
| 92 |
+
|
| 93 |
+
async def create_request(self, params, operation_model=None):
|
| 94 |
+
request = create_request_object(params)
|
| 95 |
+
if operation_model:
|
| 96 |
+
request.stream_output = any(
|
| 97 |
+
[
|
| 98 |
+
operation_model.has_streaming_output,
|
| 99 |
+
operation_model.has_event_stream_output,
|
| 100 |
+
]
|
| 101 |
+
)
|
| 102 |
+
service_id = operation_model.service_model.service_id.hyphenize()
|
| 103 |
+
event_name = f'request-created.{service_id}.{operation_model.name}'
|
| 104 |
+
await self._event_emitter.emit(
|
| 105 |
+
event_name,
|
| 106 |
+
request=request,
|
| 107 |
+
operation_name=operation_model.name,
|
| 108 |
+
)
|
| 109 |
+
prepared_request = self.prepare_request(request)
|
| 110 |
+
return prepared_request
|
| 111 |
+
|
| 112 |
+
async def _send_request(self, request_dict, operation_model):
|
| 113 |
+
attempts = 1
|
| 114 |
+
context = request_dict['context']
|
| 115 |
+
self._update_retries_context(context, attempts)
|
| 116 |
+
request = await self.create_request(request_dict, operation_model)
|
| 117 |
+
success_response, exception = await self._get_response(
|
| 118 |
+
request, operation_model, context
|
| 119 |
+
)
|
| 120 |
+
while await self._needs_retry(
|
| 121 |
+
attempts,
|
| 122 |
+
operation_model,
|
| 123 |
+
request_dict,
|
| 124 |
+
success_response,
|
| 125 |
+
exception,
|
| 126 |
+
):
|
| 127 |
+
attempts += 1
|
| 128 |
+
self._update_retries_context(context, attempts, success_response)
|
| 129 |
+
# If there is a stream associated with the request, we need
|
| 130 |
+
# to reset it before attempting to send the request again.
|
| 131 |
+
# This will ensure that we resend the entire contents of the
|
| 132 |
+
# body.
|
| 133 |
+
request.reset_stream()
|
| 134 |
+
# Create a new request when retried (including a new signature).
|
| 135 |
+
request = await self.create_request(request_dict, operation_model)
|
| 136 |
+
success_response, exception = await self._get_response(
|
| 137 |
+
request, operation_model, context
|
| 138 |
+
)
|
| 139 |
+
if (
|
| 140 |
+
success_response is not None
|
| 141 |
+
and 'ResponseMetadata' in success_response[1]
|
| 142 |
+
):
|
| 143 |
+
# We want to share num retries, not num attempts.
|
| 144 |
+
total_retries = attempts - 1
|
| 145 |
+
success_response[1]['ResponseMetadata']['RetryAttempts'] = (
|
| 146 |
+
total_retries
|
| 147 |
+
)
|
| 148 |
+
if exception is not None:
|
| 149 |
+
raise exception
|
| 150 |
+
else:
|
| 151 |
+
return success_response
|
| 152 |
+
|
| 153 |
+
async def _get_response(self, request, operation_model, context):
|
| 154 |
+
# This will return a tuple of (success_response, exception)
|
| 155 |
+
# and success_response is itself a tuple of
|
| 156 |
+
# (http_response, parsed_dict).
|
| 157 |
+
# If an exception occurs then the success_response is None.
|
| 158 |
+
# If no exception occurs then exception is None.
|
| 159 |
+
success_response, exception = await self._do_get_response(
|
| 160 |
+
request, operation_model, context
|
| 161 |
+
)
|
| 162 |
+
kwargs_to_emit = {
|
| 163 |
+
'response_dict': None,
|
| 164 |
+
'parsed_response': None,
|
| 165 |
+
'context': context,
|
| 166 |
+
'exception': exception,
|
| 167 |
+
}
|
| 168 |
+
if success_response is not None:
|
| 169 |
+
http_response, parsed_response = success_response
|
| 170 |
+
kwargs_to_emit['parsed_response'] = parsed_response
|
| 171 |
+
kwargs_to_emit['response_dict'] = await convert_to_response_dict(
|
| 172 |
+
http_response, operation_model
|
| 173 |
+
)
|
| 174 |
+
service_id = operation_model.service_model.service_id.hyphenize()
|
| 175 |
+
await self._event_emitter.emit(
|
| 176 |
+
f"response-received.{service_id}.{operation_model.name}",
|
| 177 |
+
**kwargs_to_emit,
|
| 178 |
+
)
|
| 179 |
+
return success_response, exception
|
| 180 |
+
|
| 181 |
+
async def _do_get_response(self, request, operation_model, context):
|
| 182 |
+
try:
|
| 183 |
+
logger.debug("Sending http request: %s", request)
|
| 184 |
+
history_recorder.record(
|
| 185 |
+
'HTTP_REQUEST',
|
| 186 |
+
{
|
| 187 |
+
'method': request.method,
|
| 188 |
+
'headers': request.headers,
|
| 189 |
+
'streaming': operation_model.has_streaming_input,
|
| 190 |
+
'url': request.url,
|
| 191 |
+
'body': request.body,
|
| 192 |
+
},
|
| 193 |
+
)
|
| 194 |
+
service_id = operation_model.service_model.service_id.hyphenize()
|
| 195 |
+
event_name = f"before-send.{service_id}.{operation_model.name}"
|
| 196 |
+
responses = await self._event_emitter.emit(
|
| 197 |
+
event_name, request=request
|
| 198 |
+
)
|
| 199 |
+
http_response = first_non_none_response(responses)
|
| 200 |
+
if http_response is None:
|
| 201 |
+
http_response = await self._send(request)
|
| 202 |
+
except HTTPClientError as e:
|
| 203 |
+
return (None, e)
|
| 204 |
+
except Exception as e:
|
| 205 |
+
logger.debug(
|
| 206 |
+
"Exception received when sending HTTP request.", exc_info=True
|
| 207 |
+
)
|
| 208 |
+
return (None, e)
|
| 209 |
+
|
| 210 |
+
# This returns the http_response and the parsed_data.
|
| 211 |
+
response_dict = await convert_to_response_dict(
|
| 212 |
+
http_response, operation_model
|
| 213 |
+
)
|
| 214 |
+
await handle_checksum_body(
|
| 215 |
+
http_response,
|
| 216 |
+
response_dict,
|
| 217 |
+
context,
|
| 218 |
+
operation_model,
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
http_response_record_dict = response_dict.copy()
|
| 222 |
+
http_response_record_dict['streaming'] = (
|
| 223 |
+
operation_model.has_streaming_output
|
| 224 |
+
)
|
| 225 |
+
history_recorder.record('HTTP_RESPONSE', http_response_record_dict)
|
| 226 |
+
|
| 227 |
+
protocol = operation_model.service_model.resolved_protocol
|
| 228 |
+
customized_response_dict = {}
|
| 229 |
+
await self._event_emitter.emit(
|
| 230 |
+
f"before-parse.{service_id}.{operation_model.name}",
|
| 231 |
+
operation_model=operation_model,
|
| 232 |
+
response_dict=response_dict,
|
| 233 |
+
customized_response_dict=customized_response_dict,
|
| 234 |
+
)
|
| 235 |
+
parser = self._response_parser_factory.create_parser(protocol)
|
| 236 |
+
parsed_response = await parser.parse(
|
| 237 |
+
response_dict, operation_model.output_shape
|
| 238 |
+
)
|
| 239 |
+
parsed_response.update(customized_response_dict)
|
| 240 |
+
|
| 241 |
+
if http_response.status_code >= 300:
|
| 242 |
+
await self._add_modeled_error_fields(
|
| 243 |
+
response_dict,
|
| 244 |
+
parsed_response,
|
| 245 |
+
operation_model,
|
| 246 |
+
parser,
|
| 247 |
+
)
|
| 248 |
+
history_recorder.record('PARSED_RESPONSE', parsed_response)
|
| 249 |
+
return (http_response, parsed_response), None
|
| 250 |
+
|
| 251 |
+
async def _add_modeled_error_fields(
|
| 252 |
+
self,
|
| 253 |
+
response_dict,
|
| 254 |
+
parsed_response,
|
| 255 |
+
operation_model,
|
| 256 |
+
parser,
|
| 257 |
+
):
|
| 258 |
+
error_code = parsed_response.get("Error", {}).get("Code")
|
| 259 |
+
if error_code is None:
|
| 260 |
+
return
|
| 261 |
+
service_model = operation_model.service_model
|
| 262 |
+
error_shape = service_model.shape_for_error_code(error_code)
|
| 263 |
+
if error_shape is None:
|
| 264 |
+
return
|
| 265 |
+
modeled_parse = await parser.parse(response_dict, error_shape)
|
| 266 |
+
# TODO: avoid naming conflicts with ResponseMetadata and Error
|
| 267 |
+
parsed_response.update(modeled_parse)
|
| 268 |
+
|
| 269 |
+
# NOTE: The only line changed here changing time.sleep to asyncio.sleep
|
| 270 |
+
async def _needs_retry(
|
| 271 |
+
self,
|
| 272 |
+
attempts,
|
| 273 |
+
operation_model,
|
| 274 |
+
request_dict,
|
| 275 |
+
response=None,
|
| 276 |
+
caught_exception=None,
|
| 277 |
+
):
|
| 278 |
+
service_id = operation_model.service_model.service_id.hyphenize()
|
| 279 |
+
event_name = f"needs-retry.{service_id}.{operation_model.name}"
|
| 280 |
+
responses = await self._event_emitter.emit(
|
| 281 |
+
event_name,
|
| 282 |
+
response=response,
|
| 283 |
+
endpoint=self,
|
| 284 |
+
operation=operation_model,
|
| 285 |
+
attempts=attempts,
|
| 286 |
+
caught_exception=caught_exception,
|
| 287 |
+
request_dict=request_dict,
|
| 288 |
+
)
|
| 289 |
+
handler_response = first_non_none_response(responses)
|
| 290 |
+
if handler_response is None:
|
| 291 |
+
return False
|
| 292 |
+
else:
|
| 293 |
+
# Request needs to be retried, and we need to sleep
|
| 294 |
+
# for the specified number of times.
|
| 295 |
+
logger.debug(
|
| 296 |
+
"Response received to retry, sleeping for %s seconds",
|
| 297 |
+
handler_response,
|
| 298 |
+
)
|
| 299 |
+
await asyncio.sleep(handler_response)
|
| 300 |
+
return True
|
| 301 |
+
|
| 302 |
+
async def _send(self, request):
|
| 303 |
+
return await self.http_session.send(request)
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
class AioEndpointCreator(EndpointCreator):
|
| 307 |
+
def create_endpoint(
|
| 308 |
+
self,
|
| 309 |
+
service_model,
|
| 310 |
+
region_name,
|
| 311 |
+
endpoint_url,
|
| 312 |
+
verify=None,
|
| 313 |
+
response_parser_factory=None,
|
| 314 |
+
timeout=DEFAULT_TIMEOUT,
|
| 315 |
+
max_pool_connections=MAX_POOL_CONNECTIONS,
|
| 316 |
+
http_session_cls=DEFAULT_HTTP_SESSION_CLS,
|
| 317 |
+
proxies=None,
|
| 318 |
+
socket_options=None,
|
| 319 |
+
client_cert=None,
|
| 320 |
+
proxies_config=None,
|
| 321 |
+
connector_args=None,
|
| 322 |
+
):
|
| 323 |
+
if not is_valid_endpoint_url(
|
| 324 |
+
endpoint_url
|
| 325 |
+
) and not is_valid_ipv6_endpoint_url(endpoint_url):
|
| 326 |
+
raise ValueError(f"Invalid endpoint: {endpoint_url}")
|
| 327 |
+
|
| 328 |
+
if proxies is None:
|
| 329 |
+
proxies = self._get_proxies(endpoint_url)
|
| 330 |
+
endpoint_prefix = service_model.endpoint_prefix
|
| 331 |
+
|
| 332 |
+
logger.debug('Setting %s timeout as %s', endpoint_prefix, timeout)
|
| 333 |
+
http_session = http_session_cls(
|
| 334 |
+
timeout=timeout,
|
| 335 |
+
proxies=proxies,
|
| 336 |
+
verify=self._get_verify_value(verify),
|
| 337 |
+
max_pool_connections=max_pool_connections,
|
| 338 |
+
socket_options=socket_options,
|
| 339 |
+
client_cert=client_cert,
|
| 340 |
+
proxies_config=proxies_config,
|
| 341 |
+
connector_args=connector_args,
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
return AioEndpoint(
|
| 345 |
+
endpoint_url,
|
| 346 |
+
endpoint_prefix=endpoint_prefix,
|
| 347 |
+
event_emitter=self._event_emitter,
|
| 348 |
+
response_parser_factory=response_parser_factory,
|
| 349 |
+
http_session=http_session,
|
| 350 |
+
)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/eventstream.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.eventstream import (
|
| 2 |
+
EventStream,
|
| 3 |
+
EventStreamBuffer,
|
| 4 |
+
NoInitialResponseError,
|
| 5 |
+
)
|
| 6 |
+
from botocore.exceptions import EventStreamError
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class AioEventStream(EventStream):
|
| 10 |
+
def __iter__(self):
|
| 11 |
+
raise NotImplementedError('Use async-for instead')
|
| 12 |
+
|
| 13 |
+
def __aiter__(self):
|
| 14 |
+
return self.__anext__()
|
| 15 |
+
|
| 16 |
+
async def __anext__(self):
|
| 17 |
+
async for event in self._event_generator:
|
| 18 |
+
parsed_event = await self._parse_event(event)
|
| 19 |
+
if parsed_event:
|
| 20 |
+
yield parsed_event
|
| 21 |
+
|
| 22 |
+
async def _create_raw_event_generator(self):
|
| 23 |
+
event_stream_buffer = EventStreamBuffer()
|
| 24 |
+
async for chunk, _ in self._raw_stream.content.iter_chunks():
|
| 25 |
+
event_stream_buffer.add_data(chunk)
|
| 26 |
+
for event in event_stream_buffer:
|
| 27 |
+
yield event # unfortunately no yield from async func support
|
| 28 |
+
|
| 29 |
+
async def _parse_event(self, event):
|
| 30 |
+
response_dict = event.to_response_dict()
|
| 31 |
+
parsed_response = await self._parser.parse(
|
| 32 |
+
response_dict, self._output_shape
|
| 33 |
+
)
|
| 34 |
+
if response_dict['status_code'] == 200:
|
| 35 |
+
return parsed_response
|
| 36 |
+
else:
|
| 37 |
+
raise EventStreamError(parsed_response, self._operation_name)
|
| 38 |
+
|
| 39 |
+
async def get_initial_response(self):
|
| 40 |
+
try:
|
| 41 |
+
async for event in self._event_generator:
|
| 42 |
+
event_type = event.headers.get(':event-type')
|
| 43 |
+
if event_type == 'initial-response':
|
| 44 |
+
return event
|
| 45 |
+
|
| 46 |
+
break
|
| 47 |
+
except StopIteration:
|
| 48 |
+
pass
|
| 49 |
+
raise NoInitialResponseError()
|
| 50 |
+
|
| 51 |
+
# self._raw_stream.close() is sync so no override needed
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/handlers.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.handlers import (
|
| 2 |
+
ETree,
|
| 3 |
+
_get_cross_region_presigned_url,
|
| 4 |
+
_get_presigned_url_source_and_destination_regions,
|
| 5 |
+
_looks_like_special_case_error,
|
| 6 |
+
logger,
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
async def check_for_200_error(response, **kwargs):
|
| 11 |
+
"""This function has been deprecated, but is kept for backwards compatibility."""
|
| 12 |
+
# From: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html
|
| 13 |
+
# There are two opportunities for a copy request to return an error. One
|
| 14 |
+
# can occur when Amazon S3 receives the copy request and the other can
|
| 15 |
+
# occur while Amazon S3 is copying the files. If the error occurs before
|
| 16 |
+
# the copy operation starts, you receive a standard Amazon S3 error. If the
|
| 17 |
+
# error occurs during the copy operation, the error response is embedded in
|
| 18 |
+
# the 200 OK response. This means that a 200 OK response can contain either
|
| 19 |
+
# a success or an error. Make sure to design your application to parse the
|
| 20 |
+
# contents of the response and handle it appropriately.
|
| 21 |
+
#
|
| 22 |
+
# So this handler checks for this case. Even though the server sends a
|
| 23 |
+
# 200 response, conceptually this should be handled exactly like a
|
| 24 |
+
# 500 response (with respect to raising exceptions, retries, etc.)
|
| 25 |
+
# We're connected *before* all the other retry logic handlers, so as long
|
| 26 |
+
# as we switch the error code to 500, we'll retry the error as expected.
|
| 27 |
+
if response is None:
|
| 28 |
+
# A None response can happen if an exception is raised while
|
| 29 |
+
# trying to retrieve the response. See Endpoint._get_response().
|
| 30 |
+
return
|
| 31 |
+
http_response, parsed = response
|
| 32 |
+
if _looks_like_special_case_error(
|
| 33 |
+
http_response.status_code, await http_response.content
|
| 34 |
+
):
|
| 35 |
+
logger.debug(
|
| 36 |
+
"Error found for response with 200 status code, "
|
| 37 |
+
"errors: %s, changing status code to "
|
| 38 |
+
"500.",
|
| 39 |
+
parsed,
|
| 40 |
+
)
|
| 41 |
+
http_response.status_code = 500
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
async def inject_presigned_url_ec2(params, request_signer, model, **kwargs):
|
| 45 |
+
# The customer can still provide this, so we should pass if they do.
|
| 46 |
+
if 'PresignedUrl' in params['body']:
|
| 47 |
+
return
|
| 48 |
+
src, dest = _get_presigned_url_source_and_destination_regions(
|
| 49 |
+
request_signer, params['body']
|
| 50 |
+
)
|
| 51 |
+
url = await _get_cross_region_presigned_url(
|
| 52 |
+
request_signer, params, model, src, dest
|
| 53 |
+
)
|
| 54 |
+
params['body']['PresignedUrl'] = url
|
| 55 |
+
# EC2 Requires that the destination region be sent over the wire in
|
| 56 |
+
# addition to the source region.
|
| 57 |
+
params['body']['DestinationRegion'] = dest
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
async def inject_presigned_url_rds(params, request_signer, model, **kwargs):
|
| 61 |
+
# SourceRegion is not required for RDS operations, so it's possible that
|
| 62 |
+
# it isn't set. In that case it's probably a local copy so we don't need
|
| 63 |
+
# to do anything else.
|
| 64 |
+
if 'SourceRegion' not in params['body']:
|
| 65 |
+
return
|
| 66 |
+
|
| 67 |
+
src, dest = _get_presigned_url_source_and_destination_regions(
|
| 68 |
+
request_signer, params['body']
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
# Since SourceRegion isn't actually modeled for RDS, it needs to be
|
| 72 |
+
# removed from the request params before we send the actual request.
|
| 73 |
+
del params['body']['SourceRegion']
|
| 74 |
+
|
| 75 |
+
if 'PreSignedUrl' in params['body']:
|
| 76 |
+
return
|
| 77 |
+
|
| 78 |
+
url = await _get_cross_region_presigned_url(
|
| 79 |
+
request_signer, params, model, src, dest
|
| 80 |
+
)
|
| 81 |
+
params['body']['PreSignedUrl'] = url
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
async def parse_get_bucket_location(parsed, http_response, **kwargs):
|
| 85 |
+
# s3.GetBucketLocation cannot be modeled properly. To
|
| 86 |
+
# account for this we just manually parse the XML document.
|
| 87 |
+
# The "parsed" passed in only has the ResponseMetadata
|
| 88 |
+
# filled out. This handler will fill in the LocationConstraint
|
| 89 |
+
# value.
|
| 90 |
+
if http_response.raw is None:
|
| 91 |
+
return
|
| 92 |
+
response_body = await http_response.content
|
| 93 |
+
parser = ETree.XMLParser(target=ETree.TreeBuilder(), encoding='utf-8')
|
| 94 |
+
parser.feed(response_body)
|
| 95 |
+
root = parser.close()
|
| 96 |
+
region = root.text
|
| 97 |
+
parsed['LocationConstraint'] = region
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/hooks.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.handlers import (
|
| 2 |
+
inject_presigned_url_ec2 as boto_inject_presigned_url_ec2,
|
| 3 |
+
)
|
| 4 |
+
from botocore.handlers import (
|
| 5 |
+
inject_presigned_url_rds as boto_inject_presigned_url_rds,
|
| 6 |
+
)
|
| 7 |
+
from botocore.handlers import (
|
| 8 |
+
parse_get_bucket_location as boto_parse_get_bucket_location,
|
| 9 |
+
)
|
| 10 |
+
from botocore.hooks import HierarchicalEmitter, logger
|
| 11 |
+
from botocore.signers import (
|
| 12 |
+
add_dsql_generate_db_auth_token_methods as boto_add_dsql_generate_db_auth_token_methods,
|
| 13 |
+
)
|
| 14 |
+
from botocore.signers import (
|
| 15 |
+
add_generate_db_auth_token as boto_add_generate_db_auth_token,
|
| 16 |
+
)
|
| 17 |
+
from botocore.signers import (
|
| 18 |
+
add_generate_presigned_post as boto_add_generate_presigned_post,
|
| 19 |
+
)
|
| 20 |
+
from botocore.signers import (
|
| 21 |
+
add_generate_presigned_url as boto_add_generate_presigned_url,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
from ._helpers import resolve_awaitable
|
| 25 |
+
from .handlers import (
|
| 26 |
+
inject_presigned_url_ec2,
|
| 27 |
+
inject_presigned_url_rds,
|
| 28 |
+
parse_get_bucket_location,
|
| 29 |
+
)
|
| 30 |
+
from .signers import (
|
| 31 |
+
add_dsql_generate_db_auth_token_methods,
|
| 32 |
+
add_generate_db_auth_token,
|
| 33 |
+
add_generate_presigned_post,
|
| 34 |
+
add_generate_presigned_url,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
_HANDLER_MAPPING = {
|
| 38 |
+
boto_inject_presigned_url_ec2: inject_presigned_url_ec2,
|
| 39 |
+
boto_inject_presigned_url_rds: inject_presigned_url_rds,
|
| 40 |
+
boto_add_generate_presigned_url: add_generate_presigned_url,
|
| 41 |
+
boto_add_generate_presigned_post: add_generate_presigned_post,
|
| 42 |
+
boto_add_generate_db_auth_token: add_generate_db_auth_token,
|
| 43 |
+
boto_parse_get_bucket_location: parse_get_bucket_location,
|
| 44 |
+
boto_add_dsql_generate_db_auth_token_methods: add_dsql_generate_db_auth_token_methods,
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class AioHierarchicalEmitter(HierarchicalEmitter):
|
| 49 |
+
async def _emit(self, event_name, kwargs, stop_on_response=False):
|
| 50 |
+
responses = []
|
| 51 |
+
# Invoke the event handlers from most specific
|
| 52 |
+
# to least specific, each time stripping off a dot.
|
| 53 |
+
handlers_to_call = self._lookup_cache.get(event_name)
|
| 54 |
+
if handlers_to_call is None:
|
| 55 |
+
handlers_to_call = self._handlers.prefix_search(event_name)
|
| 56 |
+
self._lookup_cache[event_name] = handlers_to_call
|
| 57 |
+
elif not handlers_to_call:
|
| 58 |
+
# Short circuit and return an empty response is we have
|
| 59 |
+
# no handlers to call. This is the common case where
|
| 60 |
+
# for the majority of signals, nothing is listening.
|
| 61 |
+
return []
|
| 62 |
+
kwargs['event_name'] = event_name
|
| 63 |
+
responses = []
|
| 64 |
+
for handler in handlers_to_call:
|
| 65 |
+
logger.debug('Event %s: calling handler %s', event_name, handler)
|
| 66 |
+
|
| 67 |
+
# Await the handler if its a coroutine.
|
| 68 |
+
response = await resolve_awaitable(handler(**kwargs))
|
| 69 |
+
responses.append((handler, response))
|
| 70 |
+
if stop_on_response and response is not None:
|
| 71 |
+
return responses
|
| 72 |
+
return responses
|
| 73 |
+
|
| 74 |
+
async def emit_until_response(self, event_name, **kwargs):
|
| 75 |
+
responses = await self._emit(event_name, kwargs, stop_on_response=True)
|
| 76 |
+
if responses:
|
| 77 |
+
return responses[-1]
|
| 78 |
+
else:
|
| 79 |
+
return None, None
|
| 80 |
+
|
| 81 |
+
def _verify_and_register(
|
| 82 |
+
self,
|
| 83 |
+
event_name,
|
| 84 |
+
handler,
|
| 85 |
+
unique_id,
|
| 86 |
+
register_method,
|
| 87 |
+
unique_id_uses_count,
|
| 88 |
+
):
|
| 89 |
+
handler = _HANDLER_MAPPING.get(handler, handler)
|
| 90 |
+
|
| 91 |
+
self._verify_is_callable(handler)
|
| 92 |
+
self._verify_accept_kwargs(handler)
|
| 93 |
+
register_method(event_name, handler, unique_id, unique_id_uses_count)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/httpchecksum.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import io
|
| 2 |
+
|
| 3 |
+
from botocore.httpchecksum import (
|
| 4 |
+
_CHECKSUM_CLS,
|
| 5 |
+
AwsChunkedWrapper,
|
| 6 |
+
FlexibleChecksumError,
|
| 7 |
+
_apply_request_header_checksum,
|
| 8 |
+
_register_checksum_algorithm_feature_id,
|
| 9 |
+
base64,
|
| 10 |
+
conditionally_calculate_md5,
|
| 11 |
+
determine_content_length,
|
| 12 |
+
logger,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
from aiobotocore._helpers import resolve_awaitable
|
| 16 |
+
from aiobotocore.response import HttpxStreamingBody, StreamingBody
|
| 17 |
+
|
| 18 |
+
try:
|
| 19 |
+
import httpx
|
| 20 |
+
except ImportError:
|
| 21 |
+
httpx = None
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class AioAwsChunkedWrapper(AwsChunkedWrapper):
|
| 25 |
+
async def read(self, size=None):
|
| 26 |
+
# Normalize "read all" size values to None
|
| 27 |
+
if size is not None and size <= 0:
|
| 28 |
+
size = None
|
| 29 |
+
|
| 30 |
+
# If the underlying body is done and we have nothing left then
|
| 31 |
+
# end the stream
|
| 32 |
+
if self._complete and not self._remaining:
|
| 33 |
+
return b""
|
| 34 |
+
|
| 35 |
+
# While we're not done and want more bytes
|
| 36 |
+
want_more_bytes = size is None or size > len(self._remaining)
|
| 37 |
+
while not self._complete and want_more_bytes:
|
| 38 |
+
self._remaining += await self._make_chunk()
|
| 39 |
+
want_more_bytes = size is None or size > len(self._remaining)
|
| 40 |
+
|
| 41 |
+
# If size was None, we want to return everything
|
| 42 |
+
if size is None:
|
| 43 |
+
size = len(self._remaining)
|
| 44 |
+
|
| 45 |
+
# Return a chunk up to the size asked for
|
| 46 |
+
to_return = self._remaining[:size]
|
| 47 |
+
self._remaining = self._remaining[size:]
|
| 48 |
+
return to_return
|
| 49 |
+
|
| 50 |
+
async def _make_chunk(self):
|
| 51 |
+
# NOTE: Chunk size is not deterministic as read could return less. This
|
| 52 |
+
# means we cannot know the content length of the encoded aws-chunked
|
| 53 |
+
# stream ahead of time without ensuring a consistent chunk size
|
| 54 |
+
|
| 55 |
+
raw_chunk = await resolve_awaitable(self._raw.read(self._chunk_size))
|
| 56 |
+
hex_len = hex(len(raw_chunk))[2:].encode("ascii")
|
| 57 |
+
self._complete = not raw_chunk
|
| 58 |
+
|
| 59 |
+
if self._checksum:
|
| 60 |
+
self._checksum.update(raw_chunk)
|
| 61 |
+
|
| 62 |
+
if self._checksum and self._complete:
|
| 63 |
+
name = self._checksum_name.encode("ascii")
|
| 64 |
+
checksum = self._checksum.b64digest().encode("ascii")
|
| 65 |
+
return b"0\r\n%s:%s\r\n\r\n" % (name, checksum)
|
| 66 |
+
|
| 67 |
+
return b"%s\r\n%s\r\n" % (hex_len, raw_chunk)
|
| 68 |
+
|
| 69 |
+
def __aiter__(self):
|
| 70 |
+
return self
|
| 71 |
+
|
| 72 |
+
async def __anext__(self):
|
| 73 |
+
while not self._complete:
|
| 74 |
+
return await self._make_chunk()
|
| 75 |
+
raise StopAsyncIteration()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
# unfortunately we can't inherit from botocore's StreamingChecksumBody due to
|
| 79 |
+
# subclassing
|
| 80 |
+
class StreamingChecksumBody(StreamingBody):
|
| 81 |
+
def __init__(self, raw_stream, content_length, checksum, expected):
|
| 82 |
+
super().__init__(raw_stream, content_length)
|
| 83 |
+
self._checksum = checksum
|
| 84 |
+
self._expected = expected
|
| 85 |
+
|
| 86 |
+
async def read(self, amt=None):
|
| 87 |
+
chunk = await super().read(amt=amt)
|
| 88 |
+
self._checksum.update(chunk)
|
| 89 |
+
if amt is None or (not chunk and amt > 0):
|
| 90 |
+
self._validate_checksum()
|
| 91 |
+
return chunk
|
| 92 |
+
|
| 93 |
+
async def readinto(self, b: bytearray):
|
| 94 |
+
chunk = await self.__wrapped__.content.read(len(b))
|
| 95 |
+
amount_read = len(chunk)
|
| 96 |
+
b[:amount_read] = chunk
|
| 97 |
+
|
| 98 |
+
if amount_read == len(b):
|
| 99 |
+
view = b
|
| 100 |
+
else:
|
| 101 |
+
view = memoryview(b)[:amount_read]
|
| 102 |
+
|
| 103 |
+
self._checksum.update(view)
|
| 104 |
+
if amount_read == 0 and len(b) > 0:
|
| 105 |
+
self._validate_checksum()
|
| 106 |
+
return amount_read
|
| 107 |
+
|
| 108 |
+
def _validate_checksum(self):
|
| 109 |
+
if self._checksum.digest() != base64.b64decode(self._expected):
|
| 110 |
+
error_msg = (
|
| 111 |
+
f"Expected checksum {self._expected} did not match calculated "
|
| 112 |
+
f"checksum: {self._checksum.b64digest()}"
|
| 113 |
+
)
|
| 114 |
+
raise FlexibleChecksumError(error_msg=error_msg)
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
# TODO: fix inheritance? read & _validate_checksum are the exact same as above
|
| 118 |
+
# only diff is super class and how to call __init__
|
| 119 |
+
class HttpxStreamingChecksumBody(HttpxStreamingBody):
|
| 120 |
+
def __init__(self, raw_stream, content_length, checksum, expected):
|
| 121 |
+
# HttpxStreamingbody doesn't use content_length
|
| 122 |
+
super().__init__(raw_stream)
|
| 123 |
+
self._checksum = checksum
|
| 124 |
+
self._expected = expected
|
| 125 |
+
|
| 126 |
+
# TODO: this class is largely (or possibly entirely) untested. The tests need to be
|
| 127 |
+
# more thoroughly rewritten wherever they directly create Streamingbody,
|
| 128 |
+
# StreamingChecksumBody, etc.
|
| 129 |
+
|
| 130 |
+
async def read(self, amt=None):
|
| 131 |
+
chunk = await super().read(amt=amt)
|
| 132 |
+
self._checksum.update(chunk)
|
| 133 |
+
if amt is None or (not chunk and amt > 0):
|
| 134 |
+
self._validate_checksum()
|
| 135 |
+
return chunk
|
| 136 |
+
|
| 137 |
+
async def readinto(self, b: bytearray):
|
| 138 |
+
chunk = await self.__wrapped__.content.read(len(b))
|
| 139 |
+
amount_read = len(chunk)
|
| 140 |
+
b[:amount_read] = chunk
|
| 141 |
+
|
| 142 |
+
if amount_read == len(b):
|
| 143 |
+
view = b
|
| 144 |
+
else:
|
| 145 |
+
view = memoryview(b)[:amount_read]
|
| 146 |
+
|
| 147 |
+
self._checksum.update(view)
|
| 148 |
+
if amount_read == 0 and len(b) > 0:
|
| 149 |
+
self._validate_checksum()
|
| 150 |
+
return amount_read
|
| 151 |
+
|
| 152 |
+
def _validate_checksum(self):
|
| 153 |
+
if self._checksum.digest() != base64.b64decode(self._expected):
|
| 154 |
+
error_msg = (
|
| 155 |
+
f"Expected checksum {self._expected} did not match calculated "
|
| 156 |
+
f"checksum: {self._checksum.b64digest()}"
|
| 157 |
+
)
|
| 158 |
+
raise FlexibleChecksumError(error_msg=error_msg)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
async def handle_checksum_body(
|
| 162 |
+
http_response, response, context, operation_model
|
| 163 |
+
):
|
| 164 |
+
headers = response["headers"]
|
| 165 |
+
checksum_context = context.get("checksum", {})
|
| 166 |
+
algorithms = checksum_context.get("response_algorithms")
|
| 167 |
+
|
| 168 |
+
if not algorithms:
|
| 169 |
+
return
|
| 170 |
+
|
| 171 |
+
for algorithm in algorithms:
|
| 172 |
+
header_name = f"x-amz-checksum-{algorithm}"
|
| 173 |
+
# If the header is not found, check the next algorithm
|
| 174 |
+
if header_name not in headers:
|
| 175 |
+
continue
|
| 176 |
+
|
| 177 |
+
# If a - is in the checksum this is not valid Base64. S3 returns
|
| 178 |
+
# checksums that include a -# suffix to indicate a checksum derived
|
| 179 |
+
# from the hash of all part checksums. We cannot wrap this response
|
| 180 |
+
if "-" in headers[header_name]:
|
| 181 |
+
continue
|
| 182 |
+
|
| 183 |
+
if operation_model.has_streaming_output:
|
| 184 |
+
response["body"] = _handle_streaming_response(
|
| 185 |
+
http_response, response, algorithm
|
| 186 |
+
)
|
| 187 |
+
else:
|
| 188 |
+
response["body"] = await _handle_bytes_response(
|
| 189 |
+
http_response, response, algorithm
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
# Expose metadata that the checksum check actually occurred
|
| 193 |
+
checksum_context = response["context"].get("checksum", {})
|
| 194 |
+
checksum_context["response_algorithm"] = algorithm
|
| 195 |
+
response["context"]["checksum"] = checksum_context
|
| 196 |
+
return
|
| 197 |
+
|
| 198 |
+
logger.debug(
|
| 199 |
+
'Skipping checksum validation. Response did not contain one of the following algorithms: %s.',
|
| 200 |
+
algorithms,
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def _handle_streaming_response(http_response, response, algorithm):
|
| 205 |
+
checksum_cls = _CHECKSUM_CLS.get(algorithm)
|
| 206 |
+
header_name = f"x-amz-checksum-{algorithm}"
|
| 207 |
+
if httpx is not None and isinstance(http_response.raw, httpx.Response):
|
| 208 |
+
streaming_cls = HttpxStreamingChecksumBody
|
| 209 |
+
else:
|
| 210 |
+
streaming_cls = StreamingChecksumBody
|
| 211 |
+
return streaming_cls(
|
| 212 |
+
http_response.raw,
|
| 213 |
+
response["headers"].get("content-length"),
|
| 214 |
+
checksum_cls(),
|
| 215 |
+
response["headers"][header_name],
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
async def _handle_bytes_response(http_response, response, algorithm):
|
| 220 |
+
body = await http_response.content
|
| 221 |
+
header_name = f"x-amz-checksum-{algorithm}"
|
| 222 |
+
checksum_cls = _CHECKSUM_CLS.get(algorithm)
|
| 223 |
+
checksum = checksum_cls()
|
| 224 |
+
checksum.update(body)
|
| 225 |
+
expected = response["headers"][header_name]
|
| 226 |
+
if checksum.digest() != base64.b64decode(expected):
|
| 227 |
+
error_msg = (
|
| 228 |
+
f"Expected checksum {expected} did not match calculated "
|
| 229 |
+
f"checksum: {checksum.b64digest()}"
|
| 230 |
+
)
|
| 231 |
+
raise FlexibleChecksumError(error_msg=error_msg)
|
| 232 |
+
return body
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def apply_request_checksum(request):
|
| 236 |
+
checksum_context = request.get("context", {}).get("checksum", {})
|
| 237 |
+
algorithm = checksum_context.get("request_algorithm")
|
| 238 |
+
|
| 239 |
+
if not algorithm:
|
| 240 |
+
return
|
| 241 |
+
|
| 242 |
+
if algorithm == "conditional-md5":
|
| 243 |
+
# Special case to handle the http checksum required trait
|
| 244 |
+
conditionally_calculate_md5(request)
|
| 245 |
+
elif algorithm["in"] == "header":
|
| 246 |
+
_apply_request_header_checksum(request)
|
| 247 |
+
elif algorithm["in"] == "trailer":
|
| 248 |
+
_apply_request_trailer_checksum(request)
|
| 249 |
+
else:
|
| 250 |
+
raise FlexibleChecksumError(
|
| 251 |
+
error_msg="Unknown checksum variant: {}".format(algorithm["in"])
|
| 252 |
+
)
|
| 253 |
+
if "request_algorithm_header" in checksum_context:
|
| 254 |
+
request_algorithm_header = checksum_context["request_algorithm_header"]
|
| 255 |
+
request["headers"][request_algorithm_header["name"]] = (
|
| 256 |
+
request_algorithm_header["value"]
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _apply_request_trailer_checksum(request):
|
| 261 |
+
checksum_context = request.get("context", {}).get("checksum", {})
|
| 262 |
+
algorithm = checksum_context.get("request_algorithm")
|
| 263 |
+
location_name = algorithm["name"]
|
| 264 |
+
checksum_cls = _CHECKSUM_CLS.get(algorithm["algorithm"])
|
| 265 |
+
|
| 266 |
+
headers = request["headers"]
|
| 267 |
+
body = request["body"]
|
| 268 |
+
|
| 269 |
+
if location_name in headers:
|
| 270 |
+
# If the header is already set by the customer, skip calculation
|
| 271 |
+
return
|
| 272 |
+
|
| 273 |
+
# Cannot set this as aiohttp complains
|
| 274 |
+
headers["Transfer-Encoding"] = "chunked"
|
| 275 |
+
if "Content-Encoding" in headers:
|
| 276 |
+
# We need to preserve the existing content encoding and add
|
| 277 |
+
# aws-chunked as a new content encoding.
|
| 278 |
+
headers["Content-Encoding"] += ",aws-chunked"
|
| 279 |
+
else:
|
| 280 |
+
headers["Content-Encoding"] = "aws-chunked"
|
| 281 |
+
headers["X-Amz-Trailer"] = location_name
|
| 282 |
+
_register_checksum_algorithm_feature_id(algorithm)
|
| 283 |
+
|
| 284 |
+
content_length = determine_content_length(body)
|
| 285 |
+
if content_length is not None:
|
| 286 |
+
# Send the decoded content length if we can determine it. Some
|
| 287 |
+
# services such as S3 may require the decoded content length
|
| 288 |
+
headers["X-Amz-Decoded-Content-Length"] = str(content_length)
|
| 289 |
+
|
| 290 |
+
if "Content-Length" in headers:
|
| 291 |
+
del headers["Content-Length"]
|
| 292 |
+
logger.debug(
|
| 293 |
+
"Removing the Content-Length header since 'chunked' is specified for Transfer-Encoding."
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
if isinstance(body, (bytes, bytearray)):
|
| 297 |
+
body = io.BytesIO(body)
|
| 298 |
+
|
| 299 |
+
request["body"] = AioAwsChunkedWrapper(
|
| 300 |
+
body,
|
| 301 |
+
checksum_cls=checksum_cls,
|
| 302 |
+
checksum_name=location_name,
|
| 303 |
+
)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/httpsession.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import contextlib
|
| 3 |
+
import io
|
| 4 |
+
import os
|
| 5 |
+
import socket
|
| 6 |
+
from concurrent.futures import CancelledError
|
| 7 |
+
from typing import Optional
|
| 8 |
+
|
| 9 |
+
import aiohttp # lgtm [py/import-and-import-from]
|
| 10 |
+
from aiohttp import (
|
| 11 |
+
ClientConnectionError,
|
| 12 |
+
ClientConnectorError,
|
| 13 |
+
ClientHttpProxyError,
|
| 14 |
+
ClientProxyConnectionError,
|
| 15 |
+
ClientSSLError,
|
| 16 |
+
ServerDisconnectedError,
|
| 17 |
+
ServerTimeoutError,
|
| 18 |
+
)
|
| 19 |
+
from aiohttp.client import URL
|
| 20 |
+
from botocore.httpsession import (
|
| 21 |
+
MAX_POOL_CONNECTIONS,
|
| 22 |
+
ConnectionClosedError,
|
| 23 |
+
ConnectTimeoutError,
|
| 24 |
+
EndpointConnectionError,
|
| 25 |
+
HTTPClientError,
|
| 26 |
+
InvalidProxiesConfigError,
|
| 27 |
+
LocationParseError,
|
| 28 |
+
ProxyConfiguration,
|
| 29 |
+
ProxyConnectionError,
|
| 30 |
+
ReadTimeoutError,
|
| 31 |
+
SSLError,
|
| 32 |
+
_is_ipaddress,
|
| 33 |
+
create_urllib3_context,
|
| 34 |
+
ensure_boolean,
|
| 35 |
+
get_cert_path,
|
| 36 |
+
logger,
|
| 37 |
+
mask_proxy_url,
|
| 38 |
+
parse_url,
|
| 39 |
+
urlparse,
|
| 40 |
+
)
|
| 41 |
+
from multidict import CIMultiDict
|
| 42 |
+
|
| 43 |
+
import aiobotocore.awsrequest
|
| 44 |
+
|
| 45 |
+
from ._constants import DEFAULT_KEEPALIVE_TIMEOUT
|
| 46 |
+
from ._endpoint_helpers import _IOBaseWrapper, _text
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class AIOHTTPSession:
|
| 50 |
+
def __init__(
|
| 51 |
+
self,
|
| 52 |
+
verify: bool = True,
|
| 53 |
+
proxies: dict[str, str] = None, # {scheme: url}
|
| 54 |
+
timeout: float = None,
|
| 55 |
+
max_pool_connections: int = MAX_POOL_CONNECTIONS,
|
| 56 |
+
socket_options=None,
|
| 57 |
+
client_cert=None,
|
| 58 |
+
proxies_config=None,
|
| 59 |
+
connector_args=None,
|
| 60 |
+
):
|
| 61 |
+
self._exit_stack = contextlib.AsyncExitStack()
|
| 62 |
+
|
| 63 |
+
# TODO: handle socket_options
|
| 64 |
+
# keep track of sessions by proxy url (if any)
|
| 65 |
+
self._sessions: dict[Optional[str], aiohttp.ClientSession] = {}
|
| 66 |
+
self._verify = verify
|
| 67 |
+
self._proxy_config = ProxyConfiguration(
|
| 68 |
+
proxies=proxies, proxies_settings=proxies_config
|
| 69 |
+
)
|
| 70 |
+
if isinstance(timeout, (list, tuple)):
|
| 71 |
+
conn_timeout, read_timeout = timeout
|
| 72 |
+
else:
|
| 73 |
+
conn_timeout = read_timeout = timeout
|
| 74 |
+
|
| 75 |
+
timeout = aiohttp.ClientTimeout(
|
| 76 |
+
sock_connect=conn_timeout, sock_read=read_timeout
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
self._cert_file = None
|
| 80 |
+
self._key_file = None
|
| 81 |
+
if isinstance(client_cert, str):
|
| 82 |
+
self._cert_file = client_cert
|
| 83 |
+
elif isinstance(client_cert, tuple):
|
| 84 |
+
self._cert_file, self._key_file = client_cert
|
| 85 |
+
|
| 86 |
+
self._timeout = timeout
|
| 87 |
+
self._connector_args = connector_args
|
| 88 |
+
if self._connector_args is None:
|
| 89 |
+
self._connector_args = dict(
|
| 90 |
+
keepalive_timeout=DEFAULT_KEEPALIVE_TIMEOUT
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
self._max_pool_connections = max_pool_connections
|
| 94 |
+
self._socket_options = socket_options
|
| 95 |
+
if socket_options is None:
|
| 96 |
+
self._socket_options = []
|
| 97 |
+
|
| 98 |
+
# aiohttp handles 100 continue so we shouldn't need AWSHTTP[S]ConnectionPool
|
| 99 |
+
# it also pools by host so we don't need a manager, and can pass proxy via
|
| 100 |
+
# request so don't need proxy manager
|
| 101 |
+
|
| 102 |
+
async def __aenter__(self):
|
| 103 |
+
assert not self._sessions
|
| 104 |
+
|
| 105 |
+
return self
|
| 106 |
+
|
| 107 |
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
| 108 |
+
self._sessions.clear()
|
| 109 |
+
await self._exit_stack.aclose()
|
| 110 |
+
|
| 111 |
+
def _get_ssl_context(self):
|
| 112 |
+
return create_urllib3_context()
|
| 113 |
+
|
| 114 |
+
def _setup_proxy_ssl_context(self, proxy_url):
|
| 115 |
+
proxies_settings = self._proxy_config.settings
|
| 116 |
+
proxy_ca_bundle = proxies_settings.get('proxy_ca_bundle')
|
| 117 |
+
proxy_cert = proxies_settings.get('proxy_client_cert')
|
| 118 |
+
if proxy_ca_bundle is None and proxy_cert is None:
|
| 119 |
+
return None
|
| 120 |
+
|
| 121 |
+
context = self._get_ssl_context()
|
| 122 |
+
try:
|
| 123 |
+
url = parse_url(proxy_url)
|
| 124 |
+
# urllib3 disables this by default but we need it for proper
|
| 125 |
+
# proxy tls negotiation when proxy_url is not an IP Address
|
| 126 |
+
if not _is_ipaddress(url.host):
|
| 127 |
+
context.check_hostname = True
|
| 128 |
+
if proxy_ca_bundle is not None:
|
| 129 |
+
context.load_verify_locations(cafile=proxy_ca_bundle)
|
| 130 |
+
|
| 131 |
+
if isinstance(proxy_cert, tuple):
|
| 132 |
+
context.load_cert_chain(proxy_cert[0], keyfile=proxy_cert[1])
|
| 133 |
+
elif isinstance(proxy_cert, str):
|
| 134 |
+
context.load_cert_chain(proxy_cert)
|
| 135 |
+
|
| 136 |
+
return context
|
| 137 |
+
except (OSError, LocationParseError) as e:
|
| 138 |
+
raise InvalidProxiesConfigError(error=e)
|
| 139 |
+
|
| 140 |
+
def _chunked(self, headers):
|
| 141 |
+
transfer_encoding = headers.get('Transfer-Encoding', '')
|
| 142 |
+
if chunked := transfer_encoding.lower() == 'chunked':
|
| 143 |
+
# aiohttp wants chunking as a param, and not a header
|
| 144 |
+
del headers['Transfer-Encoding']
|
| 145 |
+
return chunked or None
|
| 146 |
+
|
| 147 |
+
def _create_connector(self, proxy_url):
|
| 148 |
+
ssl_context = None
|
| 149 |
+
if bool(self._verify):
|
| 150 |
+
if proxy_url:
|
| 151 |
+
ssl_context = self._setup_proxy_ssl_context(proxy_url)
|
| 152 |
+
# TODO: add support for
|
| 153 |
+
# proxies_settings.get('proxy_use_forwarding_for_https')
|
| 154 |
+
else:
|
| 155 |
+
ssl_context = self._get_ssl_context()
|
| 156 |
+
|
| 157 |
+
if ssl_context:
|
| 158 |
+
if self._cert_file:
|
| 159 |
+
ssl_context.load_cert_chain(
|
| 160 |
+
self._cert_file,
|
| 161 |
+
self._key_file,
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
# inline self._setup_ssl_cert
|
| 165 |
+
ca_certs = get_cert_path(self._verify)
|
| 166 |
+
if ca_certs:
|
| 167 |
+
ssl_context.load_verify_locations(ca_certs, None, None)
|
| 168 |
+
|
| 169 |
+
return aiohttp.TCPConnector(
|
| 170 |
+
limit=self._max_pool_connections,
|
| 171 |
+
ssl=ssl_context or False,
|
| 172 |
+
**self._connector_args,
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
async def _get_session(self, proxy_url):
|
| 176 |
+
if not (session := self._sessions.get(proxy_url)):
|
| 177 |
+
connector = self._create_connector(proxy_url)
|
| 178 |
+
self._sessions[proxy_url] = (
|
| 179 |
+
session
|
| 180 |
+
) = await self._exit_stack.enter_async_context(
|
| 181 |
+
aiohttp.ClientSession(
|
| 182 |
+
connector=connector,
|
| 183 |
+
timeout=self._timeout,
|
| 184 |
+
skip_auto_headers={'CONTENT-TYPE'},
|
| 185 |
+
auto_decompress=False,
|
| 186 |
+
),
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
return session
|
| 190 |
+
|
| 191 |
+
async def close(self):
|
| 192 |
+
await self.__aexit__(None, None, None)
|
| 193 |
+
|
| 194 |
+
async def send(self, request):
|
| 195 |
+
try:
|
| 196 |
+
proxy_url = self._proxy_config.proxy_url_for(request.url)
|
| 197 |
+
proxy_headers = self._proxy_config.proxy_headers_for(request.url)
|
| 198 |
+
url = request.url
|
| 199 |
+
headers = request.headers
|
| 200 |
+
data = request.body
|
| 201 |
+
|
| 202 |
+
if ensure_boolean(
|
| 203 |
+
os.environ.get('BOTO_EXPERIMENTAL__ADD_PROXY_HOST_HEADER', '')
|
| 204 |
+
):
|
| 205 |
+
# This is currently an "experimental" feature which provides
|
| 206 |
+
# no guarantees of backwards compatibility. It may be subject
|
| 207 |
+
# to change or removal in any patch version. Anyone opting in
|
| 208 |
+
# to this feature should strictly pin botocore.
|
| 209 |
+
host = urlparse(request.url).hostname
|
| 210 |
+
proxy_headers['host'] = host
|
| 211 |
+
|
| 212 |
+
headers_ = CIMultiDict(
|
| 213 |
+
(z[0], _text(z[1], encoding='utf-8')) for z in headers.items()
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
# https://github.com/boto/botocore/issues/1255
|
| 217 |
+
headers_['Accept-Encoding'] = 'identity'
|
| 218 |
+
|
| 219 |
+
if isinstance(data, io.IOBase):
|
| 220 |
+
data = _IOBaseWrapper(data)
|
| 221 |
+
|
| 222 |
+
url = URL(url, encoded=True)
|
| 223 |
+
session = await self._get_session(proxy_url)
|
| 224 |
+
response = await session.request(
|
| 225 |
+
request.method,
|
| 226 |
+
url=url,
|
| 227 |
+
chunked=self._chunked(headers_),
|
| 228 |
+
headers=headers_,
|
| 229 |
+
data=data,
|
| 230 |
+
proxy=proxy_url,
|
| 231 |
+
proxy_headers=proxy_headers,
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
# botocore converts keys to str, so make sure that they are in
|
| 235 |
+
# the expected case. See detailed discussion here:
|
| 236 |
+
# https://github.com/aio-libs/aiobotocore/pull/116
|
| 237 |
+
# aiohttp's CIMultiDict camel cases the headers :(
|
| 238 |
+
headers = {
|
| 239 |
+
k.decode('utf-8').lower(): v.decode('utf-8')
|
| 240 |
+
for k, v in response.raw_headers
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
http_response = aiobotocore.awsrequest.AioAWSResponse(
|
| 244 |
+
str(response.url), response.status, headers, response
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
if not request.stream_output:
|
| 248 |
+
# Cause the raw stream to be exhausted immediately. We do it
|
| 249 |
+
# this way instead of using preload_content because
|
| 250 |
+
# preload_content will never buffer chunked responses
|
| 251 |
+
await http_response.content
|
| 252 |
+
|
| 253 |
+
return http_response
|
| 254 |
+
except ClientSSLError as e:
|
| 255 |
+
raise SSLError(endpoint_url=request.url, error=e)
|
| 256 |
+
except (ClientProxyConnectionError, ClientHttpProxyError) as e:
|
| 257 |
+
raise ProxyConnectionError(
|
| 258 |
+
proxy_url=mask_proxy_url(proxy_url), error=e
|
| 259 |
+
)
|
| 260 |
+
except (
|
| 261 |
+
ServerDisconnectedError,
|
| 262 |
+
aiohttp.ClientPayloadError,
|
| 263 |
+
aiohttp.http_exceptions.BadStatusLine,
|
| 264 |
+
) as e:
|
| 265 |
+
raise ConnectionClosedError(
|
| 266 |
+
error=e, request=request, endpoint_url=request.url
|
| 267 |
+
)
|
| 268 |
+
except ServerTimeoutError as e:
|
| 269 |
+
if str(e).lower().startswith('connect'):
|
| 270 |
+
raise ConnectTimeoutError(endpoint_url=request.url, error=e)
|
| 271 |
+
else:
|
| 272 |
+
raise ReadTimeoutError(endpoint_url=request.url, error=e)
|
| 273 |
+
except (
|
| 274 |
+
ClientConnectorError,
|
| 275 |
+
ClientConnectionError,
|
| 276 |
+
socket.gaierror,
|
| 277 |
+
) as e:
|
| 278 |
+
raise EndpointConnectionError(endpoint_url=request.url, error=e)
|
| 279 |
+
except asyncio.TimeoutError as e:
|
| 280 |
+
raise ReadTimeoutError(endpoint_url=request.url, error=e)
|
| 281 |
+
except CancelledError:
|
| 282 |
+
raise
|
| 283 |
+
except Exception as e:
|
| 284 |
+
message = 'Exception received when sending urllib3 HTTP request'
|
| 285 |
+
logger.debug(message, exc_info=True)
|
| 286 |
+
raise HTTPClientError(error=e)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/httpxsession.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import asyncio
|
| 4 |
+
import io
|
| 5 |
+
import os
|
| 6 |
+
import socket
|
| 7 |
+
import ssl
|
| 8 |
+
from collections.abc import AsyncIterable, Iterable
|
| 9 |
+
from concurrent.futures import CancelledError
|
| 10 |
+
from typing import TYPE_CHECKING, Any, cast
|
| 11 |
+
|
| 12 |
+
import botocore
|
| 13 |
+
from botocore.awsrequest import AWSPreparedRequest
|
| 14 |
+
from botocore.httpsession import (
|
| 15 |
+
MAX_POOL_CONNECTIONS,
|
| 16 |
+
ConnectionClosedError,
|
| 17 |
+
ConnectTimeoutError,
|
| 18 |
+
EndpointConnectionError,
|
| 19 |
+
HTTPClientError,
|
| 20 |
+
ProxyConnectionError,
|
| 21 |
+
ReadTimeoutError,
|
| 22 |
+
create_urllib3_context,
|
| 23 |
+
ensure_boolean,
|
| 24 |
+
get_cert_path,
|
| 25 |
+
logger,
|
| 26 |
+
)
|
| 27 |
+
from multidict import CIMultiDict
|
| 28 |
+
|
| 29 |
+
import aiobotocore.awsrequest
|
| 30 |
+
from aiobotocore._endpoint_helpers import _text
|
| 31 |
+
|
| 32 |
+
from ._constants import DEFAULT_KEEPALIVE_TIMEOUT
|
| 33 |
+
|
| 34 |
+
try:
|
| 35 |
+
import httpx
|
| 36 |
+
except ImportError:
|
| 37 |
+
httpx = None
|
| 38 |
+
|
| 39 |
+
if TYPE_CHECKING:
|
| 40 |
+
from ssl import SSLContext
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class HttpxSession:
|
| 44 |
+
def __init__(
|
| 45 |
+
self,
|
| 46 |
+
verify: bool = True,
|
| 47 |
+
proxies: dict[str, str] | None = None, # {scheme: url}
|
| 48 |
+
timeout: float | list[float] | tuple[float, float] | None = None,
|
| 49 |
+
max_pool_connections: int = MAX_POOL_CONNECTIONS,
|
| 50 |
+
socket_options: list[Any] | None = None,
|
| 51 |
+
client_cert: str | tuple[str, str] | None = None,
|
| 52 |
+
proxies_config: dict[str, str] | None = None,
|
| 53 |
+
connector_args: dict[str, Any] | None = None,
|
| 54 |
+
):
|
| 55 |
+
if httpx is None: # pragma: no cover
|
| 56 |
+
raise RuntimeError(
|
| 57 |
+
"Using HttpxSession requires httpx to be installed"
|
| 58 |
+
)
|
| 59 |
+
if proxies or proxies_config:
|
| 60 |
+
raise NotImplementedError(
|
| 61 |
+
"Proxy support not implemented with httpx as backend."
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
if connector_args is None:
|
| 65 |
+
self._connector_args: dict[str, Any] = {
|
| 66 |
+
'keepalive_timeout': DEFAULT_KEEPALIVE_TIMEOUT
|
| 67 |
+
}
|
| 68 |
+
else:
|
| 69 |
+
self._connector_args = connector_args
|
| 70 |
+
|
| 71 |
+
# TODO: neither this nor AIOHTTPSession handles socket_options
|
| 72 |
+
self._session: httpx.AsyncClient | None = None
|
| 73 |
+
conn_timeout: float | None
|
| 74 |
+
read_timeout: float | None
|
| 75 |
+
|
| 76 |
+
if isinstance(timeout, (list, tuple)):
|
| 77 |
+
conn_timeout, read_timeout = timeout
|
| 78 |
+
else:
|
| 79 |
+
conn_timeout = read_timeout = timeout
|
| 80 |
+
|
| 81 |
+
write_timeout = self._connector_args.get('write_timeout', 5)
|
| 82 |
+
pool_timeout = self._connector_args.get('pool_timeout', 5)
|
| 83 |
+
|
| 84 |
+
self._timeout = httpx.Timeout(
|
| 85 |
+
connect=conn_timeout,
|
| 86 |
+
read=read_timeout,
|
| 87 |
+
write=write_timeout,
|
| 88 |
+
pool=pool_timeout,
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
self._cert_file = None
|
| 92 |
+
self._key_file = None
|
| 93 |
+
if isinstance(client_cert, str):
|
| 94 |
+
self._cert_file = client_cert
|
| 95 |
+
elif isinstance(client_cert, tuple):
|
| 96 |
+
self._cert_file, self._key_file = client_cert
|
| 97 |
+
elif client_cert is not None:
|
| 98 |
+
raise TypeError(f'{client_cert} must be str or tuple[str,str]')
|
| 99 |
+
|
| 100 |
+
if 'use_dns_cache' in self._connector_args:
|
| 101 |
+
raise NotImplementedError(
|
| 102 |
+
"DNS caching is not implemented by httpx. https://github.com/encode/httpx/discussions/2211"
|
| 103 |
+
)
|
| 104 |
+
if 'force_close' in self._connector_args:
|
| 105 |
+
raise NotImplementedError("Not supported with httpx as backend.")
|
| 106 |
+
if 'resolver' in self._connector_args:
|
| 107 |
+
raise NotImplementedError("Not supported with httpx as backend.")
|
| 108 |
+
|
| 109 |
+
self._max_pool_connections = max_pool_connections
|
| 110 |
+
self._socket_options = socket_options
|
| 111 |
+
if socket_options is None:
|
| 112 |
+
self._socket_options = []
|
| 113 |
+
|
| 114 |
+
# TODO [httpx]: clean up
|
| 115 |
+
ssl_context: SSLContext | None = None
|
| 116 |
+
self._verify: bool | str | SSLContext = verify
|
| 117 |
+
if not verify:
|
| 118 |
+
return
|
| 119 |
+
if 'ssl_context' in self._connector_args:
|
| 120 |
+
self._verify = cast(
|
| 121 |
+
'SSLContext', self._connector_args['ssl_context']
|
| 122 |
+
)
|
| 123 |
+
return
|
| 124 |
+
|
| 125 |
+
ssl_context = self._get_ssl_context()
|
| 126 |
+
|
| 127 |
+
# inline self._setup_ssl_cert
|
| 128 |
+
ca_certs = get_cert_path(verify)
|
| 129 |
+
if ca_certs:
|
| 130 |
+
ssl_context.load_verify_locations(ca_certs, None, None)
|
| 131 |
+
if ssl_context is not None:
|
| 132 |
+
self._verify = ssl_context
|
| 133 |
+
|
| 134 |
+
async def __aenter__(self):
|
| 135 |
+
assert not self._session
|
| 136 |
+
|
| 137 |
+
limits = httpx.Limits(
|
| 138 |
+
max_connections=self._max_pool_connections,
|
| 139 |
+
keepalive_expiry=self._connector_args['keepalive_timeout'],
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
# TODO [httpx]: I put logic here to minimize diff / accidental downstream
|
| 143 |
+
# consequences - but can probably put this logic in __init__
|
| 144 |
+
if self._cert_file and self._key_file is None:
|
| 145 |
+
cert = self._cert_file
|
| 146 |
+
elif self._cert_file:
|
| 147 |
+
cert = (self._cert_file, self._key_file)
|
| 148 |
+
else:
|
| 149 |
+
cert = None
|
| 150 |
+
|
| 151 |
+
self._session = httpx.AsyncClient(
|
| 152 |
+
timeout=self._timeout, limits=limits, cert=cert
|
| 153 |
+
)
|
| 154 |
+
return self
|
| 155 |
+
|
| 156 |
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
| 157 |
+
if self._session:
|
| 158 |
+
await self._session.__aexit__(exc_type, exc_val, exc_tb)
|
| 159 |
+
self._session = None
|
| 160 |
+
self._connector = None
|
| 161 |
+
|
| 162 |
+
def _get_ssl_context(self) -> SSLContext:
|
| 163 |
+
ssl_context = create_urllib3_context()
|
| 164 |
+
if self._cert_file:
|
| 165 |
+
ssl_context.load_cert_chain(self._cert_file, self._key_file)
|
| 166 |
+
return ssl_context
|
| 167 |
+
|
| 168 |
+
async def close(self) -> None:
|
| 169 |
+
await self.__aexit__(None, None, None)
|
| 170 |
+
|
| 171 |
+
async def send(
|
| 172 |
+
self, request: AWSPreparedRequest
|
| 173 |
+
) -> aiobotocore.awsrequest.HttpxAWSResponse:
|
| 174 |
+
try:
|
| 175 |
+
url = request.url
|
| 176 |
+
headers = request.headers
|
| 177 |
+
|
| 178 |
+
# currently no support for BOTO_EXPERIMENTAL__ADD_PROXY_HOST_HEADER
|
| 179 |
+
if ensure_boolean(
|
| 180 |
+
os.environ.get('BOTO_EXPERIMENTAL__ADD_PROXY_HOST_HEADER', '')
|
| 181 |
+
):
|
| 182 |
+
raise NotImplementedError(
|
| 183 |
+
'httpx implementation of aiobotocore does not (currently) support proxies'
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
headers_ = CIMultiDict(
|
| 187 |
+
(z[0], _text(z[1], encoding='utf-8')) for z in headers.items()
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
# https://github.com/boto/botocore/issues/1255
|
| 191 |
+
headers_['Accept-Encoding'] = 'identity'
|
| 192 |
+
|
| 193 |
+
# content can also be https://github.com/ymyzk/tox-gh-actions
|
| 194 |
+
content: AsyncIterable | bytes | bytearray | str | None = None
|
| 195 |
+
|
| 196 |
+
async def to_async_iterable(stream: Iterable) -> AsyncIterable:
|
| 197 |
+
if isinstance(stream, AsyncIterable):
|
| 198 |
+
async for item in stream:
|
| 199 |
+
yield item
|
| 200 |
+
else:
|
| 201 |
+
for item in stream:
|
| 202 |
+
yield item
|
| 203 |
+
await asyncio.sleep(0) # Yield control to event loop
|
| 204 |
+
|
| 205 |
+
if isinstance(
|
| 206 |
+
request.body, (AsyncIterable, io.BytesIO)
|
| 207 |
+
) and isinstance(request.body, Iterable):
|
| 208 |
+
content = to_async_iterable(request.body)
|
| 209 |
+
else:
|
| 210 |
+
content = request.body
|
| 211 |
+
|
| 212 |
+
# The target gets used as the HTTP target instead of the URL path
|
| 213 |
+
# it does not get normalized or otherwise processed, which is important
|
| 214 |
+
# since arbitrary dots and slashes are valid as key paths.
|
| 215 |
+
# See test_basic_s3.test_non_normalized_key_paths
|
| 216 |
+
# This way of using it is currently ~undocumented, but recommended in
|
| 217 |
+
# https://github.com/encode/httpx/discussions/1805#discussioncomment-8975989
|
| 218 |
+
extensions = {"target": bytes(url, encoding='utf-8')}
|
| 219 |
+
|
| 220 |
+
assert self._session is not None
|
| 221 |
+
|
| 222 |
+
httpx_request = self._session.build_request(
|
| 223 |
+
method=request.method,
|
| 224 |
+
url=url,
|
| 225 |
+
headers=headers,
|
| 226 |
+
content=content,
|
| 227 |
+
extensions=extensions,
|
| 228 |
+
)
|
| 229 |
+
assert isinstance(httpx_request.stream, httpx.AsyncByteStream)
|
| 230 |
+
# auth, follow_redirects
|
| 231 |
+
response = await self._session.send(httpx_request, stream=True)
|
| 232 |
+
response_headers = botocore.compat.HTTPHeaders.from_pairs(
|
| 233 |
+
response.headers.items()
|
| 234 |
+
)
|
| 235 |
+
|
| 236 |
+
http_response = aiobotocore.awsrequest.HttpxAWSResponse(
|
| 237 |
+
str(response.url),
|
| 238 |
+
response.status_code,
|
| 239 |
+
response_headers,
|
| 240 |
+
response,
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
if not request.stream_output:
|
| 244 |
+
# Cause the raw stream to be exhausted immediately. We do it
|
| 245 |
+
# this way instead of using preload_content because
|
| 246 |
+
# preload_content will never buffer chunked responses
|
| 247 |
+
await http_response.content
|
| 248 |
+
|
| 249 |
+
return http_response
|
| 250 |
+
|
| 251 |
+
except httpx.ConnectError as e:
|
| 252 |
+
raise EndpointConnectionError(endpoint_url=request.url, error=e)
|
| 253 |
+
except (socket.gaierror,) as e:
|
| 254 |
+
raise EndpointConnectionError(endpoint_url=request.url, error=e)
|
| 255 |
+
except asyncio.TimeoutError as e:
|
| 256 |
+
raise ReadTimeoutError(endpoint_url=request.url, error=e)
|
| 257 |
+
except httpx.ReadTimeout as e:
|
| 258 |
+
raise ReadTimeoutError(endpoint_url=request.url, error=e)
|
| 259 |
+
except httpx.TimeoutException as e:
|
| 260 |
+
raise ConnectTimeoutError(endpoint_url=request.url, error=e)
|
| 261 |
+
except httpx.ProxyError as e:
|
| 262 |
+
raise ProxyConnectionError(endpoint_url=request.url, error=e)
|
| 263 |
+
except httpx.CloseError as e:
|
| 264 |
+
raise ConnectionClosedError(endpoint_url=request.url, error=e)
|
| 265 |
+
except ssl.SSLError:
|
| 266 |
+
raise botocore.exceptions.SSLError
|
| 267 |
+
|
| 268 |
+
except NotImplementedError:
|
| 269 |
+
raise # Avoid turning it into HTTPClientError.
|
| 270 |
+
except CancelledError:
|
| 271 |
+
raise
|
| 272 |
+
except Exception as e:
|
| 273 |
+
message = 'Exception received when sending httpx HTTP request'
|
| 274 |
+
logger.debug(message, exc_info=True)
|
| 275 |
+
raise HTTPClientError(error=e)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/paginate.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from functools import partial
|
| 2 |
+
|
| 3 |
+
import aioitertools
|
| 4 |
+
import jmespath
|
| 5 |
+
from botocore.exceptions import PaginationError
|
| 6 |
+
from botocore.paginate import PageIterator, Paginator
|
| 7 |
+
from botocore.useragent import register_feature_id
|
| 8 |
+
from botocore.utils import merge_dicts, set_value_from_jmespath
|
| 9 |
+
|
| 10 |
+
from .context import with_current_context
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class AioPageIterator(PageIterator):
|
| 14 |
+
def __aiter__(self):
|
| 15 |
+
return self.__anext__()
|
| 16 |
+
|
| 17 |
+
@with_current_context(partial(register_feature_id, 'PAGINATOR'))
|
| 18 |
+
async def _make_request(self, current_kwargs):
|
| 19 |
+
return await self._method(**current_kwargs)
|
| 20 |
+
|
| 21 |
+
async def __anext__(self):
|
| 22 |
+
current_kwargs = self._op_kwargs
|
| 23 |
+
previous_next_token = None
|
| 24 |
+
next_token = {key: None for key in self._input_token}
|
| 25 |
+
if self._starting_token is not None:
|
| 26 |
+
# If the starting token exists, populate the next_token with the
|
| 27 |
+
# values inside it. This ensures that we have the service's
|
| 28 |
+
# pagination token on hand if we need to truncate after the
|
| 29 |
+
# first response.
|
| 30 |
+
next_token = self._parse_starting_token()[0]
|
| 31 |
+
# The number of items from result_key we've seen so far.
|
| 32 |
+
total_items = 0
|
| 33 |
+
first_request = True
|
| 34 |
+
primary_result_key = self.result_keys[0]
|
| 35 |
+
starting_truncation = 0
|
| 36 |
+
self._inject_starting_params(current_kwargs)
|
| 37 |
+
|
| 38 |
+
while True:
|
| 39 |
+
response = await self._make_request(current_kwargs)
|
| 40 |
+
parsed = self._extract_parsed_response(response)
|
| 41 |
+
if first_request:
|
| 42 |
+
# The first request is handled differently. We could
|
| 43 |
+
# possibly have a resume/starting token that tells us where
|
| 44 |
+
# to index into the retrieved page.
|
| 45 |
+
if self._starting_token is not None:
|
| 46 |
+
starting_truncation = self._handle_first_request(
|
| 47 |
+
parsed, primary_result_key, starting_truncation
|
| 48 |
+
)
|
| 49 |
+
first_request = False
|
| 50 |
+
self._record_non_aggregate_key_values(parsed)
|
| 51 |
+
else:
|
| 52 |
+
# If this isn't the first request, we have already sliced into
|
| 53 |
+
# the first request and had to make additional requests after.
|
| 54 |
+
# We no longer need to add this to truncation.
|
| 55 |
+
starting_truncation = 0
|
| 56 |
+
current_response = primary_result_key.search(parsed)
|
| 57 |
+
if current_response is None:
|
| 58 |
+
current_response = []
|
| 59 |
+
num_current_response = len(current_response)
|
| 60 |
+
truncate_amount = 0
|
| 61 |
+
if self._max_items is not None:
|
| 62 |
+
truncate_amount = (
|
| 63 |
+
total_items + num_current_response - self._max_items
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
if truncate_amount > 0:
|
| 67 |
+
self._truncate_response(
|
| 68 |
+
parsed,
|
| 69 |
+
primary_result_key,
|
| 70 |
+
truncate_amount,
|
| 71 |
+
starting_truncation,
|
| 72 |
+
next_token,
|
| 73 |
+
)
|
| 74 |
+
yield response
|
| 75 |
+
break
|
| 76 |
+
else:
|
| 77 |
+
yield response
|
| 78 |
+
total_items += num_current_response
|
| 79 |
+
next_token = self._get_next_token(parsed)
|
| 80 |
+
if all(t is None for t in next_token.values()):
|
| 81 |
+
break
|
| 82 |
+
if (
|
| 83 |
+
self._max_items is not None
|
| 84 |
+
and total_items == self._max_items
|
| 85 |
+
):
|
| 86 |
+
# We're on a page boundary so we can set the current
|
| 87 |
+
# next token to be the resume token.
|
| 88 |
+
self.resume_token = next_token
|
| 89 |
+
break
|
| 90 |
+
if (
|
| 91 |
+
previous_next_token is not None
|
| 92 |
+
and previous_next_token == next_token
|
| 93 |
+
):
|
| 94 |
+
message = (
|
| 95 |
+
f"The same next token was received twice: {next_token}"
|
| 96 |
+
)
|
| 97 |
+
raise PaginationError(message=message)
|
| 98 |
+
self._inject_token_into_kwargs(current_kwargs, next_token)
|
| 99 |
+
previous_next_token = next_token
|
| 100 |
+
|
| 101 |
+
async def search(self, expression):
|
| 102 |
+
compiled = jmespath.compile(expression)
|
| 103 |
+
async for page in self:
|
| 104 |
+
results = compiled.search(page)
|
| 105 |
+
if isinstance(results, list):
|
| 106 |
+
for element in results:
|
| 107 |
+
yield element # unfortunately yield from not avail from async f
|
| 108 |
+
else:
|
| 109 |
+
yield results
|
| 110 |
+
|
| 111 |
+
def result_key_iters(self):
|
| 112 |
+
teed_results = aioitertools.tee(self, len(self.result_keys))
|
| 113 |
+
return [
|
| 114 |
+
ResultKeyIterator(i, result_key)
|
| 115 |
+
for i, result_key in zip(teed_results, self.result_keys)
|
| 116 |
+
]
|
| 117 |
+
|
| 118 |
+
async def build_full_result(self):
|
| 119 |
+
complete_result = {}
|
| 120 |
+
async for response in self:
|
| 121 |
+
page = response
|
| 122 |
+
# We want to try to catch operation object pagination
|
| 123 |
+
# and format correctly for those. They come in the form
|
| 124 |
+
# of a tuple of two elements: (http_response, parsed_responsed).
|
| 125 |
+
# We want the parsed_response as that is what the page iterator
|
| 126 |
+
# uses. We can remove it though once operation objects are removed.
|
| 127 |
+
if isinstance(response, tuple) and len(response) == 2:
|
| 128 |
+
page = response[1]
|
| 129 |
+
# We're incrementally building the full response page
|
| 130 |
+
# by page. For each page in the response we need to
|
| 131 |
+
# inject the necessary components from the page
|
| 132 |
+
# into the complete_result.
|
| 133 |
+
for result_expression in self.result_keys:
|
| 134 |
+
# In order to incrementally update a result key
|
| 135 |
+
# we need to search the existing value from complete_result,
|
| 136 |
+
# then we need to search the _current_ page for the
|
| 137 |
+
# current result key value. Then we append the current
|
| 138 |
+
# value onto the existing value, and re-set that value
|
| 139 |
+
# as the new value.
|
| 140 |
+
result_value = result_expression.search(page)
|
| 141 |
+
if result_value is None:
|
| 142 |
+
continue
|
| 143 |
+
existing_value = result_expression.search(complete_result)
|
| 144 |
+
if existing_value is None:
|
| 145 |
+
# Set the initial result
|
| 146 |
+
set_value_from_jmespath(
|
| 147 |
+
complete_result,
|
| 148 |
+
result_expression.expression,
|
| 149 |
+
result_value,
|
| 150 |
+
)
|
| 151 |
+
continue
|
| 152 |
+
# Now both result_value and existing_value contain something
|
| 153 |
+
if isinstance(result_value, list):
|
| 154 |
+
existing_value.extend(result_value)
|
| 155 |
+
elif isinstance(result_value, (int, float, str)):
|
| 156 |
+
# Modify the existing result with the sum or concatenation
|
| 157 |
+
set_value_from_jmespath(
|
| 158 |
+
complete_result,
|
| 159 |
+
result_expression.expression,
|
| 160 |
+
existing_value + result_value,
|
| 161 |
+
)
|
| 162 |
+
merge_dicts(complete_result, self.non_aggregate_part)
|
| 163 |
+
if self.resume_token is not None:
|
| 164 |
+
complete_result['NextToken'] = self.resume_token
|
| 165 |
+
return complete_result
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
class AioPaginator(Paginator):
|
| 169 |
+
PAGE_ITERATOR_CLS = AioPageIterator
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
class ResultKeyIterator:
|
| 173 |
+
"""Iterates over the results of paginated responses.
|
| 174 |
+
|
| 175 |
+
Each iterator is associated with a single result key.
|
| 176 |
+
Iterating over this object will give you each element in
|
| 177 |
+
the result key list.
|
| 178 |
+
|
| 179 |
+
:param pages_iterator: An iterator that will give you
|
| 180 |
+
pages of results (a ``PageIterator`` class).
|
| 181 |
+
:param result_key: The JMESPath expression representing
|
| 182 |
+
the result key.
|
| 183 |
+
|
| 184 |
+
"""
|
| 185 |
+
|
| 186 |
+
def __init__(self, pages_iterator, result_key):
|
| 187 |
+
self._pages_iterator = pages_iterator
|
| 188 |
+
self.result_key = result_key
|
| 189 |
+
|
| 190 |
+
def __aiter__(self):
|
| 191 |
+
return self.__anext__()
|
| 192 |
+
|
| 193 |
+
async def __anext__(self):
|
| 194 |
+
async for page in self._pages_iterator:
|
| 195 |
+
results = self.result_key.search(page)
|
| 196 |
+
if results is None:
|
| 197 |
+
results = []
|
| 198 |
+
for result in results:
|
| 199 |
+
yield result # yield from not avail from async func
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/parsers.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.parsers import (
|
| 2 |
+
LOG,
|
| 3 |
+
BaseCBORParser,
|
| 4 |
+
BaseEventStreamParser,
|
| 5 |
+
BaseJSONParser,
|
| 6 |
+
BaseRestParser,
|
| 7 |
+
BaseRpcV2Parser,
|
| 8 |
+
BaseXMLResponseParser,
|
| 9 |
+
EC2QueryParser,
|
| 10 |
+
EventStreamCBORParser,
|
| 11 |
+
EventStreamJSONParser,
|
| 12 |
+
EventStreamXMLParser,
|
| 13 |
+
JSONParser,
|
| 14 |
+
NoInitialResponseError,
|
| 15 |
+
QueryParser,
|
| 16 |
+
ResponseParser,
|
| 17 |
+
ResponseParserError,
|
| 18 |
+
ResponseParserFactory,
|
| 19 |
+
RestJSONParser,
|
| 20 |
+
RestXMLParser,
|
| 21 |
+
RpcV2CBORParser,
|
| 22 |
+
lowercase_dict,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
from ._helpers import resolve_awaitable
|
| 26 |
+
from .eventstream import AioEventStream
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class AioResponseParserFactory(ResponseParserFactory):
|
| 30 |
+
def create_parser(self, protocol_name):
|
| 31 |
+
parser_cls = PROTOCOL_PARSERS[protocol_name]
|
| 32 |
+
return parser_cls(**self._defaults)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def create_parser(protocol):
|
| 36 |
+
return AioResponseParserFactory().create_parser(protocol)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class AioResponseParser(ResponseParser):
|
| 40 |
+
async def parse(self, response, shape):
|
| 41 |
+
LOG.debug('Response headers: %s', response['headers'])
|
| 42 |
+
LOG.debug('Response body:\n%s', response['body'])
|
| 43 |
+
if response['status_code'] >= 301:
|
| 44 |
+
if self._is_generic_error_response(response):
|
| 45 |
+
parsed = self._do_generic_error_parse(response)
|
| 46 |
+
elif self._is_modeled_error_shape(shape):
|
| 47 |
+
parsed = self._do_modeled_error_parse(response, shape)
|
| 48 |
+
# We don't want to decorate the modeled fields with metadata
|
| 49 |
+
return parsed
|
| 50 |
+
else:
|
| 51 |
+
parsed = self._do_error_parse(response, shape)
|
| 52 |
+
else:
|
| 53 |
+
parsed = await resolve_awaitable(self._do_parse(response, shape))
|
| 54 |
+
|
| 55 |
+
# We don't want to decorate event stream responses with metadata
|
| 56 |
+
if shape and shape.serialization.get('eventstream'):
|
| 57 |
+
return parsed
|
| 58 |
+
|
| 59 |
+
# Add ResponseMetadata if it doesn't exist and inject the HTTP
|
| 60 |
+
# status code and headers from the response.
|
| 61 |
+
if isinstance(parsed, dict):
|
| 62 |
+
response_metadata = parsed.get('ResponseMetadata', {})
|
| 63 |
+
response_metadata['HTTPStatusCode'] = response['status_code']
|
| 64 |
+
# Ensure that the http header keys are all lower cased. Older
|
| 65 |
+
# versions of urllib3 (< 1.11) would unintentionally do this for us
|
| 66 |
+
# (see urllib3#633). We need to do this conversion manually now.
|
| 67 |
+
headers = response['headers']
|
| 68 |
+
response_metadata['HTTPHeaders'] = lowercase_dict(headers)
|
| 69 |
+
parsed['ResponseMetadata'] = response_metadata
|
| 70 |
+
self._add_checksum_response_metadata(response, response_metadata)
|
| 71 |
+
return parsed
|
| 72 |
+
|
| 73 |
+
def _create_event_stream(self, response, shape):
|
| 74 |
+
parser = self._event_stream_parser
|
| 75 |
+
name = response['context'].get('operation_name')
|
| 76 |
+
return AioEventStream(response['body'], shape, parser, name)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class AioBaseXMLResponseParser(BaseXMLResponseParser, AioResponseParser):
|
| 80 |
+
pass
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
class AioQueryParser(QueryParser, AioBaseXMLResponseParser):
|
| 84 |
+
pass
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class AioEC2QueryParser(EC2QueryParser, AioQueryParser):
|
| 88 |
+
pass
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
class AioBaseJSONParser(BaseJSONParser, AioResponseParser):
|
| 92 |
+
pass
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class AioBaseCBORParser(BaseCBORParser, AioResponseParser):
|
| 96 |
+
pass
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class AioBaseEventStreamParser(BaseEventStreamParser, AioResponseParser):
|
| 100 |
+
pass
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
class AioEventStreamJSONParser(
|
| 104 |
+
EventStreamJSONParser, AioBaseEventStreamParser, AioBaseJSONParser
|
| 105 |
+
):
|
| 106 |
+
pass
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class AioEventStreamXMLParser(
|
| 110 |
+
EventStreamXMLParser, AioBaseEventStreamParser, AioBaseXMLResponseParser
|
| 111 |
+
):
|
| 112 |
+
pass
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class AioEventStreamCBORParser(
|
| 116 |
+
EventStreamCBORParser, AioBaseEventStreamParser, AioBaseCBORParser
|
| 117 |
+
):
|
| 118 |
+
pass
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class AioJSONParser(JSONParser, AioBaseJSONParser):
|
| 122 |
+
EVENT_STREAM_PARSER_CLS = AioEventStreamJSONParser
|
| 123 |
+
|
| 124 |
+
async def _do_parse(self, response, shape):
|
| 125 |
+
parsed = {}
|
| 126 |
+
if shape is not None:
|
| 127 |
+
event_name = shape.event_stream_name
|
| 128 |
+
if event_name:
|
| 129 |
+
parsed = await self._handle_event_stream(
|
| 130 |
+
response, shape, event_name
|
| 131 |
+
)
|
| 132 |
+
else:
|
| 133 |
+
parsed = self._handle_json_body(response['body'], shape)
|
| 134 |
+
self._inject_response_metadata(parsed, response['headers'])
|
| 135 |
+
return parsed
|
| 136 |
+
|
| 137 |
+
async def _handle_event_stream(self, response, shape, event_name):
|
| 138 |
+
event_stream_shape = shape.members[event_name]
|
| 139 |
+
event_stream = self._create_event_stream(response, event_stream_shape)
|
| 140 |
+
try:
|
| 141 |
+
event = await event_stream.get_initial_response()
|
| 142 |
+
except NoInitialResponseError:
|
| 143 |
+
error_msg = 'First event was not of type initial-response'
|
| 144 |
+
raise ResponseParserError(error_msg)
|
| 145 |
+
parsed = self._handle_json_body(event.payload, shape)
|
| 146 |
+
parsed[event_name] = event_stream
|
| 147 |
+
return parsed
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
class AioBaseRestParser(BaseRestParser, AioResponseParser):
|
| 151 |
+
pass
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
class AioBaseRpcV2Parser(BaseRpcV2Parser, AioResponseParser):
|
| 155 |
+
async def _do_parse(self, response, shape):
|
| 156 |
+
parsed = {}
|
| 157 |
+
if shape is not None:
|
| 158 |
+
event_stream_name = shape.event_stream_name
|
| 159 |
+
if event_stream_name:
|
| 160 |
+
parsed = await self._handle_event_stream(
|
| 161 |
+
response, shape, event_stream_name
|
| 162 |
+
)
|
| 163 |
+
else:
|
| 164 |
+
parsed = {}
|
| 165 |
+
self._parse_payload(response, shape, parsed)
|
| 166 |
+
parsed['ResponseMetadata'] = self._populate_response_metadata(
|
| 167 |
+
response
|
| 168 |
+
)
|
| 169 |
+
return parsed
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
class AioRestJSONParser(RestJSONParser, AioBaseRestParser, AioBaseJSONParser):
|
| 173 |
+
EVENT_STREAM_PARSER_CLS = AioEventStreamJSONParser
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
class AioRpcV2CBORParser(
|
| 177 |
+
RpcV2CBORParser, AioBaseRpcV2Parser, AioBaseCBORParser
|
| 178 |
+
):
|
| 179 |
+
EVENT_STREAM_PARSER_CLS = AioEventStreamCBORParser
|
| 180 |
+
|
| 181 |
+
async def _handle_event_stream(self, response, shape, event_name):
|
| 182 |
+
event_stream_shape = shape.members[event_name]
|
| 183 |
+
event_stream = self._create_event_stream(response, event_stream_shape)
|
| 184 |
+
try:
|
| 185 |
+
event = await event_stream.get_initial_response()
|
| 186 |
+
except NoInitialResponseError:
|
| 187 |
+
error_msg = 'First event was not of type initial-response'
|
| 188 |
+
raise ResponseParserError(error_msg)
|
| 189 |
+
parsed = self._initial_body_parse(event.payload)
|
| 190 |
+
parsed[event_name] = event_stream
|
| 191 |
+
return parsed
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
class AioRestXMLParser(
|
| 195 |
+
RestXMLParser, AioBaseRestParser, AioBaseXMLResponseParser
|
| 196 |
+
):
|
| 197 |
+
EVENT_STREAM_PARSER_CLS = AioEventStreamXMLParser
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
PROTOCOL_PARSERS = {
|
| 201 |
+
'ec2': AioEC2QueryParser,
|
| 202 |
+
'query': AioQueryParser,
|
| 203 |
+
'json': AioJSONParser,
|
| 204 |
+
'rest-json': AioRestJSONParser,
|
| 205 |
+
'rest-xml': AioRestXMLParser,
|
| 206 |
+
'smithy-rpc-v2-cbor': AioRpcV2CBORParser,
|
| 207 |
+
}
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/regions.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
from botocore.exceptions import EndpointProviderError
|
| 5 |
+
from botocore.regions import EndpointRulesetResolver
|
| 6 |
+
|
| 7 |
+
from aiobotocore._helpers import resolve_awaitable
|
| 8 |
+
|
| 9 |
+
LOG = logging.getLogger(__name__)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class AioEndpointRulesetResolver(EndpointRulesetResolver):
|
| 13 |
+
async def construct_endpoint(
|
| 14 |
+
self,
|
| 15 |
+
operation_model,
|
| 16 |
+
call_args,
|
| 17 |
+
request_context,
|
| 18 |
+
):
|
| 19 |
+
"""Invokes the provider with params defined in the service's ruleset"""
|
| 20 |
+
if call_args is None:
|
| 21 |
+
call_args = {}
|
| 22 |
+
|
| 23 |
+
if request_context is None:
|
| 24 |
+
request_context = {}
|
| 25 |
+
|
| 26 |
+
provider_params = await self._get_provider_params(
|
| 27 |
+
operation_model, call_args, request_context
|
| 28 |
+
)
|
| 29 |
+
LOG.debug(
|
| 30 |
+
'Calling endpoint provider with parameters: %s', provider_params
|
| 31 |
+
)
|
| 32 |
+
try:
|
| 33 |
+
provider_result = self._provider.resolve_endpoint(
|
| 34 |
+
**provider_params
|
| 35 |
+
)
|
| 36 |
+
except EndpointProviderError as ex:
|
| 37 |
+
botocore_exception = self.ruleset_error_to_botocore_exception(
|
| 38 |
+
ex, provider_params
|
| 39 |
+
)
|
| 40 |
+
if botocore_exception is None:
|
| 41 |
+
raise
|
| 42 |
+
else:
|
| 43 |
+
raise botocore_exception from ex
|
| 44 |
+
LOG.debug('Endpoint provider result: %s', provider_result.url)
|
| 45 |
+
|
| 46 |
+
# The endpoint provider does not support non-secure transport.
|
| 47 |
+
if (
|
| 48 |
+
not self._use_ssl
|
| 49 |
+
and provider_result.url.startswith('https://')
|
| 50 |
+
and 'Endpoint' not in provider_params
|
| 51 |
+
):
|
| 52 |
+
provider_result = provider_result._replace(
|
| 53 |
+
url=f'http://{provider_result.url[8:]}'
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# Multi-valued headers are not supported in botocore. Replace the list
|
| 57 |
+
# of values returned for each header with just its first entry,
|
| 58 |
+
# dropping any additionally entries.
|
| 59 |
+
provider_result = provider_result._replace(
|
| 60 |
+
headers={
|
| 61 |
+
key: val[0] for key, val in provider_result.headers.items()
|
| 62 |
+
}
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
return provider_result
|
| 66 |
+
|
| 67 |
+
async def _get_provider_params(
|
| 68 |
+
self, operation_model, call_args, request_context
|
| 69 |
+
):
|
| 70 |
+
"""Resolve a value for each parameter defined in the service's ruleset
|
| 71 |
+
|
| 72 |
+
The resolution order for parameter values is:
|
| 73 |
+
1. Operation-specific static context values from the service definition
|
| 74 |
+
2. Operation-specific dynamic context values from API parameters
|
| 75 |
+
3. Client-specific context parameters
|
| 76 |
+
4. Built-in values such as region, FIPS usage, ...
|
| 77 |
+
"""
|
| 78 |
+
provider_params = {}
|
| 79 |
+
# Builtin values can be customized for each operation by hooks
|
| 80 |
+
# subscribing to the ``before-endpoint-resolution.*`` event.
|
| 81 |
+
customized_builtins = await self._get_customized_builtins(
|
| 82 |
+
operation_model, call_args, request_context
|
| 83 |
+
)
|
| 84 |
+
for param_name, param_def in self._param_definitions.items():
|
| 85 |
+
param_val = self._resolve_param_from_context(
|
| 86 |
+
param_name=param_name,
|
| 87 |
+
operation_model=operation_model,
|
| 88 |
+
call_args=call_args,
|
| 89 |
+
)
|
| 90 |
+
if param_val is None and param_def.builtin is not None:
|
| 91 |
+
param_val = await resolve_awaitable(
|
| 92 |
+
self._resolve_param_as_builtin(
|
| 93 |
+
builtin_name=param_def.builtin,
|
| 94 |
+
builtins=customized_builtins,
|
| 95 |
+
)
|
| 96 |
+
)
|
| 97 |
+
if param_val is not None:
|
| 98 |
+
provider_params[param_name] = param_val
|
| 99 |
+
self._register_endpoint_feature_ids(param_name, param_val)
|
| 100 |
+
|
| 101 |
+
return provider_params
|
| 102 |
+
|
| 103 |
+
async def _get_customized_builtins(
|
| 104 |
+
self, operation_model, call_args, request_context
|
| 105 |
+
):
|
| 106 |
+
service_id = self._service_model.service_id.hyphenize()
|
| 107 |
+
customized_builtins = copy.copy(self._builtins)
|
| 108 |
+
# Handlers are expected to modify the builtins dict in place.
|
| 109 |
+
await self._event_emitter.emit(
|
| 110 |
+
f'before-endpoint-resolution.{service_id}',
|
| 111 |
+
builtins=customized_builtins,
|
| 112 |
+
model=operation_model,
|
| 113 |
+
params=call_args,
|
| 114 |
+
context=request_context,
|
| 115 |
+
)
|
| 116 |
+
return customized_builtins
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/response.py
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
|
| 3 |
+
import aiohttp
|
| 4 |
+
import aiohttp.client_exceptions
|
| 5 |
+
import wrapt
|
| 6 |
+
from botocore.response import (
|
| 7 |
+
IncompleteReadError,
|
| 8 |
+
ReadTimeoutError,
|
| 9 |
+
ResponseStreamingError,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
from aiobotocore import parsers
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class AioReadTimeoutError(ReadTimeoutError, asyncio.TimeoutError):
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class StreamingBody(wrapt.ObjectProxy):
|
| 20 |
+
"""Wrapper class for an http response body.
|
| 21 |
+
|
| 22 |
+
This provides a few additional conveniences that do not exist
|
| 23 |
+
in the urllib3 model:
|
| 24 |
+
|
| 25 |
+
* Auto validation of content length, if the amount of bytes
|
| 26 |
+
we read does not match the content length, an exception
|
| 27 |
+
is raised.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
_DEFAULT_CHUNK_SIZE = 1024
|
| 31 |
+
|
| 32 |
+
def __init__(
|
| 33 |
+
self, raw_stream: aiohttp.ClientResponse, content_length: str
|
| 34 |
+
):
|
| 35 |
+
super().__init__(raw_stream)
|
| 36 |
+
self.__wrapped__: aiohttp.ClientResponse
|
| 37 |
+
self._self_content_length = content_length
|
| 38 |
+
self._self_amount_read = 0
|
| 39 |
+
|
| 40 |
+
# https://github.com/GrahamDumpleton/wrapt/issues/73
|
| 41 |
+
async def __aenter__(self):
|
| 42 |
+
return await self.__wrapped__.__aenter__()
|
| 43 |
+
|
| 44 |
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
| 45 |
+
return await self.__wrapped__.__aexit__(exc_type, exc_val, exc_tb)
|
| 46 |
+
|
| 47 |
+
# NOTE: set_socket_timeout was only for when requests didn't support
|
| 48 |
+
# read timeouts, so not needed
|
| 49 |
+
def readable(self):
|
| 50 |
+
return not self.at_eof()
|
| 51 |
+
|
| 52 |
+
async def read(self, amt=None):
|
| 53 |
+
"""Read at most amt bytes from the stream.
|
| 54 |
+
|
| 55 |
+
If the amt argument is omitted, read all data.
|
| 56 |
+
"""
|
| 57 |
+
# botocore to aiohttp mapping
|
| 58 |
+
try:
|
| 59 |
+
chunk = await self.__wrapped__.content.read(
|
| 60 |
+
amt if amt is not None else -1
|
| 61 |
+
)
|
| 62 |
+
except asyncio.TimeoutError as e:
|
| 63 |
+
raise AioReadTimeoutError(
|
| 64 |
+
endpoint_url=self.__wrapped__.url, error=e
|
| 65 |
+
)
|
| 66 |
+
except aiohttp.client_exceptions.ClientConnectionError as e:
|
| 67 |
+
raise ResponseStreamingError(error=e)
|
| 68 |
+
|
| 69 |
+
self._self_amount_read += len(chunk)
|
| 70 |
+
if amt is None or (not chunk and amt > 0):
|
| 71 |
+
# If the server sends empty contents or
|
| 72 |
+
# we ask to read all of the contents, then we know
|
| 73 |
+
# we need to verify the content length.
|
| 74 |
+
self._verify_content_length()
|
| 75 |
+
return chunk
|
| 76 |
+
|
| 77 |
+
async def readinto(self, b: bytearray):
|
| 78 |
+
"""Read bytes into a pre-allocated, writable bytes-like object b, and return the number of bytes read."""
|
| 79 |
+
try:
|
| 80 |
+
# AioHTTP ClientResponse does not support .readinto()
|
| 81 |
+
chunk = await self.__wrapped__.content.read(len(b))
|
| 82 |
+
amount_read = len(chunk)
|
| 83 |
+
b[:amount_read] = chunk
|
| 84 |
+
|
| 85 |
+
except asyncio.TimeoutError as e:
|
| 86 |
+
raise AioReadTimeoutError(
|
| 87 |
+
endpoint_url=self.__wrapped__.url, error=e
|
| 88 |
+
)
|
| 89 |
+
except aiohttp.client_exceptions.ClientConnectionError as e:
|
| 90 |
+
raise ResponseStreamingError(error=e)
|
| 91 |
+
|
| 92 |
+
self._self_amount_read += amount_read
|
| 93 |
+
if amount_read == 0 and len(b) > 0:
|
| 94 |
+
# If the server sends empty contents then we know we need to verify
|
| 95 |
+
# the content length.
|
| 96 |
+
self._verify_content_length()
|
| 97 |
+
return amount_read
|
| 98 |
+
|
| 99 |
+
async def readlines(self):
|
| 100 |
+
# assuming this is not an iterator
|
| 101 |
+
lines = [line async for line in self.iter_lines()]
|
| 102 |
+
return lines
|
| 103 |
+
|
| 104 |
+
def __aiter__(self):
|
| 105 |
+
"""Return an iterator to yield 1k chunks from the raw stream."""
|
| 106 |
+
return self.iter_chunks(self._DEFAULT_CHUNK_SIZE)
|
| 107 |
+
|
| 108 |
+
async def __anext__(self):
|
| 109 |
+
"""Return the next 1k chunk from the raw stream."""
|
| 110 |
+
current_chunk = await self.read(self._DEFAULT_CHUNK_SIZE)
|
| 111 |
+
if current_chunk:
|
| 112 |
+
return current_chunk
|
| 113 |
+
raise StopAsyncIteration
|
| 114 |
+
|
| 115 |
+
anext = __anext__
|
| 116 |
+
|
| 117 |
+
async def iter_lines(self, chunk_size=_DEFAULT_CHUNK_SIZE, keepends=False):
|
| 118 |
+
"""Return an iterator to yield lines from the raw stream.
|
| 119 |
+
|
| 120 |
+
This is achieved by reading chunk of bytes (of size chunk_size) at a
|
| 121 |
+
time from the raw stream, and then yielding lines from there.
|
| 122 |
+
"""
|
| 123 |
+
pending = b''
|
| 124 |
+
async for chunk in self.iter_chunks(chunk_size):
|
| 125 |
+
lines = (pending + chunk).splitlines(True)
|
| 126 |
+
for line in lines[:-1]:
|
| 127 |
+
yield line.splitlines(keepends)[0]
|
| 128 |
+
pending = lines[-1]
|
| 129 |
+
if pending:
|
| 130 |
+
yield pending.splitlines(keepends)[0]
|
| 131 |
+
|
| 132 |
+
async def iter_chunks(self, chunk_size=_DEFAULT_CHUNK_SIZE):
|
| 133 |
+
"""Return an iterator to yield chunks of chunk_size bytes from the raw
|
| 134 |
+
stream.
|
| 135 |
+
"""
|
| 136 |
+
while True:
|
| 137 |
+
current_chunk = await self.read(chunk_size)
|
| 138 |
+
if current_chunk == b"":
|
| 139 |
+
break
|
| 140 |
+
yield current_chunk
|
| 141 |
+
|
| 142 |
+
def _verify_content_length(self):
|
| 143 |
+
# See: https://github.com/kennethreitz/requests/issues/1855
|
| 144 |
+
# Basically, our http library doesn't do this for us, so we have
|
| 145 |
+
# to do this our self.
|
| 146 |
+
if (
|
| 147 |
+
self._self_content_length is not None
|
| 148 |
+
and self._self_amount_read != int(self._self_content_length)
|
| 149 |
+
):
|
| 150 |
+
raise IncompleteReadError(
|
| 151 |
+
actual_bytes=self._self_amount_read,
|
| 152 |
+
expected_bytes=int(self._self_content_length),
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
def tell(self):
|
| 156 |
+
return self._self_amount_read
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
# wraps httpx.Response
|
| 160 |
+
class HttpxStreamingBody(wrapt.ObjectProxy):
|
| 161 |
+
async def read(self, amt=None):
|
| 162 |
+
if amt is not None:
|
| 163 |
+
# We could do a fancy thing here and start doing calls to
|
| 164 |
+
# aiter_bytes()/aiter_raw() and keep state
|
| 165 |
+
raise ValueError(
|
| 166 |
+
"httpx.Response.aread does not support reading a specific number of bytes"
|
| 167 |
+
)
|
| 168 |
+
return await self.__wrapped__.aread()
|
| 169 |
+
|
| 170 |
+
async def __aenter__(self):
|
| 171 |
+
# use AsyncClient.stream somehow?
|
| 172 |
+
# See "manual mode" at https://www.python-httpx.org/async/#streaming-responses
|
| 173 |
+
return self
|
| 174 |
+
|
| 175 |
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
| 176 |
+
# When support for anyio/trio is added this needs a shielded cancelscope to
|
| 177 |
+
# avoid swallowing exceptions.
|
| 178 |
+
# See https://github.com/python-trio/trio/issues/455
|
| 179 |
+
await self.__wrapped__.aclose()
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
async def get_response(operation_model, http_response):
|
| 183 |
+
protocol = operation_model.service_model.resolved_protocol
|
| 184 |
+
response_dict = {
|
| 185 |
+
'headers': http_response.headers,
|
| 186 |
+
'status_code': http_response.status_code,
|
| 187 |
+
}
|
| 188 |
+
# TODO: Unfortunately, we have to have error logic here.
|
| 189 |
+
# If it looks like an error, in the streaming response case we
|
| 190 |
+
# need to actually grab the contents.
|
| 191 |
+
if response_dict['status_code'] >= 300:
|
| 192 |
+
response_dict['body'] = await http_response.content
|
| 193 |
+
elif operation_model.has_streaming_output:
|
| 194 |
+
response_dict['body'] = StreamingBody(
|
| 195 |
+
http_response.raw, response_dict['headers'].get('content-length')
|
| 196 |
+
)
|
| 197 |
+
else:
|
| 198 |
+
response_dict['body'] = await http_response.content
|
| 199 |
+
|
| 200 |
+
parser = parsers.create_parser(protocol)
|
| 201 |
+
parsed = await parser.parse(response_dict, operation_model.output_shape)
|
| 202 |
+
return http_response, parsed
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/retryhandler.py
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.retryhandler import (
|
| 2 |
+
ChecksumError,
|
| 3 |
+
CRC32Checker,
|
| 4 |
+
ExceptionRaiser,
|
| 5 |
+
HTTPStatusCodeChecker,
|
| 6 |
+
MaxAttemptsDecorator,
|
| 7 |
+
MultiChecker,
|
| 8 |
+
RetryHandler,
|
| 9 |
+
ServiceErrorCodeChecker,
|
| 10 |
+
_extract_retryable_exception,
|
| 11 |
+
crc32,
|
| 12 |
+
create_retry_action_from_config,
|
| 13 |
+
logger,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
from ._helpers import resolve_awaitable
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def create_retry_handler(config, operation_name=None):
|
| 20 |
+
checker = create_checker_from_retry_config(
|
| 21 |
+
config, operation_name=operation_name
|
| 22 |
+
)
|
| 23 |
+
action = create_retry_action_from_config(
|
| 24 |
+
config, operation_name=operation_name
|
| 25 |
+
)
|
| 26 |
+
return AioRetryHandler(checker=checker, action=action)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def create_checker_from_retry_config(config, operation_name=None):
|
| 30 |
+
checkers = []
|
| 31 |
+
max_attempts = None
|
| 32 |
+
retryable_exceptions = []
|
| 33 |
+
if '__default__' in config:
|
| 34 |
+
policies = config['__default__'].get('policies', [])
|
| 35 |
+
max_attempts = config['__default__']['max_attempts']
|
| 36 |
+
for key in policies:
|
| 37 |
+
current_config = policies[key]
|
| 38 |
+
checkers.append(_create_single_checker(current_config))
|
| 39 |
+
retry_exception = _extract_retryable_exception(current_config)
|
| 40 |
+
if retry_exception is not None:
|
| 41 |
+
retryable_exceptions.extend(retry_exception)
|
| 42 |
+
if operation_name is not None and config.get(operation_name) is not None:
|
| 43 |
+
operation_policies = config[operation_name]['policies']
|
| 44 |
+
for key in operation_policies:
|
| 45 |
+
checkers.append(_create_single_checker(operation_policies[key]))
|
| 46 |
+
retry_exception = _extract_retryable_exception(
|
| 47 |
+
operation_policies[key]
|
| 48 |
+
)
|
| 49 |
+
if retry_exception is not None:
|
| 50 |
+
retryable_exceptions.extend(retry_exception)
|
| 51 |
+
if len(checkers) == 1:
|
| 52 |
+
# Don't need to use a MultiChecker
|
| 53 |
+
return AioMaxAttemptsDecorator(checkers[0], max_attempts=max_attempts)
|
| 54 |
+
else:
|
| 55 |
+
multi_checker = AioMultiChecker(checkers)
|
| 56 |
+
return AioMaxAttemptsDecorator(
|
| 57 |
+
multi_checker,
|
| 58 |
+
max_attempts=max_attempts,
|
| 59 |
+
retryable_exceptions=tuple(retryable_exceptions),
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _create_single_checker(config):
|
| 64 |
+
if 'response' in config['applies_when']:
|
| 65 |
+
return _create_single_response_checker(
|
| 66 |
+
config['applies_when']['response']
|
| 67 |
+
)
|
| 68 |
+
elif 'socket_errors' in config['applies_when']:
|
| 69 |
+
return ExceptionRaiser()
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def _create_single_response_checker(response):
|
| 73 |
+
if 'service_error_code' in response:
|
| 74 |
+
checker = ServiceErrorCodeChecker(
|
| 75 |
+
status_code=response['http_status_code'],
|
| 76 |
+
error_code=response['service_error_code'],
|
| 77 |
+
)
|
| 78 |
+
elif 'http_status_code' in response:
|
| 79 |
+
checker = HTTPStatusCodeChecker(
|
| 80 |
+
status_code=response['http_status_code']
|
| 81 |
+
)
|
| 82 |
+
elif 'crc32body' in response:
|
| 83 |
+
checker = AioCRC32Checker(header=response['crc32body'])
|
| 84 |
+
else:
|
| 85 |
+
# TODO: send a signal.
|
| 86 |
+
raise ValueError("Unknown retry policy")
|
| 87 |
+
return checker
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class AioRetryHandler(RetryHandler):
|
| 91 |
+
async def _call(self, attempts, response, caught_exception, **kwargs):
|
| 92 |
+
"""Handler for a retry.
|
| 93 |
+
|
| 94 |
+
Intended to be hooked up to an event handler (hence the **kwargs),
|
| 95 |
+
this will process retries appropriately.
|
| 96 |
+
|
| 97 |
+
"""
|
| 98 |
+
checker_kwargs = {
|
| 99 |
+
'attempt_number': attempts,
|
| 100 |
+
'response': response,
|
| 101 |
+
'caught_exception': caught_exception,
|
| 102 |
+
}
|
| 103 |
+
if isinstance(self._checker, MaxAttemptsDecorator):
|
| 104 |
+
retries_context = kwargs['request_dict']['context'].get('retries')
|
| 105 |
+
checker_kwargs.update({'retries_context': retries_context})
|
| 106 |
+
|
| 107 |
+
if await resolve_awaitable(self._checker(**checker_kwargs)):
|
| 108 |
+
result = self._action(attempts=attempts)
|
| 109 |
+
logger.debug("Retry needed, action of: %s", result)
|
| 110 |
+
return result
|
| 111 |
+
logger.debug("No retry needed.")
|
| 112 |
+
|
| 113 |
+
def __call__(self, *args, **kwargs):
|
| 114 |
+
return self._call(*args, **kwargs) # return awaitable
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class AioMaxAttemptsDecorator(MaxAttemptsDecorator):
|
| 118 |
+
async def _call(
|
| 119 |
+
self, attempt_number, response, caught_exception, retries_context
|
| 120 |
+
):
|
| 121 |
+
if retries_context:
|
| 122 |
+
retries_context['max'] = max(
|
| 123 |
+
retries_context.get('max', 0), self._max_attempts
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
should_retry = await self._should_retry(
|
| 127 |
+
attempt_number, response, caught_exception
|
| 128 |
+
)
|
| 129 |
+
if should_retry:
|
| 130 |
+
if attempt_number >= self._max_attempts:
|
| 131 |
+
# explicitly set MaxAttemptsReached
|
| 132 |
+
if response is not None and 'ResponseMetadata' in response[1]:
|
| 133 |
+
response[1]['ResponseMetadata']['MaxAttemptsReached'] = (
|
| 134 |
+
True
|
| 135 |
+
)
|
| 136 |
+
logger.debug(
|
| 137 |
+
"Reached the maximum number of retry attempts: %s",
|
| 138 |
+
attempt_number,
|
| 139 |
+
)
|
| 140 |
+
return False
|
| 141 |
+
else:
|
| 142 |
+
return should_retry
|
| 143 |
+
else:
|
| 144 |
+
return False
|
| 145 |
+
|
| 146 |
+
def __call__(self, *args, **kwargs):
|
| 147 |
+
return self._call(*args, **kwargs)
|
| 148 |
+
|
| 149 |
+
async def _should_retry(self, attempt_number, response, caught_exception):
|
| 150 |
+
if self._retryable_exceptions and attempt_number < self._max_attempts:
|
| 151 |
+
try:
|
| 152 |
+
return await resolve_awaitable(
|
| 153 |
+
self._checker(attempt_number, response, caught_exception)
|
| 154 |
+
)
|
| 155 |
+
except self._retryable_exceptions as e:
|
| 156 |
+
logger.debug(
|
| 157 |
+
"retry needed, retryable exception caught: %s",
|
| 158 |
+
e,
|
| 159 |
+
exc_info=True,
|
| 160 |
+
)
|
| 161 |
+
return True
|
| 162 |
+
else:
|
| 163 |
+
# If we've exceeded the max attempts we just let the exception
|
| 164 |
+
# propagate if one has occurred.
|
| 165 |
+
return await resolve_awaitable(
|
| 166 |
+
self._checker(attempt_number, response, caught_exception)
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
class AioMultiChecker(MultiChecker):
|
| 171 |
+
async def _call(self, attempt_number, response, caught_exception):
|
| 172 |
+
for checker in self._checkers:
|
| 173 |
+
checker_response = await resolve_awaitable(
|
| 174 |
+
checker(attempt_number, response, caught_exception)
|
| 175 |
+
)
|
| 176 |
+
if checker_response:
|
| 177 |
+
return checker_response
|
| 178 |
+
return False
|
| 179 |
+
|
| 180 |
+
def __call__(self, *args, **kwargs):
|
| 181 |
+
return self._call(*args, **kwargs)
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
class AioCRC32Checker(CRC32Checker):
|
| 185 |
+
async def _call(self, attempt_number, response, caught_exception):
|
| 186 |
+
if response is not None:
|
| 187 |
+
return await self._check_response(attempt_number, response)
|
| 188 |
+
elif caught_exception is not None:
|
| 189 |
+
return self._check_caught_exception(
|
| 190 |
+
attempt_number, caught_exception
|
| 191 |
+
)
|
| 192 |
+
else:
|
| 193 |
+
raise ValueError("Both response and caught_exception are None.")
|
| 194 |
+
|
| 195 |
+
def __call__(self, *args, **kwargs):
|
| 196 |
+
return self._call(*args, **kwargs)
|
| 197 |
+
|
| 198 |
+
async def _check_response(self, attempt_number, response):
|
| 199 |
+
http_response = response[0]
|
| 200 |
+
expected_crc = http_response.headers.get(self._header_name)
|
| 201 |
+
if expected_crc is None:
|
| 202 |
+
logger.debug(
|
| 203 |
+
"crc32 check skipped, the %s header is not "
|
| 204 |
+
"in the http response.",
|
| 205 |
+
self._header_name,
|
| 206 |
+
)
|
| 207 |
+
else:
|
| 208 |
+
actual_crc32 = crc32(await response[0].content) & 0xFFFFFFFF
|
| 209 |
+
if not actual_crc32 == int(expected_crc):
|
| 210 |
+
logger.debug(
|
| 211 |
+
"retry needed: crc32 check failed, expected != actual: "
|
| 212 |
+
"%s != %s",
|
| 213 |
+
int(expected_crc),
|
| 214 |
+
actual_crc32,
|
| 215 |
+
)
|
| 216 |
+
raise ChecksumError(
|
| 217 |
+
checksum_type='crc32',
|
| 218 |
+
expected_checksum=int(expected_crc),
|
| 219 |
+
actual_checksum=actual_crc32,
|
| 220 |
+
)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/session.py
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore import UNSIGNED, translate
|
| 2 |
+
from botocore import __version__ as botocore_version
|
| 3 |
+
from botocore.context import get_context
|
| 4 |
+
from botocore.exceptions import PartialCredentialsError
|
| 5 |
+
from botocore.session import (
|
| 6 |
+
EVENT_ALIASES,
|
| 7 |
+
ServiceModel,
|
| 8 |
+
UnknownServiceError,
|
| 9 |
+
copy,
|
| 10 |
+
logger,
|
| 11 |
+
)
|
| 12 |
+
from botocore.session import Session as _SyncSession
|
| 13 |
+
from botocore.useragent import register_feature_id
|
| 14 |
+
|
| 15 |
+
from . import __version__, retryhandler
|
| 16 |
+
from .client import AioBaseClient, AioClientCreator
|
| 17 |
+
from .configprovider import AioSmartDefaultsConfigStoreFactory
|
| 18 |
+
from .context import with_current_context
|
| 19 |
+
from .credentials import AioCredentials, create_credential_resolver
|
| 20 |
+
from .hooks import AioHierarchicalEmitter
|
| 21 |
+
from .parsers import AioResponseParserFactory
|
| 22 |
+
from .tokens import create_token_resolver
|
| 23 |
+
from .utils import AioIMDSRegionProvider
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class ClientCreatorContext:
|
| 27 |
+
def __init__(self, coro):
|
| 28 |
+
self._coro = coro
|
| 29 |
+
self._client = None
|
| 30 |
+
|
| 31 |
+
async def __aenter__(self) -> AioBaseClient:
|
| 32 |
+
self._client = await self._coro
|
| 33 |
+
return await self._client.__aenter__()
|
| 34 |
+
|
| 35 |
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
| 36 |
+
await self._client.__aexit__(exc_type, exc_val, exc_tb)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class AioSession(_SyncSession):
|
| 40 |
+
# noinspection PyMissingConstructor
|
| 41 |
+
def __init__(
|
| 42 |
+
self,
|
| 43 |
+
session_vars=None,
|
| 44 |
+
event_hooks=None,
|
| 45 |
+
include_builtin_handlers=True,
|
| 46 |
+
profile=None,
|
| 47 |
+
):
|
| 48 |
+
if event_hooks is None:
|
| 49 |
+
event_hooks = AioHierarchicalEmitter()
|
| 50 |
+
|
| 51 |
+
super().__init__(
|
| 52 |
+
session_vars, event_hooks, include_builtin_handlers, profile
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
self._set_user_agent_for_session()
|
| 56 |
+
|
| 57 |
+
def _set_user_agent_for_session(self):
|
| 58 |
+
# Mimic approach taken by AWS's aws-cli project
|
| 59 |
+
# https://github.com/aws/aws-cli/blob/b862122c76a3f280ff34e93c9dcafaf964e7bf9b/awscli/clidriver.py#L84
|
| 60 |
+
|
| 61 |
+
self.user_agent_name = 'aiobotocore'
|
| 62 |
+
self.user_agent_version = __version__
|
| 63 |
+
self.user_agent_extra = f'botocore/{botocore_version}'
|
| 64 |
+
|
| 65 |
+
def _create_token_resolver(self):
|
| 66 |
+
return create_token_resolver(self)
|
| 67 |
+
|
| 68 |
+
def _create_credential_resolver(self):
|
| 69 |
+
return create_credential_resolver(
|
| 70 |
+
self, region_name=self._last_client_region_used
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
def _register_smart_defaults_factory(self):
|
| 74 |
+
def create_smart_defaults_factory():
|
| 75 |
+
default_config_resolver = self._get_internal_component(
|
| 76 |
+
'default_config_resolver'
|
| 77 |
+
)
|
| 78 |
+
imds_region_provider = AioIMDSRegionProvider(session=self)
|
| 79 |
+
return AioSmartDefaultsConfigStoreFactory(
|
| 80 |
+
default_config_resolver, imds_region_provider
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
self._internal_components.lazy_register_component(
|
| 84 |
+
'smart_defaults_factory', create_smart_defaults_factory
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
def _register_response_parser_factory(self):
|
| 88 |
+
self._components.register_component(
|
| 89 |
+
'response_parser_factory', AioResponseParserFactory()
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
def set_credentials(
|
| 93 |
+
self, access_key, secret_key, token=None, account_id=None
|
| 94 |
+
):
|
| 95 |
+
self._credentials = AioCredentials(
|
| 96 |
+
access_key, secret_key, token, account_id=account_id
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
async def get_credentials(self):
|
| 100 |
+
if self._credentials is None:
|
| 101 |
+
self._credentials = await self._components.get_component(
|
| 102 |
+
'credential_provider'
|
| 103 |
+
).load_credentials()
|
| 104 |
+
return self._credentials
|
| 105 |
+
|
| 106 |
+
async def get_service_model(self, service_name, api_version=None):
|
| 107 |
+
service_description = await self.get_service_data(
|
| 108 |
+
service_name, api_version
|
| 109 |
+
)
|
| 110 |
+
return ServiceModel(service_description, service_name=service_name)
|
| 111 |
+
|
| 112 |
+
async def get_service_data(self, service_name, api_version=None):
|
| 113 |
+
"""
|
| 114 |
+
Retrieve the fully merged data associated with a service.
|
| 115 |
+
"""
|
| 116 |
+
data_path = service_name
|
| 117 |
+
service_data = self.get_component('data_loader').load_service_model(
|
| 118 |
+
data_path, type_name='service-2', api_version=api_version
|
| 119 |
+
)
|
| 120 |
+
service_id = EVENT_ALIASES.get(service_name, service_name)
|
| 121 |
+
await self._events.emit(
|
| 122 |
+
f'service-data-loaded.{service_id}',
|
| 123 |
+
service_data=service_data,
|
| 124 |
+
service_name=service_name,
|
| 125 |
+
session=self,
|
| 126 |
+
)
|
| 127 |
+
return service_data
|
| 128 |
+
|
| 129 |
+
def create_client(self, *args, **kwargs):
|
| 130 |
+
return ClientCreatorContext(self._create_client(*args, **kwargs))
|
| 131 |
+
|
| 132 |
+
@with_current_context()
|
| 133 |
+
async def _create_client(
|
| 134 |
+
self,
|
| 135 |
+
service_name,
|
| 136 |
+
region_name=None,
|
| 137 |
+
api_version=None,
|
| 138 |
+
use_ssl=True,
|
| 139 |
+
verify=None,
|
| 140 |
+
endpoint_url=None,
|
| 141 |
+
aws_access_key_id=None,
|
| 142 |
+
aws_secret_access_key=None,
|
| 143 |
+
aws_session_token=None,
|
| 144 |
+
config=None,
|
| 145 |
+
aws_account_id=None,
|
| 146 |
+
):
|
| 147 |
+
default_client_config = self.get_default_client_config()
|
| 148 |
+
# If a config is provided and a default config is set, then
|
| 149 |
+
# use the config resulting from merging the two.
|
| 150 |
+
if config is not None and default_client_config is not None:
|
| 151 |
+
config = default_client_config.merge(config)
|
| 152 |
+
# If a config was not provided then use the default
|
| 153 |
+
# client config from the session
|
| 154 |
+
elif default_client_config is not None:
|
| 155 |
+
config = default_client_config
|
| 156 |
+
|
| 157 |
+
region_name = self._resolve_region_name(region_name, config)
|
| 158 |
+
|
| 159 |
+
# Figure out the verify value base on the various
|
| 160 |
+
# configuration options.
|
| 161 |
+
if verify is None:
|
| 162 |
+
verify = self.get_config_variable('ca_bundle')
|
| 163 |
+
|
| 164 |
+
if api_version is None:
|
| 165 |
+
api_version = self.get_config_variable('api_versions').get(
|
| 166 |
+
service_name, None
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
loader = self.get_component('data_loader')
|
| 170 |
+
event_emitter = self.get_component('event_emitter')
|
| 171 |
+
response_parser_factory = self.get_component('response_parser_factory')
|
| 172 |
+
if config is not None and config.signature_version is UNSIGNED:
|
| 173 |
+
credentials = None
|
| 174 |
+
elif (
|
| 175 |
+
aws_access_key_id is not None and aws_secret_access_key is not None
|
| 176 |
+
):
|
| 177 |
+
credentials = AioCredentials(
|
| 178 |
+
access_key=aws_access_key_id,
|
| 179 |
+
secret_key=aws_secret_access_key,
|
| 180 |
+
token=aws_session_token,
|
| 181 |
+
account_id=aws_account_id,
|
| 182 |
+
)
|
| 183 |
+
elif self._missing_cred_vars(aws_access_key_id, aws_secret_access_key):
|
| 184 |
+
raise PartialCredentialsError(
|
| 185 |
+
provider='explicit',
|
| 186 |
+
cred_var=self._missing_cred_vars(
|
| 187 |
+
aws_access_key_id, aws_secret_access_key
|
| 188 |
+
),
|
| 189 |
+
)
|
| 190 |
+
else:
|
| 191 |
+
if ignored_credentials := self._get_ignored_credentials(
|
| 192 |
+
aws_session_token, aws_account_id
|
| 193 |
+
):
|
| 194 |
+
logger.debug(
|
| 195 |
+
"Ignoring the following credential-related values which were set without "
|
| 196 |
+
"an access key id and secret key on the session or client: %s",
|
| 197 |
+
ignored_credentials,
|
| 198 |
+
)
|
| 199 |
+
credentials = await self.get_credentials()
|
| 200 |
+
if getattr(credentials, 'method', None) == 'explicit':
|
| 201 |
+
register_feature_id('CREDENTIALS_CODE')
|
| 202 |
+
auth_token = self.get_auth_token()
|
| 203 |
+
endpoint_resolver = self._get_internal_component('endpoint_resolver')
|
| 204 |
+
exceptions_factory = self._get_internal_component('exceptions_factory')
|
| 205 |
+
config_store = copy.copy(self.get_component('config_store'))
|
| 206 |
+
user_agent_creator = self.get_component('user_agent_creator')
|
| 207 |
+
# Session configuration values for the user agent string are applied
|
| 208 |
+
# just before each client creation because they may have been modified
|
| 209 |
+
# at any time between session creation and client creation.
|
| 210 |
+
user_agent_creator.set_session_config(
|
| 211 |
+
session_user_agent_name=self.user_agent_name,
|
| 212 |
+
session_user_agent_version=self.user_agent_version,
|
| 213 |
+
session_user_agent_extra=self.user_agent_extra,
|
| 214 |
+
)
|
| 215 |
+
defaults_mode = self._resolve_defaults_mode(config, config_store)
|
| 216 |
+
if defaults_mode != 'legacy':
|
| 217 |
+
smart_defaults_factory = self._get_internal_component(
|
| 218 |
+
'smart_defaults_factory'
|
| 219 |
+
)
|
| 220 |
+
await smart_defaults_factory.merge_smart_defaults(
|
| 221 |
+
config_store, defaults_mode, region_name
|
| 222 |
+
)
|
| 223 |
+
self._add_configured_endpoint_provider(
|
| 224 |
+
client_name=service_name,
|
| 225 |
+
config_store=config_store,
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
user_agent_creator.set_client_features(get_context().features)
|
| 229 |
+
|
| 230 |
+
client_creator = AioClientCreator(
|
| 231 |
+
loader,
|
| 232 |
+
endpoint_resolver,
|
| 233 |
+
self.user_agent(),
|
| 234 |
+
event_emitter,
|
| 235 |
+
retryhandler,
|
| 236 |
+
translate,
|
| 237 |
+
response_parser_factory,
|
| 238 |
+
exceptions_factory,
|
| 239 |
+
config_store,
|
| 240 |
+
user_agent_creator=user_agent_creator,
|
| 241 |
+
auth_token_resolver=self.get_auth_token,
|
| 242 |
+
)
|
| 243 |
+
client = await client_creator.create_client(
|
| 244 |
+
service_name=service_name,
|
| 245 |
+
region_name=region_name,
|
| 246 |
+
is_secure=use_ssl,
|
| 247 |
+
endpoint_url=endpoint_url,
|
| 248 |
+
verify=verify,
|
| 249 |
+
credentials=credentials,
|
| 250 |
+
scoped_config=self.get_scoped_config(),
|
| 251 |
+
client_config=config,
|
| 252 |
+
api_version=api_version,
|
| 253 |
+
auth_token=auth_token,
|
| 254 |
+
)
|
| 255 |
+
monitor = self._get_internal_component('monitor')
|
| 256 |
+
if monitor is not None:
|
| 257 |
+
monitor.register(client.meta.events)
|
| 258 |
+
self._register_client_plugins(client)
|
| 259 |
+
return client
|
| 260 |
+
|
| 261 |
+
async def get_available_regions(
|
| 262 |
+
self, service_name, partition_name='aws', allow_non_regional=False
|
| 263 |
+
):
|
| 264 |
+
resolver = self._get_internal_component('endpoint_resolver')
|
| 265 |
+
results = []
|
| 266 |
+
try:
|
| 267 |
+
service_data = await self.get_service_data(service_name)
|
| 268 |
+
endpoint_prefix = service_data['metadata'].get(
|
| 269 |
+
'endpointPrefix', service_name
|
| 270 |
+
)
|
| 271 |
+
results = resolver.get_available_endpoints(
|
| 272 |
+
endpoint_prefix, partition_name, allow_non_regional
|
| 273 |
+
)
|
| 274 |
+
except UnknownServiceError:
|
| 275 |
+
pass
|
| 276 |
+
return results
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def get_session(env_vars=None):
|
| 280 |
+
"""
|
| 281 |
+
Return a new session object.
|
| 282 |
+
"""
|
| 283 |
+
return AioSession(env_vars)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/signers.py
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime
|
| 2 |
+
|
| 3 |
+
import botocore
|
| 4 |
+
import botocore.auth
|
| 5 |
+
from botocore.compat import get_current_datetime
|
| 6 |
+
from botocore.exceptions import ParamValidationError, UnknownClientMethodError
|
| 7 |
+
from botocore.signers import (
|
| 8 |
+
RequestSigner,
|
| 9 |
+
S3PostPresigner,
|
| 10 |
+
UnknownSignatureVersionError,
|
| 11 |
+
UnsupportedSignatureVersionError,
|
| 12 |
+
_should_use_global_endpoint,
|
| 13 |
+
create_request_object,
|
| 14 |
+
prepare_request_dict,
|
| 15 |
+
)
|
| 16 |
+
from botocore.tokens import FrozenAuthToken
|
| 17 |
+
from botocore.utils import ArnParser
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class AioRequestSigner(RequestSigner):
|
| 21 |
+
async def handler(self, operation_name=None, request=None, **kwargs):
|
| 22 |
+
# This is typically hooked up to the "request-created" event
|
| 23 |
+
# from a client's event emitter. When a new request is created
|
| 24 |
+
# this method is invoked to sign the request.
|
| 25 |
+
# Don't call this method directly.
|
| 26 |
+
return await self.sign(operation_name, request)
|
| 27 |
+
|
| 28 |
+
async def sign(
|
| 29 |
+
self,
|
| 30 |
+
operation_name,
|
| 31 |
+
request,
|
| 32 |
+
region_name=None,
|
| 33 |
+
signing_type='standard',
|
| 34 |
+
expires_in=None,
|
| 35 |
+
signing_name=None,
|
| 36 |
+
):
|
| 37 |
+
explicit_region_name = region_name
|
| 38 |
+
if region_name is None:
|
| 39 |
+
region_name = self._region_name
|
| 40 |
+
|
| 41 |
+
if signing_name is None:
|
| 42 |
+
signing_name = self._signing_name
|
| 43 |
+
|
| 44 |
+
signature_version = await self._choose_signer(
|
| 45 |
+
operation_name, signing_type, request.context
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Allow mutating request before signing
|
| 49 |
+
await self._event_emitter.emit(
|
| 50 |
+
f'before-sign.{self._service_id.hyphenize()}.{operation_name}',
|
| 51 |
+
request=request,
|
| 52 |
+
signing_name=signing_name,
|
| 53 |
+
region_name=self._region_name,
|
| 54 |
+
signature_version=signature_version,
|
| 55 |
+
request_signer=self,
|
| 56 |
+
operation_name=operation_name,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
if signature_version != botocore.UNSIGNED:
|
| 60 |
+
kwargs = {
|
| 61 |
+
'signing_name': signing_name,
|
| 62 |
+
'region_name': region_name,
|
| 63 |
+
'signature_version': signature_version,
|
| 64 |
+
}
|
| 65 |
+
if expires_in is not None:
|
| 66 |
+
kwargs['expires'] = expires_in
|
| 67 |
+
signing_context = request.context.get('signing', {})
|
| 68 |
+
if not explicit_region_name and signing_context.get('region'):
|
| 69 |
+
kwargs['region_name'] = signing_context['region']
|
| 70 |
+
if signing_context.get('signing_name'):
|
| 71 |
+
kwargs['signing_name'] = signing_context['signing_name']
|
| 72 |
+
if signing_context.get('request_credentials'):
|
| 73 |
+
kwargs['request_credentials'] = signing_context[
|
| 74 |
+
'request_credentials'
|
| 75 |
+
]
|
| 76 |
+
if signing_context.get('identity_cache') is not None:
|
| 77 |
+
self._resolve_identity_cache(
|
| 78 |
+
kwargs,
|
| 79 |
+
signing_context['identity_cache'],
|
| 80 |
+
signing_context['cache_key'],
|
| 81 |
+
)
|
| 82 |
+
try:
|
| 83 |
+
auth = await self.get_auth_instance(**kwargs)
|
| 84 |
+
except UnknownSignatureVersionError as e:
|
| 85 |
+
if signing_type != 'standard':
|
| 86 |
+
raise UnsupportedSignatureVersionError(
|
| 87 |
+
signature_version=signature_version
|
| 88 |
+
)
|
| 89 |
+
else:
|
| 90 |
+
raise e
|
| 91 |
+
|
| 92 |
+
auth.add_auth(request)
|
| 93 |
+
|
| 94 |
+
async def _choose_signer(self, operation_name, signing_type, context):
|
| 95 |
+
signing_type_suffix_map = {
|
| 96 |
+
'presign-post': '-presign-post',
|
| 97 |
+
'presign-url': '-query',
|
| 98 |
+
}
|
| 99 |
+
suffix = signing_type_suffix_map.get(signing_type, '')
|
| 100 |
+
|
| 101 |
+
# operation specific signing context takes precedent over client-level
|
| 102 |
+
# defaults
|
| 103 |
+
signature_version = context.get('auth_type') or self._signature_version
|
| 104 |
+
signing = context.get('signing', {})
|
| 105 |
+
signing_name = signing.get('signing_name', self._signing_name)
|
| 106 |
+
region_name = signing.get('region', self._region_name)
|
| 107 |
+
if (
|
| 108 |
+
signature_version is not botocore.UNSIGNED
|
| 109 |
+
and not signature_version.endswith(suffix)
|
| 110 |
+
):
|
| 111 |
+
signature_version += suffix
|
| 112 |
+
|
| 113 |
+
handler, response = await self._event_emitter.emit_until_response(
|
| 114 |
+
f'choose-signer.{self._service_id.hyphenize()}.{operation_name}',
|
| 115 |
+
signing_name=signing_name,
|
| 116 |
+
region_name=region_name,
|
| 117 |
+
signature_version=signature_version,
|
| 118 |
+
context=context,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
if response is not None:
|
| 122 |
+
signature_version = response
|
| 123 |
+
# The suffix needs to be checked again in case we get an improper
|
| 124 |
+
# signature version from choose-signer.
|
| 125 |
+
if (
|
| 126 |
+
signature_version is not botocore.UNSIGNED
|
| 127 |
+
and not signature_version.endswith(suffix)
|
| 128 |
+
):
|
| 129 |
+
signature_version += suffix
|
| 130 |
+
|
| 131 |
+
return signature_version
|
| 132 |
+
|
| 133 |
+
async def get_auth_instance(
|
| 134 |
+
self,
|
| 135 |
+
signing_name,
|
| 136 |
+
region_name,
|
| 137 |
+
signature_version=None,
|
| 138 |
+
request_credentials=None,
|
| 139 |
+
**kwargs,
|
| 140 |
+
):
|
| 141 |
+
if signature_version is None:
|
| 142 |
+
signature_version = self._signature_version
|
| 143 |
+
|
| 144 |
+
cls = botocore.auth.AUTH_TYPE_MAPS.get(signature_version)
|
| 145 |
+
if cls is None:
|
| 146 |
+
raise UnknownSignatureVersionError(
|
| 147 |
+
signature_version=signature_version
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
if cls.REQUIRES_TOKEN is True:
|
| 151 |
+
if self._auth_token and not isinstance(
|
| 152 |
+
self._auth_token, FrozenAuthToken
|
| 153 |
+
):
|
| 154 |
+
frozen_token = await self._auth_token.get_frozen_token()
|
| 155 |
+
else:
|
| 156 |
+
frozen_token = self._auth_token
|
| 157 |
+
auth = cls(frozen_token)
|
| 158 |
+
return auth
|
| 159 |
+
|
| 160 |
+
credentials = request_credentials or self._credentials
|
| 161 |
+
if getattr(cls, "REQUIRES_IDENTITY_CACHE", None) is True:
|
| 162 |
+
cache = kwargs["identity_cache"]
|
| 163 |
+
key = kwargs["cache_key"]
|
| 164 |
+
credentials = await cache.get_credentials(key)
|
| 165 |
+
del kwargs["cache_key"]
|
| 166 |
+
|
| 167 |
+
frozen_credentials = None
|
| 168 |
+
if credentials is not None:
|
| 169 |
+
frozen_credentials = await credentials.get_frozen_credentials()
|
| 170 |
+
kwargs['credentials'] = frozen_credentials
|
| 171 |
+
if cls.REQUIRES_REGION:
|
| 172 |
+
if self._region_name is None:
|
| 173 |
+
raise botocore.exceptions.NoRegionError()
|
| 174 |
+
kwargs['region_name'] = region_name
|
| 175 |
+
kwargs['service_name'] = signing_name
|
| 176 |
+
auth = cls(**kwargs)
|
| 177 |
+
return auth
|
| 178 |
+
|
| 179 |
+
# Alias get_auth for backwards compatibility.
|
| 180 |
+
get_auth = get_auth_instance
|
| 181 |
+
|
| 182 |
+
async def generate_presigned_url(
|
| 183 |
+
self,
|
| 184 |
+
request_dict,
|
| 185 |
+
operation_name,
|
| 186 |
+
expires_in=3600,
|
| 187 |
+
region_name=None,
|
| 188 |
+
signing_name=None,
|
| 189 |
+
):
|
| 190 |
+
request = create_request_object(request_dict)
|
| 191 |
+
await self.sign(
|
| 192 |
+
operation_name,
|
| 193 |
+
request,
|
| 194 |
+
region_name,
|
| 195 |
+
'presign-url',
|
| 196 |
+
expires_in,
|
| 197 |
+
signing_name,
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
request.prepare()
|
| 201 |
+
return request.url
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def add_generate_db_auth_token(class_attributes, **kwargs):
|
| 205 |
+
class_attributes['generate_db_auth_token'] = generate_db_auth_token
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def add_dsql_generate_db_auth_token_methods(class_attributes, **kwargs):
|
| 209 |
+
class_attributes['generate_db_connect_auth_token'] = (
|
| 210 |
+
dsql_generate_db_connect_auth_token
|
| 211 |
+
)
|
| 212 |
+
class_attributes['generate_db_connect_admin_auth_token'] = (
|
| 213 |
+
dsql_generate_db_connect_admin_auth_token
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
async def generate_db_auth_token(
|
| 218 |
+
self, DBHostname, Port, DBUsername, Region=None
|
| 219 |
+
):
|
| 220 |
+
"""Generates an auth token used to connect to a db with IAM credentials.
|
| 221 |
+
|
| 222 |
+
:type DBHostname: str
|
| 223 |
+
:param DBHostname: The hostname of the database to connect to.
|
| 224 |
+
|
| 225 |
+
:type Port: int
|
| 226 |
+
:param Port: The port number the database is listening on.
|
| 227 |
+
|
| 228 |
+
:type DBUsername: str
|
| 229 |
+
:param DBUsername: The username to log in as.
|
| 230 |
+
|
| 231 |
+
:type Region: str
|
| 232 |
+
:param Region: The region the database is in. If None, the client
|
| 233 |
+
region will be used.
|
| 234 |
+
|
| 235 |
+
:return: A presigned url which can be used as an auth token.
|
| 236 |
+
"""
|
| 237 |
+
region = Region
|
| 238 |
+
if region is None:
|
| 239 |
+
region = self.meta.region_name
|
| 240 |
+
|
| 241 |
+
params = {
|
| 242 |
+
'Action': 'connect',
|
| 243 |
+
'DBUser': DBUsername,
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
request_dict = {
|
| 247 |
+
'url_path': '/',
|
| 248 |
+
'query_string': '',
|
| 249 |
+
'headers': {},
|
| 250 |
+
'body': params,
|
| 251 |
+
'method': 'GET',
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
# RDS requires that the scheme not be set when sent over. This can cause
|
| 255 |
+
# issues when signing because the Python url parsing libraries follow
|
| 256 |
+
# RFC 1808 closely, which states that a netloc must be introduced by `//`.
|
| 257 |
+
# Otherwise the url is presumed to be relative, and thus the whole
|
| 258 |
+
# netloc would be treated as a path component. To work around this we
|
| 259 |
+
# introduce https here and remove it once we're done processing it.
|
| 260 |
+
scheme = 'https://'
|
| 261 |
+
endpoint_url = f'{scheme}{DBHostname}:{Port}'
|
| 262 |
+
prepare_request_dict(request_dict, endpoint_url)
|
| 263 |
+
presigned_url = await self._request_signer.generate_presigned_url(
|
| 264 |
+
operation_name='connect',
|
| 265 |
+
request_dict=request_dict,
|
| 266 |
+
region_name=region,
|
| 267 |
+
expires_in=900,
|
| 268 |
+
signing_name='rds-db',
|
| 269 |
+
)
|
| 270 |
+
return presigned_url[len(scheme) :]
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
async def _dsql_generate_db_auth_token(
|
| 274 |
+
self, Hostname, Action, Region=None, ExpiresIn=900
|
| 275 |
+
):
|
| 276 |
+
"""Generate a DSQL database token for an arbitrary action.
|
| 277 |
+
:type Hostname: str
|
| 278 |
+
:param Hostname: The DSQL endpoint host name.
|
| 279 |
+
:type Action: str
|
| 280 |
+
:param Action: Action to perform on the cluster (DbConnectAdmin or DbConnect).
|
| 281 |
+
:type Region: str
|
| 282 |
+
:param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.
|
| 283 |
+
:type ExpiresIn: int
|
| 284 |
+
:param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).
|
| 285 |
+
:return: A presigned url which can be used as an auth token.
|
| 286 |
+
"""
|
| 287 |
+
possible_actions = ("DbConnect", "DbConnectAdmin")
|
| 288 |
+
|
| 289 |
+
if Action not in possible_actions:
|
| 290 |
+
raise ParamValidationError(
|
| 291 |
+
report=f"Received {Action} for action but expected one of: {', '.join(possible_actions)}"
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
+
if Region is None:
|
| 295 |
+
Region = self.meta.region_name
|
| 296 |
+
|
| 297 |
+
request_dict = {
|
| 298 |
+
'url_path': '/',
|
| 299 |
+
'query_string': '',
|
| 300 |
+
'headers': {},
|
| 301 |
+
'body': {
|
| 302 |
+
'Action': Action,
|
| 303 |
+
},
|
| 304 |
+
'method': 'GET',
|
| 305 |
+
}
|
| 306 |
+
scheme = 'https://'
|
| 307 |
+
endpoint_url = f'{scheme}{Hostname}'
|
| 308 |
+
prepare_request_dict(request_dict, endpoint_url)
|
| 309 |
+
presigned_url = await self._request_signer.generate_presigned_url(
|
| 310 |
+
operation_name=Action,
|
| 311 |
+
request_dict=request_dict,
|
| 312 |
+
region_name=Region,
|
| 313 |
+
expires_in=ExpiresIn,
|
| 314 |
+
signing_name='dsql',
|
| 315 |
+
)
|
| 316 |
+
return presigned_url[len(scheme) :]
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
async def dsql_generate_db_connect_auth_token(
|
| 320 |
+
self, Hostname, Region=None, ExpiresIn=900
|
| 321 |
+
):
|
| 322 |
+
"""Generate a DSQL database token for the "DbConnect" action.
|
| 323 |
+
:type Hostname: str
|
| 324 |
+
:param Hostname: The DSQL endpoint host name.
|
| 325 |
+
:type Region: str
|
| 326 |
+
:param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.
|
| 327 |
+
:type ExpiresIn: int
|
| 328 |
+
:param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).
|
| 329 |
+
:return: A presigned url which can be used as an auth token.
|
| 330 |
+
"""
|
| 331 |
+
return await _dsql_generate_db_auth_token(
|
| 332 |
+
self, Hostname, "DbConnect", Region, ExpiresIn
|
| 333 |
+
)
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
async def dsql_generate_db_connect_admin_auth_token(
|
| 337 |
+
self, Hostname, Region=None, ExpiresIn=900
|
| 338 |
+
):
|
| 339 |
+
"""Generate a DSQL database token for the "DbConnectAdmin" action.
|
| 340 |
+
:type Hostname: str
|
| 341 |
+
:param Hostname: The DSQL endpoint host name.
|
| 342 |
+
:type Region: str
|
| 343 |
+
:param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.
|
| 344 |
+
:type ExpiresIn: int
|
| 345 |
+
:param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).
|
| 346 |
+
:return: A presigned url which can be used as an auth token.
|
| 347 |
+
"""
|
| 348 |
+
return await _dsql_generate_db_auth_token(
|
| 349 |
+
self, Hostname, "DbConnectAdmin", Region, ExpiresIn
|
| 350 |
+
)
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
class AioS3PostPresigner(S3PostPresigner):
|
| 354 |
+
async def generate_presigned_post(
|
| 355 |
+
self,
|
| 356 |
+
request_dict,
|
| 357 |
+
fields=None,
|
| 358 |
+
conditions=None,
|
| 359 |
+
expires_in=3600,
|
| 360 |
+
region_name=None,
|
| 361 |
+
):
|
| 362 |
+
if fields is None:
|
| 363 |
+
fields = {}
|
| 364 |
+
|
| 365 |
+
if conditions is None:
|
| 366 |
+
conditions = []
|
| 367 |
+
|
| 368 |
+
# Create the policy for the post.
|
| 369 |
+
policy = {}
|
| 370 |
+
|
| 371 |
+
# Create an expiration date for the policy
|
| 372 |
+
datetime_now = get_current_datetime()
|
| 373 |
+
expire_date = datetime_now + datetime.timedelta(seconds=expires_in)
|
| 374 |
+
policy['expiration'] = expire_date.strftime(botocore.auth.ISO8601)
|
| 375 |
+
|
| 376 |
+
# Append all of the conditions that the user supplied.
|
| 377 |
+
policy['conditions'] = []
|
| 378 |
+
for condition in conditions:
|
| 379 |
+
policy['conditions'].append(condition)
|
| 380 |
+
|
| 381 |
+
# Store the policy and the fields in the request for signing
|
| 382 |
+
request = create_request_object(request_dict)
|
| 383 |
+
request.context['s3-presign-post-fields'] = fields
|
| 384 |
+
request.context['s3-presign-post-policy'] = policy
|
| 385 |
+
|
| 386 |
+
await self._request_signer.sign(
|
| 387 |
+
'PutObject', request, region_name, 'presign-post'
|
| 388 |
+
)
|
| 389 |
+
# Return the url and the fields for th form to post.
|
| 390 |
+
return {'url': request.url, 'fields': fields}
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def add_generate_presigned_url(class_attributes, **kwargs):
|
| 394 |
+
class_attributes['generate_presigned_url'] = generate_presigned_url
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
async def generate_presigned_url(
|
| 398 |
+
self, ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None
|
| 399 |
+
):
|
| 400 |
+
"""Generate a presigned url given a client, its method, and arguments
|
| 401 |
+
|
| 402 |
+
:type ClientMethod: string
|
| 403 |
+
:param ClientMethod: The client method to presign for
|
| 404 |
+
|
| 405 |
+
:type Params: dict
|
| 406 |
+
:param Params: The parameters normally passed to
|
| 407 |
+
``ClientMethod``.
|
| 408 |
+
|
| 409 |
+
:type ExpiresIn: int
|
| 410 |
+
:param ExpiresIn: The number of seconds the presigned url is valid
|
| 411 |
+
for. By default it expires in an hour (3600 seconds)
|
| 412 |
+
|
| 413 |
+
:type HttpMethod: string
|
| 414 |
+
:param HttpMethod: The http method to use on the generated url. By
|
| 415 |
+
default, the http method is whatever is used in the method's model.
|
| 416 |
+
|
| 417 |
+
:returns: The presigned url
|
| 418 |
+
"""
|
| 419 |
+
client_method = ClientMethod
|
| 420 |
+
params = Params
|
| 421 |
+
if params is None:
|
| 422 |
+
params = {}
|
| 423 |
+
expires_in = ExpiresIn
|
| 424 |
+
http_method = HttpMethod
|
| 425 |
+
context = {
|
| 426 |
+
'is_presign_request': True,
|
| 427 |
+
'use_global_endpoint': _should_use_global_endpoint(self),
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
request_signer = self._request_signer
|
| 431 |
+
|
| 432 |
+
try:
|
| 433 |
+
operation_name = self._PY_TO_OP_NAME[client_method]
|
| 434 |
+
except KeyError:
|
| 435 |
+
raise UnknownClientMethodError(method_name=client_method)
|
| 436 |
+
|
| 437 |
+
operation_model = self.meta.service_model.operation_model(operation_name)
|
| 438 |
+
params = await self._emit_api_params(
|
| 439 |
+
api_params=params,
|
| 440 |
+
operation_model=operation_model,
|
| 441 |
+
context=context,
|
| 442 |
+
)
|
| 443 |
+
bucket_is_arn = ArnParser.is_arn(params.get('Bucket', ''))
|
| 444 |
+
(
|
| 445 |
+
endpoint_url,
|
| 446 |
+
additional_headers,
|
| 447 |
+
properties,
|
| 448 |
+
) = await self._resolve_endpoint_ruleset(
|
| 449 |
+
operation_model,
|
| 450 |
+
params,
|
| 451 |
+
context,
|
| 452 |
+
ignore_signing_region=(not bucket_is_arn),
|
| 453 |
+
)
|
| 454 |
+
|
| 455 |
+
request_dict = await self._convert_to_request_dict(
|
| 456 |
+
api_params=params,
|
| 457 |
+
operation_model=operation_model,
|
| 458 |
+
endpoint_url=endpoint_url,
|
| 459 |
+
context=context,
|
| 460 |
+
headers=additional_headers,
|
| 461 |
+
set_user_agent_header=False,
|
| 462 |
+
)
|
| 463 |
+
|
| 464 |
+
# Switch out the http method if user specified it.
|
| 465 |
+
if http_method is not None:
|
| 466 |
+
request_dict['method'] = http_method
|
| 467 |
+
|
| 468 |
+
# Generate the presigned url.
|
| 469 |
+
return await request_signer.generate_presigned_url(
|
| 470 |
+
request_dict=request_dict,
|
| 471 |
+
expires_in=expires_in,
|
| 472 |
+
operation_name=operation_name,
|
| 473 |
+
)
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
def add_generate_presigned_post(class_attributes, **kwargs):
|
| 477 |
+
class_attributes['generate_presigned_post'] = generate_presigned_post
|
| 478 |
+
|
| 479 |
+
|
| 480 |
+
async def generate_presigned_post(
|
| 481 |
+
self, Bucket, Key, Fields=None, Conditions=None, ExpiresIn=3600
|
| 482 |
+
):
|
| 483 |
+
bucket = Bucket
|
| 484 |
+
key = Key
|
| 485 |
+
fields = Fields
|
| 486 |
+
conditions = Conditions
|
| 487 |
+
expires_in = ExpiresIn
|
| 488 |
+
|
| 489 |
+
if fields is None:
|
| 490 |
+
fields = {}
|
| 491 |
+
else:
|
| 492 |
+
fields = fields.copy()
|
| 493 |
+
|
| 494 |
+
if conditions is None:
|
| 495 |
+
conditions = []
|
| 496 |
+
|
| 497 |
+
context = {
|
| 498 |
+
'is_presign_request': True,
|
| 499 |
+
'use_global_endpoint': _should_use_global_endpoint(self),
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
post_presigner = AioS3PostPresigner(self._request_signer)
|
| 503 |
+
|
| 504 |
+
# We choose the CreateBucket operation model because its url gets
|
| 505 |
+
# serialized to what a presign post requires.
|
| 506 |
+
operation_model = self.meta.service_model.operation_model('CreateBucket')
|
| 507 |
+
params = await self._emit_api_params(
|
| 508 |
+
api_params={'Bucket': bucket},
|
| 509 |
+
operation_model=operation_model,
|
| 510 |
+
context=context,
|
| 511 |
+
)
|
| 512 |
+
bucket_is_arn = ArnParser.is_arn(params.get('Bucket', ''))
|
| 513 |
+
(
|
| 514 |
+
endpoint_url,
|
| 515 |
+
additional_headers,
|
| 516 |
+
properties,
|
| 517 |
+
) = await self._resolve_endpoint_ruleset(
|
| 518 |
+
operation_model,
|
| 519 |
+
params,
|
| 520 |
+
context,
|
| 521 |
+
ignore_signing_region=(not bucket_is_arn),
|
| 522 |
+
)
|
| 523 |
+
|
| 524 |
+
request_dict = await self._convert_to_request_dict(
|
| 525 |
+
api_params=params,
|
| 526 |
+
operation_model=operation_model,
|
| 527 |
+
endpoint_url=endpoint_url,
|
| 528 |
+
context=context,
|
| 529 |
+
headers=additional_headers,
|
| 530 |
+
set_user_agent_header=False,
|
| 531 |
+
)
|
| 532 |
+
|
| 533 |
+
# Append that the bucket name to the list of conditions.
|
| 534 |
+
conditions.append({'bucket': bucket})
|
| 535 |
+
|
| 536 |
+
# If the key ends with filename, the only constraint that can be
|
| 537 |
+
# imposed is if it starts with the specified prefix.
|
| 538 |
+
if key.endswith('${filename}'):
|
| 539 |
+
conditions.append(["starts-with", '$key', key[: -len('${filename}')]])
|
| 540 |
+
else:
|
| 541 |
+
conditions.append({'key': key})
|
| 542 |
+
|
| 543 |
+
# Add the key to the fields.
|
| 544 |
+
fields['key'] = key
|
| 545 |
+
|
| 546 |
+
return await post_presigner.generate_presigned_post(
|
| 547 |
+
request_dict=request_dict,
|
| 548 |
+
fields=fields,
|
| 549 |
+
conditions=conditions,
|
| 550 |
+
expires_in=expires_in,
|
| 551 |
+
)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/stub.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.stub import Stubber
|
| 2 |
+
|
| 3 |
+
from .awsrequest import AioAWSResponse
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class AioStubber(Stubber):
|
| 7 |
+
def _add_response(self, method, service_response, expected_params):
|
| 8 |
+
if not hasattr(self.client, method):
|
| 9 |
+
raise ValueError(
|
| 10 |
+
f"Client {self.client.meta.service_model.service_name} "
|
| 11 |
+
f"does not have method: {method}"
|
| 12 |
+
) # pragma: no cover
|
| 13 |
+
|
| 14 |
+
# Create a successful http response
|
| 15 |
+
http_response = AioAWSResponse(None, 200, {}, None)
|
| 16 |
+
|
| 17 |
+
operation_name = self.client.meta.method_to_api_mapping.get(method)
|
| 18 |
+
self._validate_operation_response(operation_name, service_response)
|
| 19 |
+
|
| 20 |
+
# Add the service_response to the queue for returning responses
|
| 21 |
+
response = {
|
| 22 |
+
'operation_name': operation_name,
|
| 23 |
+
'response': (http_response, service_response),
|
| 24 |
+
'expected_params': expected_params,
|
| 25 |
+
}
|
| 26 |
+
self._queue.append(response)
|
| 27 |
+
|
| 28 |
+
def add_client_error(
|
| 29 |
+
self,
|
| 30 |
+
method,
|
| 31 |
+
service_error_code='',
|
| 32 |
+
service_message='',
|
| 33 |
+
http_status_code=400,
|
| 34 |
+
service_error_meta=None,
|
| 35 |
+
expected_params=None,
|
| 36 |
+
response_meta=None,
|
| 37 |
+
modeled_fields=None,
|
| 38 |
+
):
|
| 39 |
+
"""
|
| 40 |
+
Adds a ``ClientError`` to the response queue.
|
| 41 |
+
|
| 42 |
+
:param method: The name of the service method to return the error on.
|
| 43 |
+
:type method: str
|
| 44 |
+
|
| 45 |
+
:param service_error_code: The service error code to return,
|
| 46 |
+
e.g. ``NoSuchBucket``
|
| 47 |
+
:type service_error_code: str
|
| 48 |
+
|
| 49 |
+
:param service_message: The service message to return, e.g.
|
| 50 |
+
'The specified bucket does not exist.'
|
| 51 |
+
:type service_message: str
|
| 52 |
+
|
| 53 |
+
:param http_status_code: The HTTP status code to return, e.g. 404, etc
|
| 54 |
+
:type http_status_code: int
|
| 55 |
+
|
| 56 |
+
:param service_error_meta: Additional keys to be added to the
|
| 57 |
+
service Error
|
| 58 |
+
:type service_error_meta: dict
|
| 59 |
+
|
| 60 |
+
:param expected_params: A dictionary of the expected parameters to
|
| 61 |
+
be called for the provided service response. The parameters match
|
| 62 |
+
the names of keyword arguments passed to that client call. If
|
| 63 |
+
any of the parameters differ a ``StubResponseError`` is thrown.
|
| 64 |
+
You can use stub.ANY to indicate a particular parameter to ignore
|
| 65 |
+
in validation.
|
| 66 |
+
|
| 67 |
+
:param response_meta: Additional keys to be added to the
|
| 68 |
+
response's ResponseMetadata
|
| 69 |
+
:type response_meta: dict
|
| 70 |
+
|
| 71 |
+
:param modeled_fields: Additional keys to be added to the response
|
| 72 |
+
based on fields that are modeled for the particular error code.
|
| 73 |
+
These keys will be validated against the particular error shape
|
| 74 |
+
designated by the error code.
|
| 75 |
+
:type modeled_fields: dict
|
| 76 |
+
|
| 77 |
+
"""
|
| 78 |
+
http_response = AioAWSResponse(None, http_status_code, {}, None)
|
| 79 |
+
|
| 80 |
+
# We don't look to the model to build this because the caller would
|
| 81 |
+
# need to know the details of what the HTTP body would need to
|
| 82 |
+
# look like.
|
| 83 |
+
parsed_response = {
|
| 84 |
+
'ResponseMetadata': {'HTTPStatusCode': http_status_code},
|
| 85 |
+
'Error': {'Message': service_message, 'Code': service_error_code},
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
if service_error_meta is not None:
|
| 89 |
+
parsed_response['Error'].update(service_error_meta)
|
| 90 |
+
|
| 91 |
+
if response_meta is not None:
|
| 92 |
+
parsed_response['ResponseMetadata'].update(response_meta)
|
| 93 |
+
|
| 94 |
+
if modeled_fields is not None:
|
| 95 |
+
service_model = self.client.meta.service_model
|
| 96 |
+
shape = service_model.shape_for_error_code(service_error_code)
|
| 97 |
+
self._validate_response(shape, modeled_fields)
|
| 98 |
+
parsed_response.update(modeled_fields)
|
| 99 |
+
|
| 100 |
+
operation_name = self.client.meta.method_to_api_mapping.get(method)
|
| 101 |
+
# Note that we do not allow for expected_params while
|
| 102 |
+
# adding errors into the queue yet.
|
| 103 |
+
response = {
|
| 104 |
+
'operation_name': operation_name,
|
| 105 |
+
'response': (http_response, parsed_response),
|
| 106 |
+
'expected_params': expected_params,
|
| 107 |
+
}
|
| 108 |
+
self._queue.append(response)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiobotocore/tokens.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import logging
|
| 3 |
+
from datetime import timedelta
|
| 4 |
+
|
| 5 |
+
import dateutil.parser
|
| 6 |
+
from botocore import UNSIGNED
|
| 7 |
+
from botocore.compat import total_seconds
|
| 8 |
+
from botocore.exceptions import ClientError, TokenRetrievalError
|
| 9 |
+
from botocore.tokens import (
|
| 10 |
+
DeferredRefreshableToken,
|
| 11 |
+
FrozenAuthToken,
|
| 12 |
+
ScopedEnvTokenProvider,
|
| 13 |
+
SSOTokenProvider,
|
| 14 |
+
TokenProviderChain,
|
| 15 |
+
_utc_now,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
from aiobotocore.config import AioConfig
|
| 19 |
+
from aiobotocore.utils import create_nested_client
|
| 20 |
+
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def create_token_resolver(session):
|
| 25 |
+
providers = [
|
| 26 |
+
ScopedEnvTokenProvider(session),
|
| 27 |
+
AioSSOTokenProvider(session),
|
| 28 |
+
]
|
| 29 |
+
return TokenProviderChain(providers=providers)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class AioDeferredRefreshableToken(DeferredRefreshableToken):
|
| 33 |
+
def __init__(self, method, refresh_using, time_fetcher=_utc_now): # noqa: E501, lgtm [py/missing-call-to-init]
|
| 34 |
+
self._time_fetcher = time_fetcher
|
| 35 |
+
self._refresh_using = refresh_using
|
| 36 |
+
self.method = method
|
| 37 |
+
|
| 38 |
+
# The frozen token is protected by this lock
|
| 39 |
+
self._refresh_lock = asyncio.Lock()
|
| 40 |
+
self._frozen_token = None
|
| 41 |
+
self._next_refresh = None
|
| 42 |
+
|
| 43 |
+
async def get_frozen_token(self):
|
| 44 |
+
await self._refresh()
|
| 45 |
+
return self._frozen_token
|
| 46 |
+
|
| 47 |
+
async def _refresh(self):
|
| 48 |
+
# If we don't need to refresh just return
|
| 49 |
+
refresh_type = self._should_refresh()
|
| 50 |
+
if not refresh_type:
|
| 51 |
+
return None
|
| 52 |
+
|
| 53 |
+
# Block for refresh if we're in the mandatory refresh window
|
| 54 |
+
block_for_refresh = refresh_type == "mandatory"
|
| 55 |
+
if block_for_refresh or not self._refresh_lock.locked():
|
| 56 |
+
async with self._refresh_lock:
|
| 57 |
+
await self._protected_refresh()
|
| 58 |
+
|
| 59 |
+
async def _protected_refresh(self):
|
| 60 |
+
# This should only be called after acquiring the refresh lock
|
| 61 |
+
# Another task may have already refreshed, double check refresh
|
| 62 |
+
refresh_type = self._should_refresh()
|
| 63 |
+
if not refresh_type:
|
| 64 |
+
return None
|
| 65 |
+
|
| 66 |
+
try:
|
| 67 |
+
now = self._time_fetcher()
|
| 68 |
+
self._next_refresh = now + timedelta(seconds=self._attempt_timeout)
|
| 69 |
+
self._frozen_token = await self._refresh_using()
|
| 70 |
+
except Exception:
|
| 71 |
+
logger.warning(
|
| 72 |
+
"Refreshing token failed during the %s refresh period.",
|
| 73 |
+
refresh_type,
|
| 74 |
+
exc_info=True,
|
| 75 |
+
)
|
| 76 |
+
if refresh_type == "mandatory":
|
| 77 |
+
# This refresh was mandatory, error must be propagated back
|
| 78 |
+
raise
|
| 79 |
+
|
| 80 |
+
if self._is_expired():
|
| 81 |
+
# Fresh credentials should never be expired
|
| 82 |
+
raise TokenRetrievalError(
|
| 83 |
+
provider=self.method,
|
| 84 |
+
error_msg="Token has expired and refresh failed",
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class AioSSOTokenProvider(SSOTokenProvider):
|
| 89 |
+
async def _attempt_create_token(self, token):
|
| 90 |
+
async with self._client as client:
|
| 91 |
+
response = await client.create_token(
|
| 92 |
+
grantType=self._GRANT_TYPE,
|
| 93 |
+
clientId=token["clientId"],
|
| 94 |
+
clientSecret=token["clientSecret"],
|
| 95 |
+
refreshToken=token["refreshToken"],
|
| 96 |
+
)
|
| 97 |
+
expires_in = timedelta(seconds=response["expiresIn"])
|
| 98 |
+
new_token = {
|
| 99 |
+
"startUrl": self._sso_config["sso_start_url"],
|
| 100 |
+
"region": self._sso_config["sso_region"],
|
| 101 |
+
"accessToken": response["accessToken"],
|
| 102 |
+
"expiresAt": self._now() + expires_in,
|
| 103 |
+
# Cache the registration alongside the token
|
| 104 |
+
"clientId": token["clientId"],
|
| 105 |
+
"clientSecret": token["clientSecret"],
|
| 106 |
+
"registrationExpiresAt": token["registrationExpiresAt"],
|
| 107 |
+
}
|
| 108 |
+
if "refreshToken" in response:
|
| 109 |
+
new_token["refreshToken"] = response["refreshToken"]
|
| 110 |
+
logger.info("SSO Token refresh succeeded")
|
| 111 |
+
return new_token
|
| 112 |
+
|
| 113 |
+
async def _refresh_access_token(self, token):
|
| 114 |
+
keys = (
|
| 115 |
+
"refreshToken",
|
| 116 |
+
"clientId",
|
| 117 |
+
"clientSecret",
|
| 118 |
+
"registrationExpiresAt",
|
| 119 |
+
)
|
| 120 |
+
missing_keys = [k for k in keys if k not in token]
|
| 121 |
+
if missing_keys:
|
| 122 |
+
msg = f"Unable to refresh SSO token: missing keys: {missing_keys}"
|
| 123 |
+
logger.info(msg)
|
| 124 |
+
return None
|
| 125 |
+
|
| 126 |
+
expiry = dateutil.parser.parse(token["registrationExpiresAt"])
|
| 127 |
+
if total_seconds(expiry - self._now()) <= 0:
|
| 128 |
+
logger.info("SSO token registration expired at %s", expiry)
|
| 129 |
+
return None
|
| 130 |
+
|
| 131 |
+
try:
|
| 132 |
+
return await self._attempt_create_token(token)
|
| 133 |
+
except ClientError:
|
| 134 |
+
logger.warning("SSO token refresh attempt failed", exc_info=True)
|
| 135 |
+
return None
|
| 136 |
+
|
| 137 |
+
async def _refresher(self):
|
| 138 |
+
start_url = self._sso_config["sso_start_url"]
|
| 139 |
+
session_name = self._sso_config["session_name"]
|
| 140 |
+
logger.info("Loading cached SSO token for %s", session_name)
|
| 141 |
+
token_dict = self._token_loader(start_url, session_name=session_name)
|
| 142 |
+
expiration = dateutil.parser.parse(token_dict["expiresAt"])
|
| 143 |
+
logger.debug("Cached SSO token expires at %s", expiration)
|
| 144 |
+
|
| 145 |
+
remaining = total_seconds(expiration - self._now())
|
| 146 |
+
if remaining < self._REFRESH_WINDOW:
|
| 147 |
+
new_token_dict = await self._refresh_access_token(token_dict)
|
| 148 |
+
if new_token_dict is not None:
|
| 149 |
+
token_dict = new_token_dict
|
| 150 |
+
expiration = token_dict["expiresAt"]
|
| 151 |
+
self._token_loader.save_token(
|
| 152 |
+
start_url, token_dict, session_name=session_name
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
return FrozenAuthToken(
|
| 156 |
+
token_dict["accessToken"], expiration=expiration
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
@property
|
| 160 |
+
def _client(self):
|
| 161 |
+
config = AioConfig(
|
| 162 |
+
region_name=self._sso_config["sso_region"],
|
| 163 |
+
signature_version=UNSIGNED,
|
| 164 |
+
)
|
| 165 |
+
return create_nested_client(self._session, "sso-oidc", config=config)
|
| 166 |
+
|
| 167 |
+
def load_token(self, **kwargs):
|
| 168 |
+
if self._sso_config is None:
|
| 169 |
+
return None
|
| 170 |
+
|
| 171 |
+
return AioDeferredR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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import contextlib
|
| 3 |
+
import functools
|
| 4 |
+
import inspect
|
| 5 |
+
import json
|
| 6 |
+
import logging
|
| 7 |
+
|
| 8 |
+
import botocore.awsrequest
|
| 9 |
+
from botocore.exceptions import (
|
| 10 |
+
InvalidIMDSEndpointError,
|
| 11 |
+
MetadataRetrievalError,
|
| 12 |
+
)
|
| 13 |
+
from botocore.utils import (
|
| 14 |
+
DEFAULT_METADATA_SERVICE_TIMEOUT,
|
| 15 |
+
METADATA_BASE_URL,
|
| 16 |
+
RETRYABLE_HTTP_ERRORS,
|
| 17 |
+
ArnParser,
|
| 18 |
+
BadIMDSRequestError,
|
| 19 |
+
ClientError,
|
| 20 |
+
ContainerMetadataFetcher,
|
| 21 |
+
HTTPClientError,
|
| 22 |
+
IdentityCache,
|
| 23 |
+
IMDSFetcher,
|
| 24 |
+
IMDSRegionProvider,
|
| 25 |
+
InstanceMetadataFetcher,
|
| 26 |
+
InstanceMetadataRegionFetcher,
|
| 27 |
+
PluginContext,
|
| 28 |
+
ReadTimeoutError,
|
| 29 |
+
S3ExpressIdentityCache,
|
| 30 |
+
S3ExpressIdentityResolver,
|
| 31 |
+
S3RegionRedirector,
|
| 32 |
+
S3RegionRedirectorv2,
|
| 33 |
+
get_environ_proxies,
|
| 34 |
+
os,
|
| 35 |
+
reset_plugin_context,
|
| 36 |
+
resolve_imds_endpoint_mode,
|
| 37 |
+
set_plugin_context,
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
import aiobotocore.httpsession
|
| 41 |
+
|
| 42 |
+
logger = logging.getLogger(__name__)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class _RefCountedSession(aiobotocore.httpsession.AIOHTTPSession):
|
| 46 |
+
def __init__(self, *args, **kwargs):
|
| 47 |
+
super().__init__(*args, **kwargs)
|
| 48 |
+
self.__ref_count = 0
|
| 49 |
+
self.__lock = None
|
| 50 |
+
|
| 51 |
+
@contextlib.asynccontextmanager
|
| 52 |
+
async def acquire(self):
|
| 53 |
+
if not self.__lock:
|
| 54 |
+
self.__lock = asyncio.Lock()
|
| 55 |
+
|
| 56 |
+
# ensure we have a session
|
| 57 |
+
async with self.__lock:
|
| 58 |
+
self.__ref_count += 1
|
| 59 |
+
|
| 60 |
+
try:
|
| 61 |
+
if self.__ref_count == 1:
|
| 62 |
+
await self.__aenter__()
|
| 63 |
+
except BaseException:
|
| 64 |
+
self.__ref_count -= 1
|
| 65 |
+
raise
|
| 66 |
+
|
| 67 |
+
try:
|
| 68 |
+
yield self
|
| 69 |
+
finally:
|
| 70 |
+
async with self.__lock:
|
| 71 |
+
if self.__ref_count == 1:
|
| 72 |
+
await self.__aexit__(None, None, None)
|
| 73 |
+
|
| 74 |
+
self.__ref_count -= 1
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class AioIMDSFetcher(IMDSFetcher):
|
| 78 |
+
def __init__(
|
| 79 |
+
self,
|
| 80 |
+
timeout=DEFAULT_METADATA_SERVICE_TIMEOUT, # noqa: E501, lgtm [py/missing-call-to-init]
|
| 81 |
+
num_attempts=1,
|
| 82 |
+
base_url=METADATA_BASE_URL,
|
| 83 |
+
env=None,
|
| 84 |
+
user_agent=None,
|
| 85 |
+
config=None,
|
| 86 |
+
session=None,
|
| 87 |
+
):
|
| 88 |
+
self._timeout = timeout
|
| 89 |
+
self._num_attempts = num_attempts
|
| 90 |
+
if config is None:
|
| 91 |
+
config = {}
|
| 92 |
+
self._base_url = self._select_base_url(base_url, config)
|
| 93 |
+
self._config = config
|
| 94 |
+
|
| 95 |
+
if env is None:
|
| 96 |
+
env = os.environ.copy()
|
| 97 |
+
self._disabled = (
|
| 98 |
+
env.get('AWS_EC2_METADATA_DISABLED', 'false').lower() == 'true'
|
| 99 |
+
)
|
| 100 |
+
self._imds_v1_disabled = config.get('ec2_metadata_v1_disabled')
|
| 101 |
+
self._user_agent = user_agent
|
| 102 |
+
|
| 103 |
+
self._session = session or _RefCountedSession(
|
| 104 |
+
timeout=self._timeout,
|
| 105 |
+
proxies=get_environ_proxies(self._base_url),
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
async def _fetch_metadata_token(self):
|
| 109 |
+
self._assert_enabled()
|
| 110 |
+
url = self._construct_url(self._TOKEN_PATH)
|
| 111 |
+
headers = {
|
| 112 |
+
'x-aws-ec2-metadata-token-ttl-seconds': self._TOKEN_TTL,
|
| 113 |
+
}
|
| 114 |
+
self._add_user_agent(headers)
|
| 115 |
+
|
| 116 |
+
request = botocore.awsrequest.AWSRequest(
|
| 117 |
+
method='PUT', url=url, headers=headers
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
async with self._session.acquire() as session:
|
| 121 |
+
for i in range(self._num_attempts):
|
| 122 |
+
try:
|
| 123 |
+
response = await session.send(request.prepare())
|
| 124 |
+
if response.status_code == 200:
|
| 125 |
+
return await response.text
|
| 126 |
+
elif response.status_code in (404, 403, 405):
|
| 127 |
+
return None
|
| 128 |
+
elif response.status_code in (400,):
|
| 129 |
+
raise BadIMDSRequestError(request)
|
| 130 |
+
except ReadTimeoutError:
|
| 131 |
+
return None
|
| 132 |
+
except RETRYABLE_HTTP_ERRORS as e:
|
| 133 |
+
logger.debug(
|
| 134 |
+
"Caught retryable HTTP exception while making metadata "
|
| 135 |
+
"service request to %s: %s",
|
| 136 |
+
url,
|
| 137 |
+
e,
|
| 138 |
+
exc_info=True,
|
| 139 |
+
)
|
| 140 |
+
except HTTPClientError as e:
|
| 141 |
+
error = e.kwargs.get('error')
|
| 142 |
+
if (
|
| 143 |
+
error
|
| 144 |
+
and getattr(error, 'errno', None) == 8
|
| 145 |
+
or str(getattr(error, 'os_error', None))
|
| 146 |
+
== 'Domain name not found'
|
| 147 |
+
): # threaded vs async resolver
|
| 148 |
+
raise InvalidIMDSEndpointError(endpoint=url, error=e)
|
| 149 |
+
else:
|
| 150 |
+
raise
|
| 151 |
+
|
| 152 |
+
return None
|
| 153 |
+
|
| 154 |
+
async def _get_request(self, url_path, retry_func, token=None):
|
| 155 |
+
self._assert_enabled()
|
| 156 |
+
if not token:
|
| 157 |
+
self._assert_v1_enabled()
|
| 158 |
+
if retry_func is None:
|
| 159 |
+
retry_func = self._default_retry
|
| 160 |
+
url = self._construct_url(url_path)
|
| 161 |
+
headers = {}
|
| 162 |
+
if token is not None:
|
| 163 |
+
headers['x-aws-ec2-metadata-token'] = token
|
| 164 |
+
self._add_user_agent(headers)
|
| 165 |
+
|
| 166 |
+
async with self._session.acquire() as session:
|
| 167 |
+
for i in range(self._num_attempts):
|
| 168 |
+
try:
|
| 169 |
+
request = botocore.awsrequest.AWSRequest(
|
| 170 |
+
method='GET', url=url, headers=headers
|
| 171 |
+
)
|
| 172 |
+
response = await session.send(request.prepare())
|
| 173 |
+
should_retry = retry_func(response)
|
| 174 |
+
if inspect.isawaitable(should_retry):
|
| 175 |
+
should_retry = await should_retry
|
| 176 |
+
|
| 177 |
+
if not should_retry:
|
| 178 |
+
return response
|
| 179 |
+
except RETRYABLE_HTTP_ERRORS as e:
|
| 180 |
+
logger.debug(
|
| 181 |
+
"Caught retryable HTTP exception while making metadata "
|
| 182 |
+
"service request to %s: %s",
|
| 183 |
+
url,
|
| 184 |
+
e,
|
| 185 |
+
exc_info=True,
|
| 186 |
+
)
|
| 187 |
+
raise self._RETRIES_EXCEEDED_ERROR_CLS()
|
| 188 |
+
|
| 189 |
+
async def _default_retry(self, response):
|
| 190 |
+
return await self._is_non_ok_response(
|
| 191 |
+
response
|
| 192 |
+
) or await self._is_empty(response)
|
| 193 |
+
|
| 194 |
+
async def _is_non_ok_response(self, response):
|
| 195 |
+
if response.status_code != 200:
|
| 196 |
+
await self._log_imds_response(response, 'non-200', log_body=True)
|
| 197 |
+
return True
|
| 198 |
+
return False
|
| 199 |
+
|
| 200 |
+
async def _is_empty(self, response):
|
| 201 |
+
if not await response.content:
|
| 202 |
+
await self._log_imds_response(response, 'no body', log_body=True)
|
| 203 |
+
return True
|
| 204 |
+
return False
|
| 205 |
+
|
| 206 |
+
async def _log_imds_response(
|
| 207 |
+
self, response, reason_to_log, log_body=False
|
| 208 |
+
):
|
| 209 |
+
statement = (
|
| 210 |
+
"Metadata service returned %s response "
|
| 211 |
+
"with status code of %s for url: %s"
|
| 212 |
+
)
|
| 213 |
+
logger_args = [reason_to_log, response.status_code, response.url]
|
| 214 |
+
if log_body:
|
| 215 |
+
statement += ", content body: %s"
|
| 216 |
+
logger_args.append(await response.content)
|
| 217 |
+
logger.debug(statement, *logger_args)
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
class AioInstanceMetadataFetcher(AioIMDSFetcher, InstanceMetadataFetcher):
|
| 221 |
+
async def retrieve_iam_role_credentials(self):
|
| 222 |
+
try:
|
| 223 |
+
token = await self._fetch_metadata_token()
|
| 224 |
+
role_name = await self._get_iam_role(token)
|
| 225 |
+
credentials = await self._get_credentials(role_name, token)
|
| 226 |
+
if self._contains_all_credential_fields(credentials):
|
| 227 |
+
credentials = {
|
| 228 |
+
'role_name': role_name,
|
| 229 |
+
'access_key': credentials['AccessKeyId'],
|
| 230 |
+
'secret_key': credentials['SecretAccessKey'],
|
| 231 |
+
'token': credentials['Token'],
|
| 232 |
+
'expiry_time': credentials['Expiration'],
|
| 233 |
+
}
|
| 234 |
+
self._evaluate_expiration(credentials)
|
| 235 |
+
return credentials
|
| 236 |
+
else:
|
| 237 |
+
if 'Code' in credentials and 'Message' in credentials:
|
| 238 |
+
logger.debug(
|
| 239 |
+
'Error response received when retrieving'
|
| 240 |
+
'credentials: %s.',
|
| 241 |
+
credentials,
|
| 242 |
+
)
|
| 243 |
+
return {}
|
| 244 |
+
except self._RETRIES_EXCEEDED_ERROR_CLS:
|
| 245 |
+
logger.debug(
|
| 246 |
+
"Max number of attempts exceeded (%s) when "
|
| 247 |
+
"attempting to retrieve data from metadata service.",
|
| 248 |
+
self._num_attempts,
|
| 249 |
+
)
|
| 250 |
+
except BadIMDSRequestError as e:
|
| 251 |
+
logger.debug("Bad IMDS request: %s", e.request)
|
| 252 |
+
return {}
|
| 253 |
+
|
| 254 |
+
async def _get_iam_role(self, token=None):
|
| 255 |
+
return await (
|
| 256 |
+
await self._get_request(
|
| 257 |
+
url_path=self._URL_PATH,
|
| 258 |
+
retry_func=self._needs_retry_for_role_name,
|
| 259 |
+
token=token,
|
| 260 |
+
)
|
| 261 |
+
).text
|
| 262 |
+
|
| 263 |
+
async def _get_credentials(self, role_name, token=None):
|
| 264 |
+
r = await self._get_request(
|
| 265 |
+
url_path=self._URL_PATH + role_name,
|
| 266 |
+
retry_func=self._needs_retry_for_credentials,
|
| 267 |
+
token=token,
|
| 268 |
+
)
|
| 269 |
+
return json.loads(await r.text)
|
| 270 |
+
|
| 271 |
+
async def _is_invalid_json(self, response):
|
| 272 |
+
try:
|
| 273 |
+
json.loads(await response.text)
|
| 274 |
+
return False
|
| 275 |
+
except ValueError:
|
| 276 |
+
await self._log_imds_response(response, 'invalid json')
|
| 277 |
+
return True
|
| 278 |
+
|
| 279 |
+
async def _needs_retry_for_role_name(self, response):
|
| 280 |
+
return await self._is_non_ok_response(
|
| 281 |
+
response
|
| 282 |
+
) or await self._is_empty(response)
|
| 283 |
+
|
| 284 |
+
async def _needs_retry_for_credentials(self, response):
|
| 285 |
+
return (
|
| 286 |
+
await self._is_non_ok_response(response)
|
| 287 |
+
or await self._is_empty(response)
|
| 288 |
+
or await self._is_invalid_json(response)
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
class AioIMDSRegionProvider(IMDSRegionProvider):
|
| 293 |
+
async def provide(self):
|
| 294 |
+
"""Provide the region value from IMDS."""
|
| 295 |
+
instance_region = await self._get_instance_metadata_region()
|
| 296 |
+
return instance_region
|
| 297 |
+
|
| 298 |
+
async def _get_instance_metadata_region(self):
|
| 299 |
+
fetcher = self._get_fetcher()
|
| 300 |
+
region = await fetcher.retrieve_region()
|
| 301 |
+
return region
|
| 302 |
+
|
| 303 |
+
def _create_fetcher(self):
|
| 304 |
+
metadata_timeout = self._session.get_config_variable(
|
| 305 |
+
'metadata_service_timeout'
|
| 306 |
+
)
|
| 307 |
+
metadata_num_attempts = self._session.get_config_variable(
|
| 308 |
+
'metadata_service_num_attempts'
|
| 309 |
+
)
|
| 310 |
+
imds_config = {
|
| 311 |
+
'ec2_metadata_service_endpoint': self._session.get_config_variable(
|
| 312 |
+
'ec2_metadata_service_endpoint'
|
| 313 |
+
),
|
| 314 |
+
'ec2_metadata_service_endpoint_mode': resolve_imds_endpoint_mode(
|
| 315 |
+
self._session
|
| 316 |
+
),
|
| 317 |
+
'ec2_metadata_v1_disabled': self._session.get_config_variable(
|
| 318 |
+
'ec2_metadata_v1_disabled'
|
| 319 |
+
),
|
| 320 |
+
}
|
| 321 |
+
fetcher = AioInstanceMetadataRegionFetcher(
|
| 322 |
+
timeout=metadata_timeout,
|
| 323 |
+
num_attempts=metadata_num_attempts,
|
| 324 |
+
env=self._environ,
|
| 325 |
+
user_agent=self._session.user_agent(),
|
| 326 |
+
config=imds_config,
|
| 327 |
+
)
|
| 328 |
+
return fetcher
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
class AioInstanceMetadataRegionFetcher(
|
| 332 |
+
AioIMDSFetcher, InstanceMetadataRegionFetcher
|
| 333 |
+
):
|
| 334 |
+
async def retrieve_region(self):
|
| 335 |
+
try:
|
| 336 |
+
region = await self._get_region()
|
| 337 |
+
return region
|
| 338 |
+
except self._RETRIES_EXCEEDED_ERROR_CLS:
|
| 339 |
+
logger.debug(
|
| 340 |
+
"Max number of attempts exceeded (%s) when "
|
| 341 |
+
"attempting to retrieve data from metadata service.",
|
| 342 |
+
self._num_attempts,
|
| 343 |
+
)
|
| 344 |
+
return None
|
| 345 |
+
|
| 346 |
+
async def _get_region(self):
|
| 347 |
+
token = await self._fetch_metadata_token()
|
| 348 |
+
response = await self._get_request(
|
| 349 |
+
url_path=self._URL_PATH,
|
| 350 |
+
retry_func=self._default_retry,
|
| 351 |
+
token=token,
|
| 352 |
+
)
|
| 353 |
+
availability_zone = await response.text
|
| 354 |
+
region = availability_zone[:-1]
|
| 355 |
+
return region
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
class AioIdentityCache(IdentityCache):
|
| 359 |
+
async def get_credentials(self, **kwargs):
|
| 360 |
+
callback = self.build_refresh_callback(**kwargs)
|
| 361 |
+
metadata = await callback()
|
| 362 |
+
credential_entry = self._credential_cls.create_from_metadata(
|
| 363 |
+
metadata=metadata,
|
| 364 |
+
refresh_using=callback,
|
| 365 |
+
method=self.METHOD,
|
| 366 |
+
advisory_timeout=45,
|
| 367 |
+
mandatory_timeout=10,
|
| 368 |
+
)
|
| 369 |
+
return credential_entry
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
class AioS3ExpressIdentityCache(AioIdentityCache, S3ExpressIdentityCache):
|
| 373 |
+
@functools.lru_cache(maxsize=100)
|
| 374 |
+
def _get_credentials(self, bucket):
|
| 375 |
+
return asyncio.create_task(super().get_credentials(bucket=bucket))
|
| 376 |
+
|
| 377 |
+
async def get_credentials(self, bucket):
|
| 378 |
+
# upstream uses `@functools.lru_cache(maxsize=100)` to cache credentials.
|
| 379 |
+
# This is incompatible with async code.
|
| 380 |
+
# We need to implement custom caching logic.
|
| 381 |
+
|
| 382 |
+
return await self._get_credentials(bucket=bucket)
|
| 383 |
+
|
| 384 |
+
def build_refresh_callback(self, bucket):
|
| 385 |
+
async def refresher():
|
| 386 |
+
response = await self._client.create_session(Bucket=bucket)
|
| 387 |
+
creds = response['Credentials']
|
| 388 |
+
expiration = self._serialize_if_needed(
|
| 389 |
+
creds['Expiration'], iso=True
|
| 390 |
+
)
|
| 391 |
+
return {
|
| 392 |
+
"access_key": creds['AccessKeyId'],
|
| 393 |
+
"secret_key": creds['SecretAccessKey'],
|
| 394 |
+
"token": creds['SessionToken'],
|
| 395 |
+
"expiry_time": expiration,
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
return refresher
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
class AioS3ExpressIdentityResolver(S3ExpressIdentityResolver):
|
| 402 |
+
def __init__(self, client, credential_cls, cache=None):
|
| 403 |
+
super().__init__(client, credential_cls, cache)
|
| 404 |
+
|
| 405 |
+
if cache is None:
|
| 406 |
+
cache = AioS3ExpressIdentityCache(self._client, credential_cls)
|
| 407 |
+
self._cache = cache
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
class AioS3RegionRedirectorv2(S3RegionRedirectorv2):
|
| 411 |
+
async def redirect_from_error(
|
| 412 |
+
self,
|
| 413 |
+
request_dict,
|
| 414 |
+
response,
|
| 415 |
+
operation,
|
| 416 |
+
**kwargs,
|
| 417 |
+
):
|
| 418 |
+
"""
|
| 419 |
+
An S3 request sent to the wrong region will return an error that
|
| 420 |
+
contains the endpoint the request should be sent to. This handler
|
| 421 |
+
will add the redirect information to the signing context and then
|
| 422 |
+
redirect the request.
|
| 423 |
+
"""
|
| 424 |
+
if response is None:
|
| 425 |
+
# This could be none if there was a ConnectionError or other
|
| 426 |
+
# transport error.
|
| 427 |
+
return
|
| 428 |
+
|
| 429 |
+
redirect_ctx = request_dict.get('context', {}).get('s3_redirect', {})
|
| 430 |
+
if ArnParser.is_arn(redirect_ctx.get('bucket')):
|
| 431 |
+
logger.debug(
|
| 432 |
+
'S3 request was previously for an Accesspoint ARN, not '
|
| 433 |
+
'redirecting.'
|
| 434 |
+
)
|
| 435 |
+
return
|
| 436 |
+
|
| 437 |
+
if redirect_ctx.get('redirected'):
|
| 438 |
+
logger.debug(
|
| 439 |
+
'S3 request was previously redirected, not redirecting.'
|
| 440 |
+
)
|
| 441 |
+
return
|
| 442 |
+
|
| 443 |
+
error = response[1].get('Error', {})
|
| 444 |
+
error_code = error.get('Code')
|
| 445 |
+
response_metadata = response[1].get('ResponseMetadata', {})
|
| 446 |
+
|
| 447 |
+
# We have to account for 400 responses because
|
| 448 |
+
# if we sign a Head* request with the wrong region,
|
| 449 |
+
# we'll get a 400 Bad Request but we won't get a
|
| 450 |
+
# body saying it's an "AuthorizationHeaderMalformed".
|
| 451 |
+
is_special_head_object = (
|
| 452 |
+
error_code in ('301', '400') and operation.name == 'HeadObject'
|
| 453 |
+
)
|
| 454 |
+
is_special_head_bucket = (
|
| 455 |
+
error_code in ('301', '400')
|
| 456 |
+
and operation.name == 'HeadBucket'
|
| 457 |
+
and 'x-amz-bucket-region'
|
| 458 |
+
in response_metadata.get('HTTPHeaders', {})
|
| 459 |
+
)
|
| 460 |
+
is_wrong_signing_region = (
|
| 461 |
+
error_code == 'AuthorizationHeaderMalformed' and 'Region' in error
|
| 462 |
+
)
|
| 463 |
+
is_redirect_status = response[0] is not None and response[
|
| 464 |
+
0
|
| 465 |
+
].status_code in (301, 302, 307)
|
| 466 |
+
is_permanent_redirect = error_code == 'PermanentRedirect'
|
| 467 |
+
is_opt_in_region_redirect = (
|
| 468 |
+
error_code == 'IllegalLocationConstraintException'
|
| 469 |
+
and operation.name != 'CreateBucket'
|
| 470 |
+
)
|
| 471 |
+
if not any(
|
| 472 |
+
[
|
| 473 |
+
is_special_head_object,
|
| 474 |
+
is_wrong_signing_region,
|
| 475 |
+
is_permanent_redirect,
|
| 476 |
+
is_special_head_bucket,
|
| 477 |
+
is_redirect_status,
|
| 478 |
+
is_opt_in_region_redirect,
|
| 479 |
+
]
|
| 480 |
+
):
|
| 481 |
+
return
|
| 482 |
+
|
| 483 |
+
bucket = request_dict['context']['s3_redirect']['bucket']
|
| 484 |
+
client_region = request_dict['context'].get('client_region')
|
| 485 |
+
new_region = await self.get_bucket_region(bucket, response)
|
| 486 |
+
|
| 487 |
+
if new_region is None:
|
| 488 |
+
logger.debug(
|
| 489 |
+
"S3 client configured for region %s but the "
|
| 490 |
+
"bucket %s is not in that region and the proper region "
|
| 491 |
+
"could not be automatically determined.",
|
| 492 |
+
client_region,
|
| 493 |
+
bucket,
|
| 494 |
+
)
|
| 495 |
+
return
|
| 496 |
+
|
| 497 |
+
logger.debug(
|
| 498 |
+
"S3 client configured for region %s but the bucket %s "
|
| 499 |
+
"is in region %s; Please configure the proper region to "
|
| 500 |
+
"avoid multiple unnecessary redirects and signing attempts.",
|
| 501 |
+
client_region,
|
| 502 |
+
bucket,
|
| 503 |
+
new_region,
|
| 504 |
+
)
|
| 505 |
+
# Adding the new region to _cache will make construct_endpoint() to
|
| 506 |
+
# use the new region as value for the AWS::Region builtin parameter.
|
| 507 |
+
self._cache[bucket] = new_region
|
| 508 |
+
|
| 509 |
+
# Re-resolve endpoint with new region and modify request_dict with
|
| 510 |
+
# the new URL, auth scheme, and signing context.
|
| 511 |
+
ep_resolver = self._client._ruleset_resolver
|
| 512 |
+
ep_info = await ep_resolver.construct_endpoint(
|
| 513 |
+
operation_model=operation,
|
| 514 |
+
call_args=request_dict['context']['s3_redirect']['params'],
|
| 515 |
+
request_context=request_dict['context'],
|
| 516 |
+
)
|
| 517 |
+
request_dict['url'] = self.set_request_url(
|
| 518 |
+
request_dict['url'], ep_info.url
|
| 519 |
+
)
|
| 520 |
+
request_dict['context']['s3_redirect']['redirected'] = True
|
| 521 |
+
auth_schemes = ep_info.properties.get('authSchemes')
|
| 522 |
+
if auth_schemes is not None:
|
| 523 |
+
auth_info = ep_resolver.auth_schemes_to_signing_ctx(auth_schemes)
|
| 524 |
+
auth_type, signing_context = auth_info
|
| 525 |
+
request_dict['context']['auth_type'] = auth_type
|
| 526 |
+
request_dict['context']['signing'] = {
|
| 527 |
+
**request_dict['context'].get('signing', {}),
|
| 528 |
+
**signing_context,
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
# Return 0 so it doesn't wait to retry
|
| 532 |
+
return 0
|
| 533 |
+
|
| 534 |
+
async def get_bucket_region(self, bucket, response):
|
| 535 |
+
"""
|
| 536 |
+
There are multiple potential sources for the new region to redirect to,
|
| 537 |
+
but they aren't all universally available for use. This will try to
|
| 538 |
+
find region from response elements, but will fall back to calling
|
| 539 |
+
HEAD on the bucket if all else fails.
|
| 540 |
+
:param bucket: The bucket to find the region for. This is necessary if
|
| 541 |
+
the region is not available in the error response.
|
| 542 |
+
:param response: A response representing a service request that failed
|
| 543 |
+
due to incorrect region configuration.
|
| 544 |
+
"""
|
| 545 |
+
# First try to source the region from the headers.
|
| 546 |
+
service_response = response[1]
|
| 547 |
+
response_headers = service_response['ResponseMetadata']['HTTPHeaders']
|
| 548 |
+
if 'x-amz-bucket-region' in response_headers:
|
| 549 |
+
return response_headers['x-amz-bucket-region']
|
| 550 |
+
|
| 551 |
+
# Next, check the error body
|
| 552 |
+
region = service_response.get('Error', {}).get('Region', None)
|
| 553 |
+
if region is not None:
|
| 554 |
+
return region
|
| 555 |
+
|
| 556 |
+
# Finally, HEAD the bucket. No other choice sadly.
|
| 557 |
+
try:
|
| 558 |
+
# NOTE: we don't need to aenter/aexit as we have a ref to the base client
|
| 559 |
+
response = await self._client.head_bucket(Bucket=bucket)
|
| 560 |
+
headers = response['ResponseMetadata']['HTTPHeaders']
|
| 561 |
+
except ClientError as e:
|
| 562 |
+
headers = e.response['ResponseMetadata']['HTTPHeaders']
|
| 563 |
+
|
| 564 |
+
region = headers.get('x-amz-bucket-region', None)
|
| 565 |
+
return region
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
class AioS3RegionRedirector(S3RegionRedirector):
|
| 569 |
+
async def redirect_from_error(
|
| 570 |
+
self, request_dict, response, operation, **kwargs
|
| 571 |
+
):
|
| 572 |
+
if response is None:
|
| 573 |
+
# This could be none if there was a ConnectionError or other
|
| 574 |
+
# transport error.
|
| 575 |
+
return
|
| 576 |
+
|
| 577 |
+
if self._is_s3_accesspoint(request_dict.get('context', {})):
|
| 578 |
+
logger.debug(
|
| 579 |
+
'S3 request was previously to an accesspoint, not redirecting.'
|
| 580 |
+
)
|
| 581 |
+
return
|
| 582 |
+
|
| 583 |
+
if request_dict.get('context', {}).get('s3_redirected'):
|
| 584 |
+
logger.debug(
|
| 585 |
+
'S3 request was previously redirected, not redirecting.'
|
| 586 |
+
)
|
| 587 |
+
return
|
| 588 |
+
|
| 589 |
+
error = response[1].get('Error', {})
|
| 590 |
+
error_code = error.get('Code')
|
| 591 |
+
response_metadata = response[1].get('ResponseMetadata', {})
|
| 592 |
+
|
| 593 |
+
# We have to account for 400 responses because
|
| 594 |
+
# if we sign a Head* request with the wrong region,
|
| 595 |
+
# we'll get a 400 Bad Request but we won't get a
|
| 596 |
+
# body saying it's an "AuthorizationHeaderMalformed".
|
| 597 |
+
is_special_head_object = (
|
| 598 |
+
error_code in ('301', '400') and operation.name == 'HeadObject'
|
| 599 |
+
)
|
| 600 |
+
is_special_head_bucket = (
|
| 601 |
+
error_code in ('301', '400')
|
| 602 |
+
and operation.name == 'HeadBucket'
|
| 603 |
+
and 'x-amz-bucket-region'
|
| 604 |
+
in response_metadata.get('HTTPHeaders', {})
|
| 605 |
+
)
|
| 606 |
+
is_wrong_signing_region = (
|
| 607 |
+
error_code == 'AuthorizationHeaderMalformed' and 'Region' in error
|
| 608 |
+
)
|
| 609 |
+
is_redirect_status = response[0] is not None and response[
|
| 610 |
+
0
|
| 611 |
+
].status_code in (301, 302, 307)
|
| 612 |
+
is_permanent_redirect = error_code == 'PermanentRedirect'
|
| 613 |
+
if not any(
|
| 614 |
+
[
|
| 615 |
+
is_special_head_object,
|
| 616 |
+
is_wrong_signing_region,
|
| 617 |
+
is_permanent_redirect,
|
| 618 |
+
is_special_head_bucket,
|
| 619 |
+
is_redirect_status,
|
| 620 |
+
]
|
| 621 |
+
):
|
| 622 |
+
return
|
| 623 |
+
|
| 624 |
+
bucket = request_dict['context']['signing']['bucket']
|
| 625 |
+
client_region = request_dict['context'].get('client_region')
|
| 626 |
+
new_region = await self.get_bucket_region(bucket, response)
|
| 627 |
+
|
| 628 |
+
if new_region is None:
|
| 629 |
+
logger.debug(
|
| 630 |
+
"S3 client configured for region %s but the bucket %s is not "
|
| 631 |
+
"in that region and the proper region could not be "
|
| 632 |
+
"automatically determined.",
|
| 633 |
+
client_region,
|
| 634 |
+
bucket,
|
| 635 |
+
)
|
| 636 |
+
return
|
| 637 |
+
|
| 638 |
+
logger.debug(
|
| 639 |
+
"S3 client configured for region %s but the bucket %s is in region"
|
| 640 |
+
" %s; Please configure the proper region to avoid multiple "
|
| 641 |
+
"unnecessary redirects and signing attempts.",
|
| 642 |
+
client_region,
|
| 643 |
+
bucket,
|
| 644 |
+
new_region,
|
| 645 |
+
)
|
| 646 |
+
endpoint = self._endpoint_resolver.resolve('s3', new_region)
|
| 647 |
+
endpoint = endpoint['endpoint_url']
|
| 648 |
+
|
| 649 |
+
signing_context = {
|
| 650 |
+
'region': new_region,
|
| 651 |
+
'bucket': bucket,
|
| 652 |
+
'endpoint': endpoint,
|
| 653 |
+
}
|
| 654 |
+
request_dict['context']['signing'] = signing_context
|
| 655 |
+
|
| 656 |
+
self._cache[bucket] = signing_context
|
| 657 |
+
self.set_request_url(request_dict, request_dict['context'])
|
| 658 |
+
|
| 659 |
+
request_dict['context']['s3_redirected'] = True
|
| 660 |
+
|
| 661 |
+
# Return 0 so it doesn't wait to retry
|
| 662 |
+
return 0
|
| 663 |
+
|
| 664 |
+
async def get_bucket_region(self, bucket, response):
|
| 665 |
+
# First try to source the region from the headers.
|
| 666 |
+
service_response = response[1]
|
| 667 |
+
response_headers = service_response['ResponseMetadata']['HTTPHeaders']
|
| 668 |
+
if 'x-amz-bucket-region' in response_headers:
|
| 669 |
+
return response_headers['x-amz-bucket-region']
|
| 670 |
+
|
| 671 |
+
# Next, check the error body
|
| 672 |
+
region = service_response.get('Error', {}).get('Region', None)
|
| 673 |
+
if region is not None:
|
| 674 |
+
return region
|
| 675 |
+
|
| 676 |
+
# Finally, HEAD the bucket. No other choice sadly.
|
| 677 |
+
try:
|
| 678 |
+
# NOTE: we don't need to aenter/aexit as we have a ref to the base client
|
| 679 |
+
response = await self._client.head_bucket(Bucket=bucket)
|
| 680 |
+
headers = response['ResponseMetadata']['HTTPHeaders']
|
| 681 |
+
except ClientError as e:
|
| 682 |
+
headers = e.response['ResponseMetadata']['HTTPHeaders']
|
| 683 |
+
|
| 684 |
+
region = headers.get('x-amz-bucket-region', None)
|
| 685 |
+
return region
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
class AioContainerMetadataFetcher(ContainerMetadataFetcher):
|
| 689 |
+
def __init__(self, session=None, sleep=asyncio.sleep): # noqa: E501, lgtm [py/missing-call-to-init]
|
| 690 |
+
if session is None:
|
| 691 |
+
session = _RefCountedSession(timeout=self.TIMEOUT_SECONDS)
|
| 692 |
+
self._session = session
|
| 693 |
+
self._sleep = sleep
|
| 694 |
+
|
| 695 |
+
async def retrieve_full_uri(self, full_url, headers=None):
|
| 696 |
+
self._validate_allowed_url(full_url)
|
| 697 |
+
return await self._retrieve_credentials(full_url, headers)
|
| 698 |
+
|
| 699 |
+
async def retrieve_uri(self, relative_uri):
|
| 700 |
+
"""Retrieve JSON metadata from container metadata.
|
| 701 |
+
|
| 702 |
+
:type relative_uri: str
|
| 703 |
+
:param relative_uri: A relative URI, e.g "/foo/bar?id=123"
|
| 704 |
+
|
| 705 |
+
:return: The parsed JSON response.
|
| 706 |
+
|
| 707 |
+
"""
|
| 708 |
+
full_url = self.full_url(relative_uri)
|
| 709 |
+
return await self._retrieve_credentials(full_url)
|
| 710 |
+
|
| 711 |
+
async def _retrieve_credentials(self, full_url, extra_headers=None):
|
| 712 |
+
headers = {'Accept': 'application/json'}
|
| 713 |
+
if extra_headers is not None:
|
| 714 |
+
headers.update(extra_headers)
|
| 715 |
+
attempts = 0
|
| 716 |
+
while True:
|
| 717 |
+
try:
|
| 718 |
+
return await self._get_response(
|
| 719 |
+
full_url, headers, self.TIMEOUT_SECONDS
|
| 720 |
+
)
|
| 721 |
+
except MetadataRetrievalError as e:
|
| 722 |
+
logger.debug(
|
| 723 |
+
"Received error when attempting to retrieve "
|
| 724 |
+
"container metadata: %s",
|
| 725 |
+
e,
|
| 726 |
+
exc_info=True,
|
| 727 |
+
)
|
| 728 |
+
await self._sleep(self.SLEEP_TIME)
|
| 729 |
+
attempts += 1
|
| 730 |
+
if attempts >= self.RETRY_ATTEMPTS:
|
| 731 |
+
raise
|
| 732 |
+
|
| 733 |
+
async def _get_response(self, full_url, headers, timeout):
|
| 734 |
+
try:
|
| 735 |
+
async with self._session.acquire() as session:
|
| 736 |
+
AWSRequest = botocore.awsrequest.AWSRequest
|
| 737 |
+
request = AWSRequest(
|
| 738 |
+
method='GET', url=full_url, headers=headers
|
| 739 |
+
)
|
| 740 |
+
response = await session.send(request.prepare())
|
| 741 |
+
response_text = (await response.content).decode('utf-8')
|
| 742 |
+
|
| 743 |
+
if response.status_code != 200:
|
| 744 |
+
raise MetadataRetrievalError(
|
| 745 |
+
error_msg=(
|
| 746 |
+
f"Received non 200 response {response.status_code} "
|
| 747 |
+
f"from container metadata: {response_text}"
|
| 748 |
+
)
|
| 749 |
+
)
|
| 750 |
+
try:
|
| 751 |
+
return json.loads(response_text)
|
| 752 |
+
except ValueError:
|
| 753 |
+
error_msg = "Unable to parse JSON returned from container metadata services"
|
| 754 |
+
logger.debug('%s:%s', error_msg, response_text)
|
| 755 |
+
raise MetadataRetrievalError(error_msg=error_msg)
|
| 756 |
+
|
| 757 |
+
except RETRYABLE_HTTP_ERRORS as e:
|
| 758 |
+
error_msg = (
|
| 759 |
+
"Received error when attempting to retrieve "
|
| 760 |
+
f"container metadata: {e}"
|
| 761 |
+
)
|
| 762 |
+
raise MetadataRetrievalError(error_msg=error_msg)
|
| 763 |
+
|
| 764 |
+
|
| 765 |
+
@contextlib.asynccontextmanager
|
| 766 |
+
async def create_nested_client(session, service_name, **kwargs):
|
| 767 |
+
"""Create a nested client with plugin context disabled.
|
| 768 |
+
|
| 769 |
+
If a client is created from within a plugin based on the environment variable,
|
| 770 |
+
an infinite loop could arise. Any clients created from within another client
|
| 771 |
+
must use this method to prevent infinite loops.
|
| 772 |
+
|
| 773 |
+
This is the async version of botocore.utils.create_nested_client that works
|
| 774 |
+
with aiobotocore's async session.
|
| 775 |
+
|
| 776 |
+
Usage:
|
| 777 |
+
async with create_nested_client(session, 'sts', region_name='us-east-1') as client:
|
| 778 |
+
response = await client.assume_role(...)
|
| 779 |
+
"""
|
| 780 |
+
# Set plugin context to disabled
|
| 781 |
+
ctx = PluginContext(plugins="DISABLED")
|
| 782 |
+
token = set_plugin_context(ctx)
|
| 783 |
+
|
| 784 |
+
try:
|
| 785 |
+
# Create client context
|
| 786 |
+
async with session.create_client(service_name, **kwargs) as client:
|
| 787 |
+
# Reset plugin context immediately after client creation, matching botocore behavior
|
| 788 |
+
reset_plugin_context(token)
|
| 789 |
+
token =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
| 1 |
+
import asyncio
|
| 2 |
+
from functools import partial
|
| 3 |
+
|
| 4 |
+
# WaiterModel is required for client.py import
|
| 5 |
+
from botocore.docs.docstring import WaiterDocstring
|
| 6 |
+
from botocore.exceptions import ClientError
|
| 7 |
+
from botocore.useragent import register_feature_id
|
| 8 |
+
from botocore.utils import get_service_module_name
|
| 9 |
+
from botocore.waiter import (
|
| 10 |
+
NormalizedOperationMethod as _NormalizedOperationMethod,
|
| 11 |
+
)
|
| 12 |
+
from botocore.waiter import (
|
| 13 |
+
Waiter,
|
| 14 |
+
WaiterError,
|
| 15 |
+
WaiterModel, # noqa: F401 lgtm[py/unused-import]
|
| 16 |
+
is_valid_waiter_error,
|
| 17 |
+
logger,
|
| 18 |
+
xform_name,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
from .context import with_current_context
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def create_waiter_with_client(waiter_name, waiter_model, client):
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
:type waiter_name: str
|
| 28 |
+
:param waiter_name: The name of the waiter. The name should match
|
| 29 |
+
the name (including the casing) of the key name in the waiter
|
| 30 |
+
model file (typically this is CamelCasing).
|
| 31 |
+
|
| 32 |
+
:type waiter_model: botocore.waiter.WaiterModel
|
| 33 |
+
:param waiter_model: The model for the waiter configuration.
|
| 34 |
+
|
| 35 |
+
:type client: botocore.client.BaseClient
|
| 36 |
+
:param client: The botocore client associated with the service.
|
| 37 |
+
|
| 38 |
+
:rtype: botocore.waiter.Waiter
|
| 39 |
+
:return: The waiter object.
|
| 40 |
+
|
| 41 |
+
"""
|
| 42 |
+
single_waiter_config = waiter_model.get_waiter(waiter_name)
|
| 43 |
+
operation_name = xform_name(single_waiter_config.operation)
|
| 44 |
+
operation_method = NormalizedOperationMethod(
|
| 45 |
+
getattr(client, operation_name)
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Create a new wait method that will serve as a proxy to the underlying
|
| 49 |
+
# Waiter.wait method. This is needed to attach a docstring to the
|
| 50 |
+
# method.
|
| 51 |
+
async def wait(self, **kwargs):
|
| 52 |
+
return await AIOWaiter.wait(self, **kwargs)
|
| 53 |
+
|
| 54 |
+
wait.__doc__ = WaiterDocstring(
|
| 55 |
+
waiter_name=waiter_name,
|
| 56 |
+
event_emitter=client.meta.events,
|
| 57 |
+
service_model=client.meta.service_model,
|
| 58 |
+
service_waiter_model=waiter_model,
|
| 59 |
+
include_signature=False,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# Rename the waiter class based on the type of waiter.
|
| 63 |
+
waiter_class_name = str(
|
| 64 |
+
f'{get_service_module_name(client.meta.service_model)}.Waiter.{waiter_name}'
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
# Create the new waiter class
|
| 68 |
+
documented_waiter_cls = type(
|
| 69 |
+
waiter_class_name, (AIOWaiter,), {'wait': wait}
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
# Return an instance of the new waiter class.
|
| 73 |
+
return documented_waiter_cls(
|
| 74 |
+
waiter_name, single_waiter_config, operation_method
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
class NormalizedOperationMethod(_NormalizedOperationMethod):
|
| 79 |
+
async def __call__(self, **kwargs):
|
| 80 |
+
try:
|
| 81 |
+
return await self._client_method(**kwargs)
|
| 82 |
+
except ClientError as e:
|
| 83 |
+
return e.response
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class AIOWaiter(Waiter):
|
| 87 |
+
@with_current_context(partial(register_feature_id, 'WAITER'))
|
| 88 |
+
async def wait(self, **kwargs):
|
| 89 |
+
acceptors = list(self.config.acceptors)
|
| 90 |
+
current_state = 'waiting'
|
| 91 |
+
# pop the invocation specific config
|
| 92 |
+
config = kwargs.pop('WaiterConfig', {})
|
| 93 |
+
sleep_amount = config.get('Delay', self.config.delay)
|
| 94 |
+
max_attempts = config.get('MaxAttempts', self.config.max_attempts)
|
| 95 |
+
last_matched_acceptor = None
|
| 96 |
+
num_attempts = 0
|
| 97 |
+
|
| 98 |
+
while True:
|
| 99 |
+
response = await self._operation_method(**kwargs)
|
| 100 |
+
num_attempts += 1
|
| 101 |
+
for acceptor in acceptors:
|
| 102 |
+
if acceptor.matcher_func(response):
|
| 103 |
+
last_matched_acceptor = acceptor
|
| 104 |
+
current_state = acceptor.state
|
| 105 |
+
break
|
| 106 |
+
else:
|
| 107 |
+
# If none of the acceptors matched, we should
|
| 108 |
+
# transition to the failure state if an error
|
| 109 |
+
# response was received.
|
| 110 |
+
if is_valid_waiter_error(response):
|
| 111 |
+
# Transition to a failure state, which we
|
| 112 |
+
# can just handle here by raising an exception.
|
| 113 |
+
raise WaiterError(
|
| 114 |
+
name=self.name,
|
| 115 |
+
reason='An error occurred ({}): {}'.format(
|
| 116 |
+
response['Error'].get('Code', 'Unknown'),
|
| 117 |
+
response['Error'].get('Message', 'Unknown'),
|
| 118 |
+
),
|
| 119 |
+
last_response=response,
|
| 120 |
+
)
|
| 121 |
+
if current_state == 'success':
|
| 122 |
+
logger.debug(
|
| 123 |
+
"Waiting complete, waiter matched the success state."
|
| 124 |
+
)
|
| 125 |
+
return response
|
| 126 |
+
if current_state == 'failure':
|
| 127 |
+
reason = f'Waiter encountered a terminal failure state: {acceptor.explanation}'
|
| 128 |
+
raise WaiterError(
|
| 129 |
+
name=self.name,
|
| 130 |
+
reason=reason,
|
| 131 |
+
last_response=response,
|
| 132 |
+
)
|
| 133 |
+
if num_attempts >= max_attempts:
|
| 134 |
+
if last_matched_acceptor is None:
|
| 135 |
+
reason = 'Max attempts exceeded'
|
| 136 |
+
else:
|
| 137 |
+
reason = (
|
| 138 |
+
f'Max attempts exceeded. Previously accepted state: '
|
| 139 |
+
f'{acceptor.explanation}'
|
| 140 |
+
)
|
| 141 |
+
raise WaiterError(
|
| 142 |
+
name=self.name,
|
| 143 |
+
reason=reason,
|
| 144 |
+
last_response=response,
|
| 145 |
+
)
|
| 146 |
+
await asyncio.sleep(sleep_amount)
|
data/con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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
A. HISTORY OF THE SOFTWARE
|
| 2 |
+
==========================
|
| 3 |
+
|
| 4 |
+
Python was created in the early 1990s by Guido van Rossum at Stichting
|
| 5 |
+
Mathematisch Centrum (CWI, see https://www.cwi.nl) in the Netherlands
|
| 6 |
+
as a successor of a language called ABC. Guido remains Python's
|
| 7 |
+
principal author, although it includes many contributions from others.
|
| 8 |
+
|
| 9 |
+
In 1995, Guido continued his work on Python at the Corporation for
|
| 10 |
+
National Research Initiatives (CNRI, see https://www.cnri.reston.va.us)
|
| 11 |
+
in Reston, Virginia where he released several versions of the
|
| 12 |
+
software.
|
| 13 |
+
|
| 14 |
+
In May 2000, Guido and the Python core development team moved to
|
| 15 |
+
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
| 16 |
+
year, the PythonLabs team moved to Digital Creations, which became
|
| 17 |
+
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
|
| 18 |
+
https://www.python.org/psf/) was formed, a non-profit organization
|
| 19 |
+
created specifically to own Python-related Intellectual Property.
|
| 20 |
+
Zope Corporation was a sponsoring member of the PSF.
|
| 21 |
+
|
| 22 |
+
All Python releases are Open Source (see https://opensource.org for
|
| 23 |
+
the Open Source Definition). Historically, most, but not all, Python
|
| 24 |
+
releases have also been GPL-compatible; the table below summarizes
|
| 25 |
+
the various releases.
|
| 26 |
+
|
| 27 |
+
Release Derived Year Owner GPL-
|
| 28 |
+
from compatible? (1)
|
| 29 |
+
|
| 30 |
+
0.9.0 thru 1.2 1991-1995 CWI yes
|
| 31 |
+
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
| 32 |
+
1.6 1.5.2 2000 CNRI no
|
| 33 |
+
2.0 1.6 2000 BeOpen.com no
|
| 34 |
+
1.6.1 1.6 2001 CNRI yes (2)
|
| 35 |
+
2.1 2.0+1.6.1 2001 PSF no
|
| 36 |
+
2.0.1 2.0+1.6.1 2001 PSF yes
|
| 37 |
+
2.1.1 2.1+2.0.1 2001 PSF yes
|
| 38 |
+
2.1.2 2.1.1 2002 PSF yes
|
| 39 |
+
2.1.3 2.1.2 2002 PSF yes
|
| 40 |
+
2.2 and above 2.1.1 2001-now PSF yes
|
| 41 |
+
|
| 42 |
+
Footnotes:
|
| 43 |
+
|
| 44 |
+
(1) GPL-compatible doesn't mean that we're distributing Python under
|
| 45 |
+
the GPL. All Python licenses, unlike the GPL, let you distribute
|
| 46 |
+
a modified version without making your changes open source. The
|
| 47 |
+
GPL-compatible licenses make it possible to combine Python with
|
| 48 |
+
other software that is released under the GPL; the others don't.
|
| 49 |
+
|
| 50 |
+
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
| 51 |
+
because its license has a choice of law clause. According to
|
| 52 |
+
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
| 53 |
+
is "not incompatible" with the GPL.
|
| 54 |
+
|
| 55 |
+
Thanks to the many outside volunteers who have worked under Guido's
|
| 56 |
+
direction to make these releases possible.
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
| 60 |
+
===============================================================
|
| 61 |
+
|
| 62 |
+
Python software and documentation are licensed under the
|
| 63 |
+
Python Software Foundation License Version 2.
|
| 64 |
+
|
| 65 |
+
Starting with Python 3.8.6, examples, recipes, and other code in
|
| 66 |
+
the documentation are dual licensed under the PSF License Version 2
|
| 67 |
+
and the Zero-Clause BSD license.
|
| 68 |
+
|
| 69 |
+
Some software incorporated into Python is under different licenses.
|
| 70 |
+
The licenses are listed with code falling under that license.
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
| 74 |
+
--------------------------------------------
|
| 75 |
+
|
| 76 |
+
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
| 77 |
+
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
| 78 |
+
otherwise using this software ("Python") in source or binary form and
|
| 79 |
+
its associated documentation.
|
| 80 |
+
|
| 81 |
+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
| 82 |
+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
| 83 |
+
analyze, test, perform and/or display publicly, prepare derivative works,
|
| 84 |
+
distribute, and otherwise use Python alone or in any derivative version,
|
| 85 |
+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
| 86 |
+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
| 87 |
+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Python Software Foundation;
|
| 88 |
+
All Rights Reserved" are retained in Python alone or in any derivative version
|
| 89 |
+
prepared by Licensee.
|
| 90 |
+
|
| 91 |
+
3. In the event Licensee prepares a derivative work that is based on
|
| 92 |
+
or incorporates Python or any part thereof, and wants to make
|
| 93 |
+
the derivative work available to others as provided herein, then
|
| 94 |
+
Licensee hereby agrees to include in any such work a brief summary of
|
| 95 |
+
the changes made to Python.
|
| 96 |
+
|
| 97 |
+
4. PSF is making Python available to Licensee on an "AS IS"
|
| 98 |
+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 99 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
| 100 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 101 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
| 102 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 103 |
+
|
| 104 |
+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
| 105 |
+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
| 106 |
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
| 107 |
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 108 |
+
|
| 109 |
+
6. This License Agreement will automatically terminate upon a material
|
| 110 |
+
breach of its terms and conditions.
|
| 111 |
+
|
| 112 |
+
7. Nothing in this License Agreement shall be deemed to create any
|
| 113 |
+
relationship of agency, partnership, or joint venture between PSF and
|
| 114 |
+
Licensee. This License Agreement does not grant permission to use PSF
|
| 115 |
+
trademarks or trade name in a trademark sense to endorse or promote
|
| 116 |
+
products or services of Licensee, or any third party.
|
| 117 |
+
|
| 118 |
+
8. By copying, installing or otherwise using Python, Licensee
|
| 119 |
+
agrees to be bound by the terms and conditions of this License
|
| 120 |
+
Agreement.
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
| 124 |
+
-------------------------------------------
|
| 125 |
+
|
| 126 |
+
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
| 127 |
+
|
| 128 |
+
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
| 129 |
+
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
| 130 |
+
Individual or Organization ("Licensee") accessing and otherwise using
|
| 131 |
+
this software in source or binary form and its associated
|
| 132 |
+
documentation ("the Software").
|
| 133 |
+
|
| 134 |
+
2. Subject to the terms and conditions of this BeOpen Python License
|
| 135 |
+
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
| 136 |
+
royalty-free, world-wide license to reproduce, analyze, test, perform
|
| 137 |
+
and/or display publicly, prepare derivative works, distribute, and
|
| 138 |
+
otherwise use the Software alone or in any derivative version,
|
| 139 |
+
provided, however, that the BeOpen Python License is retained in the
|
| 140 |
+
Software, alone or in any derivative version prepared by Licensee.
|
| 141 |
+
|
| 142 |
+
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
| 143 |
+
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 144 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
| 145 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 146 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
| 147 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 148 |
+
|
| 149 |
+
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
| 150 |
+
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
| 151 |
+
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
| 152 |
+
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 153 |
+
|
| 154 |
+
5. This License Agreement will automatically terminate upon a material
|
| 155 |
+
breach of its terms and conditions.
|
| 156 |
+
|
| 157 |
+
6. This License Agreement shall be governed by and interpreted in all
|
| 158 |
+
respects by the law of the State of California, excluding conflict of
|
| 159 |
+
law provisions. Nothing in this License Agreement shall be deemed to
|
| 160 |
+
create any relationship of agency, partnership, or joint venture
|
| 161 |
+
between BeOpen and Licensee. This License Agreement does not grant
|
| 162 |
+
permission to use BeOpen trademarks or trade names in a trademark
|
| 163 |
+
sense to endorse or promote products or services of Licensee, or any
|
| 164 |
+
third party. As an exception, the "BeOpen Python" logos available at
|
| 165 |
+
http://www.pythonlabs.com/logos.html may be used according to the
|
| 166 |
+
permissions granted on that web page.
|
| 167 |
+
|
| 168 |
+
7. By copying, installing or otherwise using the software, Licensee
|
| 169 |
+
agrees to be bound by the terms and conditions of this License
|
| 170 |
+
Agreement.
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
| 174 |
+
---------------------------------------
|
| 175 |
+
|
| 176 |
+
1. This LICENSE AGREEMENT is between the Corporation for National
|
| 177 |
+
Research Initiatives, having an office at 1895 Preston White Drive,
|
| 178 |
+
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
| 179 |
+
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
| 180 |
+
source or binary form and its associated documentation.
|
| 181 |
+
|
| 182 |
+
2. Subject to the terms and conditions of this License Agreement, CNRI
|
| 183 |
+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
| 184 |
+
license to reproduce, analyze, test, perform and/or display publicly,
|
| 185 |
+
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
| 186 |
+
alone or in any derivative version, provided, however, that CNRI's
|
| 187 |
+
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
| 188 |
+
1995-2001 Corporation for National Research Initiatives; All Rights
|
| 189 |
+
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
| 190 |
+
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
| 191 |
+
Agreement, Licensee may substitute the following text (omitting the
|
| 192 |
+
quotes): "Python 1.6.1 is made available subject to the terms and
|
| 193 |
+
conditions in CNRI's License Agreement. This Agreement together with
|
| 194 |
+
Python 1.6.1 may be located on the internet using the following
|
| 195 |
+
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
| 196 |
+
Agreement may also be obtained from a proxy server on the internet
|
| 197 |
+
using the following URL: http://hdl.handle.net/1895.22/1013".
|
| 198 |
+
|
| 199 |
+
3. In the event Licensee prepares a derivative work that is based on
|
| 200 |
+
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
| 201 |
+
the derivative work available to others as provided herein, then
|
| 202 |
+
Licensee hereby agrees to include in any such work a brief summary of
|
| 203 |
+
the changes made to Python 1.6.1.
|
| 204 |
+
|
| 205 |
+
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
| 206 |
+
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 207 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
| 208 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 209 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
| 210 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 211 |
+
|
| 212 |
+
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
| 213 |
+
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
| 214 |
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
| 215 |
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 216 |
+
|
| 217 |
+
6. This License Agreement will automatically terminate upon a material
|
| 218 |
+
breach of its terms and conditions.
|
| 219 |
+
|
| 220 |
+
7. This License Agreement shall be governed by the federal
|
| 221 |
+
intellectual property law of the United States, including without
|
| 222 |
+
limitation the federal copyright law, and, to the extent such
|
| 223 |
+
U.S. federal law does not apply, by the law of the Commonwealth of
|
| 224 |
+
Virginia, excluding Virginia's conflict of law provisions.
|
| 225 |
+
Notwithstanding the foregoing, with regard to derivative works based
|
| 226 |
+
on Python 1.6.1 that incorporate non-separable material that was
|
| 227 |
+
previously distributed under the GNU General Public License (GPL), the
|
| 228 |
+
law of the Commonwealth of Virginia shall govern this License
|
| 229 |
+
Agreement only as to issues arising under or with respect to
|
| 230 |
+
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
| 231 |
+
License Agreement shall be deemed to create any relationship of
|
| 232 |
+
agency, partnership, or joint venture between CNRI and Licensee. This
|
| 233 |
+
License Agreement does not grant permission to use CNRI trademarks or
|
| 234 |
+
trade name in a trademark sense to endorse or promote products or
|
| 235 |
+
services of Licensee, or any third party.
|
| 236 |
+
|
| 237 |
+
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
| 238 |
+
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
| 239 |
+
bound by the terms and conditions of this License Agreement.
|
| 240 |
+
|
| 241 |
+
ACCEPT
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
| 245 |
+
--------------------------------------------------
|
| 246 |
+
|
| 247 |
+
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
| 248 |
+
The Netherlands. All rights reserved.
|
| 249 |
+
|
| 250 |
+
Permission to use, copy, modify, and distribute this software and its
|
| 251 |
+
documentation for any purpose and without fee is hereby granted,
|
| 252 |
+
provided that the above copyright notice appear in all copies and that
|
| 253 |
+
both that copyright notice and this permission notice appear in
|
| 254 |
+
supporting documentation, and that the name of Stichting Mathematisch
|
| 255 |
+
Centrum or CWI not be used in advertising or publicity pertaining to
|
| 256 |
+
distribution of the software without specific, written prior
|
| 257 |
+
permission.
|
| 258 |
+
|
| 259 |
+
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
| 260 |
+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
| 261 |
+
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
| 262 |
+
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 263 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 264 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
| 265 |
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 266 |
+
|
| 267 |
+
ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION
|
| 268 |
+
----------------------------------------------------------------------
|
| 269 |
+
|
| 270 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 271 |
+
purpose with or without fee is hereby granted.
|
| 272 |
+
|
| 273 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
| 274 |
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
| 275 |
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
| 276 |
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
| 277 |
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
| 278 |
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
| 279 |
+
PERFORMANCE OF THIS SOFTWARE.
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/METADATA
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.3
|
| 2 |
+
Name: aiohappyeyeballs
|
| 3 |
+
Version: 2.6.1
|
| 4 |
+
Summary: Happy Eyeballs for asyncio
|
| 5 |
+
License: PSF-2.0
|
| 6 |
+
Author: J. Nick Koston
|
| 7 |
+
Author-email: nick@koston.org
|
| 8 |
+
Requires-Python: >=3.9
|
| 9 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 10 |
+
Classifier: Intended Audience :: Developers
|
| 11 |
+
Classifier: Natural Language :: English
|
| 12 |
+
Classifier: Operating System :: OS Independent
|
| 13 |
+
Classifier: Topic :: Software Development :: Libraries
|
| 14 |
+
Classifier: Programming Language :: Python :: 3
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 20 |
+
Classifier: License :: OSI Approved :: Python Software Foundation License
|
| 21 |
+
Project-URL: Bug Tracker, https://github.com/aio-libs/aiohappyeyeballs/issues
|
| 22 |
+
Project-URL: Changelog, https://github.com/aio-libs/aiohappyeyeballs/blob/main/CHANGELOG.md
|
| 23 |
+
Project-URL: Documentation, https://aiohappyeyeballs.readthedocs.io
|
| 24 |
+
Project-URL: Repository, https://github.com/aio-libs/aiohappyeyeballs
|
| 25 |
+
Description-Content-Type: text/markdown
|
| 26 |
+
|
| 27 |
+
# aiohappyeyeballs
|
| 28 |
+
|
| 29 |
+
<p align="center">
|
| 30 |
+
<a href="https://github.com/aio-libs/aiohappyeyeballs/actions/workflows/ci.yml?query=branch%3Amain">
|
| 31 |
+
<img src="https://img.shields.io/github/actions/workflow/status/aio-libs/aiohappyeyeballs/ci-cd.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
|
| 32 |
+
</a>
|
| 33 |
+
<a href="https://aiohappyeyeballs.readthedocs.io">
|
| 34 |
+
<img src="https://img.shields.io/readthedocs/aiohappyeyeballs.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
|
| 35 |
+
</a>
|
| 36 |
+
<a href="https://codecov.io/gh/aio-libs/aiohappyeyeballs">
|
| 37 |
+
<img src="https://img.shields.io/codecov/c/github/aio-libs/aiohappyeyeballs.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
| 38 |
+
</a>
|
| 39 |
+
</p>
|
| 40 |
+
<p align="center">
|
| 41 |
+
<a href="https://python-poetry.org/">
|
| 42 |
+
<img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=" alt="Poetry">
|
| 43 |
+
</a>
|
| 44 |
+
<a href="https://github.com/astral-sh/ruff">
|
| 45 |
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
| 46 |
+
</a>
|
| 47 |
+
<a href="https://github.com/pre-commit/pre-commit">
|
| 48 |
+
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
|
| 49 |
+
</a>
|
| 50 |
+
</p>
|
| 51 |
+
<p align="center">
|
| 52 |
+
<a href="https://pypi.org/project/aiohappyeyeballs/">
|
| 53 |
+
<img src="https://img.shields.io/pypi/v/aiohappyeyeballs.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
|
| 54 |
+
</a>
|
| 55 |
+
<img src="https://img.shields.io/pypi/pyversions/aiohappyeyeballs.svg?style=flat-square&logo=python&logoColor=fff" alt="Supported Python versions">
|
| 56 |
+
<img src="https://img.shields.io/pypi/l/aiohappyeyeballs.svg?style=flat-square" alt="License">
|
| 57 |
+
</p>
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
**Documentation**: <a href="https://aiohappyeyeballs.readthedocs.io" target="_blank">https://aiohappyeyeballs.readthedocs.io </a>
|
| 62 |
+
|
| 63 |
+
**Source Code**: <a href="https://github.com/aio-libs/aiohappyeyeballs" target="_blank">https://github.com/aio-libs/aiohappyeyeballs </a>
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
[Happy Eyeballs](https://en.wikipedia.org/wiki/Happy_Eyeballs)
|
| 68 |
+
([RFC 8305](https://www.rfc-editor.org/rfc/rfc8305.html))
|
| 69 |
+
|
| 70 |
+
## Use case
|
| 71 |
+
|
| 72 |
+
This library exists to allow connecting with
|
| 73 |
+
[Happy Eyeballs](https://en.wikipedia.org/wiki/Happy_Eyeballs)
|
| 74 |
+
([RFC 8305](https://www.rfc-editor.org/rfc/rfc8305.html))
|
| 75 |
+
when you
|
| 76 |
+
already have a list of addrinfo and not a DNS name.
|
| 77 |
+
|
| 78 |
+
The stdlib version of `loop.create_connection()`
|
| 79 |
+
will only work when you pass in an unresolved name which
|
| 80 |
+
is not a good fit when using DNS caching or resolving
|
| 81 |
+
names via another method such as `zeroconf`.
|
| 82 |
+
|
| 83 |
+
## Installation
|
| 84 |
+
|
| 85 |
+
Install this via pip (or your favourite package manager):
|
| 86 |
+
|
| 87 |
+
`pip install aiohappyeyeballs`
|
| 88 |
+
|
| 89 |
+
## License
|
| 90 |
+
|
| 91 |
+
[aiohappyeyeballs is licensed under the same terms as cpython itself.](https://github.com/python/cpython/blob/main/LICENSE)
|
| 92 |
+
|
| 93 |
+
## Example usage
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
|
| 97 |
+
addr_infos = await loop.getaddrinfo("example.org", 80)
|
| 98 |
+
|
| 99 |
+
socket = await start_connection(addr_infos)
|
| 100 |
+
socket = await start_connection(addr_infos, local_addr_infos=local_addr_infos, happy_eyeballs_delay=0.2)
|
| 101 |
+
|
| 102 |
+
transport, protocol = await loop.create_connection(
|
| 103 |
+
MyProtocol, sock=socket, ...)
|
| 104 |
+
|
| 105 |
+
# Remove the first address for each family from addr_info
|
| 106 |
+
pop_addr_infos_interleave(addr_info, 1)
|
| 107 |
+
|
| 108 |
+
# Remove all matching address from addr_info
|
| 109 |
+
remove_addr_infos(addr_info, "dead::beef::")
|
| 110 |
+
|
| 111 |
+
# Convert a local_addr to local_addr_infos
|
| 112 |
+
local_addr_infos = addr_to_addr_infos(("127.0.0.1",0))
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
## Credits
|
| 116 |
+
|
| 117 |
+
This package contains code from cpython and is licensed under the same terms as cpython itself.
|
| 118 |
+
|
| 119 |
+
This package was created with
|
| 120 |
+
[Copier](https://copier.readthedocs.io/) and the
|
| 121 |
+
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
|
| 122 |
+
project template.
|
| 123 |
+
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/RECORD
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiohappyeyeballs-2.6.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
aiohappyeyeballs-2.6.1.dist-info/LICENSE,sha256=Oy-B_iHRgcSZxZolbI4ZaEVdZonSaaqFNzv7avQdo78,13936
|
| 3 |
+
aiohappyeyeballs-2.6.1.dist-info/METADATA,sha256=NSXlhJwAfi380eEjAo7BQ4P_TVal9xi0qkyZWibMsVM,5915
|
| 4 |
+
aiohappyeyeballs-2.6.1.dist-info/RECORD,,
|
| 5 |
+
aiohappyeyeballs-2.6.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
| 6 |
+
aiohappyeyeballs/__init__.py,sha256=x7kktHEtaD9quBcWDJPuLeKyjuVAI-Jj14S9B_5hcTs,361
|
| 7 |
+
aiohappyeyeballs/__pycache__/__init__.cpython-311.pyc,,
|
| 8 |
+
aiohappyeyeballs/__pycache__/_staggered.cpython-311.pyc,,
|
| 9 |
+
aiohappyeyeballs/__pycache__/impl.cpython-311.pyc,,
|
| 10 |
+
aiohappyeyeballs/__pycache__/types.cpython-311.pyc,,
|
| 11 |
+
aiohappyeyeballs/__pycache__/utils.cpython-311.pyc,,
|
| 12 |
+
aiohappyeyeballs/_staggered.py,sha256=edfVowFx-P-ywJjIEF3MdPtEMVODujV6CeMYr65otac,6900
|
| 13 |
+
aiohappyeyeballs/impl.py,sha256=Dlcm2mTJ28ucrGnxkb_fo9CZzLAkOOBizOt7dreBbXE,9681
|
| 14 |
+
aiohappyeyeballs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 15 |
+
aiohappyeyeballs/types.py,sha256=YZJIAnyoV4Dz0WFtlaf_OyE4EW7Xus1z7aIfNI6tDDQ,425
|
| 16 |
+
aiohappyeyeballs/utils.py,sha256=on9GxIR0LhEfZu8P6Twi9hepX9zDanuZM20MWsb3xlQ,3028
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohappyeyeballs-2.6.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: poetry-core 2.1.1
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/METADATA
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: aiohttp
|
| 3 |
+
Version: 3.13.3
|
| 4 |
+
Summary: Async http client/server framework (asyncio)
|
| 5 |
+
Maintainer-email: aiohttp team <team@aiohttp.org>
|
| 6 |
+
License: Apache-2.0 AND MIT
|
| 7 |
+
Project-URL: Homepage, https://github.com/aio-libs/aiohttp
|
| 8 |
+
Project-URL: Chat: Matrix, https://matrix.to/#/#aio-libs:matrix.org
|
| 9 |
+
Project-URL: Chat: Matrix Space, https://matrix.to/#/#aio-libs-space:matrix.org
|
| 10 |
+
Project-URL: CI: GitHub Actions, https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI
|
| 11 |
+
Project-URL: Coverage: codecov, https://codecov.io/github/aio-libs/aiohttp
|
| 12 |
+
Project-URL: Docs: Changelog, https://docs.aiohttp.org/en/stable/changes.html
|
| 13 |
+
Project-URL: Docs: RTD, https://docs.aiohttp.org
|
| 14 |
+
Project-URL: GitHub: issues, https://github.com/aio-libs/aiohttp/issues
|
| 15 |
+
Project-URL: GitHub: repo, https://github.com/aio-libs/aiohttp
|
| 16 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 17 |
+
Classifier: Framework :: AsyncIO
|
| 18 |
+
Classifier: Intended Audience :: Developers
|
| 19 |
+
Classifier: Operating System :: POSIX
|
| 20 |
+
Classifier: Operating System :: MacOS :: MacOS X
|
| 21 |
+
Classifier: Operating System :: Microsoft :: Windows
|
| 22 |
+
Classifier: Programming Language :: Python
|
| 23 |
+
Classifier: Programming Language :: Python :: 3
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 25 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 26 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 27 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 28 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 29 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 30 |
+
Classifier: Topic :: Internet :: WWW/HTTP
|
| 31 |
+
Requires-Python: >=3.9
|
| 32 |
+
Description-Content-Type: text/x-rst
|
| 33 |
+
License-File: LICENSE.txt
|
| 34 |
+
License-File: vendor/llhttp/LICENSE
|
| 35 |
+
Requires-Dist: aiohappyeyeballs>=2.5.0
|
| 36 |
+
Requires-Dist: aiosignal>=1.4.0
|
| 37 |
+
Requires-Dist: async-timeout<6.0,>=4.0; python_version < "3.11"
|
| 38 |
+
Requires-Dist: attrs>=17.3.0
|
| 39 |
+
Requires-Dist: frozenlist>=1.1.1
|
| 40 |
+
Requires-Dist: multidict<7.0,>=4.5
|
| 41 |
+
Requires-Dist: propcache>=0.2.0
|
| 42 |
+
Requires-Dist: yarl<2.0,>=1.17.0
|
| 43 |
+
Provides-Extra: speedups
|
| 44 |
+
Requires-Dist: aiodns>=3.3.0; extra == "speedups"
|
| 45 |
+
Requires-Dist: Brotli>=1.2; platform_python_implementation == "CPython" and extra == "speedups"
|
| 46 |
+
Requires-Dist: brotlicffi>=1.2; platform_python_implementation != "CPython" and extra == "speedups"
|
| 47 |
+
Requires-Dist: backports.zstd; (platform_python_implementation == "CPython" and python_version < "3.14") and extra == "speedups"
|
| 48 |
+
Dynamic: license-file
|
| 49 |
+
|
| 50 |
+
==================================
|
| 51 |
+
Async http client/server framework
|
| 52 |
+
==================================
|
| 53 |
+
|
| 54 |
+
.. image:: https://raw.githubusercontent.com/aio-libs/aiohttp/master/docs/aiohttp-plain.svg
|
| 55 |
+
:height: 64px
|
| 56 |
+
:width: 64px
|
| 57 |
+
:alt: aiohttp logo
|
| 58 |
+
|
| 59 |
+
|
|
| 60 |
+
|
| 61 |
+
.. image:: https://github.com/aio-libs/aiohttp/workflows/CI/badge.svg
|
| 62 |
+
:target: https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI
|
| 63 |
+
:alt: GitHub Actions status for master branch
|
| 64 |
+
|
| 65 |
+
.. image:: https://codecov.io/gh/aio-libs/aiohttp/branch/master/graph/badge.svg
|
| 66 |
+
:target: https://codecov.io/gh/aio-libs/aiohttp
|
| 67 |
+
:alt: codecov.io status for master branch
|
| 68 |
+
|
| 69 |
+
.. image:: https://badge.fury.io/py/aiohttp.svg
|
| 70 |
+
:target: https://pypi.org/project/aiohttp
|
| 71 |
+
:alt: Latest PyPI package version
|
| 72 |
+
|
| 73 |
+
.. image:: https://img.shields.io/pypi/dm/aiohttp
|
| 74 |
+
:target: https://pypistats.org/packages/aiohttp
|
| 75 |
+
:alt: Downloads count
|
| 76 |
+
|
| 77 |
+
.. image:: https://readthedocs.org/projects/aiohttp/badge/?version=latest
|
| 78 |
+
:target: https://docs.aiohttp.org/
|
| 79 |
+
:alt: Latest Read The Docs
|
| 80 |
+
|
| 81 |
+
.. image:: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json
|
| 82 |
+
:target: https://codspeed.io/aio-libs/aiohttp
|
| 83 |
+
:alt: Codspeed.io status for aiohttp
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
Key Features
|
| 87 |
+
============
|
| 88 |
+
|
| 89 |
+
- Supports both client and server side of HTTP protocol.
|
| 90 |
+
- Supports both client and server Web-Sockets out-of-the-box and avoids
|
| 91 |
+
Callback Hell.
|
| 92 |
+
- Provides Web-server with middleware and pluggable routing.
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
Getting started
|
| 96 |
+
===============
|
| 97 |
+
|
| 98 |
+
Client
|
| 99 |
+
------
|
| 100 |
+
|
| 101 |
+
To get something from the web:
|
| 102 |
+
|
| 103 |
+
.. code-block:: python
|
| 104 |
+
|
| 105 |
+
import aiohttp
|
| 106 |
+
import asyncio
|
| 107 |
+
|
| 108 |
+
async def main():
|
| 109 |
+
|
| 110 |
+
async with aiohttp.ClientSession() as session:
|
| 111 |
+
async with session.get('http://python.org') as response:
|
| 112 |
+
|
| 113 |
+
print("Status:", response.status)
|
| 114 |
+
print("Content-type:", response.headers['content-type'])
|
| 115 |
+
|
| 116 |
+
html = await response.text()
|
| 117 |
+
print("Body:", html[:15], "...")
|
| 118 |
+
|
| 119 |
+
asyncio.run(main())
|
| 120 |
+
|
| 121 |
+
This prints:
|
| 122 |
+
|
| 123 |
+
.. code-block::
|
| 124 |
+
|
| 125 |
+
Status: 200
|
| 126 |
+
Content-type: text/html; charset=utf-8
|
| 127 |
+
Body: <!doctype html> ...
|
| 128 |
+
|
| 129 |
+
Coming from `requests <https://requests.readthedocs.io/>`_ ? Read `why we need so many lines <https://aiohttp.readthedocs.io/en/latest/http_request_lifecycle.html>`_.
|
| 130 |
+
|
| 131 |
+
Server
|
| 132 |
+
------
|
| 133 |
+
|
| 134 |
+
An example using a simple server:
|
| 135 |
+
|
| 136 |
+
.. code-block:: python
|
| 137 |
+
|
| 138 |
+
# examples/server_simple.py
|
| 139 |
+
from aiohttp import web
|
| 140 |
+
|
| 141 |
+
async def handle(request):
|
| 142 |
+
name = request.match_info.get('name', "Anonymous")
|
| 143 |
+
text = "Hello, " + name
|
| 144 |
+
return web.Response(text=text)
|
| 145 |
+
|
| 146 |
+
async def wshandle(request):
|
| 147 |
+
ws = web.WebSocketResponse()
|
| 148 |
+
await ws.prepare(request)
|
| 149 |
+
|
| 150 |
+
async for msg in ws:
|
| 151 |
+
if msg.type == web.WSMsgType.text:
|
| 152 |
+
await ws.send_str("Hello, {}".format(msg.data))
|
| 153 |
+
elif msg.type == web.WSMsgType.binary:
|
| 154 |
+
await ws.send_bytes(msg.data)
|
| 155 |
+
elif msg.type == web.WSMsgType.close:
|
| 156 |
+
break
|
| 157 |
+
|
| 158 |
+
return ws
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
app = web.Application()
|
| 162 |
+
app.add_routes([web.get('/', handle),
|
| 163 |
+
web.get('/echo', wshandle),
|
| 164 |
+
web.get('/{name}', handle)])
|
| 165 |
+
|
| 166 |
+
if __name__ == '__main__':
|
| 167 |
+
web.run_app(app)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
Documentation
|
| 171 |
+
=============
|
| 172 |
+
|
| 173 |
+
https://aiohttp.readthedocs.io/
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
Demos
|
| 177 |
+
=====
|
| 178 |
+
|
| 179 |
+
https://github.com/aio-libs/aiohttp-demos
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
External links
|
| 183 |
+
==============
|
| 184 |
+
|
| 185 |
+
* `Third party libraries
|
| 186 |
+
<http://aiohttp.readthedocs.io/en/latest/third_party.html>`_
|
| 187 |
+
* `Built with aiohttp
|
| 188 |
+
<http://aiohttp.readthedocs.io/en/latest/built_with.html>`_
|
| 189 |
+
* `Powered by aiohttp
|
| 190 |
+
<http://aiohttp.readthedocs.io/en/latest/powered_by.html>`_
|
| 191 |
+
|
| 192 |
+
Feel free to make a Pull Request for adding your link to these pages!
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
Communication channels
|
| 196 |
+
======================
|
| 197 |
+
|
| 198 |
+
*aio-libs Discussions*: https://github.com/aio-libs/aiohttp/discussions
|
| 199 |
+
|
| 200 |
+
*Matrix*: `#aio-libs:matrix.org <https://matrix.to/#/#aio-libs:matrix.org>`_
|
| 201 |
+
|
| 202 |
+
We support `Stack Overflow
|
| 203 |
+
<https://stackoverflow.com/questions/tagged/aiohttp>`_.
|
| 204 |
+
Please add *aiohttp* tag to your question there.
|
| 205 |
+
|
| 206 |
+
Requirements
|
| 207 |
+
============
|
| 208 |
+
|
| 209 |
+
- attrs_
|
| 210 |
+
- multidict_
|
| 211 |
+
- yarl_
|
| 212 |
+
- frozenlist_
|
| 213 |
+
|
| 214 |
+
Optionally you may install the aiodns_ library (highly recommended for sake of speed).
|
| 215 |
+
|
| 216 |
+
.. _aiodns: https://pypi.python.org/pypi/aiodns
|
| 217 |
+
.. _attrs: https://github.com/python-attrs/attrs
|
| 218 |
+
.. _multidict: https://pypi.python.org/pypi/multidict
|
| 219 |
+
.. _frozenlist: https://pypi.org/project/frozenlist/
|
| 220 |
+
.. _yarl: https://pypi.python.org/pypi/yarl
|
| 221 |
+
.. _async-timeout: https://pypi.python.org/pypi/async_timeout
|
| 222 |
+
|
| 223 |
+
License
|
| 224 |
+
=======
|
| 225 |
+
|
| 226 |
+
``aiohttp`` is offered under the Apache 2 license.
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
Keepsafe
|
| 230 |
+
========
|
| 231 |
+
|
| 232 |
+
The aiohttp community would like to thank Keepsafe
|
| 233 |
+
(https://www.getkeepsafe.com) for its support in the early days of
|
| 234 |
+
the project.
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
Source code
|
| 238 |
+
===========
|
| 239 |
+
|
| 240 |
+
The latest developer version is available in a GitHub repository:
|
| 241 |
+
https://github.com/aio-libs/aiohttp
|
| 242 |
+
|
| 243 |
+
Benchmarks
|
| 244 |
+
==========
|
| 245 |
+
|
| 246 |
+
If you are interested in efficiency, the AsyncIO community maintains a
|
| 247 |
+
list of benchmarks on the official wiki:
|
| 248 |
+
https://github.com/python/asyncio/wiki/Benchmarks
|
| 249 |
+
|
| 250 |
+
--------
|
| 251 |
+
|
| 252 |
+
.. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
|
| 253 |
+
:target: https://matrix.to/#/%23aio-libs:matrix.org
|
| 254 |
+
:alt: Matrix Room — #aio-libs:matrix.org
|
| 255 |
+
|
| 256 |
+
.. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
|
| 257 |
+
:target: https://matrix.to/#/%23aio-libs-space:matrix.org
|
| 258 |
+
:alt: Matrix Space — #aio-libs-space:matrix.org
|
| 259 |
+
|
| 260 |
+
.. image:: https://insights.linuxfoundation.org/api/badge/health-score?project=aiohttp
|
| 261 |
+
:target: https://insights.linuxfoundation.org/project/aiohttp
|
| 262 |
+
:alt: LFX Health Score
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/RECORD
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiohttp-3.13.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
aiohttp-3.13.3.dist-info/METADATA,sha256=CQROZCStho-eb7xiFIuAzj30JuupEU_jHpYDFiG_HhM,8145
|
| 3 |
+
aiohttp-3.13.3.dist-info/RECORD,,
|
| 4 |
+
aiohttp-3.13.3.dist-info/WHEEL,sha256=BvA_i88wcFUl5ehXLgmhwyDL4XPGrCKn6CTUA9axFDE,190
|
| 5 |
+
aiohttp-3.13.3.dist-info/licenses/LICENSE.txt,sha256=n4DQ2311WpQdtFchcsJw7L2PCCuiFd3QlZhZQu2Uqes,588
|
| 6 |
+
aiohttp-3.13.3.dist-info/licenses/vendor/llhttp/LICENSE,sha256=68qFTgE0zSVtZzYnwgSZ9CV363S6zwi58ltianPJEnc,1105
|
| 7 |
+
aiohttp-3.13.3.dist-info/top_level.txt,sha256=iv-JIaacmTl-hSho3QmphcKnbRRYx1st47yjz_178Ro,8
|
| 8 |
+
aiohttp/.hash/_cparser.pxd.hash,sha256=pjs-sEXNw_eijXGAedwG-BHnlFp8B7sOCgUagIWaU2A,121
|
| 9 |
+
aiohttp/.hash/_find_header.pxd.hash,sha256=_mbpD6vM-CVCKq3ulUvsOAz5Wdo88wrDzfpOsMQaMNA,125
|
| 10 |
+
aiohttp/.hash/_http_parser.pyx.hash,sha256=RKkD9x-EhXksvXrpCaTNWYtffb52urLvuTnxbTN2Lmw,125
|
| 11 |
+
aiohttp/.hash/_http_writer.pyx.hash,sha256=9txOh7t7c3y-vLmiuEY5dltmXvEo0CYyU4U853yyv9E,125
|
| 12 |
+
aiohttp/.hash/hdrs.py.hash,sha256=v6IaKbsxjsdQxBzhb5AjP0x_9G3rUe84D7avf7AI4cs,116
|
| 13 |
+
aiohttp/__init__.py,sha256=QWssFaD-DaFFcwP36lLUQzRmlSZ5KxivJBU-yg5C1wg,8302
|
| 14 |
+
aiohttp/__pycache__/__init__.cpython-311.pyc,,
|
| 15 |
+
aiohttp/__pycache__/_cookie_helpers.cpython-311.pyc,,
|
| 16 |
+
aiohttp/__pycache__/abc.cpython-311.pyc,,
|
| 17 |
+
aiohttp/__pycache__/base_protocol.cpython-311.pyc,,
|
| 18 |
+
aiohttp/__pycache__/client.cpython-311.pyc,,
|
| 19 |
+
aiohttp/__pycache__/client_exceptions.cpython-311.pyc,,
|
| 20 |
+
aiohttp/__pycache__/client_middleware_digest_auth.cpython-311.pyc,,
|
| 21 |
+
aiohttp/__pycache__/client_middlewares.cpython-311.pyc,,
|
| 22 |
+
aiohttp/__pycache__/client_proto.cpython-311.pyc,,
|
| 23 |
+
aiohttp/__pycache__/client_reqrep.cpython-311.pyc,,
|
| 24 |
+
aiohttp/__pycache__/client_ws.cpython-311.pyc,,
|
| 25 |
+
aiohttp/__pycache__/compression_utils.cpython-311.pyc,,
|
| 26 |
+
aiohttp/__pycache__/connector.cpython-311.pyc,,
|
| 27 |
+
aiohttp/__pycache__/cookiejar.cpython-311.pyc,,
|
| 28 |
+
aiohttp/__pycache__/formdata.cpython-311.pyc,,
|
| 29 |
+
aiohttp/__pycache__/hdrs.cpython-311.pyc,,
|
| 30 |
+
aiohttp/__pycache__/helpers.cpython-311.pyc,,
|
| 31 |
+
aiohttp/__pycache__/http.cpython-311.pyc,,
|
| 32 |
+
aiohttp/__pycache__/http_exceptions.cpython-311.pyc,,
|
| 33 |
+
aiohttp/__pycache__/http_parser.cpython-311.pyc,,
|
| 34 |
+
aiohttp/__pycache__/http_websocket.cpython-311.pyc,,
|
| 35 |
+
aiohttp/__pycache__/http_writer.cpython-311.pyc,,
|
| 36 |
+
aiohttp/__pycache__/log.cpython-311.pyc,,
|
| 37 |
+
aiohttp/__pycache__/multipart.cpython-311.pyc,,
|
| 38 |
+
aiohttp/__pycache__/payload.cpython-311.pyc,,
|
| 39 |
+
aiohttp/__pycache__/payload_streamer.cpython-311.pyc,,
|
| 40 |
+
aiohttp/__pycache__/pytest_plugin.cpython-311.pyc,,
|
| 41 |
+
aiohttp/__pycache__/resolver.cpython-311.pyc,,
|
| 42 |
+
aiohttp/__pycache__/streams.cpython-311.pyc,,
|
| 43 |
+
aiohttp/__pycache__/tcp_helpers.cpython-311.pyc,,
|
| 44 |
+
aiohttp/__pycache__/test_utils.cpython-311.pyc,,
|
| 45 |
+
aiohttp/__pycache__/tracing.cpython-311.pyc,,
|
| 46 |
+
aiohttp/__pycache__/typedefs.cpython-311.pyc,,
|
| 47 |
+
aiohttp/__pycache__/web.cpython-311.pyc,,
|
| 48 |
+
aiohttp/__pycache__/web_app.cpython-311.pyc,,
|
| 49 |
+
aiohttp/__pycache__/web_exceptions.cpython-311.pyc,,
|
| 50 |
+
aiohttp/__pycache__/web_fileresponse.cpython-311.pyc,,
|
| 51 |
+
aiohttp/__pycache__/web_log.cpython-311.pyc,,
|
| 52 |
+
aiohttp/__pycache__/web_middlewares.cpython-311.pyc,,
|
| 53 |
+
aiohttp/__pycache__/web_protocol.cpython-311.pyc,,
|
| 54 |
+
aiohttp/__pycache__/web_request.cpython-311.pyc,,
|
| 55 |
+
aiohttp/__pycache__/web_response.cpython-311.pyc,,
|
| 56 |
+
aiohttp/__pycache__/web_routedef.cpython-311.pyc,,
|
| 57 |
+
aiohttp/__pycache__/web_runner.cpython-311.pyc,,
|
| 58 |
+
aiohttp/__pycache__/web_server.cpython-311.pyc,,
|
| 59 |
+
aiohttp/__pycache__/web_urldispatcher.cpython-311.pyc,,
|
| 60 |
+
aiohttp/__pycache__/web_ws.cpython-311.pyc,,
|
| 61 |
+
aiohttp/__pycache__/worker.cpython-311.pyc,,
|
| 62 |
+
aiohttp/_cookie_helpers.py,sha256=_p7y-B8OCAk7FLjByiuwFIpDLGuNoJn3_vixzymAFnE,13659
|
| 63 |
+
aiohttp/_cparser.pxd,sha256=UnbUYCHg4NdXfgyRVYAMv2KTLWClB4P-xCrvtj_r7ew,4295
|
| 64 |
+
aiohttp/_find_header.pxd,sha256=0GfwFCPN2zxEKTO1_MA5sYq2UfzsG8kcV3aTqvwlz3g,68
|
| 65 |
+
aiohttp/_headers.pxi,sha256=n701k28dVPjwRnx5j6LpJhLTfj7dqu2vJt7f0O60Oyg,2007
|
| 66 |
+
aiohttp/_http_parser.cpython-311-x86_64-linux-gnu.so,sha256=PObtJEOjKDBqrkmgccbJHcbvu_Kl_uxPiB6Aowzp82c,2794568
|
| 67 |
+
aiohttp/_http_parser.pyx,sha256=-YI8YIY4uKd_7Bwr0o3FwEPwjHdexZ5-Ji3XS067c4Q,28261
|
| 68 |
+
aiohttp/_http_writer.cpython-311-x86_64-linux-gnu.so,sha256=Vpk9H46UhD2wm3VA8YAMz221EqyT5oBdkmR3TWH9sm0,533008
|
| 69 |
+
aiohttp/_http_writer.pyx,sha256=VlFEBM6HoVv8a0AAJtc6JwFlsv2-cDE8-gB94p3dfhQ,4664
|
| 70 |
+
aiohttp/_websocket/.hash/mask.pxd.hash,sha256=Y0zBddk_ck3pi9-BFzMcpkcvCKvwvZ4GTtZFb9u1nxQ,128
|
| 71 |
+
aiohttp/_websocket/.hash/mask.pyx.hash,sha256=90owpXYM8_kIma4KUcOxhWSk-Uv4NVMBoCYeFM1B3d0,128
|
| 72 |
+
aiohttp/_websocket/.hash/reader_c.pxd.hash,sha256=5xf3oobk6vx4xbJm-xtZ1_QufB8fYFtLQV2MNdqUc1w,132
|
| 73 |
+
aiohttp/_websocket/__init__.py,sha256=Mar3R9_vBN_Ea4lsW7iTAVXD7OKswKPGqF5xgSyt77k,44
|
| 74 |
+
aiohttp/_websocket/__pycache__/__init__.cpython-311.pyc,,
|
| 75 |
+
aiohttp/_websocket/__pycache__/helpers.cpython-311.pyc,,
|
| 76 |
+
aiohttp/_websocket/__pycache__/models.cpython-311.pyc,,
|
| 77 |
+
aiohttp/_websocket/__pycache__/reader.cpython-311.pyc,,
|
| 78 |
+
aiohttp/_websocket/__pycache__/reader_c.cpython-311.pyc,,
|
| 79 |
+
aiohttp/_websocket/__pycache__/reader_py.cpython-311.pyc,,
|
| 80 |
+
aiohttp/_websocket/__pycache__/writer.cpython-311.pyc,,
|
| 81 |
+
aiohttp/_websocket/helpers.py,sha256=P-XLv8IUaihKzDenVUqfKU5DJbWE5HvG8uhvUZK8Ic4,5038
|
| 82 |
+
aiohttp/_websocket/mask.cpython-311-x86_64-linux-gnu.so,sha256=a4UBGy0mRIUT6RM3kVyNJKj5rQs3h2I8WW9jXsIfuSY,238600
|
| 83 |
+
aiohttp/_websocket/mask.pxd,sha256=sBmZ1Amym9kW4Ge8lj1fLZ7mPPya4LzLdpkQExQXv5M,112
|
| 84 |
+
aiohttp/_websocket/mask.pyx,sha256=BHjOtV0O0w7xp9p0LNADRJvGmgfPn9sGeJvSs0fL__4,1397
|
| 85 |
+
aiohttp/_websocket/models.py,sha256=XAzjs_8JYszWXIgZ6R3ZRrF-tX9Q_6LiD49WRYojopM,2121
|
| 86 |
+
aiohttp/_websocket/reader.py,sha256=eC4qS0c5sOeQ2ebAHLaBpIaTVFaSKX79pY2xvh3Pqyw,1030
|
| 87 |
+
aiohttp/_websocket/reader_c.cpython-311-x86_64-linux-gnu.so,sha256=vFqv6jKbkwDhazMnZ8ZjKmCofmqRodyoVrWxI2w1Pdo,1864328
|
| 88 |
+
aiohttp/_websocket/reader_c.pxd,sha256=nl_njtDrzlQU0rjgGGjZDB-swguE0tX_bCPobkShVa4,2625
|
| 89 |
+
aiohttp/_websocket/reader_c.py,sha256=V5YtZ2gj2BjE2Q-W9sR_MdAl1VAm1pB7ZjozVJcOpbg,18868
|
| 90 |
+
aiohttp/_websocket/reader_py.py,sha256=V5YtZ2gj2BjE2Q-W9sR_MdAl1VAm1pB7ZjozVJcOpbg,18868
|
| 91 |
+
aiohttp/_websocket/writer.py,sha256=2OvSktPmNh_g20h1cXJt2Xu8u6IvswnPjdur7OwBbJk,11261
|
| 92 |
+
aiohttp/abc.py,sha256=M66F4S6m00bIEn7y4ha_XLTMDmVQ9dPihfOVB0pGfOo,7149
|
| 93 |
+
aiohttp/base_protocol.py,sha256=Tp8cxUPQvv9kUPk3w6lAzk6d2MAzV3scwI_3Go3C47c,3025
|
| 94 |
+
aiohttp/client.py,sha256=fOQfwcIUL1NGAVRV4DDj6-wipBzeD8KZpmzhO-LLKp4,58357
|
| 95 |
+
aiohttp/client_exceptions.py,sha256=uyKbxI2peZhKl7lELBMx3UeusNkfpemPWpGFq0r6JeM,11367
|
| 96 |
+
aiohttp/client_middleware_digest_auth.py,sha256=G5JM9YtzL9AWklz6NP28xEOBeAvrAZgDzU657JqO4qs,17627
|
| 97 |
+
aiohttp/client_middlewares.py,sha256=kP5N9CMzQPMGPIEydeVUiLUTLsw8Vl8Gr4qAWYdu3vM,1918
|
| 98 |
+
aiohttp/client_proto.py,sha256=56_WtLStZGBFPYKzgEgY6v24JkhV1y6JEmmuxeJT2So,12110
|
| 99 |
+
aiohttp/client_reqrep.py,sha256=eEREDrZ0M8ZFTt1wjHduR-P8_sm40K65gNz-iMGYask,53391
|
| 100 |
+
aiohttp/client_ws.py,sha256=1CIjIXwyzOMIYw6AjUES4-qUwbyVHW1seJKQfg_Rta8,15109
|
| 101 |
+
aiohttp/compression_utils.py,sha256=hJ2LXhN2OWukFHm5b78TJFGKcAiL2kthi9Sf5PRYO-U,11738
|
| 102 |
+
aiohttp/connector.py,sha256=vT22BNuCDtbadE1Uq7HC7zpOWCHMxI4n3PtCz7zZZkw,69004
|
| 103 |
+
aiohttp/cookiejar.py,sha256=e28ZMQwJ5P0vbPX1OX4Se7-k3zeGvocFEqzGhwpG53k,18922
|
| 104 |
+
aiohttp/formdata.py,sha256=xqYMbUo1qoLYPuzY92XeR4pyEe-w-DNcToARDF3GUhA,6384
|
| 105 |
+
aiohttp/hdrs.py,sha256=2rj5MyA-6yRdYPhW5UKkW4iNWhEAlGIOSBH5D4FmKNE,5111
|
| 106 |
+
aiohttp/helpers.py,sha256=Q1307PCEnWz4RP8crUw8dk58c0YF2Ei3JywkKfRxz5E,30629
|
| 107 |
+
aiohttp/http.py,sha256=8o8j8xH70OWjnfTWA9V44NR785QPxEPrUtzMXiAVpwc,1842
|
| 108 |
+
aiohttp/http_exceptions.py,sha256=BjIxD4LtrQgytqoR5lOI9zAttNmSygRgksUsMRy7sss,3069
|
| 109 |
+
aiohttp/http_parser.py,sha256=z6djZDOUs7hdPzplTEsAVyz0of-rQAwT7xz8OpXhnuY,38177
|
| 110 |
+
aiohttp/http_websocket.py,sha256=8VXFKw6KQUEmPg48GtRMB37v0gTK7A0inoxXuDxMZEc,842
|
| 111 |
+
aiohttp/http_writer.py,sha256=fbRtKPYSqRbtAdr_gqpjF2-4sI1ESL8dPDF-xY_mAMY,12446
|
| 112 |
+
aiohttp/log.py,sha256=BbNKx9e3VMIm0xYjZI0IcBBoS7wjdeIeSaiJE7-qK2g,325
|
| 113 |
+
aiohttp/multipart.py,sha256=326npYdWxYI3raoRfmpBeUV_ef3-LRn8sV9WqcIOoPk,40482
|
| 114 |
+
aiohttp/payload.py,sha256=O6nsYNULL7AeM2cyJ6TYX73ncVnL5xJwt5AegxwMKqw,40874
|
| 115 |
+
aiohttp/payload_streamer.py,sha256=ZzEYyfzcjGWkVkK3XR2pBthSCSIykYvY3Wr5cGQ2eTc,2211
|
| 116 |
+
aiohttp/py.typed,sha256=sow9soTwP9T_gEAQSVh7Gb8855h04Nwmhs2We-JRgZM,7
|
| 117 |
+
aiohttp/pytest_plugin.py,sha256=z4XwqmsKdyJCKxbGiA5kFf90zcedvomqk4RqjZbhKNk,12901
|
| 118 |
+
aiohttp/resolver.py,sha256=gsrfUpFf8iHlcHfJvY-1fiBHW3PRvRVNb5lNZBg3zlY,10031
|
| 119 |
+
aiohttp/streams.py,sha256=rlwL7ek6CkMMYil_e_EokWv26uHmtzi3lKqlnLNrXCc,23666
|
| 120 |
+
aiohttp/tcp_helpers.py,sha256=BSadqVWaBpMFDRWnhaaR941N9MiDZ7bdTrxgCb0CW-M,961
|
| 121 |
+
aiohttp/test_utils.py,sha256=ZJSzZWjC76KSbtwddTKcP6vHpUl_ozfAf3F93ewmHRU,23016
|
| 122 |
+
aiohttp/tracing.py,sha256=-6aaW6l0J9uJD45LzR4cijYH0j62pt0U_nn_aVzFku4,14558
|
| 123 |
+
aiohttp/typedefs.py,sha256=wUlqwe9Mw9W8jT3HsYJcYk00qP3EMPz3nTkYXmeNN48,1657
|
| 124 |
+
aiohttp/web.py,sha256=JzSNmejg5G6YeFAnkIgZfytqbU86sNu844yYKmoUpqs,17852
|
| 125 |
+
aiohttp/web_app.py,sha256=lGU_aAMN-h3wy-LTTHi6SeKH8ydt1G51BXcCspgD5ZA,19452
|
| 126 |
+
aiohttp/web_exceptions.py,sha256=7nIuiwhZ39vJJ9KrWqArA5QcWbUdqkz2CLwEpJapeN8,10360
|
| 127 |
+
aiohttp/web_fileresponse.py,sha256=Xzau8EMrWNrFg3u46h4UEteg93G4zYq94CU6vy0HiqE,16362
|
| 128 |
+
aiohttp/web_log.py,sha256=rX5D7xLOX2B6BMdiZ-chme_KfJfW5IXEoFwLfkfkajs,7865
|
| 129 |
+
aiohttp/web_middlewares.py,sha256=sFI0AgeNjdyAjuz92QtMIpngmJSOxrqe2Jfbs4BNUu0,4165
|
| 130 |
+
aiohttp/web_protocol.py,sha256=6s9dMzmaqW77bzM1T111uGNSLFo6gNmfDg7XzYnA8xk,27010
|
| 131 |
+
aiohttp/web_request.py,sha256=KqrOp6AeWB5e6tKrG55Lo7Zbwq49DxdrKniuW2t2u04,29849
|
| 132 |
+
aiohttp/web_response.py,sha256=PKcziNU4LmftXqKVvoRMrAbOeVClpSN-iznHsiWezmU,29341
|
| 133 |
+
aiohttp/web_routedef.py,sha256=VT1GAx6BrawoDh5RwBwBu5wSABSqgWwAe74AUCyZAEo,6110
|
| 134 |
+
aiohttp/web_runner.py,sha256=v1G1nKiOOQgFnTSR4IMc6I9ReEFDMaHtMLvO_roDM-A,11786
|
| 135 |
+
aiohttp/web_server.py,sha256=-9WDKUAiR9ll-rSdwXSqG6YjaoW79d1R4y0BGSqgUMA,2888
|
| 136 |
+
aiohttp/web_urldispatcher.py,sha256=JM-TlriKCNbTLNL43Ra9sdZ0zChxZmIEYQM6ZpbyjI4,44290
|
| 137 |
+
aiohttp/web_ws.py,sha256=lItgmyatkXh0M6EY7JoZnSZkUl6R0wv8B88X4ILqQbU,22739
|
| 138 |
+
aiohttp/worker.py,sha256=zT0iWN5Xze194bO6_VjHou0x7lR_k0MviN6Kadnk22g,8152
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (80.9.0)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: cp311-cp311-manylinux_2_17_x86_64
|
| 5 |
+
Tag: cp311-cp311-manylinux2014_x86_64
|
| 6 |
+
Tag: cp311-cp311-manylinux_2_28_x86_64
|
| 7 |
+
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
aiohttp
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/__init__.py
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__version__ = "3.13.3"
|
| 2 |
+
|
| 3 |
+
from typing import TYPE_CHECKING, Tuple
|
| 4 |
+
|
| 5 |
+
from . import hdrs as hdrs
|
| 6 |
+
from .client import (
|
| 7 |
+
BaseConnector,
|
| 8 |
+
ClientConnectionError,
|
| 9 |
+
ClientConnectionResetError,
|
| 10 |
+
ClientConnectorCertificateError,
|
| 11 |
+
ClientConnectorDNSError,
|
| 12 |
+
ClientConnectorError,
|
| 13 |
+
ClientConnectorSSLError,
|
| 14 |
+
ClientError,
|
| 15 |
+
ClientHttpProxyError,
|
| 16 |
+
ClientOSError,
|
| 17 |
+
ClientPayloadError,
|
| 18 |
+
ClientProxyConnectionError,
|
| 19 |
+
ClientRequest,
|
| 20 |
+
ClientResponse,
|
| 21 |
+
ClientResponseError,
|
| 22 |
+
ClientSession,
|
| 23 |
+
ClientSSLError,
|
| 24 |
+
ClientTimeout,
|
| 25 |
+
ClientWebSocketResponse,
|
| 26 |
+
ClientWSTimeout,
|
| 27 |
+
ConnectionTimeoutError,
|
| 28 |
+
ContentTypeError,
|
| 29 |
+
Fingerprint,
|
| 30 |
+
InvalidURL,
|
| 31 |
+
InvalidUrlClientError,
|
| 32 |
+
InvalidUrlRedirectClientError,
|
| 33 |
+
NamedPipeConnector,
|
| 34 |
+
NonHttpUrlClientError,
|
| 35 |
+
NonHttpUrlRedirectClientError,
|
| 36 |
+
RedirectClientError,
|
| 37 |
+
RequestInfo,
|
| 38 |
+
ServerConnectionError,
|
| 39 |
+
ServerDisconnectedError,
|
| 40 |
+
ServerFingerprintMismatch,
|
| 41 |
+
ServerTimeoutError,
|
| 42 |
+
SocketTimeoutError,
|
| 43 |
+
TCPConnector,
|
| 44 |
+
TooManyRedirects,
|
| 45 |
+
UnixConnector,
|
| 46 |
+
WSMessageTypeError,
|
| 47 |
+
WSServerHandshakeError,
|
| 48 |
+
request,
|
| 49 |
+
)
|
| 50 |
+
from .client_middleware_digest_auth import DigestAuthMiddleware
|
| 51 |
+
from .client_middlewares import ClientHandlerType, ClientMiddlewareType
|
| 52 |
+
from .compression_utils import set_zlib_backend
|
| 53 |
+
from .connector import (
|
| 54 |
+
AddrInfoType as AddrInfoType,
|
| 55 |
+
SocketFactoryType as SocketFactoryType,
|
| 56 |
+
)
|
| 57 |
+
from .cookiejar import CookieJar as CookieJar, DummyCookieJar as DummyCookieJar
|
| 58 |
+
from .formdata import FormData as FormData
|
| 59 |
+
from .helpers import BasicAuth, ChainMapProxy, ETag
|
| 60 |
+
from .http import (
|
| 61 |
+
HttpVersion as HttpVersion,
|
| 62 |
+
HttpVersion10 as HttpVersion10,
|
| 63 |
+
HttpVersion11 as HttpVersion11,
|
| 64 |
+
WebSocketError as WebSocketError,
|
| 65 |
+
WSCloseCode as WSCloseCode,
|
| 66 |
+
WSMessage as WSMessage,
|
| 67 |
+
WSMsgType as WSMsgType,
|
| 68 |
+
)
|
| 69 |
+
from .multipart import (
|
| 70 |
+
BadContentDispositionHeader as BadContentDispositionHeader,
|
| 71 |
+
BadContentDispositionParam as BadContentDispositionParam,
|
| 72 |
+
BodyPartReader as BodyPartReader,
|
| 73 |
+
MultipartReader as MultipartReader,
|
| 74 |
+
MultipartWriter as MultipartWriter,
|
| 75 |
+
content_disposition_filename as content_disposition_filename,
|
| 76 |
+
parse_content_disposition as parse_content_disposition,
|
| 77 |
+
)
|
| 78 |
+
from .payload import (
|
| 79 |
+
PAYLOAD_REGISTRY as PAYLOAD_REGISTRY,
|
| 80 |
+
AsyncIterablePayload as AsyncIterablePayload,
|
| 81 |
+
BufferedReaderPayload as BufferedReaderPayload,
|
| 82 |
+
BytesIOPayload as BytesIOPayload,
|
| 83 |
+
BytesPayload as BytesPayload,
|
| 84 |
+
IOBasePayload as IOBasePayload,
|
| 85 |
+
JsonPayload as JsonPayload,
|
| 86 |
+
Payload as Payload,
|
| 87 |
+
StringIOPayload as StringIOPayload,
|
| 88 |
+
StringPayload as StringPayload,
|
| 89 |
+
TextIOPayload as TextIOPayload,
|
| 90 |
+
get_payload as get_payload,
|
| 91 |
+
payload_type as payload_type,
|
| 92 |
+
)
|
| 93 |
+
from .payload_streamer import streamer as streamer
|
| 94 |
+
from .resolver import (
|
| 95 |
+
AsyncResolver as AsyncResolver,
|
| 96 |
+
DefaultResolver as DefaultResolver,
|
| 97 |
+
ThreadedResolver as ThreadedResolver,
|
| 98 |
+
)
|
| 99 |
+
from .streams import (
|
| 100 |
+
EMPTY_PAYLOAD as EMPTY_PAYLOAD,
|
| 101 |
+
DataQueue as DataQueue,
|
| 102 |
+
EofStream as EofStream,
|
| 103 |
+
FlowControlDataQueue as FlowControlDataQueue,
|
| 104 |
+
StreamReader as StreamReader,
|
| 105 |
+
)
|
| 106 |
+
from .tracing import (
|
| 107 |
+
TraceConfig as TraceConfig,
|
| 108 |
+
TraceConnectionCreateEndParams as TraceConnectionCreateEndParams,
|
| 109 |
+
TraceConnectionCreateStartParams as TraceConnectionCreateStartParams,
|
| 110 |
+
TraceConnectionQueuedEndParams as TraceConnectionQueuedEndParams,
|
| 111 |
+
TraceConnectionQueuedStartParams as TraceConnectionQueuedStartParams,
|
| 112 |
+
TraceConnectionReuseconnParams as TraceConnectionReuseconnParams,
|
| 113 |
+
TraceDnsCacheHitParams as TraceDnsCacheHitParams,
|
| 114 |
+
TraceDnsCacheMissParams as TraceDnsCacheMissParams,
|
| 115 |
+
TraceDnsResolveHostEndParams as TraceDnsResolveHostEndParams,
|
| 116 |
+
TraceDnsResolveHostStartParams as TraceDnsResolveHostStartParams,
|
| 117 |
+
TraceRequestChunkSentParams as TraceRequestChunkSentParams,
|
| 118 |
+
TraceRequestEndParams as TraceRequestEndParams,
|
| 119 |
+
TraceRequestExceptionParams as TraceRequestExceptionParams,
|
| 120 |
+
TraceRequestHeadersSentParams as TraceRequestHeadersSentParams,
|
| 121 |
+
TraceRequestRedirectParams as TraceRequestRedirectParams,
|
| 122 |
+
TraceRequestStartParams as TraceRequestStartParams,
|
| 123 |
+
TraceResponseChunkReceivedParams as TraceResponseChunkReceivedParams,
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
if TYPE_CHECKING:
|
| 127 |
+
# At runtime these are lazy-loaded at the bottom of the file.
|
| 128 |
+
from .worker import (
|
| 129 |
+
GunicornUVLoopWebWorker as GunicornUVLoopWebWorker,
|
| 130 |
+
GunicornWebWorker as GunicornWebWorker,
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
__all__: Tuple[str, ...] = (
|
| 134 |
+
"hdrs",
|
| 135 |
+
# client
|
| 136 |
+
"AddrInfoType",
|
| 137 |
+
"BaseConnector",
|
| 138 |
+
"ClientConnectionError",
|
| 139 |
+
"ClientConnectionResetError",
|
| 140 |
+
"ClientConnectorCertificateError",
|
| 141 |
+
"ClientConnectorDNSError",
|
| 142 |
+
"ClientConnectorError",
|
| 143 |
+
"ClientConnectorSSLError",
|
| 144 |
+
"ClientError",
|
| 145 |
+
"ClientHttpProxyError",
|
| 146 |
+
"ClientOSError",
|
| 147 |
+
"ClientPayloadError",
|
| 148 |
+
"ClientProxyConnectionError",
|
| 149 |
+
"ClientResponse",
|
| 150 |
+
"ClientRequest",
|
| 151 |
+
"ClientResponseError",
|
| 152 |
+
"ClientSSLError",
|
| 153 |
+
"ClientSession",
|
| 154 |
+
"ClientTimeout",
|
| 155 |
+
"ClientWebSocketResponse",
|
| 156 |
+
"ClientWSTimeout",
|
| 157 |
+
"ConnectionTimeoutError",
|
| 158 |
+
"ContentTypeError",
|
| 159 |
+
"Fingerprint",
|
| 160 |
+
"FlowControlDataQueue",
|
| 161 |
+
"InvalidURL",
|
| 162 |
+
"InvalidUrlClientError",
|
| 163 |
+
"InvalidUrlRedirectClientError",
|
| 164 |
+
"NonHttpUrlClientError",
|
| 165 |
+
"NonHttpUrlRedirectClientError",
|
| 166 |
+
"RedirectClientError",
|
| 167 |
+
"RequestInfo",
|
| 168 |
+
"ServerConnectionError",
|
| 169 |
+
"ServerDisconnectedError",
|
| 170 |
+
"ServerFingerprintMismatch",
|
| 171 |
+
"ServerTimeoutError",
|
| 172 |
+
"SocketFactoryType",
|
| 173 |
+
"SocketTimeoutError",
|
| 174 |
+
"TCPConnector",
|
| 175 |
+
"TooManyRedirects",
|
| 176 |
+
"UnixConnector",
|
| 177 |
+
"NamedPipeConnector",
|
| 178 |
+
"WSServerHandshakeError",
|
| 179 |
+
"request",
|
| 180 |
+
# client_middleware
|
| 181 |
+
"ClientMiddlewareType",
|
| 182 |
+
"ClientHandlerType",
|
| 183 |
+
# cookiejar
|
| 184 |
+
"CookieJar",
|
| 185 |
+
"DummyCookieJar",
|
| 186 |
+
# formdata
|
| 187 |
+
"FormData",
|
| 188 |
+
# helpers
|
| 189 |
+
"BasicAuth",
|
| 190 |
+
"ChainMapProxy",
|
| 191 |
+
"DigestAuthMiddleware",
|
| 192 |
+
"ETag",
|
| 193 |
+
"set_zlib_backend",
|
| 194 |
+
# http
|
| 195 |
+
"HttpVersion",
|
| 196 |
+
"HttpVersion10",
|
| 197 |
+
"HttpVersion11",
|
| 198 |
+
"WSMsgType",
|
| 199 |
+
"WSCloseCode",
|
| 200 |
+
"WSMessage",
|
| 201 |
+
"WebSocketError",
|
| 202 |
+
# multipart
|
| 203 |
+
"BadContentDispositionHeader",
|
| 204 |
+
"BadContentDispositionParam",
|
| 205 |
+
"BodyPartReader",
|
| 206 |
+
"MultipartReader",
|
| 207 |
+
"MultipartWriter",
|
| 208 |
+
"content_disposition_filename",
|
| 209 |
+
"parse_content_disposition",
|
| 210 |
+
# payload
|
| 211 |
+
"AsyncIterablePayload",
|
| 212 |
+
"BufferedReaderPayload",
|
| 213 |
+
"BytesIOPayload",
|
| 214 |
+
"BytesPayload",
|
| 215 |
+
"IOBasePayload",
|
| 216 |
+
"JsonPayload",
|
| 217 |
+
"PAYLOAD_REGISTRY",
|
| 218 |
+
"Payload",
|
| 219 |
+
"StringIOPayload",
|
| 220 |
+
"StringPayload",
|
| 221 |
+
"TextIOPayload",
|
| 222 |
+
"get_payload",
|
| 223 |
+
"payload_type",
|
| 224 |
+
# payload_streamer
|
| 225 |
+
"streamer",
|
| 226 |
+
# resolver
|
| 227 |
+
"AsyncResolver",
|
| 228 |
+
"DefaultResolver",
|
| 229 |
+
"ThreadedResolver",
|
| 230 |
+
# streams
|
| 231 |
+
"DataQueue",
|
| 232 |
+
"EMPTY_PAYLOAD",
|
| 233 |
+
"EofStream",
|
| 234 |
+
"StreamReader",
|
| 235 |
+
# tracing
|
| 236 |
+
"TraceConfig",
|
| 237 |
+
"TraceConnectionCreateEndParams",
|
| 238 |
+
"TraceConnectionCreateStartParams",
|
| 239 |
+
"TraceConnectionQueuedEndParams",
|
| 240 |
+
"TraceConnectionQueuedStartParams",
|
| 241 |
+
"TraceConnectionReuseconnParams",
|
| 242 |
+
"TraceDnsCacheHitParams",
|
| 243 |
+
"TraceDnsCacheMissParams",
|
| 244 |
+
"TraceDnsResolveHostEndParams",
|
| 245 |
+
"TraceDnsResolveHostStartParams",
|
| 246 |
+
"TraceRequestChunkSentParams",
|
| 247 |
+
"TraceRequestEndParams",
|
| 248 |
+
"TraceRequestExceptionParams",
|
| 249 |
+
"TraceRequestHeadersSentParams",
|
| 250 |
+
"TraceRequestRedirectParams",
|
| 251 |
+
"TraceRequestStartParams",
|
| 252 |
+
"TraceResponseChunkReceivedParams",
|
| 253 |
+
# workers (imported lazily with __getattr__)
|
| 254 |
+
"GunicornUVLoopWebWorker",
|
| 255 |
+
"GunicornWebWorker",
|
| 256 |
+
"WSMessageTypeError",
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def __dir__() -> Tuple[str, ...]:
|
| 261 |
+
return __all__ + ("__doc__",)
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
def __getattr__(name: str) -> object:
|
| 265 |
+
global GunicornUVLoopWebWorker, GunicornWebWorker
|
| 266 |
+
|
| 267 |
+
# Importing gunicorn takes a long time (>100ms), so only import if actually needed.
|
| 268 |
+
if name in ("GunicornUVLoopWebWorker", "GunicornWebWorker"):
|
| 269 |
+
try:
|
| 270 |
+
from .worker import GunicornUVLoopWebWorker as guv, GunicornWebWorker as gw
|
| 271 |
+
except ImportError:
|
| 272 |
+
return None
|
| 273 |
+
|
| 274 |
+
GunicornUVLoopWebWorker = guv # type: ignore[misc]
|
| 275 |
+
GunicornWebWorker = gw # type: ignore[misc]
|
| 276 |
+
return guv if name == "GunicornUVLoopWebWorker" else gw
|
| 277 |
+
|
| 278 |
+
raise AttributeError(f"module {__name__} has no attribute {name}")
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/_cookie_helpers.py
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Internal cookie handling helpers.
|
| 3 |
+
|
| 4 |
+
This module contains internal utilities for cookie parsing and manipulation.
|
| 5 |
+
These are not part of the public API and may change without notice.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import re
|
| 9 |
+
from http.cookies import Morsel
|
| 10 |
+
from typing import List, Optional, Sequence, Tuple, cast
|
| 11 |
+
|
| 12 |
+
from .log import internal_logger
|
| 13 |
+
|
| 14 |
+
__all__ = (
|
| 15 |
+
"parse_set_cookie_headers",
|
| 16 |
+
"parse_cookie_header",
|
| 17 |
+
"preserve_morsel_with_coded_value",
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Cookie parsing constants
|
| 21 |
+
# Allow more characters in cookie names to handle real-world cookies
|
| 22 |
+
# that don't strictly follow RFC standards (fixes #2683)
|
| 23 |
+
# RFC 6265 defines cookie-name token as per RFC 2616 Section 2.2,
|
| 24 |
+
# but many servers send cookies with characters like {} [] () etc.
|
| 25 |
+
# This makes the cookie parser more tolerant of real-world cookies
|
| 26 |
+
# while still providing some validation to catch obviously malformed names.
|
| 27 |
+
_COOKIE_NAME_RE = re.compile(r"^[!#$%&\'()*+\-./0-9:<=>?@A-Z\[\]^_`a-z{|}~]+$")
|
| 28 |
+
_COOKIE_KNOWN_ATTRS = frozenset( # AKA Morsel._reserved
|
| 29 |
+
(
|
| 30 |
+
"path",
|
| 31 |
+
"domain",
|
| 32 |
+
"max-age",
|
| 33 |
+
"expires",
|
| 34 |
+
"secure",
|
| 35 |
+
"httponly",
|
| 36 |
+
"samesite",
|
| 37 |
+
"partitioned",
|
| 38 |
+
"version",
|
| 39 |
+
"comment",
|
| 40 |
+
)
|
| 41 |
+
)
|
| 42 |
+
_COOKIE_BOOL_ATTRS = frozenset( # AKA Morsel._flags
|
| 43 |
+
("secure", "httponly", "partitioned")
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# SimpleCookie's pattern for parsing cookies with relaxed validation
|
| 47 |
+
# Based on http.cookies pattern but extended to allow more characters in cookie names
|
| 48 |
+
# to handle real-world cookies (fixes #2683)
|
| 49 |
+
_COOKIE_PATTERN = re.compile(
|
| 50 |
+
r"""
|
| 51 |
+
\s* # Optional whitespace at start of cookie
|
| 52 |
+
(?P<key> # Start of group 'key'
|
| 53 |
+
# aiohttp has extended to include [] for compatibility with real-world cookies
|
| 54 |
+
[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\[\]]+ # Any word of at least one letter
|
| 55 |
+
) # End of group 'key'
|
| 56 |
+
( # Optional group: there may not be a value.
|
| 57 |
+
\s*=\s* # Equal Sign
|
| 58 |
+
(?P<val> # Start of group 'val'
|
| 59 |
+
"(?:[^\\"]|\\.)*" # Any double-quoted string (properly closed)
|
| 60 |
+
| # or
|
| 61 |
+
"[^";]* # Unmatched opening quote (differs from SimpleCookie - issue #7993)
|
| 62 |
+
| # or
|
| 63 |
+
# Special case for "expires" attr - RFC 822, RFC 850, RFC 1036, RFC 1123
|
| 64 |
+
(\w{3,6}day|\w{3}),\s # Day of the week or abbreviated day (with comma)
|
| 65 |
+
[\w\d\s-]{9,11}\s[\d:]{8}\s # Date and time in specific format
|
| 66 |
+
(GMT|[+-]\d{4}) # Timezone: GMT or RFC 2822 offset like -0000, +0100
|
| 67 |
+
# NOTE: RFC 2822 timezone support is an aiohttp extension
|
| 68 |
+
# for issue #4493 - SimpleCookie does NOT support this
|
| 69 |
+
| # or
|
| 70 |
+
# ANSI C asctime() format: "Wed Jun 9 10:18:14 2021"
|
| 71 |
+
# NOTE: This is an aiohttp extension for issue #4327 - SimpleCookie does NOT support this format
|
| 72 |
+
\w{3}\s+\w{3}\s+[\s\d]\d\s+\d{2}:\d{2}:\d{2}\s+\d{4}
|
| 73 |
+
| # or
|
| 74 |
+
[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=\[\]]* # Any word or empty string
|
| 75 |
+
) # End of group 'val'
|
| 76 |
+
)? # End of optional value group
|
| 77 |
+
\s* # Any number of spaces.
|
| 78 |
+
(\s+|;|$) # Ending either at space, semicolon, or EOS.
|
| 79 |
+
""",
|
| 80 |
+
re.VERBOSE | re.ASCII,
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def preserve_morsel_with_coded_value(cookie: Morsel[str]) -> Morsel[str]:
|
| 85 |
+
"""
|
| 86 |
+
Preserve a Morsel's coded_value exactly as received from the server.
|
| 87 |
+
|
| 88 |
+
This function ensures that cookie encoding is preserved exactly as sent by
|
| 89 |
+
the server, which is critical for compatibility with old servers that have
|
| 90 |
+
strict requirements about cookie formats.
|
| 91 |
+
|
| 92 |
+
This addresses the issue described in https://github.com/aio-libs/aiohttp/pull/1453
|
| 93 |
+
where Python's SimpleCookie would re-encode cookies, breaking authentication
|
| 94 |
+
with certain servers.
|
| 95 |
+
|
| 96 |
+
Args:
|
| 97 |
+
cookie: A Morsel object from SimpleCookie
|
| 98 |
+
|
| 99 |
+
Returns:
|
| 100 |
+
A Morsel object with preserved coded_value
|
| 101 |
+
|
| 102 |
+
"""
|
| 103 |
+
mrsl_val = cast("Morsel[str]", cookie.get(cookie.key, Morsel()))
|
| 104 |
+
# We use __setstate__ instead of the public set() API because it allows us to
|
| 105 |
+
# bypass validation and set already validated state. This is more stable than
|
| 106 |
+
# setting protected attributes directly and unlikely to change since it would
|
| 107 |
+
# break pickling.
|
| 108 |
+
mrsl_val.__setstate__( # type: ignore[attr-defined]
|
| 109 |
+
{"key": cookie.key, "value": cookie.value, "coded_value": cookie.coded_value}
|
| 110 |
+
)
|
| 111 |
+
return mrsl_val
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
_unquote_sub = re.compile(r"\\(?:([0-3][0-7][0-7])|(.))").sub
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def _unquote_replace(m: re.Match[str]) -> str:
|
| 118 |
+
"""
|
| 119 |
+
Replace function for _unquote_sub regex substitution.
|
| 120 |
+
|
| 121 |
+
Handles escaped characters in cookie values:
|
| 122 |
+
- Octal sequences are converted to their character representation
|
| 123 |
+
- Other escaped characters are unescaped by removing the backslash
|
| 124 |
+
"""
|
| 125 |
+
if m[1]:
|
| 126 |
+
return chr(int(m[1], 8))
|
| 127 |
+
return m[2]
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _unquote(value: str) -> str:
|
| 131 |
+
"""
|
| 132 |
+
Unquote a cookie value.
|
| 133 |
+
|
| 134 |
+
Vendored from http.cookies._unquote to ensure compatibility.
|
| 135 |
+
|
| 136 |
+
Note: The original implementation checked for None, but we've removed
|
| 137 |
+
that check since all callers already ensure the value is not None.
|
| 138 |
+
"""
|
| 139 |
+
# If there aren't any doublequotes,
|
| 140 |
+
# then there can't be any special characters. See RFC 2109.
|
| 141 |
+
if len(value) < 2:
|
| 142 |
+
return value
|
| 143 |
+
if value[0] != '"' or value[-1] != '"':
|
| 144 |
+
return value
|
| 145 |
+
|
| 146 |
+
# We have to assume that we must decode this string.
|
| 147 |
+
# Down to work.
|
| 148 |
+
|
| 149 |
+
# Remove the "s
|
| 150 |
+
value = value[1:-1]
|
| 151 |
+
|
| 152 |
+
# Check for special sequences. Examples:
|
| 153 |
+
# \012 --> \n
|
| 154 |
+
# \" --> "
|
| 155 |
+
#
|
| 156 |
+
return _unquote_sub(_unquote_replace, value)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def parse_cookie_header(header: str) -> List[Tuple[str, Morsel[str]]]:
|
| 160 |
+
"""
|
| 161 |
+
Parse a Cookie header according to RFC 6265 Section 5.4.
|
| 162 |
+
|
| 163 |
+
Cookie headers contain only name-value pairs separated by semicolons.
|
| 164 |
+
There are no attributes in Cookie headers - even names that match
|
| 165 |
+
attribute names (like 'path' or 'secure') should be treated as cookies.
|
| 166 |
+
|
| 167 |
+
This parser uses the same regex-based approach as parse_set_cookie_headers
|
| 168 |
+
to properly handle quoted values that may contain semicolons. When the
|
| 169 |
+
regex fails to match a malformed cookie, it falls back to simple parsing
|
| 170 |
+
to ensure subsequent cookies are not lost
|
| 171 |
+
https://github.com/aio-libs/aiohttp/issues/11632
|
| 172 |
+
|
| 173 |
+
Args:
|
| 174 |
+
header: The Cookie header value to parse
|
| 175 |
+
|
| 176 |
+
Returns:
|
| 177 |
+
List of (name, Morsel) tuples for compatibility with SimpleCookie.update()
|
| 178 |
+
"""
|
| 179 |
+
if not header:
|
| 180 |
+
return []
|
| 181 |
+
|
| 182 |
+
cookies: List[Tuple[str, Morsel[str]]] = []
|
| 183 |
+
morsel: Morsel[str]
|
| 184 |
+
i = 0
|
| 185 |
+
n = len(header)
|
| 186 |
+
|
| 187 |
+
invalid_names = []
|
| 188 |
+
while i < n:
|
| 189 |
+
# Use the same pattern as parse_set_cookie_headers to find cookies
|
| 190 |
+
match = _COOKIE_PATTERN.match(header, i)
|
| 191 |
+
if not match:
|
| 192 |
+
# Fallback for malformed cookies https://github.com/aio-libs/aiohttp/issues/11632
|
| 193 |
+
# Find next semicolon to skip or attempt simple key=value parsing
|
| 194 |
+
next_semi = header.find(";", i)
|
| 195 |
+
eq_pos = header.find("=", i)
|
| 196 |
+
|
| 197 |
+
# Try to extract key=value if '=' comes before ';'
|
| 198 |
+
if eq_pos != -1 and (next_semi == -1 or eq_pos < next_semi):
|
| 199 |
+
end_pos = next_semi if next_semi != -1 else n
|
| 200 |
+
key = header[i:eq_pos].strip()
|
| 201 |
+
value = header[eq_pos + 1 : end_pos].strip()
|
| 202 |
+
|
| 203 |
+
# Validate the name (same as regex path)
|
| 204 |
+
if not _COOKIE_NAME_RE.match(key):
|
| 205 |
+
invalid_names.append(key)
|
| 206 |
+
else:
|
| 207 |
+
morsel = Morsel()
|
| 208 |
+
morsel.__setstate__( # type: ignore[attr-defined]
|
| 209 |
+
{"key": key, "value": _unquote(value), "coded_value": value}
|
| 210 |
+
)
|
| 211 |
+
cookies.append((key, morsel))
|
| 212 |
+
|
| 213 |
+
# Move to next cookie or end
|
| 214 |
+
i = next_semi + 1 if next_semi != -1 else n
|
| 215 |
+
continue
|
| 216 |
+
|
| 217 |
+
key = match.group("key")
|
| 218 |
+
value = match.group("val") or ""
|
| 219 |
+
i = match.end(0)
|
| 220 |
+
|
| 221 |
+
# Validate the name
|
| 222 |
+
if not key or not _COOKIE_NAME_RE.match(key):
|
| 223 |
+
invalid_names.append(key)
|
| 224 |
+
continue
|
| 225 |
+
|
| 226 |
+
# Create new morsel
|
| 227 |
+
morsel = Morsel()
|
| 228 |
+
# Preserve the original value as coded_value (with quotes if present)
|
| 229 |
+
# We use __setstate__ instead of the public set() API because it allows us to
|
| 230 |
+
# bypass validation and set already validated state. This is more stable than
|
| 231 |
+
# setting protected attributes directly and unlikely to change since it would
|
| 232 |
+
# break pickling.
|
| 233 |
+
morsel.__setstate__( # type: ignore[attr-defined]
|
| 234 |
+
{"key": key, "value": _unquote(value), "coded_value": value}
|
| 235 |
+
)
|
| 236 |
+
|
| 237 |
+
cookies.append((key, morsel))
|
| 238 |
+
|
| 239 |
+
if invalid_names:
|
| 240 |
+
internal_logger.debug(
|
| 241 |
+
"Cannot load cookie. Illegal cookie names: %r", invalid_names
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
return cookies
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def parse_set_cookie_headers(headers: Sequence[str]) -> List[Tuple[str, Morsel[str]]]:
|
| 248 |
+
"""
|
| 249 |
+
Parse cookie headers using a vendored version of SimpleCookie parsing.
|
| 250 |
+
|
| 251 |
+
This implementation is based on SimpleCookie.__parse_string to ensure
|
| 252 |
+
compatibility with how SimpleCookie parses cookies, including handling
|
| 253 |
+
of malformed cookies with missing semicolons.
|
| 254 |
+
|
| 255 |
+
This function is used for both Cookie and Set-Cookie headers in order to be
|
| 256 |
+
forgiving. Ideally we would have followed RFC 6265 Section 5.2 (for Cookie
|
| 257 |
+
headers) and RFC 6265 Section 4.2.1 (for Set-Cookie headers), but the
|
| 258 |
+
real world data makes it impossible since we need to be a bit more forgiving.
|
| 259 |
+
|
| 260 |
+
NOTE: This implementation differs from SimpleCookie in handling unmatched quotes.
|
| 261 |
+
SimpleCookie will stop parsing when it encounters a cookie value with an unmatched
|
| 262 |
+
quote (e.g., 'cookie="value'), causing subsequent cookies to be silently dropped.
|
| 263 |
+
This implementation handles unmatched quotes more gracefully to prevent cookie loss.
|
| 264 |
+
See https://github.com/aio-libs/aiohttp/issues/7993
|
| 265 |
+
"""
|
| 266 |
+
parsed_cookies: List[Tuple[str, Morsel[str]]] = []
|
| 267 |
+
|
| 268 |
+
for header in headers:
|
| 269 |
+
if not header:
|
| 270 |
+
continue
|
| 271 |
+
|
| 272 |
+
# Parse cookie string using SimpleCookie's algorithm
|
| 273 |
+
i = 0
|
| 274 |
+
n = len(header)
|
| 275 |
+
current_morsel: Optional[Morsel[str]] = None
|
| 276 |
+
morsel_seen = False
|
| 277 |
+
|
| 278 |
+
while 0 <= i < n:
|
| 279 |
+
# Start looking for a cookie
|
| 280 |
+
match = _COOKIE_PATTERN.match(header, i)
|
| 281 |
+
if not match:
|
| 282 |
+
# No more cookies
|
| 283 |
+
break
|
| 284 |
+
|
| 285 |
+
key, value = match.group("key"), match.group("val")
|
| 286 |
+
i = match.end(0)
|
| 287 |
+
lower_key = key.lower()
|
| 288 |
+
|
| 289 |
+
if key[0] == "$":
|
| 290 |
+
if not morsel_seen:
|
| 291 |
+
# We ignore attributes which pertain to the cookie
|
| 292 |
+
# mechanism as a whole, such as "$Version".
|
| 293 |
+
continue
|
| 294 |
+
# Process as attribute
|
| 295 |
+
if current_morsel is not None:
|
| 296 |
+
attr_lower_key = lower_key[1:]
|
| 297 |
+
if attr_lower_key in _COOKIE_KNOWN_ATTRS:
|
| 298 |
+
current_morsel[attr_lower_key] = value or ""
|
| 299 |
+
elif lower_key in _COOKIE_KNOWN_ATTRS:
|
| 300 |
+
if not morsel_seen:
|
| 301 |
+
# Invalid cookie string - attribute before cookie
|
| 302 |
+
break
|
| 303 |
+
if lower_key in _COOKIE_BOOL_ATTRS:
|
| 304 |
+
# Boolean attribute with any value should be True
|
| 305 |
+
if current_morsel is not None and current_morsel.isReservedKey(key):
|
| 306 |
+
current_morsel[lower_key] = True
|
| 307 |
+
elif value is None:
|
| 308 |
+
# Invalid cookie string - non-boolean attribute without value
|
| 309 |
+
break
|
| 310 |
+
elif current_morsel is not None:
|
| 311 |
+
# Regular attribute with value
|
| 312 |
+
current_morsel[lower_key] = _unquote(value)
|
| 313 |
+
elif value is not None:
|
| 314 |
+
# This is a cookie name=value pair
|
| 315 |
+
# Validate the name
|
| 316 |
+
if key in _COOKIE_KNOWN_ATTRS or not _COOKIE_NAME_RE.match(key):
|
| 317 |
+
internal_logger.warning(
|
| 318 |
+
"Can not load cookies: Illegal cookie name %r", key
|
| 319 |
+
)
|
| 320 |
+
current_morsel = None
|
| 321 |
+
else:
|
| 322 |
+
# Create new morsel
|
| 323 |
+
current_morsel = Morsel()
|
| 324 |
+
# Preserve the original value as coded_value (with quotes if present)
|
| 325 |
+
# We use __setstate__ instead of the public set() API because it allows us to
|
| 326 |
+
# bypass validation and set already validated state. This is more stable than
|
| 327 |
+
# setting protected attributes directly and unlikely to change since it would
|
| 328 |
+
# break pickling.
|
| 329 |
+
current_morsel.__setstate__( # type: ignore[attr-defined]
|
| 330 |
+
{"key": key, "value": _unquote(value), "coded_value": value}
|
| 331 |
+
)
|
| 332 |
+
parsed_cookies.append((key, current_morsel))
|
| 333 |
+
morsel_seen = True
|
| 334 |
+
else:
|
| 335 |
+
# Invalid cookie string - no value for non-attribute
|
| 336 |
+
break
|
| 337 |
+
|
| 338 |
+
return parsed_cookies
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/_cparser.pxd
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from libc.stdint cimport int32_t, uint8_t, uint16_t, uint64_t
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
cdef extern from "llhttp.h":
|
| 5 |
+
|
| 6 |
+
struct llhttp__internal_s:
|
| 7 |
+
int32_t _index
|
| 8 |
+
void* _span_pos0
|
| 9 |
+
void* _span_cb0
|
| 10 |
+
int32_t error
|
| 11 |
+
const char* reason
|
| 12 |
+
const char* error_pos
|
| 13 |
+
void* data
|
| 14 |
+
void* _current
|
| 15 |
+
uint64_t content_length
|
| 16 |
+
uint8_t type
|
| 17 |
+
uint8_t method
|
| 18 |
+
uint8_t http_major
|
| 19 |
+
uint8_t http_minor
|
| 20 |
+
uint8_t header_state
|
| 21 |
+
uint8_t lenient_flags
|
| 22 |
+
uint8_t upgrade
|
| 23 |
+
uint8_t finish
|
| 24 |
+
uint16_t flags
|
| 25 |
+
uint16_t status_code
|
| 26 |
+
void* settings
|
| 27 |
+
|
| 28 |
+
ctypedef llhttp__internal_s llhttp__internal_t
|
| 29 |
+
ctypedef llhttp__internal_t llhttp_t
|
| 30 |
+
|
| 31 |
+
ctypedef int (*llhttp_data_cb)(llhttp_t*, const char *at, size_t length) except -1
|
| 32 |
+
ctypedef int (*llhttp_cb)(llhttp_t*) except -1
|
| 33 |
+
|
| 34 |
+
struct llhttp_settings_s:
|
| 35 |
+
llhttp_cb on_message_begin
|
| 36 |
+
llhttp_data_cb on_url
|
| 37 |
+
llhttp_data_cb on_status
|
| 38 |
+
llhttp_data_cb on_header_field
|
| 39 |
+
llhttp_data_cb on_header_value
|
| 40 |
+
llhttp_cb on_headers_complete
|
| 41 |
+
llhttp_data_cb on_body
|
| 42 |
+
llhttp_cb on_message_complete
|
| 43 |
+
llhttp_cb on_chunk_header
|
| 44 |
+
llhttp_cb on_chunk_complete
|
| 45 |
+
|
| 46 |
+
llhttp_cb on_url_complete
|
| 47 |
+
llhttp_cb on_status_complete
|
| 48 |
+
llhttp_cb on_header_field_complete
|
| 49 |
+
llhttp_cb on_header_value_complete
|
| 50 |
+
|
| 51 |
+
ctypedef llhttp_settings_s llhttp_settings_t
|
| 52 |
+
|
| 53 |
+
enum llhttp_errno:
|
| 54 |
+
HPE_OK,
|
| 55 |
+
HPE_INTERNAL,
|
| 56 |
+
HPE_STRICT,
|
| 57 |
+
HPE_LF_EXPECTED,
|
| 58 |
+
HPE_UNEXPECTED_CONTENT_LENGTH,
|
| 59 |
+
HPE_CLOSED_CONNECTION,
|
| 60 |
+
HPE_INVALID_METHOD,
|
| 61 |
+
HPE_INVALID_URL,
|
| 62 |
+
HPE_INVALID_CONSTANT,
|
| 63 |
+
HPE_INVALID_VERSION,
|
| 64 |
+
HPE_INVALID_HEADER_TOKEN,
|
| 65 |
+
HPE_INVALID_CONTENT_LENGTH,
|
| 66 |
+
HPE_INVALID_CHUNK_SIZE,
|
| 67 |
+
HPE_INVALID_STATUS,
|
| 68 |
+
HPE_INVALID_EOF_STATE,
|
| 69 |
+
HPE_INVALID_TRANSFER_ENCODING,
|
| 70 |
+
HPE_CB_MESSAGE_BEGIN,
|
| 71 |
+
HPE_CB_HEADERS_COMPLETE,
|
| 72 |
+
HPE_CB_MESSAGE_COMPLETE,
|
| 73 |
+
HPE_CB_CHUNK_HEADER,
|
| 74 |
+
HPE_CB_CHUNK_COMPLETE,
|
| 75 |
+
HPE_PAUSED,
|
| 76 |
+
HPE_PAUSED_UPGRADE,
|
| 77 |
+
HPE_USER
|
| 78 |
+
|
| 79 |
+
ctypedef llhttp_errno llhttp_errno_t
|
| 80 |
+
|
| 81 |
+
enum llhttp_flags:
|
| 82 |
+
F_CHUNKED,
|
| 83 |
+
F_CONTENT_LENGTH
|
| 84 |
+
|
| 85 |
+
enum llhttp_type:
|
| 86 |
+
HTTP_REQUEST,
|
| 87 |
+
HTTP_RESPONSE,
|
| 88 |
+
HTTP_BOTH
|
| 89 |
+
|
| 90 |
+
enum llhttp_method:
|
| 91 |
+
HTTP_DELETE,
|
| 92 |
+
HTTP_GET,
|
| 93 |
+
HTTP_HEAD,
|
| 94 |
+
HTTP_POST,
|
| 95 |
+
HTTP_PUT,
|
| 96 |
+
HTTP_CONNECT,
|
| 97 |
+
HTTP_OPTIONS,
|
| 98 |
+
HTTP_TRACE,
|
| 99 |
+
HTTP_COPY,
|
| 100 |
+
HTTP_LOCK,
|
| 101 |
+
HTTP_MKCOL,
|
| 102 |
+
HTTP_MOVE,
|
| 103 |
+
HTTP_PROPFIND,
|
| 104 |
+
HTTP_PROPPATCH,
|
| 105 |
+
HTTP_SEARCH,
|
| 106 |
+
HTTP_UNLOCK,
|
| 107 |
+
HTTP_BIND,
|
| 108 |
+
HTTP_REBIND,
|
| 109 |
+
HTTP_UNBIND,
|
| 110 |
+
HTTP_ACL,
|
| 111 |
+
HTTP_REPORT,
|
| 112 |
+
HTTP_MKACTIVITY,
|
| 113 |
+
HTTP_CHECKOUT,
|
| 114 |
+
HTTP_MERGE,
|
| 115 |
+
HTTP_MSEARCH,
|
| 116 |
+
HTTP_NOTIFY,
|
| 117 |
+
HTTP_SUBSCRIBE,
|
| 118 |
+
HTTP_UNSUBSCRIBE,
|
| 119 |
+
HTTP_PATCH,
|
| 120 |
+
HTTP_PURGE,
|
| 121 |
+
HTTP_MKCALENDAR,
|
| 122 |
+
HTTP_LINK,
|
| 123 |
+
HTTP_UNLINK,
|
| 124 |
+
HTTP_SOURCE,
|
| 125 |
+
HTTP_PRI,
|
| 126 |
+
HTTP_DESCRIBE,
|
| 127 |
+
HTTP_ANNOUNCE,
|
| 128 |
+
HTTP_SETUP,
|
| 129 |
+
HTTP_PLAY,
|
| 130 |
+
HTTP_PAUSE,
|
| 131 |
+
HTTP_TEARDOWN,
|
| 132 |
+
HTTP_GET_PARAMETER,
|
| 133 |
+
HTTP_SET_PARAMETER,
|
| 134 |
+
HTTP_REDIRECT,
|
| 135 |
+
HTTP_RECORD,
|
| 136 |
+
HTTP_FLUSH
|
| 137 |
+
|
| 138 |
+
ctypedef llhttp_method llhttp_method_t;
|
| 139 |
+
|
| 140 |
+
void llhttp_settings_init(llhttp_settings_t* settings)
|
| 141 |
+
void llhttp_init(llhttp_t* parser, llhttp_type type,
|
| 142 |
+
const llhttp_settings_t* settings)
|
| 143 |
+
|
| 144 |
+
llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len)
|
| 145 |
+
|
| 146 |
+
int llhttp_should_keep_alive(const llhttp_t* parser)
|
| 147 |
+
|
| 148 |
+
void llhttp_resume_after_upgrade(llhttp_t* parser)
|
| 149 |
+
|
| 150 |
+
llhttp_errno_t llhttp_get_errno(const llhttp_t* parser)
|
| 151 |
+
const char* llhttp_get_error_reason(const llhttp_t* parser)
|
| 152 |
+
const char* llhttp_get_error_pos(const llhttp_t* parser)
|
| 153 |
+
|
| 154 |
+
const char* llhttp_method_name(llhttp_method_t method)
|
| 155 |
+
|
| 156 |
+
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled)
|
| 157 |
+
void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled)
|
| 158 |
+
void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled)
|
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp/_find_header.pxd
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef extern from "_find_header.h":
|
| 2 |
+
int find_header(char *, int)
|