|
1 | 1 | import asyncio |
2 | | -import aiohttp |
3 | 2 | import http.cookiejar |
4 | 3 | import logging |
5 | 4 | from contextlib import contextmanager |
6 | 5 | from copy import deepcopy |
7 | 6 | from pathlib import Path |
8 | | -from typing import Union, Optional |
| 7 | +from typing import Optional, Union |
9 | 8 |
|
| 9 | +import aiohttp |
10 | 10 | import requests |
| 11 | + |
11 | 12 | from indico.client.request import HTTPRequest |
12 | 13 | from indico.config import IndicoConfig |
13 | 14 | from indico.errors import ( |
14 | 15 | IndicoAuthenticationFailed, |
15 | | - IndicoRequestError, |
16 | 16 | IndicoHibernationError, |
| 17 | + IndicoRequestError, |
17 | 18 | ) |
18 | | -from indico.http.serialization import deserialize, aio_deserialize |
| 19 | +from indico.http.serialization import aio_deserialize, deserialize |
| 20 | + |
19 | 21 | from .retry import aioretry |
20 | 22 |
|
21 | 23 | logger = logging.getLogger(__file__) |
@@ -87,7 +89,6 @@ def execute_request(self, request: HTTPRequest): |
87 | 89 |
|
88 | 90 | @contextmanager |
89 | 91 | def _handle_files(self, req_kwargs): |
90 | | - |
91 | 92 | streams = None |
92 | 93 | # deepcopying buffers is not supported |
93 | 94 | # so, remove "streams" before the deepcopy. |
@@ -256,7 +257,7 @@ def _handle_files(self, req_kwargs): |
256 | 257 | ) |
257 | 258 | dup_counts[path.stem] += 1 |
258 | 259 | else: |
259 | | - data.add_field("file", fd, filename=path.stem) |
| 260 | + data.add_field("file", fd, filename=path.name) |
260 | 261 | dup_counts[path.stem] = 1 |
261 | 262 | file_args.append(data) |
262 | 263 |
|
@@ -313,7 +314,6 @@ async def _make_request( |
313 | 314 | verify_ssl=self.config.verify_ssl, |
314 | 315 | **request_kwargs, |
315 | 316 | ) as response: |
316 | | - |
317 | 317 | # If auth expired refresh |
318 | 318 | if response.status == 401 and not _refreshed: |
319 | 319 | await self.get_short_lived_access_token() |
|
0 commit comments