Skip to content

Commit

Permalink
[fix][chore] Bump Libs (#2199)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Sep 19, 2024
1 parent 50ec1d3 commit 1735b14
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 120 deletions.
2 changes: 1 addition & 1 deletion fixcore/fixcore/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4240,7 +4240,7 @@ async def perform_request(e: JsonElement) -> int:
headers=template.headers,
params=template.params,
data=data,
compress=template.compress,
compress="deflate" if template.compress else None,
timeout=template.timeout,
ssl=False if template.no_ssl_verify else self.dependencies.cert_handler.client_context,
auth=BasicAuth(login=authuser, password=(authpass if authpass else "")) if authuser else None,
Expand Down
1 change: 0 additions & 1 deletion fixcore/fixcore/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
from aiohttp.web import Request, StreamResponse

RequestHandler = Callable[[Request], Awaitable[StreamResponse]]
Middleware = Callable[[Request, RequestHandler], Awaitable[StreamResponse]]
32 changes: 21 additions & 11 deletions fixcore/fixcore/web/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
)
from urllib.parse import urlencode, urlparse, parse_qs, urlunparse

import aiofiles
import aiohttp_jinja2
import jinja2
import prometheus_client
Expand All @@ -44,6 +45,7 @@
MultipartReader,
ClientSession,
TCPConnector,
BodyPartReader,
)
from aiohttp.abc import AbstractStreamWriter
from aiohttp.hdrs import METH_ANY
Expand Down Expand Up @@ -1380,6 +1382,23 @@ def line_to_js(line: ParsedCommandLine) -> Json:
@timed("api", "execute")
async def execute(self, request: Request, deps: TenantDependencies) -> StreamResponse:
temp_dir: Optional[str] = None

async def write_files(mpr: MultipartReader, tmp_dir: str) -> Dict[str, str]:
files: Dict[str, str] = {}
async for part in mpr:
if isinstance(part, MultipartReader):
files.update(await write_files(part, tmp_dir))
elif isinstance(part, BodyPartReader):
name = part.filename
if not name:
raise AttributeError("Multipart request: content disposition name is required!")
path = os.path.join(tmp_dir, rnd_str()) # use random local path to avoid clashes
files[name] = path
async with aiofiles.open(path, "wb") as writer:
while not part.at_eof():
await writer.write(await part.read_chunk())
return files

try:
ctx = self.cli_context_from_request(request)
if request.content_type.startswith("text"):
Expand All @@ -1388,18 +1407,9 @@ async def execute(self, request: Request, deps: TenantDependencies) -> StreamRes
command = request.headers["Fix-Shell-Command"].strip()
temp = tempfile.mkdtemp()
temp_dir = temp
files = {}
# for now, we assume that all multi-parts are file uploads
async for part in MultipartReader(request.headers, request.content):
name = part.name
if not name:
raise AttributeError("Multipart request: content disposition name is required!")
path = os.path.join(temp, rnd_str()) # use random local path to avoid clashes
files[name] = path
with open(path, "wb") as writer:
while not part.at_eof():
writer.write(await part.read_chunk())
ctx = evolve(ctx, uploaded_files=files)
uploaded = await write_files(MultipartReader(request.headers, request.content), temp)
ctx = evolve(ctx, uploaded_files=uploaded)
else:
raise AttributeError(f"Not able to handle: {request.content_type}")

Expand Down
3 changes: 2 additions & 1 deletion fixcore/fixcore/web/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import jwt
from aiohttp import web
from aiohttp.typedefs import Middleware
from aiohttp.web import Request, StreamResponse
from aiohttp.web import middleware
from attr import define
Expand All @@ -26,7 +27,7 @@
from fixcore.web.certificate_handler import CertificateHandler
from fixcore.web.permission import PermissionChecker
from fixlib import jwt as ck_jwt
from fixlib.asynchronous.web import RequestHandler, Middleware, TenantRequestHandler
from fixlib.asynchronous.web import RequestHandler, TenantRequestHandler
from fixlib.jwt import encode_jwt, create_jwk_dict
from fixlib.types import Json
from fixlib.utils import utc
Expand Down
9 changes: 4 additions & 5 deletions fixcore/fixcore/web/directives.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging
from re import RegexFlag, fullmatch
from typing import Optional, Callable, Awaitable, Tuple
from typing import Optional, Tuple

from aiohttp.hdrs import METH_OPTIONS, METH_GET, METH_HEAD, METH_POST, METH_PUT, METH_DELETE, METH_PATCH
from aiohttp.typedefs import Middleware
from aiohttp.web import HTTPRedirection, HTTPNotFound, HTTPBadRequest, HTTPException, HTTPNoContent
from aiohttp.web_exceptions import HTTPServiceUnavailable, HTTPError
from aiohttp.web_middlewares import middleware
Expand Down Expand Up @@ -84,9 +85,7 @@ async def metrics_handler(request: Request, handler: RequestHandler) -> StreamRe
RequestInProgress.labels(request.path, request.method).dec()


def error_handler(
config: CoreConfig, event_sender: AnalyticsEventSender
) -> Callable[[Request, RequestHandler], Awaitable[StreamResponse]]:
def error_handler(config: CoreConfig, event_sender: AnalyticsEventSender) -> Middleware:
is_debug = (logging.root.level < logging.INFO) or config.runtime.debug

def exc_info(ex: Exception) -> Optional[Exception]:
Expand Down Expand Up @@ -129,7 +128,7 @@ def message_from_error(e: Exception) -> Tuple[str, str, str]:
return error_handler_middleware


def default_middleware(api_handler: "api.Api") -> Callable[[Request, RequestHandler], Awaitable[StreamResponse]]:
def default_middleware(api_handler: "api.Api") -> Middleware:
@middleware
async def default_handler(request: Request, handler: RequestHandler) -> StreamResponse:
if api_handler.in_shutdown:
Expand Down
4 changes: 2 additions & 2 deletions fixcore/tests/fixcore/web/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest
from _pytest.fixtures import fixture
from aiohttp import ClientSession, MultipartReader
from aiohttp import ClientSession, MultipartReader, BodyPartReader
from networkx import MultiDiGraph
from datetime import timedelta
from fixclient import models as rc
Expand Down Expand Up @@ -394,7 +394,7 @@ async def test_cli(core_client: FixInventoryClient) -> None:
# execute multiple commands
response = await core_client.cli_execute_raw("echo foo; echo bar; echo bla")
reader: MultipartReader = MultipartReader.from_response(response.undrelying) # type: ignore
assert [await p.text() async for p in reader] == ['"foo"', '"bar"', '"bla"']
assert [await p.text() async for p in reader if isinstance(p, BodyPartReader)] == ['"foo"', '"bar"', '"bla"']

# list all cli commands
info = AccessJson(await core_client.cli_info())
Expand Down
1 change: 0 additions & 1 deletion fixlib/fixlib/asynchronous/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@

RequestHandler = Callable[[Request], Awaitable[StreamResponse]]
TenantRequestHandler = Callable[[Request, TenantDependencies], Awaitable[StreamResponse]]
Middleware = Callable[[Request, RequestHandler], Awaitable[StreamResponse]]
84 changes: 43 additions & 41 deletions requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
aiodns==3.2.0
aiofiles==24.1.0
aiohttp[speedups]==3.9.5
aiohappyeyeballs==2.4.0
aiohttp[speedups]==3.10.5
aiohttp-jinja2==1.6
aiohttp-swagger3==0.8.0
aiohttp-swagger3==0.9.0
aiosignal==1.3.1
aiostream==0.6.2
appdirs==1.4.4
Expand All @@ -12,39 +13,39 @@ astroid==3.2.4
attrs==24.2.0
autocommand==2.2.2
azure-common==1.1.28
azure-core==1.30.2
azure-core==1.31.0
azure-identity==1.17.1
azure-mgmt-core==1.4.0
azure-mgmt-resource==23.1.1
backoff==2.2.1
backports-tarfile==1.2.0
bcrypt==4.2.0
black==24.8.0
boto3==1.35.10
botocore==1.35.10
boto3==1.35.22
botocore==1.35.22
brotli==1.1.0
build==1.2.1
build==1.2.2
cachetools==5.5.0
cattrs==24.1.0
cattrs==24.1.1
cerberus==1.3.5
certifi==2024.8.30
cffi==1.17.0
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.3.2
cheroot==10.0.1
cherrypy==18.10.0
click==8.1.7
colorama==0.4.6
coverage[toml]==7.6.1
cryptography==43.0.0
cryptography==43.0.1
deepdiff==8.0.1
defusedxml==0.7.1
deprecated==1.2.14
detect-secrets==1.5.0
dill==0.3.8
distlib==0.3.8
fastjsonschema==2.19.1
filelock==3.15.4
filelock==3.16.1
fixcompliance==0.4.34
fixdatalink[extra]==2.0.2
fixinventoryclient==2.0.1
Expand All @@ -55,18 +56,19 @@ flexparser==0.3.1
frozendict==2.4.4
frozenlist==1.4.1
google-api-core==2.19.2
google-api-python-client==2.143.0
google-api-python-client==2.146.0
google-auth==2.34.0
google-auth-httplib2==0.2.0
google-cloud-core==2.4.1
google-cloud-storage==2.18.2
google-crc32c==1.5.0
google-crc32c==1.6.0
google-resumable-media==2.7.2
googleapis-common-protos==1.65.0
hcloud==2.2.0
httplib2==0.22.0
hypothesis==6.111.2
idna==3.8
importlib-metadata==8.4.0
hypothesis==6.112.1
idna==3.10
importlib-metadata==8.5.0
iniconfig==2.0.0
isodate==0.6.1
isort==5.13.2
Expand All @@ -84,41 +86,41 @@ markupsafe==2.1.5
mccabe==0.7.0
mdurl==0.1.2
monotonic==1.6
more-itertools==10.4.0
msal==1.30.0
more-itertools==10.5.0
msal==1.31.0
msal-extensions==1.2.0
multidict==6.0.5
multidict==6.1.0
mypy==1.11.2
mypy-extensions==1.0.0
networkx==3.3
numpy==2.1.0
numpy==2.1.1
oauth2client==4.1.3
oauthlib==3.2.2
onelogin==2.0.4
orderly-set==5.2.2
packaging==24.1
paramiko==3.4.1
paramiko==3.5.0
parsy==2.1
pathspec==0.12.1
pep8-naming==0.14.1
pint==0.24.3
pip==24.2
pip-tools==7.4.1
plantuml==0.3.0
platformdirs==4.2.2
platformdirs==4.3.6
pluggy==1.5.0
portalocker==2.10.1
portend==3.2.0
posthog==3.6.0
posthog==3.6.6
prometheus-client==0.20.0
prompt-toolkit==3.0.47
proto-plus==1.24.0
protobuf==5.28.0
protobuf==5.28.2
psutil==6.0.0
psycopg2-binary==2.9.9
pyarrow==17.0.0
pyasn1==0.6.0
pyasn1-modules==0.4.0
pyasn1==0.6.1
pyasn1-modules==0.4.1
pycares==4.4.0
pycodestyle==2.12.1
pycparser==2.22
Expand All @@ -131,13 +133,13 @@ pymysql==1.1.1
pynacl==1.5.0
pyopenssl==24.2.1
pyparsing==3.1.4
pyproject-api==1.7.1
pyproject-api==1.8.0
pyproject-hooks==1.1.0
pytest==8.3.2
pytest==8.3.3
pytest-asyncio==0.24.0
pytest-cov==5.0.0
pytest-runner==6.0.1
python-arango==8.1.0
python-arango==8.1.1
python-dateutil==2.9.0.post0
pytz==2024.1
pyvmomi==8.0.3.0.1
Expand All @@ -147,30 +149,30 @@ requests-oauthlib==2.0.0
requests-toolbelt==1.0.0
retrying==1.3.4
rfc3339-validator==0.1.4
rich==13.8.0
rich==13.8.1
rsa==4.9
s3transfer==0.10.2
setuptools==74.0.0
setuptools==75.1.0
six==1.16.0
slack-sdk==3.31.0
snowflake-connector-python==3.12.1
slack-sdk==3.33.0
snowflake-connector-python==3.12.2
snowflake-sqlalchemy==1.6.1
sortedcontainers==2.4.0
sqlalchemy==1.4.53
sqlalchemy==1.4.54
tempora==5.7.0
tenacity==9.0.0
toml==0.10.2
tomlkit==0.13.2
toolz==0.12.1
tox==4.18.0
tox==4.20.0
transitions==0.9.2
typeguard==4.3.0
types-aiofiles==24.1.0.20240626
types-python-dateutil==2.9.0.20240821
types-pytz==2024.1.0.20240417
types-pyyaml==6.0.12.20240808
types-python-dateutil==2.9.0.20240906
types-pytz==2024.2.0.20240913
types-pyyaml==6.0.12.20240917
types-requests==2.31.0.6
types-setuptools==74.0.0.20240831
types-setuptools==75.1.0.20240917
types-six==1.16.21.20240513
types-tzlocal==5.1.0.1
types-urllib3==1.26.25.14
Expand All @@ -181,11 +183,11 @@ tzlocal==5.2
uritemplate==4.1.1
urllib3==1.26.20
ustache==0.1.5
virtualenv==20.26.3
virtualenv==20.26.5
wcwidth==0.2.13
websocket-client==1.8.0
wheel==0.44.0
wrapt==1.16.0
yarl==1.9.7
yarl==1.11.1
zc-lockfile==3.0.post1
zipp==3.20.1
zipp==3.20.2
Loading

0 comments on commit 1735b14

Please sign in to comment.