Skip to content

Commit 4e196e6

Browse files
author
Two Dev
committed
v1.1.0
1 parent 80e7e71 commit 4e196e6

File tree

4 files changed

+167
-39
lines changed

4 files changed

+167
-39
lines changed

.github/workflows/documentation.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Documentation
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 1
10+
matrix:
11+
python-version: ['3.9']
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Install Dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -r requirements-dev.txt
22+
- name: Configure Git Credentials
23+
run: |
24+
git config user.name github-actions[bot]
25+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
26+
- uses: actions/cache@v4
27+
with:
28+
key: mkdocs-material-${{ env.cache_id }}
29+
path: .cache
30+
restore-keys: |
31+
mkdocs-material-
32+
- name: Publish Documentation
33+
run: |
34+
echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
35+
mkdocs gh-deploy --force

tls_requests/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
__url__ = "https://github.com/thewebscraping/tls-requests"
44
__author__ = "Tu Pham"
55
__author_email__ = "[email protected]"
6-
__version__ = "1.0.9"
6+
__version__ = "1.1.0"
77
__license__ = "MIT"

tls_requests/client.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,7 @@ def send(
479479
request = request_
480480

481481
self.follow_redirects = follow_redirects
482-
response = self._send(
483-
request,
484-
start=time.perf_counter(),
485-
history=[]
486-
)
482+
response = self._send(request, start=time.perf_counter(), history=[])
487483

488484
if self.hooks.get("response"):
489485
response_ = self.build_hook_response(response)
@@ -980,11 +976,7 @@ async def send(
980976
request = request_
981977

982978
self.follow_redirects = follow_redirects
983-
response = await self._send(
984-
request,
985-
start=time.perf_counter(),
986-
history=[]
987-
)
979+
response = await self._send(request, start=time.perf_counter(), history=[])
988980

989981
if self.hooks.get("response"):
990982
response_ = self.build_hook_response(response)
@@ -1002,7 +994,8 @@ async def _send(
1002994
start = start or time.perf_counter()
1003995
config = self.prepare_config(request)
1004996
response = Response.from_tls_response(
1005-
await self.session.arequest(config.to_dict()), is_byte_response=config.isByteResponse,
997+
await self.session.arequest(config.to_dict()),
998+
is_byte_response=config.isByteResponse,
1006999
)
10071000
response.request = request
10081001
response.default_encoding = self.encoding

tls_requests/models/libraries.py

+127-27
Original file line numberDiff line numberDiff line change
@@ -132,43 +132,135 @@ class TLSLibrary:
132132
"""
133133

134134
_PATH: str = None
135+
_STATIC_API_DATA = {
136+
"name": "v1.7.10",
137+
"tag_name": "v1.7.10",
138+
"assets": [
139+
{
140+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-darwin-amd64-1.7.10.dylib",
141+
"name": "tls-client-darwin-amd64-1.7.10.dylib",
142+
},
143+
{
144+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-darwin-arm64-1.7.10.dylib",
145+
"name": "tls-client-darwin-arm64-1.7.10.dylib",
146+
},
147+
{
148+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-linux-arm64-1.7.10.so",
149+
"name": "tls-client-linux-arm64-1.7.10.so",
150+
},
151+
{
152+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-linux-armv7-1.7.10.so",
153+
"name": "tls-client-linux-armv7-1.7.10.so",
154+
},
155+
{
156+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-linux-ubuntu-amd64-1.7.10.so",
157+
"name": "tls-client-linux-ubuntu-amd64-1.7.10.so",
158+
},
159+
{
160+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-windows-32-1.7.10.dll",
161+
"name": "tls-client-windows-32-1.7.10.dll",
162+
},
163+
{
164+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-windows-64-1.7.10.dll",
165+
"name": "tls-client-windows-64-1.7.10.dll",
166+
},
167+
{
168+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-darwin-amd64.dylib",
169+
"name": "tls-client-xgo-1.7.10-darwin-amd64.dylib",
170+
},
171+
{
172+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-darwin-arm64.dylib",
173+
"name": "tls-client-xgo-1.7.10-darwin-arm64.dylib",
174+
},
175+
{
176+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-386.so",
177+
"name": "tls-client-xgo-1.7.10-linux-386.so",
178+
},
179+
{
180+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-amd64.so",
181+
"name": "tls-client-xgo-1.7.10-linux-amd64.so",
182+
},
183+
{
184+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-arm-5.so",
185+
"name": "tls-client-xgo-1.7.10-linux-arm-5.so",
186+
},
187+
{
188+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-arm-6.so",
189+
"name": "tls-client-xgo-1.7.10-linux-arm-6.so",
190+
},
191+
{
192+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-arm-7.so",
193+
"name": "tls-client-xgo-1.7.10-linux-arm-7.so",
194+
},
195+
{
196+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-arm64.so",
197+
"name": "tls-client-xgo-1.7.10-linux-arm64.so",
198+
},
199+
{
200+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-ppc64le.so",
201+
"name": "tls-client-xgo-1.7.10-linux-ppc64le.so",
202+
},
203+
{
204+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-riscv64.so",
205+
"name": "tls-client-xgo-1.7.10-linux-riscv64.so",
206+
},
207+
{
208+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-linux-s390x.so",
209+
"name": "tls-client-xgo-1.7.10-linux-s390x.so",
210+
},
211+
{
212+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-windows-386.dll",
213+
"name": "tls-client-xgo-1.7.10-windows-386.dll",
214+
},
215+
{
216+
"browser_download_url": "https://github.com/bogdanfinn/tls-client/releases/download/v1.7.10/tls-client-xgo-1.7.10-windows-amd64.dll",
217+
"name": "tls-client-xgo-1.7.10-windows-amd64.dll",
218+
},
219+
],
220+
}
135221

136222
@classmethod
137223
def fetch_api(cls, version: str = None, retries: int = 3):
224+
def _find_release(data, version_: str = None):
225+
releases = [
226+
Release.from_kwargs(**kwargs) for kwargs in data
227+
]
228+
229+
if version_ is not None:
230+
version_ = (
231+
"v%s" % version_
232+
if not str(version_).startswith("v")
233+
else str(version_)
234+
)
235+
releases = [
236+
release
237+
for release in releases
238+
if re.search(version_, release.name, re.I)
239+
]
240+
241+
for release in releases:
242+
for asset in release.assets:
243+
if IS_UBUNTU and PATTERN_UBUNTU_RE.search(
244+
asset.browser_download_url
245+
):
246+
ubuntu_urls.append(asset.browser_download_url)
247+
if PATTERN_RE.search(asset.browser_download_url):
248+
asset_urls.append(asset.browser_download_url)
249+
138250
asset_urls, ubuntu_urls = [], []
139251
for _ in range(retries):
140252
try:
141253
response = requests.get(GITHUB_API_URL)
142254
if response.ok:
143-
response_json = response.json()
144-
releases = [
145-
Release.from_kwargs(**kwargs) for kwargs in response_json
146-
]
147-
148-
if version is not None:
149-
version = (
150-
"v%s" % version
151-
if not str(version).startswith("v")
152-
else str(version)
153-
)
154-
releases = [
155-
release
156-
for release in releases
157-
if re.search(version, release.name, re.I)
158-
]
159-
160-
for release in releases:
161-
for asset in release.assets:
162-
if IS_UBUNTU and PATTERN_UBUNTU_RE.search(
163-
asset.browser_download_url
164-
):
165-
ubuntu_urls.append(asset.browser_download_url)
166-
if PATTERN_RE.search(asset.browser_download_url):
167-
asset_urls.append(asset.browser_download_url)
255+
_find_release(response.json())
256+
break
168257

169258
except Exception as ex:
170259
print("Unable to fetch GitHub API: %s" % ex)
171260

261+
if not asset_urls and not ubuntu_urls:
262+
_find_release([cls._STATIC_API_DATA])
263+
172264
for url in ubuntu_urls:
173265
yield url
174266

@@ -183,14 +275,22 @@ def find(cls) -> str:
183275

184276
@classmethod
185277
def find_all(cls) -> list[str]:
186-
return [src for src in glob.glob(os.path.join(BIN_DIR, r"*")) if src.lower().endswith(('so', 'dll', 'dylib'))]
278+
return [
279+
src
280+
for src in glob.glob(os.path.join(BIN_DIR, r"*"))
281+
if src.lower().endswith(("so", "dll", "dylib"))
282+
]
187283

188284
@classmethod
189285
def download(cls, version: str = None) -> str:
190286
try:
191287
print(
192288
"System Info - Platform: %s, Machine: %s, File Ext : %s."
193-
% (PLATFORM, "%s (Ubuntu)" % MACHINE if IS_UBUNTU else MACHINE, FILE_EXT)
289+
% (
290+
PLATFORM,
291+
"%s (Ubuntu)" % MACHINE if IS_UBUNTU else MACHINE,
292+
FILE_EXT,
293+
)
194294
)
195295
download_url = None
196296
for download_url in cls.fetch_api(version):

0 commit comments

Comments
 (0)