mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-21 08:56:29 +00:00
Fix proxy 2 (#1236)
* ci: upgrade actions * chore: improve exception handling * fix: incorect url behind proxy
This commit is contained in:
@@ -17,6 +17,7 @@ inputs:
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Update psacc-ha config
|
||||
env:
|
||||
GH_TOKEN: ${{ inputs.gh_token }}
|
||||
|
||||
@@ -9,9 +9,9 @@ jobs:
|
||||
name: Push to pypi
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v6
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Install dependencies
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
poetry build
|
||||
poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }}
|
||||
mv dist/psa_car_controller-${PSACC_VERSION:1}-py3-none-any.whl dist/psa_car_controller-0.0.0-py3-none-any.whl
|
||||
- uses: actions/upload-artifact@master
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: wheel-package
|
||||
path: dist/psa_car_controller-0.0.0-py3-none-any.whl
|
||||
@@ -50,27 +50,27 @@ jobs:
|
||||
fi
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@master
|
||||
uses: docker/setup-qemu-action@v4
|
||||
with:
|
||||
platforms: all
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@master
|
||||
uses: actions/checkout@v6
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: wheel-package
|
||||
path: dist/psa_car_controller-0.0.0-py3-none-any.whl
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
|
||||
@@ -13,13 +13,13 @@ jobs:
|
||||
steps:
|
||||
- name: Set up python
|
||||
id: setup-python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: 3.11
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v6
|
||||
- name: Load cached venv
|
||||
id: cached-poetry-dependencies
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: .venv
|
||||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
|
||||
|
||||
@@ -6,7 +6,7 @@ from hashlib import md5
|
||||
from sqlite3.dbapi2 import IntegrityError
|
||||
|
||||
from oauth2_client.credentials_manager import ServiceInformation
|
||||
from urllib3.exceptions import InvalidHeader
|
||||
from urllib3.exceptions import HTTPError
|
||||
|
||||
from psa_car_controller.psa.connected_car_api.api.vehicles_api import VehiclesApi
|
||||
from psa_car_controller.psa.connected_car_api.rest import ApiException
|
||||
@@ -110,7 +110,7 @@ class PSAClient:
|
||||
if self._record_enabled:
|
||||
self.record_info(car)
|
||||
return res
|
||||
except (ApiException, InvalidHeader) as ex:
|
||||
except (ApiException, HTTPError) as ex:
|
||||
logger.error("get_vehicle_info: ApiException: %s", ex, exc_info_debug=True)
|
||||
car.status = res
|
||||
return res
|
||||
@@ -142,7 +142,7 @@ class PSAClient:
|
||||
for vehicle in res.embedded.vehicles:
|
||||
self.vehicles_list.add(Car(vehicle.vin, vehicle.id, vehicle.brand, vehicle.label))
|
||||
self.vehicles_list.save_cars()
|
||||
except (ApiException, InvalidHeader):
|
||||
except (ApiException, HTTPError):
|
||||
logger.exception("get_vehicles:")
|
||||
return self.vehicles_list
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import logging
|
||||
|
||||
from dash import callback_context, html, dcc
|
||||
from dash.exceptions import PreventUpdate
|
||||
from flask import request
|
||||
|
||||
from psa_car_controller.web.app import dash_app
|
||||
import dash_bootstrap_components as dbc
|
||||
@@ -55,9 +54,8 @@ def finish_oauth(n_clicks, code): # pylint: disable=unused-argument
|
||||
if ctx.triggered:
|
||||
try:
|
||||
config_views.INITIAL_SETUP.connect(code)
|
||||
return dbc.Alert(["PSA login finish !",
|
||||
html.A(" Go to otp config", href=request.url_root + "config_otp")],
|
||||
color="success")
|
||||
return dbc.Alert(["PSA login finish !", html.A(" Go to otp config",
|
||||
href=dash_app.config.requests_pathname_prefix + "config_otp")], color="success")
|
||||
except Exception as e:
|
||||
logger.exception("finish_oauth:")
|
||||
return dbc.Alert(str(e), color="danger")
|
||||
|
||||
@@ -3,7 +3,6 @@ from urllib import parse
|
||||
|
||||
from dash import callback_context, html, dcc
|
||||
from dash.exceptions import PreventUpdate
|
||||
from flask import request
|
||||
|
||||
from psa_car_controller.psa.otp.otp import new_otp_session
|
||||
from psa_car_controller.psa.setup.headless_oauth import HeadlessOAuthError, get_oauth_code_headless
|
||||
@@ -149,40 +148,47 @@ def connectPSA(n_clicks, app_name, email, password, countrycode): # pylint: dis
|
||||
try:
|
||||
code = get_oauth_code_headless(auth_url, email, password, scheme)
|
||||
INITIAL_SETUP.connect(code)
|
||||
return dbc.Alert(
|
||||
["Login successful! ", html.A("Go to OTP config", href=request.url_root + "config_otp")],
|
||||
color="success"
|
||||
)
|
||||
return dbc.Alert(["Login successful! ",
|
||||
html.A("Go to OTP config",
|
||||
href=dash_app.config.requests_pathname_prefix + "config_otp")], color="success")
|
||||
except HeadlessOAuthError as e:
|
||||
redirect_uri = parse.quote(auth_url)
|
||||
return dbc.Alert(
|
||||
[
|
||||
html.P("Automatic login failed. Please complete manually: "),
|
||||
html.A("Go to login", href=f"{request.url_root}config_connect?url={redirect_uri}"),
|
||||
html.A(
|
||||
"Go to login",
|
||||
href=f"{dash_app.config.requests_pathname_prefix}config_connect?url={redirect_uri}"),
|
||||
html.Hr(),
|
||||
html.P("Debug information (please include in GitHub issue):"),
|
||||
dbc.Label("Last URL:"),
|
||||
dbc.Input(value=e.url, readonly=True, style={"margin-bottom": "10px"}),
|
||||
dbc.Input(
|
||||
value=e.url,
|
||||
readonly=True,
|
||||
style={
|
||||
"margin-bottom": "10px"}),
|
||||
dbc.Label("Console Logs:"),
|
||||
dbc.Textarea(
|
||||
value="\n".join(e.logs),
|
||||
value="\n".join(
|
||||
e.logs),
|
||||
style={
|
||||
"height": "100px",
|
||||
"font-family": "monospace",
|
||||
"font-size": "12px",
|
||||
"margin-bottom": "10px"
|
||||
},
|
||||
"margin-bottom": "10px"},
|
||||
readonly=True,
|
||||
),
|
||||
dbc.Label("HTML Content:"),
|
||||
dbc.Textarea(
|
||||
value=e.html,
|
||||
style={"height": "200px", "font-family": "monospace", "font-size": "12px"},
|
||||
style={
|
||||
"height": "200px",
|
||||
"font-family": "monospace",
|
||||
"font-size": "12px"},
|
||||
readonly=True,
|
||||
),
|
||||
],
|
||||
color="warning"
|
||||
)
|
||||
color="warning")
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
logger.warning("Headless OAuth failed (%s), falling back to manual flow", e)
|
||||
|
||||
@@ -190,7 +196,8 @@ def connectPSA(n_clicks, app_name, email, password, countrycode): # pylint: dis
|
||||
redirect_uri = parse.quote(auth_url)
|
||||
return dbc.Alert(
|
||||
["Automatic login failed. Please complete manually: ",
|
||||
html.A("Go to login", href=f"{request.url_root}config_connect?url={redirect_uri}")],
|
||||
html.A("Go to login",
|
||||
href=f"{dash_app.config.requests_pathname_prefix}config_connect?url={redirect_uri}")],
|
||||
color="warning"
|
||||
)
|
||||
return ""
|
||||
@@ -224,8 +231,8 @@ def finishOtp(n_clicks, code_pin, sms_code): # pylint: disable=unused-argument
|
||||
app.myp.remote_client.otp = otp_session
|
||||
app.myp.save_config()
|
||||
app.start_remote_control()
|
||||
return dbc.Alert(["OTP config finish !!! ", html.A("Go to home", href=request.url_root)],
|
||||
color="success")
|
||||
return dbc.Alert(["OTP config finish !!! ", html.A(
|
||||
"Go to home", href=dash_app.config.requests_pathname_prefix)], color="success")
|
||||
except Exception as e:
|
||||
res = str(e)
|
||||
logger.exception("finishOtp:")
|
||||
|
||||
@@ -8,7 +8,6 @@ from dash import dcc, html
|
||||
from dash.dependencies import Output, Input, State
|
||||
from dash.exceptions import PreventUpdate
|
||||
import time
|
||||
from flask import request
|
||||
|
||||
from psa_car_controller.common import utils
|
||||
from psa_car_controller.common.mylogger import CustomLogger
|
||||
@@ -362,7 +361,7 @@ def serve_layout():
|
||||
]),
|
||||
dbc.Tab(label="Map", tab_id="map", children=[maps]),
|
||||
dbc.Tab(label="Control", tab_id="control", children=html.Iframe(
|
||||
src=request.url_root + "control?header=false",
|
||||
src=dash_app.config.requests_pathname_prefix + "control?header=false",
|
||||
style={"position": "absolute",
|
||||
"height": "100%",
|
||||
"width": "100%",
|
||||
|
||||
Reference in New Issue
Block a user