ZTWHHH commited on
Commit
fa6a896
·
verified ·
1 Parent(s): efc10a1

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. mplug_owl2/share/terminfo/l/la120 +0 -0
  2. mplug_owl2/share/terminfo/l/layer +0 -0
  3. mplug_owl2/share/terminfo/l/lft +0 -0
  4. mplug_owl2/share/terminfo/l/lft-pc850 +0 -0
  5. mplug_owl2/share/terminfo/l/linux +0 -0
  6. mplug_owl2/share/terminfo/l/linux+sfkeys +0 -0
  7. mplug_owl2/share/terminfo/l/linux-16color +0 -0
  8. mplug_owl2/share/terminfo/l/linux-basic +0 -0
  9. mplug_owl2/share/terminfo/l/linux-c +0 -0
  10. mplug_owl2/share/terminfo/l/linux-koi8r +0 -0
  11. mplug_owl2/share/terminfo/l/linux-lat +0 -0
  12. mplug_owl2/share/terminfo/l/linux-m1 +0 -0
  13. mplug_owl2/share/terminfo/l/linux-m2 +0 -0
  14. mplug_owl2/share/terminfo/l/linux-nic +0 -0
  15. mplug_owl2/share/terminfo/l/linux-s +0 -0
  16. mplug_owl2/share/terminfo/l/linux-vt +0 -0
  17. mplug_owl2/share/terminfo/l/linux2.2 +0 -0
  18. mplug_owl2/share/terminfo/l/linux2.6 +0 -0
  19. mplug_owl2/share/terminfo/l/linux2.6.26 +0 -0
  20. mplug_owl2/share/terminfo/l/linux3.0 +0 -0
  21. mplug_owl2/share/terminfo/l/lisaterm +0 -0
  22. mplug_owl2/share/terminfo/l/lisaterm-w +0 -0
  23. mplug_owl2/share/terminfo/l/liswb +0 -0
  24. mplug_owl2/share/terminfo/l/ln03 +0 -0
  25. mplug_owl2/share/terminfo/l/ln03-w +0 -0
  26. mplug_owl2/share/terminfo/l/lpr +0 -0
  27. mplug_owl2/share/terminfo/l/luna +0 -0
  28. mplug_owl2/share/terminfo/o/oldibmpc3 +0 -0
  29. mplug_owl2/share/terminfo/o/opennt-100-nti +0 -0
  30. mplug_owl2/share/terminfo/o/osborne +0 -0
  31. openflamingo/lib/python3.10/site-packages/networkx-3.2.1.dist-info/LICENSE.txt +37 -0
  32. openflamingo/lib/python3.10/site-packages/psutil-6.1.1.dist-info/INSTALLER +1 -0
  33. openflamingo/lib/python3.10/site-packages/psutil-6.1.1.dist-info/METADATA +548 -0
  34. openflamingo/lib/python3.10/site-packages/requests/__init__.py +184 -0
  35. openflamingo/lib/python3.10/site-packages/requests/__pycache__/__init__.cpython-310.pyc +0 -0
  36. openflamingo/lib/python3.10/site-packages/requests/__pycache__/__version__.cpython-310.pyc +0 -0
  37. openflamingo/lib/python3.10/site-packages/requests/__pycache__/adapters.cpython-310.pyc +0 -0
  38. openflamingo/lib/python3.10/site-packages/requests/__pycache__/api.cpython-310.pyc +0 -0
  39. openflamingo/lib/python3.10/site-packages/requests/__pycache__/certs.cpython-310.pyc +0 -0
  40. openflamingo/lib/python3.10/site-packages/requests/__pycache__/cookies.cpython-310.pyc +0 -0
  41. openflamingo/lib/python3.10/site-packages/requests/__pycache__/exceptions.cpython-310.pyc +0 -0
  42. openflamingo/lib/python3.10/site-packages/requests/__pycache__/hooks.cpython-310.pyc +0 -0
  43. openflamingo/lib/python3.10/site-packages/requests/__pycache__/models.cpython-310.pyc +0 -0
  44. openflamingo/lib/python3.10/site-packages/requests/__pycache__/packages.cpython-310.pyc +0 -0
  45. openflamingo/lib/python3.10/site-packages/requests/adapters.py +719 -0
  46. openflamingo/lib/python3.10/site-packages/requests/certs.py +17 -0
  47. openflamingo/lib/python3.10/site-packages/requests/compat.py +94 -0
  48. openflamingo/lib/python3.10/site-packages/requests/help.py +134 -0
  49. openflamingo/lib/python3.10/site-packages/requests/hooks.py +33 -0
  50. openflamingo/lib/python3.10/site-packages/requests/sessions.py +831 -0
mplug_owl2/share/terminfo/l/la120 ADDED
Binary file (473 Bytes). View file
 
mplug_owl2/share/terminfo/l/layer ADDED
Binary file (470 Bytes). View file
 
mplug_owl2/share/terminfo/l/lft ADDED
Binary file (1.3 kB). View file
 
mplug_owl2/share/terminfo/l/lft-pc850 ADDED
Binary file (1.3 kB). View file
 
mplug_owl2/share/terminfo/l/linux ADDED
Binary file (1.74 kB). View file
 
mplug_owl2/share/terminfo/l/linux+sfkeys ADDED
Binary file (566 Bytes). View file
 
mplug_owl2/share/terminfo/l/linux-16color ADDED
Binary file (1.82 kB). View file
 
mplug_owl2/share/terminfo/l/linux-basic ADDED
Binary file (1.61 kB). View file
 
mplug_owl2/share/terminfo/l/linux-c ADDED
Binary file (2.06 kB). View file
 
mplug_owl2/share/terminfo/l/linux-koi8r ADDED
Binary file (1.77 kB). View file
 
mplug_owl2/share/terminfo/l/linux-lat ADDED
Binary file (1.78 kB). View file
 
mplug_owl2/share/terminfo/l/linux-m1 ADDED
Binary file (1.79 kB). View file
 
mplug_owl2/share/terminfo/l/linux-m2 ADDED
Binary file (1.9 kB). View file
 
mplug_owl2/share/terminfo/l/linux-nic ADDED
Binary file (1.77 kB). View file
 
mplug_owl2/share/terminfo/l/linux-s ADDED
Binary file (1.96 kB). View file
 
mplug_owl2/share/terminfo/l/linux-vt ADDED
Binary file (1.67 kB). View file
 
mplug_owl2/share/terminfo/l/linux2.2 ADDED
Binary file (1.73 kB). View file
 
mplug_owl2/share/terminfo/l/linux2.6 ADDED
Binary file (1.72 kB). View file
 
mplug_owl2/share/terminfo/l/linux2.6.26 ADDED
Binary file (1.73 kB). View file
 
mplug_owl2/share/terminfo/l/linux3.0 ADDED
Binary file (1.75 kB). View file
 
mplug_owl2/share/terminfo/l/lisaterm ADDED
Binary file (732 Bytes). View file
 
mplug_owl2/share/terminfo/l/lisaterm-w ADDED
Binary file (720 Bytes). View file
 
mplug_owl2/share/terminfo/l/liswb ADDED
Binary file (563 Bytes). View file
 
mplug_owl2/share/terminfo/l/ln03 ADDED
Binary file (375 Bytes). View file
 
mplug_owl2/share/terminfo/l/ln03-w ADDED
Binary file (393 Bytes). View file
 
mplug_owl2/share/terminfo/l/lpr ADDED
Binary file (354 Bytes). View file
 
mplug_owl2/share/terminfo/l/luna ADDED
Binary file (396 Bytes). View file
 
mplug_owl2/share/terminfo/o/oldibmpc3 ADDED
Binary file (447 Bytes). View file
 
mplug_owl2/share/terminfo/o/opennt-100-nti ADDED
Binary file (1.46 kB). View file
 
mplug_owl2/share/terminfo/o/osborne ADDED
Binary file (430 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/networkx-3.2.1.dist-info/LICENSE.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NetworkX is distributed with the 3-clause BSD license.
2
+
3
+ ::
4
+
5
+ Copyright (C) 2004-2023, NetworkX Developers
6
+ Aric Hagberg <hagberg@lanl.gov>
7
+ Dan Schult <dschult@colgate.edu>
8
+ Pieter Swart <swart@lanl.gov>
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are
13
+ met:
14
+
15
+ * Redistributions of source code must retain the above copyright
16
+ notice, this list of conditions and the following disclaimer.
17
+
18
+ * Redistributions in binary form must reproduce the above
19
+ copyright notice, this list of conditions and the following
20
+ disclaimer in the documentation and/or other materials provided
21
+ with the distribution.
22
+
23
+ * Neither the name of the NetworkX Developers nor the names of its
24
+ contributors may be used to endorse or promote products derived
25
+ from this software without specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
openflamingo/lib/python3.10/site-packages/psutil-6.1.1.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
openflamingo/lib/python3.10/site-packages/psutil-6.1.1.dist-info/METADATA ADDED
@@ -0,0 +1,548 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: psutil
3
+ Version: 6.1.1
4
+ Summary: Cross-platform lib for process and system monitoring in Python.
5
+ Home-page: https://github.com/giampaolo/psutil
6
+ Author: Giampaolo Rodola
7
+ Author-email: g.rodola@gmail.com
8
+ License: BSD-3-Clause
9
+ Keywords: ps,top,kill,free,lsof,netstat,nice,tty,ionice,uptime,taskmgr,process,df,iotop,iostat,ifconfig,taskset,who,pidof,pmap,smem,pstree,monitoring,ulimit,prlimit,smem,performance,metrics,agent,observability
10
+ Platform: Platform Independent
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Environment :: Win32 (MS Windows)
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Information Technology
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: License :: OSI Approved :: BSD License
18
+ Classifier: Operating System :: MacOS :: MacOS X
19
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
20
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 7
21
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 8
22
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 8.1
23
+ Classifier: Operating System :: Microsoft :: Windows :: Windows Server 2003
24
+ Classifier: Operating System :: Microsoft :: Windows :: Windows Server 2008
25
+ Classifier: Operating System :: Microsoft :: Windows :: Windows Vista
26
+ Classifier: Operating System :: Microsoft
27
+ Classifier: Operating System :: OS Independent
28
+ Classifier: Operating System :: POSIX :: AIX
29
+ Classifier: Operating System :: POSIX :: BSD :: FreeBSD
30
+ Classifier: Operating System :: POSIX :: BSD :: NetBSD
31
+ Classifier: Operating System :: POSIX :: BSD :: OpenBSD
32
+ Classifier: Operating System :: POSIX :: BSD
33
+ Classifier: Operating System :: POSIX :: Linux
34
+ Classifier: Operating System :: POSIX :: SunOS/Solaris
35
+ Classifier: Operating System :: POSIX
36
+ Classifier: Programming Language :: C
37
+ Classifier: Programming Language :: Python :: 2
38
+ Classifier: Programming Language :: Python :: 2.7
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Programming Language :: Python :: Implementation :: CPython
41
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
42
+ Classifier: Programming Language :: Python
43
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
44
+ Classifier: Topic :: Software Development :: Libraries
45
+ Classifier: Topic :: System :: Benchmark
46
+ Classifier: Topic :: System :: Hardware :: Hardware Drivers
47
+ Classifier: Topic :: System :: Hardware
48
+ Classifier: Topic :: System :: Monitoring
49
+ Classifier: Topic :: System :: Networking :: Monitoring :: Hardware Watchdog
50
+ Classifier: Topic :: System :: Networking :: Monitoring
51
+ Classifier: Topic :: System :: Networking
52
+ Classifier: Topic :: System :: Operating System
53
+ Classifier: Topic :: System :: Systems Administration
54
+ Classifier: Topic :: Utilities
55
+ Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
56
+ Description-Content-Type: text/x-rst
57
+ License-File: LICENSE
58
+ Provides-Extra: dev
59
+ Requires-Dist: abi3audit ; extra == 'dev'
60
+ Requires-Dist: black ; extra == 'dev'
61
+ Requires-Dist: check-manifest ; extra == 'dev'
62
+ Requires-Dist: coverage ; extra == 'dev'
63
+ Requires-Dist: packaging ; extra == 'dev'
64
+ Requires-Dist: pylint ; extra == 'dev'
65
+ Requires-Dist: pyperf ; extra == 'dev'
66
+ Requires-Dist: pypinfo ; extra == 'dev'
67
+ Requires-Dist: pytest-cov ; extra == 'dev'
68
+ Requires-Dist: requests ; extra == 'dev'
69
+ Requires-Dist: rstcheck ; extra == 'dev'
70
+ Requires-Dist: ruff ; extra == 'dev'
71
+ Requires-Dist: sphinx ; extra == 'dev'
72
+ Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
73
+ Requires-Dist: toml-sort ; extra == 'dev'
74
+ Requires-Dist: twine ; extra == 'dev'
75
+ Requires-Dist: virtualenv ; extra == 'dev'
76
+ Requires-Dist: vulture ; extra == 'dev'
77
+ Requires-Dist: wheel ; extra == 'dev'
78
+ Provides-Extra: test
79
+ Requires-Dist: pytest ; extra == 'test'
80
+ Requires-Dist: pytest-xdist ; extra == 'test'
81
+ Requires-Dist: setuptools ; extra == 'test'
82
+
83
+ | |downloads| |stars| |forks| |contributors| |coverage|
84
+ | |version| |py-versions| |packages| |license|
85
+ | |github-actions-wheels| |github-actions-bsd| |appveyor| |doc| |twitter| |tidelift|
86
+
87
+ .. |downloads| image:: https://img.shields.io/pypi/dm/psutil.svg
88
+ :target: https://pepy.tech/project/psutil
89
+ :alt: Downloads
90
+
91
+ .. |stars| image:: https://img.shields.io/github/stars/giampaolo/psutil.svg
92
+ :target: https://github.com/giampaolo/psutil/stargazers
93
+ :alt: Github stars
94
+
95
+ .. |forks| image:: https://img.shields.io/github/forks/giampaolo/psutil.svg
96
+ :target: https://github.com/giampaolo/psutil/network/members
97
+ :alt: Github forks
98
+
99
+ .. |contributors| image:: https://img.shields.io/github/contributors/giampaolo/psutil.svg
100
+ :target: https://github.com/giampaolo/psutil/graphs/contributors
101
+ :alt: Contributors
102
+
103
+ .. |github-actions-wheels| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/build.yml.svg?label=Linux%2C%20macOS%2C%20Windows
104
+ :target: https://github.com/giampaolo/psutil/actions?query=workflow%3Abuild
105
+ :alt: Linux, macOS, Windows
106
+
107
+ .. |github-actions-bsd| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/bsd.yml.svg?label=FreeBSD,%20NetBSD,%20OpenBSD
108
+ :target: https://github.com/giampaolo/psutil/actions?query=workflow%3Absd-tests
109
+ :alt: FreeBSD, NetBSD, OpenBSD
110
+
111
+ .. |appveyor| image:: https://img.shields.io/appveyor/build/giampaolo/psutil/master.svg?maxAge=3600&label=Windows%20(py2)
112
+ :target: https://ci.appveyor.com/project/giampaolo/psutil
113
+ :alt: Windows (Appveyor)
114
+
115
+ .. |coverage| image:: https://coveralls.io/repos/github/giampaolo/psutil/badge.svg?branch=master
116
+ :target: https://coveralls.io/github/giampaolo/psutil?branch=master
117
+ :alt: Test coverage (coverall.io)
118
+
119
+ .. |doc| image:: https://readthedocs.org/projects/psutil/badge/?version=latest
120
+ :target: https://psutil.readthedocs.io/en/latest/
121
+ :alt: Documentation Status
122
+
123
+ .. |version| image:: https://img.shields.io/pypi/v/psutil.svg?label=pypi
124
+ :target: https://pypi.org/project/psutil
125
+ :alt: Latest version
126
+
127
+ .. |py-versions| image:: https://img.shields.io/pypi/pyversions/psutil.svg
128
+ :alt: Supported Python versions
129
+
130
+ .. |packages| image:: https://repology.org/badge/tiny-repos/python:psutil.svg
131
+ :target: https://repology.org/metapackage/python:psutil/versions
132
+ :alt: Binary packages
133
+
134
+ .. |license| image:: https://img.shields.io/pypi/l/psutil.svg
135
+ :target: https://github.com/giampaolo/psutil/blob/master/LICENSE
136
+ :alt: License
137
+
138
+ .. |twitter| image:: https://img.shields.io/twitter/follow/grodola.svg?label=follow&style=flat&logo=twitter&logoColor=4FADFF
139
+ :target: https://twitter.com/grodola
140
+ :alt: Twitter Follow
141
+
142
+ .. |tidelift| image:: https://tidelift.com/badges/github/giampaolo/psutil?style=flat
143
+ :target: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme
144
+ :alt: Tidelift
145
+
146
+ -----
147
+
148
+ Quick links
149
+ ===========
150
+
151
+ - `Home page <https://github.com/giampaolo/psutil>`_
152
+ - `Install <https://github.com/giampaolo/psutil/blob/master/INSTALL.rst>`_
153
+ - `Documentation <http://psutil.readthedocs.io>`_
154
+ - `Download <https://pypi.org/project/psutil/#files>`_
155
+ - `Forum <http://groups.google.com/group/psutil/topics>`_
156
+ - `StackOverflow <https://stackoverflow.com/questions/tagged/psutil>`_
157
+ - `Blog <https://gmpy.dev/tags/psutil>`_
158
+ - `What's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst>`_
159
+
160
+
161
+ Summary
162
+ =======
163
+
164
+ psutil (process and system utilities) is a cross-platform library for
165
+ retrieving information on **running processes** and **system utilization**
166
+ (CPU, memory, disks, network, sensors) in Python.
167
+ It is useful mainly for **system monitoring**, **profiling and limiting process
168
+ resources** and **management of running processes**.
169
+ It implements many functionalities offered by classic UNIX command line tools
170
+ such as *ps, top, iotop, lsof, netstat, ifconfig, free* and others.
171
+ psutil currently supports the following platforms:
172
+
173
+ - **Linux**
174
+ - **Windows**
175
+ - **macOS**
176
+ - **FreeBSD, OpenBSD**, **NetBSD**
177
+ - **Sun Solaris**
178
+ - **AIX**
179
+
180
+ Supported Python versions are **2.7**, **3.6+** and
181
+ `PyPy <http://pypy.org/>`__.
182
+
183
+ Funding
184
+ =======
185
+
186
+ While psutil is free software and will always be, the project would benefit
187
+ immensely from some funding.
188
+ Keeping up with bug reports and maintenance has become hardly sustainable for
189
+ me alone in terms of time.
190
+ If you're a company that's making significant use of psutil you can consider
191
+ becoming a sponsor via `GitHub Sponsors <https://github.com/sponsors/giampaolo>`__,
192
+ `Open Collective <https://opencollective.com/psutil>`__ or
193
+ `PayPal <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9ZS7PKKRM3S8>`__
194
+ and have your logo displayed in here and psutil `doc <https://psutil.readthedocs.io>`__.
195
+
196
+ Sponsors
197
+ ========
198
+
199
+ .. image:: https://github.com/giampaolo/psutil/raw/master/docs/_static/tidelift-logo.png
200
+ :width: 200
201
+ :alt: Alternative text
202
+
203
+ `Add your logo <https://github.com/sponsors/giampaolo>`__.
204
+
205
+ Example usages
206
+ ==============
207
+
208
+ This represents pretty much the whole psutil API.
209
+
210
+ CPU
211
+ ---
212
+
213
+ .. code-block:: python
214
+
215
+ >>> import psutil
216
+ >>>
217
+ >>> psutil.cpu_times()
218
+ scputimes(user=3961.46, nice=169.729, system=2150.659, idle=16900.540, iowait=629.59, irq=0.0, softirq=19.42, steal=0.0, guest=0, guest_nice=0.0)
219
+ >>>
220
+ >>> for x in range(3):
221
+ ... psutil.cpu_percent(interval=1)
222
+ ...
223
+ 4.0
224
+ 5.9
225
+ 3.8
226
+ >>>
227
+ >>> for x in range(3):
228
+ ... psutil.cpu_percent(interval=1, percpu=True)
229
+ ...
230
+ [4.0, 6.9, 3.7, 9.2]
231
+ [7.0, 8.5, 2.4, 2.1]
232
+ [1.2, 9.0, 9.9, 7.2]
233
+ >>>
234
+ >>> for x in range(3):
235
+ ... psutil.cpu_times_percent(interval=1, percpu=False)
236
+ ...
237
+ scputimes(user=1.5, nice=0.0, system=0.5, idle=96.5, iowait=1.5, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
238
+ scputimes(user=1.0, nice=0.0, system=0.0, idle=99.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
239
+ scputimes(user=2.0, nice=0.0, system=0.0, idle=98.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
240
+ >>>
241
+ >>> psutil.cpu_count()
242
+ 4
243
+ >>> psutil.cpu_count(logical=False)
244
+ 2
245
+ >>>
246
+ >>> psutil.cpu_stats()
247
+ scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0)
248
+ >>>
249
+ >>> psutil.cpu_freq()
250
+ scpufreq(current=931.42925, min=800.0, max=3500.0)
251
+ >>>
252
+ >>> psutil.getloadavg() # also on Windows (emulated)
253
+ (3.14, 3.89, 4.67)
254
+
255
+ Memory
256
+ ------
257
+
258
+ .. code-block:: python
259
+
260
+ >>> psutil.virtual_memory()
261
+ svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
262
+ >>> psutil.swap_memory()
263
+ sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944)
264
+ >>>
265
+
266
+ Disks
267
+ -----
268
+
269
+ .. code-block:: python
270
+
271
+ >>> psutil.disk_partitions()
272
+ [sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'),
273
+ sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext', opts='rw')]
274
+ >>>
275
+ >>> psutil.disk_usage('/')
276
+ sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5)
277
+ >>>
278
+ >>> psutil.disk_io_counters(perdisk=False)
279
+ sdiskio(read_count=719566, write_count=1082197, read_bytes=18626220032, write_bytes=24081764352, read_time=5023392, write_time=63199568, read_merged_count=619166, write_merged_count=812396, busy_time=4523412)
280
+ >>>
281
+
282
+ Network
283
+ -------
284
+
285
+ .. code-block:: python
286
+
287
+ >>> psutil.net_io_counters(pernic=True)
288
+ {'eth0': netio(bytes_sent=485291293, bytes_recv=6004858642, packets_sent=3251564, packets_recv=4787798, errin=0, errout=0, dropin=0, dropout=0),
289
+ 'lo': netio(bytes_sent=2838627, bytes_recv=2838627, packets_sent=30567, packets_recv=30567, errin=0, errout=0, dropin=0, dropout=0)}
290
+ >>>
291
+ >>> psutil.net_connections(kind='tcp')
292
+ [sconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED', pid=1254),
293
+ sconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status='CLOSING', pid=2987),
294
+ ...]
295
+ >>>
296
+ >>> psutil.net_if_addrs()
297
+ {'lo': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast='127.0.0.1', ptp=None),
298
+ snicaddr(family=<AddressFamily.AF_INET6: 10>, address='::1', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', broadcast=None, ptp=None),
299
+ snicaddr(family=<AddressFamily.AF_LINK: 17>, address='00:00:00:00:00:00', netmask=None, broadcast='00:00:00:00:00:00', ptp=None)],
300
+ 'wlan0': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='192.168.1.3', netmask='255.255.255.0', broadcast='192.168.1.255', ptp=None),
301
+ snicaddr(family=<AddressFamily.AF_INET6: 10>, address='fe80::c685:8ff:fe45:641%wlan0', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None),
302
+ snicaddr(family=<AddressFamily.AF_LINK: 17>, address='c4:85:08:45:06:41', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]}
303
+ >>>
304
+ >>> psutil.net_if_stats()
305
+ {'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536, flags='up,loopback,running'),
306
+ 'wlan0': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=100, mtu=1500, flags='up,broadcast,running,multicast')}
307
+ >>>
308
+
309
+ Sensors
310
+ -------
311
+
312
+ .. code-block:: python
313
+
314
+ >>> import psutil
315
+ >>> psutil.sensors_temperatures()
316
+ {'acpitz': [shwtemp(label='', current=47.0, high=103.0, critical=103.0)],
317
+ 'asus': [shwtemp(label='', current=47.0, high=None, critical=None)],
318
+ 'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0),
319
+ shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0)]}
320
+ >>>
321
+ >>> psutil.sensors_fans()
322
+ {'asus': [sfan(label='cpu_fan', current=3200)]}
323
+ >>>
324
+ >>> psutil.sensors_battery()
325
+ sbattery(percent=93, secsleft=16628, power_plugged=False)
326
+ >>>
327
+
328
+ Other system info
329
+ -----------------
330
+
331
+ .. code-block:: python
332
+
333
+ >>> import psutil
334
+ >>> psutil.users()
335
+ [suser(name='giampaolo', terminal='pts/2', host='localhost', started=1340737536.0, pid=1352),
336
+ suser(name='giampaolo', terminal='pts/3', host='localhost', started=1340737792.0, pid=1788)]
337
+ >>>
338
+ >>> psutil.boot_time()
339
+ 1365519115.0
340
+ >>>
341
+
342
+ Process management
343
+ ------------------
344
+
345
+ .. code-block:: python
346
+
347
+ >>> import psutil
348
+ >>> psutil.pids()
349
+ [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, 268, 1215,
350
+ 1216, 1220, 1221, 1243, 1244, 1301, 1601, 2237, 2355, 2637, 2774, 3932,
351
+ 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 4263, 4282, 4306, 4311,
352
+ 4312, 4313, 4314, 4337, 4339, 4357, 4358, 4363, 4383, 4395, 4408, 4433,
353
+ 4443, 4445, 4446, 5167, 5234, 5235, 5252, 5318, 5424, 5644, 6987, 7054,
354
+ 7055, 7071]
355
+ >>>
356
+ >>> p = psutil.Process(7055)
357
+ >>> p
358
+ psutil.Process(pid=7055, name='python3', status='running', started='09:04:44')
359
+ >>> p.pid
360
+ 7055
361
+ >>> p.name()
362
+ 'python3'
363
+ >>> p.exe()
364
+ '/usr/bin/python3'
365
+ >>> p.cwd()
366
+ '/home/giampaolo'
367
+ >>> p.cmdline()
368
+ ['/usr/bin/python3', 'main.py']
369
+ >>>
370
+ >>> p.ppid()
371
+ 7054
372
+ >>> p.parent()
373
+ psutil.Process(pid=4699, name='bash', status='sleeping', started='09:06:44')
374
+ >>> p.parents()
375
+ [psutil.Process(pid=4699, name='bash', started='09:06:44'),
376
+ psutil.Process(pid=4689, name='gnome-terminal-server', status='sleeping', started='0:06:44'),
377
+ psutil.Process(pid=1, name='systemd', status='sleeping', started='05:56:55')]
378
+ >>> p.children(recursive=True)
379
+ [psutil.Process(pid=29835, name='python3', status='sleeping', started='11:45:38'),
380
+ psutil.Process(pid=29836, name='python3', status='waking', started='11:43:39')]
381
+ >>>
382
+ >>> p.status()
383
+ 'running'
384
+ >>> p.create_time()
385
+ 1267551141.5019531
386
+ >>> p.terminal()
387
+ '/dev/pts/0'
388
+ >>>
389
+ >>> p.username()
390
+ 'giampaolo'
391
+ >>> p.uids()
392
+ puids(real=1000, effective=1000, saved=1000)
393
+ >>> p.gids()
394
+ pgids(real=1000, effective=1000, saved=1000)
395
+ >>>
396
+ >>> p.cpu_times()
397
+ pcputimes(user=1.02, system=0.31, children_user=0.32, children_system=0.1, iowait=0.0)
398
+ >>> p.cpu_percent(interval=1.0)
399
+ 12.1
400
+ >>> p.cpu_affinity()
401
+ [0, 1, 2, 3]
402
+ >>> p.cpu_affinity([0, 1]) # set
403
+ >>> p.cpu_num()
404
+ 1
405
+ >>>
406
+ >>> p.memory_info()
407
+ pmem(rss=10915840, vms=67608576, shared=3313664, text=2310144, lib=0, data=7262208, dirty=0)
408
+ >>> p.memory_full_info() # "real" USS memory usage (Linux, macOS, Win only)
409
+ pfullmem(rss=10199040, vms=52133888, shared=3887104, text=2867200, lib=0, data=5967872, dirty=0, uss=6545408, pss=6872064, swap=0)
410
+ >>> p.memory_percent()
411
+ 0.7823
412
+ >>> p.memory_maps()
413
+ [pmmap_grouped(path='/lib/x8664-linux-gnu/libutil-2.15.so', rss=32768, size=2125824, pss=32768, shared_clean=0, shared_dirty=0, private_clean=20480, private_dirty=12288, referenced=32768, anonymous=12288, swap=0),
414
+ pmmap_grouped(path='/lib/x8664-linux-gnu/libc-2.15.so', rss=3821568, size=3842048, pss=3821568, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=3821568, referenced=3575808, anonymous=3821568, swap=0),
415
+ pmmap_grouped(path='[heap]', rss=32768, size=139264, pss=32768, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=32768, referenced=32768, anonymous=32768, swap=0),
416
+ pmmap_grouped(path='[stack]', rss=2465792, size=2494464, pss=2465792, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=2465792, referenced=2277376, anonymous=2465792, swap=0),
417
+ ...]
418
+ >>>
419
+ >>> p.io_counters()
420
+ pio(read_count=478001, write_count=59371, read_bytes=700416, write_bytes=69632, read_chars=456232, write_chars=517543)
421
+ >>>
422
+ >>> p.open_files()
423
+ [popenfile(path='/home/giampaolo/monit.py', fd=3, position=0, mode='r', flags=32768),
424
+ popenfile(path='/var/log/monit.log', fd=4, position=235542, mode='a', flags=33793)]
425
+ >>>
426
+ >>> p.net_connections(kind='tcp')
427
+ [pconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED'),
428
+ pconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status='CLOSING')]
429
+ >>>
430
+ >>> p.threads()
431
+ [pthread(id=5234, user_time=22.5, system_time=9.2891),
432
+ pthread(id=5237, user_time=0.0707, system_time=1.1)]
433
+ >>>
434
+ >>> p.num_threads()
435
+ 4
436
+ >>> p.num_fds()
437
+ 8
438
+ >>> p.num_ctx_switches()
439
+ pctxsw(voluntary=78, involuntary=19)
440
+ >>>
441
+ >>> p.nice()
442
+ 0
443
+ >>> p.nice(10) # set
444
+ >>>
445
+ >>> p.ionice(psutil.IOPRIO_CLASS_IDLE) # IO priority (Win and Linux only)
446
+ >>> p.ionice()
447
+ pionice(ioclass=<IOPriority.IOPRIO_CLASS_IDLE: 3>, value=0)
448
+ >>>
449
+ >>> p.rlimit(psutil.RLIMIT_NOFILE, (5, 5)) # set resource limits (Linux only)
450
+ >>> p.rlimit(psutil.RLIMIT_NOFILE)
451
+ (5, 5)
452
+ >>>
453
+ >>> p.environ()
454
+ {'LC_PAPER': 'it_IT.UTF-8', 'SHELL': '/bin/bash', 'GREP_OPTIONS': '--color=auto',
455
+ 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg',
456
+ ...}
457
+ >>>
458
+ >>> p.as_dict()
459
+ {'status': 'running', 'num_ctx_switches': pctxsw(voluntary=63, involuntary=1), 'pid': 5457, ...}
460
+ >>> p.is_running()
461
+ True
462
+ >>> p.suspend()
463
+ >>> p.resume()
464
+ >>>
465
+ >>> p.terminate()
466
+ >>> p.kill()
467
+ >>> p.wait(timeout=3)
468
+ <Exitcode.EX_OK: 0>
469
+ >>>
470
+ >>> psutil.test()
471
+ USER PID %CPU %MEM VSZ RSS TTY START TIME COMMAND
472
+ root 1 0.0 0.0 24584 2240 Jun17 00:00 init
473
+ root 2 0.0 0.0 0 0 Jun17 00:00 kthreadd
474
+ ...
475
+ giampaolo 31475 0.0 0.0 20760 3024 /dev/pts/0 Jun19 00:00 python2.4
476
+ giampaolo 31721 0.0 2.2 773060 181896 00:04 10:30 chrome
477
+ root 31763 0.0 0.0 0 0 00:05 00:00 kworker/0:1
478
+ >>>
479
+
480
+ Further process APIs
481
+ --------------------
482
+
483
+ .. code-block:: python
484
+
485
+ >>> import psutil
486
+ >>> for proc in psutil.process_iter(['pid', 'name']):
487
+ ... print(proc.info)
488
+ ...
489
+ {'pid': 1, 'name': 'systemd'}
490
+ {'pid': 2, 'name': 'kthreadd'}
491
+ {'pid': 3, 'name': 'ksoftirqd/0'}
492
+ ...
493
+ >>>
494
+ >>> psutil.pid_exists(3)
495
+ True
496
+ >>>
497
+ >>> def on_terminate(proc):
498
+ ... print("process {} terminated".format(proc))
499
+ ...
500
+ >>> # waits for multiple processes to terminate
501
+ >>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate)
502
+ >>>
503
+
504
+ Windows services
505
+ ----------------
506
+
507
+ .. code-block:: python
508
+
509
+ >>> list(psutil.win_service_iter())
510
+ [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>,
511
+ <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>,
512
+ <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>,
513
+ <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>,
514
+ ...]
515
+ >>> s = psutil.win_service_get('alg')
516
+ >>> s.as_dict()
517
+ {'binpath': 'C:\\Windows\\System32\\alg.exe',
518
+ 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing',
519
+ 'display_name': 'Application Layer Gateway Service',
520
+ 'name': 'alg',
521
+ 'pid': None,
522
+ 'start_type': 'manual',
523
+ 'status': 'stopped',
524
+ 'username': 'NT AUTHORITY\\LocalService'}
525
+
526
+ Projects using psutil
527
+ =====================
528
+
529
+ Here's some I find particularly interesting:
530
+
531
+ - https://github.com/google/grr
532
+ - https://github.com/facebook/osquery/
533
+ - https://github.com/nicolargo/glances
534
+ - https://github.com/aristocratos/bpytop
535
+ - https://github.com/Jahaja/psdash
536
+ - https://github.com/ajenti/ajenti
537
+ - https://github.com/home-assistant/home-assistant/
538
+
539
+ Portings
540
+ ========
541
+
542
+ - Go: https://github.com/shirou/gopsutil
543
+ - C: https://github.com/hamon-in/cpslib
544
+ - Rust: https://github.com/rust-psutil/rust-psutil
545
+ - Nim: https://github.com/johnscillieri/psutil-nim
546
+
547
+
548
+
openflamingo/lib/python3.10/site-packages/requests/__init__.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # __
2
+ # /__) _ _ _ _ _/ _
3
+ # / ( (- (/ (/ (- _) / _)
4
+ # /
5
+
6
+ """
7
+ Requests HTTP Library
8
+ ~~~~~~~~~~~~~~~~~~~~~
9
+
10
+ Requests is an HTTP library, written in Python, for human beings.
11
+ Basic GET usage:
12
+
13
+ >>> import requests
14
+ >>> r = requests.get('https://www.python.org')
15
+ >>> r.status_code
16
+ 200
17
+ >>> b'Python is a programming language' in r.content
18
+ True
19
+
20
+ ... or POST:
21
+
22
+ >>> payload = dict(key1='value1', key2='value2')
23
+ >>> r = requests.post('https://httpbin.org/post', data=payload)
24
+ >>> print(r.text)
25
+ {
26
+ ...
27
+ "form": {
28
+ "key1": "value1",
29
+ "key2": "value2"
30
+ },
31
+ ...
32
+ }
33
+
34
+ The other HTTP methods are supported - see `requests.api`. Full documentation
35
+ is at <https://requests.readthedocs.io>.
36
+
37
+ :copyright: (c) 2017 by Kenneth Reitz.
38
+ :license: Apache 2.0, see LICENSE for more details.
39
+ """
40
+
41
+ import warnings
42
+
43
+ import urllib3
44
+
45
+ from .exceptions import RequestsDependencyWarning
46
+
47
+ try:
48
+ from charset_normalizer import __version__ as charset_normalizer_version
49
+ except ImportError:
50
+ charset_normalizer_version = None
51
+
52
+ try:
53
+ from chardet import __version__ as chardet_version
54
+ except ImportError:
55
+ chardet_version = None
56
+
57
+
58
+ def check_compatibility(urllib3_version, chardet_version, charset_normalizer_version):
59
+ urllib3_version = urllib3_version.split(".")
60
+ assert urllib3_version != ["dev"] # Verify urllib3 isn't installed from git.
61
+
62
+ # Sometimes, urllib3 only reports its version as 16.1.
63
+ if len(urllib3_version) == 2:
64
+ urllib3_version.append("0")
65
+
66
+ # Check urllib3 for compatibility.
67
+ major, minor, patch = urllib3_version # noqa: F811
68
+ major, minor, patch = int(major), int(minor), int(patch)
69
+ # urllib3 >= 1.21.1
70
+ assert major >= 1
71
+ if major == 1:
72
+ assert minor >= 21
73
+
74
+ # Check charset_normalizer for compatibility.
75
+ if chardet_version:
76
+ major, minor, patch = chardet_version.split(".")[:3]
77
+ major, minor, patch = int(major), int(minor), int(patch)
78
+ # chardet_version >= 3.0.2, < 6.0.0
79
+ assert (3, 0, 2) <= (major, minor, patch) < (6, 0, 0)
80
+ elif charset_normalizer_version:
81
+ major, minor, patch = charset_normalizer_version.split(".")[:3]
82
+ major, minor, patch = int(major), int(minor), int(patch)
83
+ # charset_normalizer >= 2.0.0 < 4.0.0
84
+ assert (2, 0, 0) <= (major, minor, patch) < (4, 0, 0)
85
+ else:
86
+ warnings.warn(
87
+ "Unable to find acceptable character detection dependency "
88
+ "(chardet or charset_normalizer).",
89
+ RequestsDependencyWarning,
90
+ )
91
+
92
+
93
+ def _check_cryptography(cryptography_version):
94
+ # cryptography < 1.3.4
95
+ try:
96
+ cryptography_version = list(map(int, cryptography_version.split(".")))
97
+ except ValueError:
98
+ return
99
+
100
+ if cryptography_version < [1, 3, 4]:
101
+ warning = "Old version of cryptography ({}) may cause slowdown.".format(
102
+ cryptography_version
103
+ )
104
+ warnings.warn(warning, RequestsDependencyWarning)
105
+
106
+
107
+ # Check imported dependencies for compatibility.
108
+ try:
109
+ check_compatibility(
110
+ urllib3.__version__, chardet_version, charset_normalizer_version
111
+ )
112
+ except (AssertionError, ValueError):
113
+ warnings.warn(
114
+ "urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
115
+ "version!".format(
116
+ urllib3.__version__, chardet_version, charset_normalizer_version
117
+ ),
118
+ RequestsDependencyWarning,
119
+ )
120
+
121
+ # Attempt to enable urllib3's fallback for SNI support
122
+ # if the standard library doesn't support SNI or the
123
+ # 'ssl' library isn't available.
124
+ try:
125
+ try:
126
+ import ssl
127
+ except ImportError:
128
+ ssl = None
129
+
130
+ if not getattr(ssl, "HAS_SNI", False):
131
+ from urllib3.contrib import pyopenssl
132
+
133
+ pyopenssl.inject_into_urllib3()
134
+
135
+ # Check cryptography version
136
+ from cryptography import __version__ as cryptography_version
137
+
138
+ _check_cryptography(cryptography_version)
139
+ except ImportError:
140
+ pass
141
+
142
+ # urllib3's DependencyWarnings should be silenced.
143
+ from urllib3.exceptions import DependencyWarning
144
+
145
+ warnings.simplefilter("ignore", DependencyWarning)
146
+
147
+ # Set default logging handler to avoid "No handler found" warnings.
148
+ import logging
149
+ from logging import NullHandler
150
+
151
+ from . import packages, utils
152
+ from .__version__ import (
153
+ __author__,
154
+ __author_email__,
155
+ __build__,
156
+ __cake__,
157
+ __copyright__,
158
+ __description__,
159
+ __license__,
160
+ __title__,
161
+ __url__,
162
+ __version__,
163
+ )
164
+ from .api import delete, get, head, options, patch, post, put, request
165
+ from .exceptions import (
166
+ ConnectionError,
167
+ ConnectTimeout,
168
+ FileModeWarning,
169
+ HTTPError,
170
+ JSONDecodeError,
171
+ ReadTimeout,
172
+ RequestException,
173
+ Timeout,
174
+ TooManyRedirects,
175
+ URLRequired,
176
+ )
177
+ from .models import PreparedRequest, Request, Response
178
+ from .sessions import Session, session
179
+ from .status_codes import codes
180
+
181
+ logging.getLogger(__name__).addHandler(NullHandler())
182
+
183
+ # FileModeWarnings go off per the default.
184
+ warnings.simplefilter("default", FileModeWarning, append=True)
openflamingo/lib/python3.10/site-packages/requests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (3.91 kB). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/__version__.cpython-310.pyc ADDED
Binary file (524 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/adapters.cpython-310.pyc ADDED
Binary file (22 kB). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/api.cpython-310.pyc ADDED
Binary file (6.7 kB). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/certs.cpython-310.pyc ADDED
Binary file (601 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/cookies.cpython-310.pyc ADDED
Binary file (18.7 kB). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (6.2 kB). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/hooks.cpython-310.pyc ADDED
Binary file (968 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/models.cpython-310.pyc ADDED
Binary file (24.2 kB). View file
 
openflamingo/lib/python3.10/site-packages/requests/__pycache__/packages.cpython-310.pyc ADDED
Binary file (605 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/requests/adapters.py ADDED
@@ -0,0 +1,719 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ requests.adapters
3
+ ~~~~~~~~~~~~~~~~~
4
+
5
+ This module contains the transport adapters that Requests uses to define
6
+ and maintain connections.
7
+ """
8
+
9
+ import os.path
10
+ import socket # noqa: F401
11
+ import typing
12
+ import warnings
13
+
14
+ from urllib3.exceptions import ClosedPoolError, ConnectTimeoutError
15
+ from urllib3.exceptions import HTTPError as _HTTPError
16
+ from urllib3.exceptions import InvalidHeader as _InvalidHeader
17
+ from urllib3.exceptions import (
18
+ LocationValueError,
19
+ MaxRetryError,
20
+ NewConnectionError,
21
+ ProtocolError,
22
+ )
23
+ from urllib3.exceptions import ProxyError as _ProxyError
24
+ from urllib3.exceptions import ReadTimeoutError, ResponseError
25
+ from urllib3.exceptions import SSLError as _SSLError
26
+ from urllib3.poolmanager import PoolManager, proxy_from_url
27
+ from urllib3.util import Timeout as TimeoutSauce
28
+ from urllib3.util import parse_url
29
+ from urllib3.util.retry import Retry
30
+ from urllib3.util.ssl_ import create_urllib3_context
31
+
32
+ from .auth import _basic_auth_str
33
+ from .compat import basestring, urlparse
34
+ from .cookies import extract_cookies_to_jar
35
+ from .exceptions import (
36
+ ConnectionError,
37
+ ConnectTimeout,
38
+ InvalidHeader,
39
+ InvalidProxyURL,
40
+ InvalidSchema,
41
+ InvalidURL,
42
+ ProxyError,
43
+ ReadTimeout,
44
+ RetryError,
45
+ SSLError,
46
+ )
47
+ from .models import Response
48
+ from .structures import CaseInsensitiveDict
49
+ from .utils import (
50
+ DEFAULT_CA_BUNDLE_PATH,
51
+ extract_zipped_paths,
52
+ get_auth_from_url,
53
+ get_encoding_from_headers,
54
+ prepend_scheme_if_needed,
55
+ select_proxy,
56
+ urldefragauth,
57
+ )
58
+
59
+ try:
60
+ from urllib3.contrib.socks import SOCKSProxyManager
61
+ except ImportError:
62
+
63
+ def SOCKSProxyManager(*args, **kwargs):
64
+ raise InvalidSchema("Missing dependencies for SOCKS support.")
65
+
66
+
67
+ if typing.TYPE_CHECKING:
68
+ from .models import PreparedRequest
69
+
70
+
71
+ DEFAULT_POOLBLOCK = False
72
+ DEFAULT_POOLSIZE = 10
73
+ DEFAULT_RETRIES = 0
74
+ DEFAULT_POOL_TIMEOUT = None
75
+
76
+
77
+ try:
78
+ import ssl # noqa: F401
79
+
80
+ _preloaded_ssl_context = create_urllib3_context()
81
+ _preloaded_ssl_context.load_verify_locations(
82
+ extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH)
83
+ )
84
+ except ImportError:
85
+ # Bypass default SSLContext creation when Python
86
+ # interpreter isn't built with the ssl module.
87
+ _preloaded_ssl_context = None
88
+
89
+
90
+ def _urllib3_request_context(
91
+ request: "PreparedRequest",
92
+ verify: "bool | str | None",
93
+ client_cert: "typing.Tuple[str, str] | str | None",
94
+ poolmanager: "PoolManager",
95
+ ) -> "(typing.Dict[str, typing.Any], typing.Dict[str, typing.Any])":
96
+ host_params = {}
97
+ pool_kwargs = {}
98
+ parsed_request_url = urlparse(request.url)
99
+ scheme = parsed_request_url.scheme.lower()
100
+ port = parsed_request_url.port
101
+
102
+ # Determine if we have and should use our default SSLContext
103
+ # to optimize performance on standard requests.
104
+ poolmanager_kwargs = getattr(poolmanager, "connection_pool_kw", {})
105
+ has_poolmanager_ssl_context = poolmanager_kwargs.get("ssl_context")
106
+ should_use_default_ssl_context = (
107
+ _preloaded_ssl_context is not None and not has_poolmanager_ssl_context
108
+ )
109
+
110
+ cert_reqs = "CERT_REQUIRED"
111
+ if verify is False:
112
+ cert_reqs = "CERT_NONE"
113
+ elif verify is True and should_use_default_ssl_context:
114
+ pool_kwargs["ssl_context"] = _preloaded_ssl_context
115
+ elif isinstance(verify, str):
116
+ if not os.path.isdir(verify):
117
+ pool_kwargs["ca_certs"] = verify
118
+ else:
119
+ pool_kwargs["ca_cert_dir"] = verify
120
+ pool_kwargs["cert_reqs"] = cert_reqs
121
+ if client_cert is not None:
122
+ if isinstance(client_cert, tuple) and len(client_cert) == 2:
123
+ pool_kwargs["cert_file"] = client_cert[0]
124
+ pool_kwargs["key_file"] = client_cert[1]
125
+ else:
126
+ # According to our docs, we allow users to specify just the client
127
+ # cert path
128
+ pool_kwargs["cert_file"] = client_cert
129
+ host_params = {
130
+ "scheme": scheme,
131
+ "host": parsed_request_url.hostname,
132
+ "port": port,
133
+ }
134
+ return host_params, pool_kwargs
135
+
136
+
137
+ class BaseAdapter:
138
+ """The Base Transport Adapter"""
139
+
140
+ def __init__(self):
141
+ super().__init__()
142
+
143
+ def send(
144
+ self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None
145
+ ):
146
+ """Sends PreparedRequest object. Returns Response object.
147
+
148
+ :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
149
+ :param stream: (optional) Whether to stream the request content.
150
+ :param timeout: (optional) How long to wait for the server to send
151
+ data before giving up, as a float, or a :ref:`(connect timeout,
152
+ read timeout) <timeouts>` tuple.
153
+ :type timeout: float or tuple
154
+ :param verify: (optional) Either a boolean, in which case it controls whether we verify
155
+ the server's TLS certificate, or a string, in which case it must be a path
156
+ to a CA bundle to use
157
+ :param cert: (optional) Any user-provided SSL certificate to be trusted.
158
+ :param proxies: (optional) The proxies dictionary to apply to the request.
159
+ """
160
+ raise NotImplementedError
161
+
162
+ def close(self):
163
+ """Cleans up adapter specific items."""
164
+ raise NotImplementedError
165
+
166
+
167
+ class HTTPAdapter(BaseAdapter):
168
+ """The built-in HTTP Adapter for urllib3.
169
+
170
+ Provides a general-case interface for Requests sessions to contact HTTP and
171
+ HTTPS urls by implementing the Transport Adapter interface. This class will
172
+ usually be created by the :class:`Session <Session>` class under the
173
+ covers.
174
+
175
+ :param pool_connections: The number of urllib3 connection pools to cache.
176
+ :param pool_maxsize: The maximum number of connections to save in the pool.
177
+ :param max_retries: The maximum number of retries each connection
178
+ should attempt. Note, this applies only to failed DNS lookups, socket
179
+ connections and connection timeouts, never to requests where data has
180
+ made it to the server. By default, Requests does not retry failed
181
+ connections. If you need granular control over the conditions under
182
+ which we retry a request, import urllib3's ``Retry`` class and pass
183
+ that instead.
184
+ :param pool_block: Whether the connection pool should block for connections.
185
+
186
+ Usage::
187
+
188
+ >>> import requests
189
+ >>> s = requests.Session()
190
+ >>> a = requests.adapters.HTTPAdapter(max_retries=3)
191
+ >>> s.mount('http://', a)
192
+ """
193
+
194
+ __attrs__ = [
195
+ "max_retries",
196
+ "config",
197
+ "_pool_connections",
198
+ "_pool_maxsize",
199
+ "_pool_block",
200
+ ]
201
+
202
+ def __init__(
203
+ self,
204
+ pool_connections=DEFAULT_POOLSIZE,
205
+ pool_maxsize=DEFAULT_POOLSIZE,
206
+ max_retries=DEFAULT_RETRIES,
207
+ pool_block=DEFAULT_POOLBLOCK,
208
+ ):
209
+ if max_retries == DEFAULT_RETRIES:
210
+ self.max_retries = Retry(0, read=False)
211
+ else:
212
+ self.max_retries = Retry.from_int(max_retries)
213
+ self.config = {}
214
+ self.proxy_manager = {}
215
+
216
+ super().__init__()
217
+
218
+ self._pool_connections = pool_connections
219
+ self._pool_maxsize = pool_maxsize
220
+ self._pool_block = pool_block
221
+
222
+ self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
223
+
224
+ def __getstate__(self):
225
+ return {attr: getattr(self, attr, None) for attr in self.__attrs__}
226
+
227
+ def __setstate__(self, state):
228
+ # Can't handle by adding 'proxy_manager' to self.__attrs__ because
229
+ # self.poolmanager uses a lambda function, which isn't pickleable.
230
+ self.proxy_manager = {}
231
+ self.config = {}
232
+
233
+ for attr, value in state.items():
234
+ setattr(self, attr, value)
235
+
236
+ self.init_poolmanager(
237
+ self._pool_connections, self._pool_maxsize, block=self._pool_block
238
+ )
239
+
240
+ def init_poolmanager(
241
+ self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs
242
+ ):
243
+ """Initializes a urllib3 PoolManager.
244
+
245
+ This method should not be called from user code, and is only
246
+ exposed for use when subclassing the
247
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
248
+
249
+ :param connections: The number of urllib3 connection pools to cache.
250
+ :param maxsize: The maximum number of connections to save in the pool.
251
+ :param block: Block when no free connections are available.
252
+ :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager.
253
+ """
254
+ # save these values for pickling
255
+ self._pool_connections = connections
256
+ self._pool_maxsize = maxsize
257
+ self._pool_block = block
258
+
259
+ self.poolmanager = PoolManager(
260
+ num_pools=connections,
261
+ maxsize=maxsize,
262
+ block=block,
263
+ **pool_kwargs,
264
+ )
265
+
266
+ def proxy_manager_for(self, proxy, **proxy_kwargs):
267
+ """Return urllib3 ProxyManager for the given proxy.
268
+
269
+ This method should not be called from user code, and is only
270
+ exposed for use when subclassing the
271
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
272
+
273
+ :param proxy: The proxy to return a urllib3 ProxyManager for.
274
+ :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
275
+ :returns: ProxyManager
276
+ :rtype: urllib3.ProxyManager
277
+ """
278
+ if proxy in self.proxy_manager:
279
+ manager = self.proxy_manager[proxy]
280
+ elif proxy.lower().startswith("socks"):
281
+ username, password = get_auth_from_url(proxy)
282
+ manager = self.proxy_manager[proxy] = SOCKSProxyManager(
283
+ proxy,
284
+ username=username,
285
+ password=password,
286
+ num_pools=self._pool_connections,
287
+ maxsize=self._pool_maxsize,
288
+ block=self._pool_block,
289
+ **proxy_kwargs,
290
+ )
291
+ else:
292
+ proxy_headers = self.proxy_headers(proxy)
293
+ manager = self.proxy_manager[proxy] = proxy_from_url(
294
+ proxy,
295
+ proxy_headers=proxy_headers,
296
+ num_pools=self._pool_connections,
297
+ maxsize=self._pool_maxsize,
298
+ block=self._pool_block,
299
+ **proxy_kwargs,
300
+ )
301
+
302
+ return manager
303
+
304
+ def cert_verify(self, conn, url, verify, cert):
305
+ """Verify a SSL certificate. This method should not be called from user
306
+ code, and is only exposed for use when subclassing the
307
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
308
+
309
+ :param conn: The urllib3 connection object associated with the cert.
310
+ :param url: The requested URL.
311
+ :param verify: Either a boolean, in which case it controls whether we verify
312
+ the server's TLS certificate, or a string, in which case it must be a path
313
+ to a CA bundle to use
314
+ :param cert: The SSL certificate to verify.
315
+ """
316
+ if url.lower().startswith("https") and verify:
317
+ conn.cert_reqs = "CERT_REQUIRED"
318
+
319
+ # Only load the CA certificates if 'verify' is a string indicating the CA bundle to use.
320
+ # Otherwise, if verify is a boolean, we don't load anything since
321
+ # the connection will be using a context with the default certificates already loaded,
322
+ # and this avoids a call to the slow load_verify_locations()
323
+ if verify is not True:
324
+ # `verify` must be a str with a path then
325
+ cert_loc = verify
326
+
327
+ if not os.path.exists(cert_loc):
328
+ raise OSError(
329
+ f"Could not find a suitable TLS CA certificate bundle, "
330
+ f"invalid path: {cert_loc}"
331
+ )
332
+
333
+ if not os.path.isdir(cert_loc):
334
+ conn.ca_certs = cert_loc
335
+ else:
336
+ conn.ca_cert_dir = cert_loc
337
+ else:
338
+ conn.cert_reqs = "CERT_NONE"
339
+ conn.ca_certs = None
340
+ conn.ca_cert_dir = None
341
+
342
+ if cert:
343
+ if not isinstance(cert, basestring):
344
+ conn.cert_file = cert[0]
345
+ conn.key_file = cert[1]
346
+ else:
347
+ conn.cert_file = cert
348
+ conn.key_file = None
349
+ if conn.cert_file and not os.path.exists(conn.cert_file):
350
+ raise OSError(
351
+ f"Could not find the TLS certificate file, "
352
+ f"invalid path: {conn.cert_file}"
353
+ )
354
+ if conn.key_file and not os.path.exists(conn.key_file):
355
+ raise OSError(
356
+ f"Could not find the TLS key file, invalid path: {conn.key_file}"
357
+ )
358
+
359
+ def build_response(self, req, resp):
360
+ """Builds a :class:`Response <requests.Response>` object from a urllib3
361
+ response. This should not be called from user code, and is only exposed
362
+ for use when subclassing the
363
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
364
+
365
+ :param req: The :class:`PreparedRequest <PreparedRequest>` used to generate the response.
366
+ :param resp: The urllib3 response object.
367
+ :rtype: requests.Response
368
+ """
369
+ response = Response()
370
+
371
+ # Fallback to None if there's no status_code, for whatever reason.
372
+ response.status_code = getattr(resp, "status", None)
373
+
374
+ # Make headers case-insensitive.
375
+ response.headers = CaseInsensitiveDict(getattr(resp, "headers", {}))
376
+
377
+ # Set encoding.
378
+ response.encoding = get_encoding_from_headers(response.headers)
379
+ response.raw = resp
380
+ response.reason = response.raw.reason
381
+
382
+ if isinstance(req.url, bytes):
383
+ response.url = req.url.decode("utf-8")
384
+ else:
385
+ response.url = req.url
386
+
387
+ # Add new cookies from the server.
388
+ extract_cookies_to_jar(response.cookies, req, resp)
389
+
390
+ # Give the Response some context.
391
+ response.request = req
392
+ response.connection = self
393
+
394
+ return response
395
+
396
+ def build_connection_pool_key_attributes(self, request, verify, cert=None):
397
+ """Build the PoolKey attributes used by urllib3 to return a connection.
398
+
399
+ This looks at the PreparedRequest, the user-specified verify value,
400
+ and the value of the cert parameter to determine what PoolKey values
401
+ to use to select a connection from a given urllib3 Connection Pool.
402
+
403
+ The SSL related pool key arguments are not consistently set. As of
404
+ this writing, use the following to determine what keys may be in that
405
+ dictionary:
406
+
407
+ * If ``verify`` is ``True``, ``"ssl_context"`` will be set and will be the
408
+ default Requests SSL Context
409
+ * If ``verify`` is ``False``, ``"ssl_context"`` will not be set but
410
+ ``"cert_reqs"`` will be set
411
+ * If ``verify`` is a string, (i.e., it is a user-specified trust bundle)
412
+ ``"ca_certs"`` will be set if the string is not a directory recognized
413
+ by :py:func:`os.path.isdir`, otherwise ``"ca_certs_dir"`` will be
414
+ set.
415
+ * If ``"cert"`` is specified, ``"cert_file"`` will always be set. If
416
+ ``"cert"`` is a tuple with a second item, ``"key_file"`` will also
417
+ be present
418
+
419
+ To override these settings, one may subclass this class, call this
420
+ method and use the above logic to change parameters as desired. For
421
+ example, if one wishes to use a custom :py:class:`ssl.SSLContext` one
422
+ must both set ``"ssl_context"`` and based on what else they require,
423
+ alter the other keys to ensure the desired behaviour.
424
+
425
+ :param request:
426
+ The PreparedReqest being sent over the connection.
427
+ :type request:
428
+ :class:`~requests.models.PreparedRequest`
429
+ :param verify:
430
+ Either a boolean, in which case it controls whether
431
+ we verify the server's TLS certificate, or a string, in which case it
432
+ must be a path to a CA bundle to use.
433
+ :param cert:
434
+ (optional) Any user-provided SSL certificate for client
435
+ authentication (a.k.a., mTLS). This may be a string (i.e., just
436
+ the path to a file which holds both certificate and key) or a
437
+ tuple of length 2 with the certificate file path and key file
438
+ path.
439
+ :returns:
440
+ A tuple of two dictionaries. The first is the "host parameters"
441
+ portion of the Pool Key including scheme, hostname, and port. The
442
+ second is a dictionary of SSLContext related parameters.
443
+ """
444
+ return _urllib3_request_context(request, verify, cert, self.poolmanager)
445
+
446
+ def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
447
+ """Returns a urllib3 connection for the given request and TLS settings.
448
+ This should not be called from user code, and is only exposed for use
449
+ when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
450
+
451
+ :param request:
452
+ The :class:`PreparedRequest <PreparedRequest>` object to be sent
453
+ over the connection.
454
+ :param verify:
455
+ Either a boolean, in which case it controls whether we verify the
456
+ server's TLS certificate, or a string, in which case it must be a
457
+ path to a CA bundle to use.
458
+ :param proxies:
459
+ (optional) The proxies dictionary to apply to the request.
460
+ :param cert:
461
+ (optional) Any user-provided SSL certificate to be used for client
462
+ authentication (a.k.a., mTLS).
463
+ :rtype:
464
+ urllib3.ConnectionPool
465
+ """
466
+ proxy = select_proxy(request.url, proxies)
467
+ try:
468
+ host_params, pool_kwargs = self.build_connection_pool_key_attributes(
469
+ request,
470
+ verify,
471
+ cert,
472
+ )
473
+ except ValueError as e:
474
+ raise InvalidURL(e, request=request)
475
+ if proxy:
476
+ proxy = prepend_scheme_if_needed(proxy, "http")
477
+ proxy_url = parse_url(proxy)
478
+ if not proxy_url.host:
479
+ raise InvalidProxyURL(
480
+ "Please check proxy URL. It is malformed "
481
+ "and could be missing the host."
482
+ )
483
+ proxy_manager = self.proxy_manager_for(proxy)
484
+ conn = proxy_manager.connection_from_host(
485
+ **host_params, pool_kwargs=pool_kwargs
486
+ )
487
+ else:
488
+ # Only scheme should be lower case
489
+ conn = self.poolmanager.connection_from_host(
490
+ **host_params, pool_kwargs=pool_kwargs
491
+ )
492
+
493
+ return conn
494
+
495
+ def get_connection(self, url, proxies=None):
496
+ """DEPRECATED: Users should move to `get_connection_with_tls_context`
497
+ for all subclasses of HTTPAdapter using Requests>=2.32.2.
498
+
499
+ Returns a urllib3 connection for the given URL. This should not be
500
+ called from user code, and is only exposed for use when subclassing the
501
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
502
+
503
+ :param url: The URL to connect to.
504
+ :param proxies: (optional) A Requests-style dictionary of proxies used on this request.
505
+ :rtype: urllib3.ConnectionPool
506
+ """
507
+ warnings.warn(
508
+ (
509
+ "`get_connection` has been deprecated in favor of "
510
+ "`get_connection_with_tls_context`. Custom HTTPAdapter subclasses "
511
+ "will need to migrate for Requests>=2.32.2. Please see "
512
+ "https://github.com/psf/requests/pull/6710 for more details."
513
+ ),
514
+ DeprecationWarning,
515
+ )
516
+ proxy = select_proxy(url, proxies)
517
+
518
+ if proxy:
519
+ proxy = prepend_scheme_if_needed(proxy, "http")
520
+ proxy_url = parse_url(proxy)
521
+ if not proxy_url.host:
522
+ raise InvalidProxyURL(
523
+ "Please check proxy URL. It is malformed "
524
+ "and could be missing the host."
525
+ )
526
+ proxy_manager = self.proxy_manager_for(proxy)
527
+ conn = proxy_manager.connection_from_url(url)
528
+ else:
529
+ # Only scheme should be lower case
530
+ parsed = urlparse(url)
531
+ url = parsed.geturl()
532
+ conn = self.poolmanager.connection_from_url(url)
533
+
534
+ return conn
535
+
536
+ def close(self):
537
+ """Disposes of any internal state.
538
+
539
+ Currently, this closes the PoolManager and any active ProxyManager,
540
+ which closes any pooled connections.
541
+ """
542
+ self.poolmanager.clear()
543
+ for proxy in self.proxy_manager.values():
544
+ proxy.clear()
545
+
546
+ def request_url(self, request, proxies):
547
+ """Obtain the url to use when making the final request.
548
+
549
+ If the message is being sent through a HTTP proxy, the full URL has to
550
+ be used. Otherwise, we should only use the path portion of the URL.
551
+
552
+ This should not be called from user code, and is only exposed for use
553
+ when subclassing the
554
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
555
+
556
+ :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
557
+ :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs.
558
+ :rtype: str
559
+ """
560
+ proxy = select_proxy(request.url, proxies)
561
+ scheme = urlparse(request.url).scheme
562
+
563
+ is_proxied_http_request = proxy and scheme != "https"
564
+ using_socks_proxy = False
565
+ if proxy:
566
+ proxy_scheme = urlparse(proxy).scheme.lower()
567
+ using_socks_proxy = proxy_scheme.startswith("socks")
568
+
569
+ url = request.path_url
570
+ if url.startswith("//"): # Don't confuse urllib3
571
+ url = f"/{url.lstrip('/')}"
572
+
573
+ if is_proxied_http_request and not using_socks_proxy:
574
+ url = urldefragauth(request.url)
575
+
576
+ return url
577
+
578
+ def add_headers(self, request, **kwargs):
579
+ """Add any headers needed by the connection. As of v2.0 this does
580
+ nothing by default, but is left for overriding by users that subclass
581
+ the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
582
+
583
+ This should not be called from user code, and is only exposed for use
584
+ when subclassing the
585
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
586
+
587
+ :param request: The :class:`PreparedRequest <PreparedRequest>` to add headers to.
588
+ :param kwargs: The keyword arguments from the call to send().
589
+ """
590
+ pass
591
+
592
+ def proxy_headers(self, proxy):
593
+ """Returns a dictionary of the headers to add to any request sent
594
+ through a proxy. This works with urllib3 magic to ensure that they are
595
+ correctly sent to the proxy, rather than in a tunnelled request if
596
+ CONNECT is being used.
597
+
598
+ This should not be called from user code, and is only exposed for use
599
+ when subclassing the
600
+ :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
601
+
602
+ :param proxy: The url of the proxy being used for this request.
603
+ :rtype: dict
604
+ """
605
+ headers = {}
606
+ username, password = get_auth_from_url(proxy)
607
+
608
+ if username:
609
+ headers["Proxy-Authorization"] = _basic_auth_str(username, password)
610
+
611
+ return headers
612
+
613
+ def send(
614
+ self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None
615
+ ):
616
+ """Sends PreparedRequest object. Returns Response object.
617
+
618
+ :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
619
+ :param stream: (optional) Whether to stream the request content.
620
+ :param timeout: (optional) How long to wait for the server to send
621
+ data before giving up, as a float, or a :ref:`(connect timeout,
622
+ read timeout) <timeouts>` tuple.
623
+ :type timeout: float or tuple or urllib3 Timeout object
624
+ :param verify: (optional) Either a boolean, in which case it controls whether
625
+ we verify the server's TLS certificate, or a string, in which case it
626
+ must be a path to a CA bundle to use
627
+ :param cert: (optional) Any user-provided SSL certificate to be trusted.
628
+ :param proxies: (optional) The proxies dictionary to apply to the request.
629
+ :rtype: requests.Response
630
+ """
631
+
632
+ try:
633
+ conn = self.get_connection_with_tls_context(
634
+ request, verify, proxies=proxies, cert=cert
635
+ )
636
+ except LocationValueError as e:
637
+ raise InvalidURL(e, request=request)
638
+
639
+ self.cert_verify(conn, request.url, verify, cert)
640
+ url = self.request_url(request, proxies)
641
+ self.add_headers(
642
+ request,
643
+ stream=stream,
644
+ timeout=timeout,
645
+ verify=verify,
646
+ cert=cert,
647
+ proxies=proxies,
648
+ )
649
+
650
+ chunked = not (request.body is None or "Content-Length" in request.headers)
651
+
652
+ if isinstance(timeout, tuple):
653
+ try:
654
+ connect, read = timeout
655
+ timeout = TimeoutSauce(connect=connect, read=read)
656
+ except ValueError:
657
+ raise ValueError(
658
+ f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, "
659
+ f"or a single float to set both timeouts to the same value."
660
+ )
661
+ elif isinstance(timeout, TimeoutSauce):
662
+ pass
663
+ else:
664
+ timeout = TimeoutSauce(connect=timeout, read=timeout)
665
+
666
+ try:
667
+ resp = conn.urlopen(
668
+ method=request.method,
669
+ url=url,
670
+ body=request.body,
671
+ headers=request.headers,
672
+ redirect=False,
673
+ assert_same_host=False,
674
+ preload_content=False,
675
+ decode_content=False,
676
+ retries=self.max_retries,
677
+ timeout=timeout,
678
+ chunked=chunked,
679
+ )
680
+
681
+ except (ProtocolError, OSError) as err:
682
+ raise ConnectionError(err, request=request)
683
+
684
+ except MaxRetryError as e:
685
+ if isinstance(e.reason, ConnectTimeoutError):
686
+ # TODO: Remove this in 3.0.0: see #2811
687
+ if not isinstance(e.reason, NewConnectionError):
688
+ raise ConnectTimeout(e, request=request)
689
+
690
+ if isinstance(e.reason, ResponseError):
691
+ raise RetryError(e, request=request)
692
+
693
+ if isinstance(e.reason, _ProxyError):
694
+ raise ProxyError(e, request=request)
695
+
696
+ if isinstance(e.reason, _SSLError):
697
+ # This branch is for urllib3 v1.22 and later.
698
+ raise SSLError(e, request=request)
699
+
700
+ raise ConnectionError(e, request=request)
701
+
702
+ except ClosedPoolError as e:
703
+ raise ConnectionError(e, request=request)
704
+
705
+ except _ProxyError as e:
706
+ raise ProxyError(e)
707
+
708
+ except (_SSLError, _HTTPError) as e:
709
+ if isinstance(e, _SSLError):
710
+ # This branch is for urllib3 versions earlier than v1.22
711
+ raise SSLError(e, request=request)
712
+ elif isinstance(e, ReadTimeoutError):
713
+ raise ReadTimeout(e, request=request)
714
+ elif isinstance(e, _InvalidHeader):
715
+ raise InvalidHeader(e, request=request)
716
+ else:
717
+ raise
718
+
719
+ return self.build_response(request, resp)
openflamingo/lib/python3.10/site-packages/requests/certs.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ requests.certs
5
+ ~~~~~~~~~~~~~~
6
+
7
+ This module returns the preferred default CA certificate bundle. There is
8
+ only one — the one from the certifi package.
9
+
10
+ If you are packaging Requests, e.g., for a Linux distribution or a managed
11
+ environment, you can change the definition of where() to return a separately
12
+ packaged CA bundle.
13
+ """
14
+ from certifi import where
15
+
16
+ if __name__ == "__main__":
17
+ print(where())
openflamingo/lib/python3.10/site-packages/requests/compat.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ requests.compat
3
+ ~~~~~~~~~~~~~~~
4
+
5
+ This module previously handled import compatibility issues
6
+ between Python 2 and Python 3. It remains for backwards
7
+ compatibility until the next major version.
8
+ """
9
+
10
+ import importlib
11
+ import sys
12
+
13
+ # -------------------
14
+ # Character Detection
15
+ # -------------------
16
+
17
+
18
+ def _resolve_char_detection():
19
+ """Find supported character detection libraries."""
20
+ chardet = None
21
+ for lib in ("chardet", "charset_normalizer"):
22
+ if chardet is None:
23
+ try:
24
+ chardet = importlib.import_module(lib)
25
+ except ImportError:
26
+ pass
27
+ return chardet
28
+
29
+
30
+ chardet = _resolve_char_detection()
31
+
32
+ # -------
33
+ # Pythons
34
+ # -------
35
+
36
+ # Syntax sugar.
37
+ _ver = sys.version_info
38
+
39
+ #: Python 2.x?
40
+ is_py2 = _ver[0] == 2
41
+
42
+ #: Python 3.x?
43
+ is_py3 = _ver[0] == 3
44
+
45
+ # json/simplejson module import resolution
46
+ has_simplejson = False
47
+ try:
48
+ import simplejson as json
49
+
50
+ has_simplejson = True
51
+ except ImportError:
52
+ import json
53
+
54
+ if has_simplejson:
55
+ from simplejson import JSONDecodeError
56
+ else:
57
+ from json import JSONDecodeError
58
+
59
+ # Keep OrderedDict for backwards compatibility.
60
+ from collections import OrderedDict
61
+ from collections.abc import Callable, Mapping, MutableMapping
62
+ from http import cookiejar as cookielib
63
+ from http.cookies import Morsel
64
+ from io import StringIO
65
+
66
+ # --------------
67
+ # Legacy Imports
68
+ # --------------
69
+ from urllib.parse import (
70
+ quote,
71
+ quote_plus,
72
+ unquote,
73
+ unquote_plus,
74
+ urldefrag,
75
+ urlencode,
76
+ urljoin,
77
+ urlparse,
78
+ urlsplit,
79
+ urlunparse,
80
+ )
81
+ from urllib.request import (
82
+ getproxies,
83
+ getproxies_environment,
84
+ parse_http_list,
85
+ proxy_bypass,
86
+ proxy_bypass_environment,
87
+ )
88
+
89
+ builtin_str = str
90
+ str = str
91
+ bytes = bytes
92
+ basestring = (str, bytes)
93
+ numeric_types = (int, float)
94
+ integer_types = (int,)
openflamingo/lib/python3.10/site-packages/requests/help.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Module containing bug report helper(s)."""
2
+
3
+ import json
4
+ import platform
5
+ import ssl
6
+ import sys
7
+
8
+ import idna
9
+ import urllib3
10
+
11
+ from . import __version__ as requests_version
12
+
13
+ try:
14
+ import charset_normalizer
15
+ except ImportError:
16
+ charset_normalizer = None
17
+
18
+ try:
19
+ import chardet
20
+ except ImportError:
21
+ chardet = None
22
+
23
+ try:
24
+ from urllib3.contrib import pyopenssl
25
+ except ImportError:
26
+ pyopenssl = None
27
+ OpenSSL = None
28
+ cryptography = None
29
+ else:
30
+ import cryptography
31
+ import OpenSSL
32
+
33
+
34
+ def _implementation():
35
+ """Return a dict with the Python implementation and version.
36
+
37
+ Provide both the name and the version of the Python implementation
38
+ currently running. For example, on CPython 3.10.3 it will return
39
+ {'name': 'CPython', 'version': '3.10.3'}.
40
+
41
+ This function works best on CPython and PyPy: in particular, it probably
42
+ doesn't work for Jython or IronPython. Future investigation should be done
43
+ to work out the correct shape of the code for those platforms.
44
+ """
45
+ implementation = platform.python_implementation()
46
+
47
+ if implementation == "CPython":
48
+ implementation_version = platform.python_version()
49
+ elif implementation == "PyPy":
50
+ implementation_version = "{}.{}.{}".format(
51
+ sys.pypy_version_info.major,
52
+ sys.pypy_version_info.minor,
53
+ sys.pypy_version_info.micro,
54
+ )
55
+ if sys.pypy_version_info.releaselevel != "final":
56
+ implementation_version = "".join(
57
+ [implementation_version, sys.pypy_version_info.releaselevel]
58
+ )
59
+ elif implementation == "Jython":
60
+ implementation_version = platform.python_version() # Complete Guess
61
+ elif implementation == "IronPython":
62
+ implementation_version = platform.python_version() # Complete Guess
63
+ else:
64
+ implementation_version = "Unknown"
65
+
66
+ return {"name": implementation, "version": implementation_version}
67
+
68
+
69
+ def info():
70
+ """Generate information for a bug report."""
71
+ try:
72
+ platform_info = {
73
+ "system": platform.system(),
74
+ "release": platform.release(),
75
+ }
76
+ except OSError:
77
+ platform_info = {
78
+ "system": "Unknown",
79
+ "release": "Unknown",
80
+ }
81
+
82
+ implementation_info = _implementation()
83
+ urllib3_info = {"version": urllib3.__version__}
84
+ charset_normalizer_info = {"version": None}
85
+ chardet_info = {"version": None}
86
+ if charset_normalizer:
87
+ charset_normalizer_info = {"version": charset_normalizer.__version__}
88
+ if chardet:
89
+ chardet_info = {"version": chardet.__version__}
90
+
91
+ pyopenssl_info = {
92
+ "version": None,
93
+ "openssl_version": "",
94
+ }
95
+ if OpenSSL:
96
+ pyopenssl_info = {
97
+ "version": OpenSSL.__version__,
98
+ "openssl_version": f"{OpenSSL.SSL.OPENSSL_VERSION_NUMBER:x}",
99
+ }
100
+ cryptography_info = {
101
+ "version": getattr(cryptography, "__version__", ""),
102
+ }
103
+ idna_info = {
104
+ "version": getattr(idna, "__version__", ""),
105
+ }
106
+
107
+ system_ssl = ssl.OPENSSL_VERSION_NUMBER
108
+ system_ssl_info = {"version": f"{system_ssl:x}" if system_ssl is not None else ""}
109
+
110
+ return {
111
+ "platform": platform_info,
112
+ "implementation": implementation_info,
113
+ "system_ssl": system_ssl_info,
114
+ "using_pyopenssl": pyopenssl is not None,
115
+ "using_charset_normalizer": chardet is None,
116
+ "pyOpenSSL": pyopenssl_info,
117
+ "urllib3": urllib3_info,
118
+ "chardet": chardet_info,
119
+ "charset_normalizer": charset_normalizer_info,
120
+ "cryptography": cryptography_info,
121
+ "idna": idna_info,
122
+ "requests": {
123
+ "version": requests_version,
124
+ },
125
+ }
126
+
127
+
128
+ def main():
129
+ """Pretty-print the bug information as JSON."""
130
+ print(json.dumps(info(), sort_keys=True, indent=2))
131
+
132
+
133
+ if __name__ == "__main__":
134
+ main()
openflamingo/lib/python3.10/site-packages/requests/hooks.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ requests.hooks
3
+ ~~~~~~~~~~~~~~
4
+
5
+ This module provides the capabilities for the Requests hooks system.
6
+
7
+ Available hooks:
8
+
9
+ ``response``:
10
+ The response generated from a Request.
11
+ """
12
+ HOOKS = ["response"]
13
+
14
+
15
+ def default_hooks():
16
+ return {event: [] for event in HOOKS}
17
+
18
+
19
+ # TODO: response is the only one
20
+
21
+
22
+ def dispatch_hook(key, hooks, hook_data, **kwargs):
23
+ """Dispatches a hook dictionary on a given piece of data."""
24
+ hooks = hooks or {}
25
+ hooks = hooks.get(key)
26
+ if hooks:
27
+ if hasattr(hooks, "__call__"):
28
+ hooks = [hooks]
29
+ for hook in hooks:
30
+ _hook_data = hook(hook_data, **kwargs)
31
+ if _hook_data is not None:
32
+ hook_data = _hook_data
33
+ return hook_data
openflamingo/lib/python3.10/site-packages/requests/sessions.py ADDED
@@ -0,0 +1,831 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ requests.sessions
3
+ ~~~~~~~~~~~~~~~~~
4
+
5
+ This module provides a Session object to manage and persist settings across
6
+ requests (cookies, auth, proxies).
7
+ """
8
+ import os
9
+ import sys
10
+ import time
11
+ from collections import OrderedDict
12
+ from datetime import timedelta
13
+
14
+ from ._internal_utils import to_native_string
15
+ from .adapters import HTTPAdapter
16
+ from .auth import _basic_auth_str
17
+ from .compat import Mapping, cookielib, urljoin, urlparse
18
+ from .cookies import (
19
+ RequestsCookieJar,
20
+ cookiejar_from_dict,
21
+ extract_cookies_to_jar,
22
+ merge_cookies,
23
+ )
24
+ from .exceptions import (
25
+ ChunkedEncodingError,
26
+ ContentDecodingError,
27
+ InvalidSchema,
28
+ TooManyRedirects,
29
+ )
30
+ from .hooks import default_hooks, dispatch_hook
31
+
32
+ # formerly defined here, reexposed here for backward compatibility
33
+ from .models import ( # noqa: F401
34
+ DEFAULT_REDIRECT_LIMIT,
35
+ REDIRECT_STATI,
36
+ PreparedRequest,
37
+ Request,
38
+ )
39
+ from .status_codes import codes
40
+ from .structures import CaseInsensitiveDict
41
+ from .utils import ( # noqa: F401
42
+ DEFAULT_PORTS,
43
+ default_headers,
44
+ get_auth_from_url,
45
+ get_environ_proxies,
46
+ get_netrc_auth,
47
+ requote_uri,
48
+ resolve_proxies,
49
+ rewind_body,
50
+ should_bypass_proxies,
51
+ to_key_val_list,
52
+ )
53
+
54
+ # Preferred clock, based on which one is more accurate on a given system.
55
+ if sys.platform == "win32":
56
+ preferred_clock = time.perf_counter
57
+ else:
58
+ preferred_clock = time.time
59
+
60
+
61
+ def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
62
+ """Determines appropriate setting for a given request, taking into account
63
+ the explicit setting on that request, and the setting in the session. If a
64
+ setting is a dictionary, they will be merged together using `dict_class`
65
+ """
66
+
67
+ if session_setting is None:
68
+ return request_setting
69
+
70
+ if request_setting is None:
71
+ return session_setting
72
+
73
+ # Bypass if not a dictionary (e.g. verify)
74
+ if not (
75
+ isinstance(session_setting, Mapping) and isinstance(request_setting, Mapping)
76
+ ):
77
+ return request_setting
78
+
79
+ merged_setting = dict_class(to_key_val_list(session_setting))
80
+ merged_setting.update(to_key_val_list(request_setting))
81
+
82
+ # Remove keys that are set to None. Extract keys first to avoid altering
83
+ # the dictionary during iteration.
84
+ none_keys = [k for (k, v) in merged_setting.items() if v is None]
85
+ for key in none_keys:
86
+ del merged_setting[key]
87
+
88
+ return merged_setting
89
+
90
+
91
+ def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
92
+ """Properly merges both requests and session hooks.
93
+
94
+ This is necessary because when request_hooks == {'response': []}, the
95
+ merge breaks Session hooks entirely.
96
+ """
97
+ if session_hooks is None or session_hooks.get("response") == []:
98
+ return request_hooks
99
+
100
+ if request_hooks is None or request_hooks.get("response") == []:
101
+ return session_hooks
102
+
103
+ return merge_setting(request_hooks, session_hooks, dict_class)
104
+
105
+
106
+ class SessionRedirectMixin:
107
+ def get_redirect_target(self, resp):
108
+ """Receives a Response. Returns a redirect URI or ``None``"""
109
+ # Due to the nature of how requests processes redirects this method will
110
+ # be called at least once upon the original response and at least twice
111
+ # on each subsequent redirect response (if any).
112
+ # If a custom mixin is used to handle this logic, it may be advantageous
113
+ # to cache the redirect location onto the response object as a private
114
+ # attribute.
115
+ if resp.is_redirect:
116
+ location = resp.headers["location"]
117
+ # Currently the underlying http module on py3 decode headers
118
+ # in latin1, but empirical evidence suggests that latin1 is very
119
+ # rarely used with non-ASCII characters in HTTP headers.
120
+ # It is more likely to get UTF8 header rather than latin1.
121
+ # This causes incorrect handling of UTF8 encoded location headers.
122
+ # To solve this, we re-encode the location in latin1.
123
+ location = location.encode("latin1")
124
+ return to_native_string(location, "utf8")
125
+ return None
126
+
127
+ def should_strip_auth(self, old_url, new_url):
128
+ """Decide whether Authorization header should be removed when redirecting"""
129
+ old_parsed = urlparse(old_url)
130
+ new_parsed = urlparse(new_url)
131
+ if old_parsed.hostname != new_parsed.hostname:
132
+ return True
133
+ # Special case: allow http -> https redirect when using the standard
134
+ # ports. This isn't specified by RFC 7235, but is kept to avoid
135
+ # breaking backwards compatibility with older versions of requests
136
+ # that allowed any redirects on the same host.
137
+ if (
138
+ old_parsed.scheme == "http"
139
+ and old_parsed.port in (80, None)
140
+ and new_parsed.scheme == "https"
141
+ and new_parsed.port in (443, None)
142
+ ):
143
+ return False
144
+
145
+ # Handle default port usage corresponding to scheme.
146
+ changed_port = old_parsed.port != new_parsed.port
147
+ changed_scheme = old_parsed.scheme != new_parsed.scheme
148
+ default_port = (DEFAULT_PORTS.get(old_parsed.scheme, None), None)
149
+ if (
150
+ not changed_scheme
151
+ and old_parsed.port in default_port
152
+ and new_parsed.port in default_port
153
+ ):
154
+ return False
155
+
156
+ # Standard case: root URI must match
157
+ return changed_port or changed_scheme
158
+
159
+ def resolve_redirects(
160
+ self,
161
+ resp,
162
+ req,
163
+ stream=False,
164
+ timeout=None,
165
+ verify=True,
166
+ cert=None,
167
+ proxies=None,
168
+ yield_requests=False,
169
+ **adapter_kwargs,
170
+ ):
171
+ """Receives a Response. Returns a generator of Responses or Requests."""
172
+
173
+ hist = [] # keep track of history
174
+
175
+ url = self.get_redirect_target(resp)
176
+ previous_fragment = urlparse(req.url).fragment
177
+ while url:
178
+ prepared_request = req.copy()
179
+
180
+ # Update history and keep track of redirects.
181
+ # resp.history must ignore the original request in this loop
182
+ hist.append(resp)
183
+ resp.history = hist[1:]
184
+
185
+ try:
186
+ resp.content # Consume socket so it can be released
187
+ except (ChunkedEncodingError, ContentDecodingError, RuntimeError):
188
+ resp.raw.read(decode_content=False)
189
+
190
+ if len(resp.history) >= self.max_redirects:
191
+ raise TooManyRedirects(
192
+ f"Exceeded {self.max_redirects} redirects.", response=resp
193
+ )
194
+
195
+ # Release the connection back into the pool.
196
+ resp.close()
197
+
198
+ # Handle redirection without scheme (see: RFC 1808 Section 4)
199
+ if url.startswith("//"):
200
+ parsed_rurl = urlparse(resp.url)
201
+ url = ":".join([to_native_string(parsed_rurl.scheme), url])
202
+
203
+ # Normalize url case and attach previous fragment if needed (RFC 7231 7.1.2)
204
+ parsed = urlparse(url)
205
+ if parsed.fragment == "" and previous_fragment:
206
+ parsed = parsed._replace(fragment=previous_fragment)
207
+ elif parsed.fragment:
208
+ previous_fragment = parsed.fragment
209
+ url = parsed.geturl()
210
+
211
+ # Facilitate relative 'location' headers, as allowed by RFC 7231.
212
+ # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
213
+ # Compliant with RFC3986, we percent encode the url.
214
+ if not parsed.netloc:
215
+ url = urljoin(resp.url, requote_uri(url))
216
+ else:
217
+ url = requote_uri(url)
218
+
219
+ prepared_request.url = to_native_string(url)
220
+
221
+ self.rebuild_method(prepared_request, resp)
222
+
223
+ # https://github.com/psf/requests/issues/1084
224
+ if resp.status_code not in (
225
+ codes.temporary_redirect,
226
+ codes.permanent_redirect,
227
+ ):
228
+ # https://github.com/psf/requests/issues/3490
229
+ purged_headers = ("Content-Length", "Content-Type", "Transfer-Encoding")
230
+ for header in purged_headers:
231
+ prepared_request.headers.pop(header, None)
232
+ prepared_request.body = None
233
+
234
+ headers = prepared_request.headers
235
+ headers.pop("Cookie", None)
236
+
237
+ # Extract any cookies sent on the response to the cookiejar
238
+ # in the new request. Because we've mutated our copied prepared
239
+ # request, use the old one that we haven't yet touched.
240
+ extract_cookies_to_jar(prepared_request._cookies, req, resp.raw)
241
+ merge_cookies(prepared_request._cookies, self.cookies)
242
+ prepared_request.prepare_cookies(prepared_request._cookies)
243
+
244
+ # Rebuild auth and proxy information.
245
+ proxies = self.rebuild_proxies(prepared_request, proxies)
246
+ self.rebuild_auth(prepared_request, resp)
247
+
248
+ # A failed tell() sets `_body_position` to `object()`. This non-None
249
+ # value ensures `rewindable` will be True, allowing us to raise an
250
+ # UnrewindableBodyError, instead of hanging the connection.
251
+ rewindable = prepared_request._body_position is not None and (
252
+ "Content-Length" in headers or "Transfer-Encoding" in headers
253
+ )
254
+
255
+ # Attempt to rewind consumed file-like object.
256
+ if rewindable:
257
+ rewind_body(prepared_request)
258
+
259
+ # Override the original request.
260
+ req = prepared_request
261
+
262
+ if yield_requests:
263
+ yield req
264
+ else:
265
+ resp = self.send(
266
+ req,
267
+ stream=stream,
268
+ timeout=timeout,
269
+ verify=verify,
270
+ cert=cert,
271
+ proxies=proxies,
272
+ allow_redirects=False,
273
+ **adapter_kwargs,
274
+ )
275
+
276
+ extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
277
+
278
+ # extract redirect url, if any, for the next loop
279
+ url = self.get_redirect_target(resp)
280
+ yield resp
281
+
282
+ def rebuild_auth(self, prepared_request, response):
283
+ """When being redirected we may want to strip authentication from the
284
+ request to avoid leaking credentials. This method intelligently removes
285
+ and reapplies authentication where possible to avoid credential loss.
286
+ """
287
+ headers = prepared_request.headers
288
+ url = prepared_request.url
289
+
290
+ if "Authorization" in headers and self.should_strip_auth(
291
+ response.request.url, url
292
+ ):
293
+ # If we get redirected to a new host, we should strip out any
294
+ # authentication headers.
295
+ del headers["Authorization"]
296
+
297
+ # .netrc might have more auth for us on our new host.
298
+ new_auth = get_netrc_auth(url) if self.trust_env else None
299
+ if new_auth is not None:
300
+ prepared_request.prepare_auth(new_auth)
301
+
302
+ def rebuild_proxies(self, prepared_request, proxies):
303
+ """This method re-evaluates the proxy configuration by considering the
304
+ environment variables. If we are redirected to a URL covered by
305
+ NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
306
+ proxy keys for this URL (in case they were stripped by a previous
307
+ redirect).
308
+
309
+ This method also replaces the Proxy-Authorization header where
310
+ necessary.
311
+
312
+ :rtype: dict
313
+ """
314
+ headers = prepared_request.headers
315
+ scheme = urlparse(prepared_request.url).scheme
316
+ new_proxies = resolve_proxies(prepared_request, proxies, self.trust_env)
317
+
318
+ if "Proxy-Authorization" in headers:
319
+ del headers["Proxy-Authorization"]
320
+
321
+ try:
322
+ username, password = get_auth_from_url(new_proxies[scheme])
323
+ except KeyError:
324
+ username, password = None, None
325
+
326
+ # urllib3 handles proxy authorization for us in the standard adapter.
327
+ # Avoid appending this to TLS tunneled requests where it may be leaked.
328
+ if not scheme.startswith("https") and username and password:
329
+ headers["Proxy-Authorization"] = _basic_auth_str(username, password)
330
+
331
+ return new_proxies
332
+
333
+ def rebuild_method(self, prepared_request, response):
334
+ """When being redirected we may want to change the method of the request
335
+ based on certain specs or browser behavior.
336
+ """
337
+ method = prepared_request.method
338
+
339
+ # https://tools.ietf.org/html/rfc7231#section-6.4.4
340
+ if response.status_code == codes.see_other and method != "HEAD":
341
+ method = "GET"
342
+
343
+ # Do what the browsers do, despite standards...
344
+ # First, turn 302s into GETs.
345
+ if response.status_code == codes.found and method != "HEAD":
346
+ method = "GET"
347
+
348
+ # Second, if a POST is responded to with a 301, turn it into a GET.
349
+ # This bizarre behaviour is explained in Issue 1704.
350
+ if response.status_code == codes.moved and method == "POST":
351
+ method = "GET"
352
+
353
+ prepared_request.method = method
354
+
355
+
356
+ class Session(SessionRedirectMixin):
357
+ """A Requests session.
358
+
359
+ Provides cookie persistence, connection-pooling, and configuration.
360
+
361
+ Basic Usage::
362
+
363
+ >>> import requests
364
+ >>> s = requests.Session()
365
+ >>> s.get('https://httpbin.org/get')
366
+ <Response [200]>
367
+
368
+ Or as a context manager::
369
+
370
+ >>> with requests.Session() as s:
371
+ ... s.get('https://httpbin.org/get')
372
+ <Response [200]>
373
+ """
374
+
375
+ __attrs__ = [
376
+ "headers",
377
+ "cookies",
378
+ "auth",
379
+ "proxies",
380
+ "hooks",
381
+ "params",
382
+ "verify",
383
+ "cert",
384
+ "adapters",
385
+ "stream",
386
+ "trust_env",
387
+ "max_redirects",
388
+ ]
389
+
390
+ def __init__(self):
391
+ #: A case-insensitive dictionary of headers to be sent on each
392
+ #: :class:`Request <Request>` sent from this
393
+ #: :class:`Session <Session>`.
394
+ self.headers = default_headers()
395
+
396
+ #: Default Authentication tuple or object to attach to
397
+ #: :class:`Request <Request>`.
398
+ self.auth = None
399
+
400
+ #: Dictionary mapping protocol or protocol and host to the URL of the proxy
401
+ #: (e.g. {'http': 'foo.bar:3128', 'http://host.name': 'foo.bar:4012'}) to
402
+ #: be used on each :class:`Request <Request>`.
403
+ self.proxies = {}
404
+
405
+ #: Event-handling hooks.
406
+ self.hooks = default_hooks()
407
+
408
+ #: Dictionary of querystring data to attach to each
409
+ #: :class:`Request <Request>`. The dictionary values may be lists for
410
+ #: representing multivalued query parameters.
411
+ self.params = {}
412
+
413
+ #: Stream response content default.
414
+ self.stream = False
415
+
416
+ #: SSL Verification default.
417
+ #: Defaults to `True`, requiring requests to verify the TLS certificate at the
418
+ #: remote end.
419
+ #: If verify is set to `False`, requests will accept any TLS certificate
420
+ #: presented by the server, and will ignore hostname mismatches and/or
421
+ #: expired certificates, which will make your application vulnerable to
422
+ #: man-in-the-middle (MitM) attacks.
423
+ #: Only set this to `False` for testing.
424
+ self.verify = True
425
+
426
+ #: SSL client certificate default, if String, path to ssl client
427
+ #: cert file (.pem). If Tuple, ('cert', 'key') pair.
428
+ self.cert = None
429
+
430
+ #: Maximum number of redirects allowed. If the request exceeds this
431
+ #: limit, a :class:`TooManyRedirects` exception is raised.
432
+ #: This defaults to requests.models.DEFAULT_REDIRECT_LIMIT, which is
433
+ #: 30.
434
+ self.max_redirects = DEFAULT_REDIRECT_LIMIT
435
+
436
+ #: Trust environment settings for proxy configuration, default
437
+ #: authentication and similar.
438
+ self.trust_env = True
439
+
440
+ #: A CookieJar containing all currently outstanding cookies set on this
441
+ #: session. By default it is a
442
+ #: :class:`RequestsCookieJar <requests.cookies.RequestsCookieJar>`, but
443
+ #: may be any other ``cookielib.CookieJar`` compatible object.
444
+ self.cookies = cookiejar_from_dict({})
445
+
446
+ # Default connection adapters.
447
+ self.adapters = OrderedDict()
448
+ self.mount("https://", HTTPAdapter())
449
+ self.mount("http://", HTTPAdapter())
450
+
451
+ def __enter__(self):
452
+ return self
453
+
454
+ def __exit__(self, *args):
455
+ self.close()
456
+
457
+ def prepare_request(self, request):
458
+ """Constructs a :class:`PreparedRequest <PreparedRequest>` for
459
+ transmission and returns it. The :class:`PreparedRequest` has settings
460
+ merged from the :class:`Request <Request>` instance and those of the
461
+ :class:`Session`.
462
+
463
+ :param request: :class:`Request` instance to prepare with this
464
+ session's settings.
465
+ :rtype: requests.PreparedRequest
466
+ """
467
+ cookies = request.cookies or {}
468
+
469
+ # Bootstrap CookieJar.
470
+ if not isinstance(cookies, cookielib.CookieJar):
471
+ cookies = cookiejar_from_dict(cookies)
472
+
473
+ # Merge with session cookies
474
+ merged_cookies = merge_cookies(
475
+ merge_cookies(RequestsCookieJar(), self.cookies), cookies
476
+ )
477
+
478
+ # Set environment's basic authentication if not explicitly set.
479
+ auth = request.auth
480
+ if self.trust_env and not auth and not self.auth:
481
+ auth = get_netrc_auth(request.url)
482
+
483
+ p = PreparedRequest()
484
+ p.prepare(
485
+ method=request.method.upper(),
486
+ url=request.url,
487
+ files=request.files,
488
+ data=request.data,
489
+ json=request.json,
490
+ headers=merge_setting(
491
+ request.headers, self.headers, dict_class=CaseInsensitiveDict
492
+ ),
493
+ params=merge_setting(request.params, self.params),
494
+ auth=merge_setting(auth, self.auth),
495
+ cookies=merged_cookies,
496
+ hooks=merge_hooks(request.hooks, self.hooks),
497
+ )
498
+ return p
499
+
500
+ def request(
501
+ self,
502
+ method,
503
+ url,
504
+ params=None,
505
+ data=None,
506
+ headers=None,
507
+ cookies=None,
508
+ files=None,
509
+ auth=None,
510
+ timeout=None,
511
+ allow_redirects=True,
512
+ proxies=None,
513
+ hooks=None,
514
+ stream=None,
515
+ verify=None,
516
+ cert=None,
517
+ json=None,
518
+ ):
519
+ """Constructs a :class:`Request <Request>`, prepares it and sends it.
520
+ Returns :class:`Response <Response>` object.
521
+
522
+ :param method: method for the new :class:`Request` object.
523
+ :param url: URL for the new :class:`Request` object.
524
+ :param params: (optional) Dictionary or bytes to be sent in the query
525
+ string for the :class:`Request`.
526
+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like
527
+ object to send in the body of the :class:`Request`.
528
+ :param json: (optional) json to send in the body of the
529
+ :class:`Request`.
530
+ :param headers: (optional) Dictionary of HTTP Headers to send with the
531
+ :class:`Request`.
532
+ :param cookies: (optional) Dict or CookieJar object to send with the
533
+ :class:`Request`.
534
+ :param files: (optional) Dictionary of ``'filename': file-like-objects``
535
+ for multipart encoding upload.
536
+ :param auth: (optional) Auth tuple or callable to enable
537
+ Basic/Digest/Custom HTTP Auth.
538
+ :param timeout: (optional) How long to wait for the server to send
539
+ data before giving up, as a float, or a :ref:`(connect timeout,
540
+ read timeout) <timeouts>` tuple.
541
+ :type timeout: float or tuple
542
+ :param allow_redirects: (optional) Set to True by default.
543
+ :type allow_redirects: bool
544
+ :param proxies: (optional) Dictionary mapping protocol or protocol and
545
+ hostname to the URL of the proxy.
546
+ :param hooks: (optional) Dictionary mapping hook name to one event or
547
+ list of events, event must be callable.
548
+ :param stream: (optional) whether to immediately download the response
549
+ content. Defaults to ``False``.
550
+ :param verify: (optional) Either a boolean, in which case it controls whether we verify
551
+ the server's TLS certificate, or a string, in which case it must be a path
552
+ to a CA bundle to use. Defaults to ``True``. When set to
553
+ ``False``, requests will accept any TLS certificate presented by
554
+ the server, and will ignore hostname mismatches and/or expired
555
+ certificates, which will make your application vulnerable to
556
+ man-in-the-middle (MitM) attacks. Setting verify to ``False``
557
+ may be useful during local development or testing.
558
+ :param cert: (optional) if String, path to ssl client cert file (.pem).
559
+ If Tuple, ('cert', 'key') pair.
560
+ :rtype: requests.Response
561
+ """
562
+ # Create the Request.
563
+ req = Request(
564
+ method=method.upper(),
565
+ url=url,
566
+ headers=headers,
567
+ files=files,
568
+ data=data or {},
569
+ json=json,
570
+ params=params or {},
571
+ auth=auth,
572
+ cookies=cookies,
573
+ hooks=hooks,
574
+ )
575
+ prep = self.prepare_request(req)
576
+
577
+ proxies = proxies or {}
578
+
579
+ settings = self.merge_environment_settings(
580
+ prep.url, proxies, stream, verify, cert
581
+ )
582
+
583
+ # Send the request.
584
+ send_kwargs = {
585
+ "timeout": timeout,
586
+ "allow_redirects": allow_redirects,
587
+ }
588
+ send_kwargs.update(settings)
589
+ resp = self.send(prep, **send_kwargs)
590
+
591
+ return resp
592
+
593
+ def get(self, url, **kwargs):
594
+ r"""Sends a GET request. Returns :class:`Response` object.
595
+
596
+ :param url: URL for the new :class:`Request` object.
597
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
598
+ :rtype: requests.Response
599
+ """
600
+
601
+ kwargs.setdefault("allow_redirects", True)
602
+ return self.request("GET", url, **kwargs)
603
+
604
+ def options(self, url, **kwargs):
605
+ r"""Sends a OPTIONS request. Returns :class:`Response` object.
606
+
607
+ :param url: URL for the new :class:`Request` object.
608
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
609
+ :rtype: requests.Response
610
+ """
611
+
612
+ kwargs.setdefault("allow_redirects", True)
613
+ return self.request("OPTIONS", url, **kwargs)
614
+
615
+ def head(self, url, **kwargs):
616
+ r"""Sends a HEAD request. Returns :class:`Response` object.
617
+
618
+ :param url: URL for the new :class:`Request` object.
619
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
620
+ :rtype: requests.Response
621
+ """
622
+
623
+ kwargs.setdefault("allow_redirects", False)
624
+ return self.request("HEAD", url, **kwargs)
625
+
626
+ def post(self, url, data=None, json=None, **kwargs):
627
+ r"""Sends a POST request. Returns :class:`Response` object.
628
+
629
+ :param url: URL for the new :class:`Request` object.
630
+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like
631
+ object to send in the body of the :class:`Request`.
632
+ :param json: (optional) json to send in the body of the :class:`Request`.
633
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
634
+ :rtype: requests.Response
635
+ """
636
+
637
+ return self.request("POST", url, data=data, json=json, **kwargs)
638
+
639
+ def put(self, url, data=None, **kwargs):
640
+ r"""Sends a PUT request. Returns :class:`Response` object.
641
+
642
+ :param url: URL for the new :class:`Request` object.
643
+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like
644
+ object to send in the body of the :class:`Request`.
645
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
646
+ :rtype: requests.Response
647
+ """
648
+
649
+ return self.request("PUT", url, data=data, **kwargs)
650
+
651
+ def patch(self, url, data=None, **kwargs):
652
+ r"""Sends a PATCH request. Returns :class:`Response` object.
653
+
654
+ :param url: URL for the new :class:`Request` object.
655
+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like
656
+ object to send in the body of the :class:`Request`.
657
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
658
+ :rtype: requests.Response
659
+ """
660
+
661
+ return self.request("PATCH", url, data=data, **kwargs)
662
+
663
+ def delete(self, url, **kwargs):
664
+ r"""Sends a DELETE request. Returns :class:`Response` object.
665
+
666
+ :param url: URL for the new :class:`Request` object.
667
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
668
+ :rtype: requests.Response
669
+ """
670
+
671
+ return self.request("DELETE", url, **kwargs)
672
+
673
+ def send(self, request, **kwargs):
674
+ """Send a given PreparedRequest.
675
+
676
+ :rtype: requests.Response
677
+ """
678
+ # Set defaults that the hooks can utilize to ensure they always have
679
+ # the correct parameters to reproduce the previous request.
680
+ kwargs.setdefault("stream", self.stream)
681
+ kwargs.setdefault("verify", self.verify)
682
+ kwargs.setdefault("cert", self.cert)
683
+ if "proxies" not in kwargs:
684
+ kwargs["proxies"] = resolve_proxies(request, self.proxies, self.trust_env)
685
+
686
+ # It's possible that users might accidentally send a Request object.
687
+ # Guard against that specific failure case.
688
+ if isinstance(request, Request):
689
+ raise ValueError("You can only send PreparedRequests.")
690
+
691
+ # Set up variables needed for resolve_redirects and dispatching of hooks
692
+ allow_redirects = kwargs.pop("allow_redirects", True)
693
+ stream = kwargs.get("stream")
694
+ hooks = request.hooks
695
+
696
+ # Get the appropriate adapter to use
697
+ adapter = self.get_adapter(url=request.url)
698
+
699
+ # Start time (approximately) of the request
700
+ start = preferred_clock()
701
+
702
+ # Send the request
703
+ r = adapter.send(request, **kwargs)
704
+
705
+ # Total elapsed time of the request (approximately)
706
+ elapsed = preferred_clock() - start
707
+ r.elapsed = timedelta(seconds=elapsed)
708
+
709
+ # Response manipulation hooks
710
+ r = dispatch_hook("response", hooks, r, **kwargs)
711
+
712
+ # Persist cookies
713
+ if r.history:
714
+ # If the hooks create history then we want those cookies too
715
+ for resp in r.history:
716
+ extract_cookies_to_jar(self.cookies, resp.request, resp.raw)
717
+
718
+ extract_cookies_to_jar(self.cookies, request, r.raw)
719
+
720
+ # Resolve redirects if allowed.
721
+ if allow_redirects:
722
+ # Redirect resolving generator.
723
+ gen = self.resolve_redirects(r, request, **kwargs)
724
+ history = [resp for resp in gen]
725
+ else:
726
+ history = []
727
+
728
+ # Shuffle things around if there's history.
729
+ if history:
730
+ # Insert the first (original) request at the start
731
+ history.insert(0, r)
732
+ # Get the last request made
733
+ r = history.pop()
734
+ r.history = history
735
+
736
+ # If redirects aren't being followed, store the response on the Request for Response.next().
737
+ if not allow_redirects:
738
+ try:
739
+ r._next = next(
740
+ self.resolve_redirects(r, request, yield_requests=True, **kwargs)
741
+ )
742
+ except StopIteration:
743
+ pass
744
+
745
+ if not stream:
746
+ r.content
747
+
748
+ return r
749
+
750
+ def merge_environment_settings(self, url, proxies, stream, verify, cert):
751
+ """
752
+ Check the environment and merge it with some settings.
753
+
754
+ :rtype: dict
755
+ """
756
+ # Gather clues from the surrounding environment.
757
+ if self.trust_env:
758
+ # Set environment's proxies.
759
+ no_proxy = proxies.get("no_proxy") if proxies is not None else None
760
+ env_proxies = get_environ_proxies(url, no_proxy=no_proxy)
761
+ for k, v in env_proxies.items():
762
+ proxies.setdefault(k, v)
763
+
764
+ # Look for requests environment configuration
765
+ # and be compatible with cURL.
766
+ if verify is True or verify is None:
767
+ verify = (
768
+ os.environ.get("REQUESTS_CA_BUNDLE")
769
+ or os.environ.get("CURL_CA_BUNDLE")
770
+ or verify
771
+ )
772
+
773
+ # Merge all the kwargs.
774
+ proxies = merge_setting(proxies, self.proxies)
775
+ stream = merge_setting(stream, self.stream)
776
+ verify = merge_setting(verify, self.verify)
777
+ cert = merge_setting(cert, self.cert)
778
+
779
+ return {"proxies": proxies, "stream": stream, "verify": verify, "cert": cert}
780
+
781
+ def get_adapter(self, url):
782
+ """
783
+ Returns the appropriate connection adapter for the given URL.
784
+
785
+ :rtype: requests.adapters.BaseAdapter
786
+ """
787
+ for prefix, adapter in self.adapters.items():
788
+ if url.lower().startswith(prefix.lower()):
789
+ return adapter
790
+
791
+ # Nothing matches :-/
792
+ raise InvalidSchema(f"No connection adapters were found for {url!r}")
793
+
794
+ def close(self):
795
+ """Closes all adapters and as such the session"""
796
+ for v in self.adapters.values():
797
+ v.close()
798
+
799
+ def mount(self, prefix, adapter):
800
+ """Registers a connection adapter to a prefix.
801
+
802
+ Adapters are sorted in descending order by prefix length.
803
+ """
804
+ self.adapters[prefix] = adapter
805
+ keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
806
+
807
+ for key in keys_to_move:
808
+ self.adapters[key] = self.adapters.pop(key)
809
+
810
+ def __getstate__(self):
811
+ state = {attr: getattr(self, attr, None) for attr in self.__attrs__}
812
+ return state
813
+
814
+ def __setstate__(self, state):
815
+ for attr, value in state.items():
816
+ setattr(self, attr, value)
817
+
818
+
819
+ def session():
820
+ """
821
+ Returns a :class:`Session` for context-management.
822
+
823
+ .. deprecated:: 1.0.0
824
+
825
+ This method has been deprecated since version 1.0.0 and is only kept for
826
+ backwards compatibility. New code should use :class:`~requests.sessions.Session`
827
+ to create a session. This may be removed at a future date.
828
+
829
+ :rtype: Session
830
+ """
831
+ return Session()