Better handling of client start locations
This commit is contained in:
2
.github/workflows/pytest.yml
vendored
2
.github/workflows/pytest.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade pip wheel
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-test.txt
|
||||
sudo apt-get install libopenjp2-7
|
||||
|
||||
@@ -27,7 +27,7 @@ async def amain():
|
||||
await client.login(
|
||||
username=os.environ["HIPPO_USERNAME"],
|
||||
password=os.environ["HIPPO_PASSWORD"],
|
||||
start_location=os.environ.get("HIPPO_START_LOCATION", "home"),
|
||||
start_location=os.environ.get("HIPPO_START_LOCATION", "last"),
|
||||
)
|
||||
print("I'm here")
|
||||
await client.send_chat("Hello World!", chat_type=ChatType.SHOUT)
|
||||
|
||||
@@ -12,7 +12,7 @@ from typing import *
|
||||
import aiohttp
|
||||
import multidict
|
||||
|
||||
from hippolyzer.lib.base.datatypes import Vector3
|
||||
from hippolyzer.lib.base.datatypes import Vector3, StringEnum
|
||||
from hippolyzer.lib.base.helpers import proxify, get_resource_filename
|
||||
from hippolyzer.lib.base.message.circuit import Circuit
|
||||
from hippolyzer.lib.base.message.llsd_msg_serializer import LLSDMessageSerializer
|
||||
@@ -35,6 +35,11 @@ from hippolyzer.lib.client.state import BaseClientSession, BaseClientRegion, Bas
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StartLocation(StringEnum):
|
||||
LAST = "last"
|
||||
HOME = "home"
|
||||
|
||||
|
||||
class ClientSettings(Settings):
|
||||
# Off by default for now, the cert validation is a big mess due to LL using an internal CA.
|
||||
SSL_VERIFY: bool = SettingDescriptor(False)
|
||||
@@ -568,9 +573,9 @@ class HippoClient(BaseClientSessionManager):
|
||||
self,
|
||||
username: str,
|
||||
password: str,
|
||||
login_uri: Optional[str] = "",
|
||||
login_uri: Optional[str] = None,
|
||||
agree_to_tos: bool = False,
|
||||
start_location: str = "home"
|
||||
start_location: Union[StartLocation, str, None] = StartLocation.LAST
|
||||
):
|
||||
if self.session:
|
||||
raise RuntimeError("Already logged in!")
|
||||
@@ -578,6 +583,13 @@ class HippoClient(BaseClientSessionManager):
|
||||
if not login_uri:
|
||||
login_uri = self.DEFAULT_LOGIN_URI
|
||||
|
||||
if start_location is None:
|
||||
start_location = StartLocation.LAST
|
||||
|
||||
# This isn't a symbolic start location and isn't a URI, must be a sim name.
|
||||
if start_location not in iter(StartLocation) and not start_location.startswith("uri:"):
|
||||
start_location = f"uri:{start_location}&128&128&128"
|
||||
|
||||
split_username = username.split(" ")
|
||||
if len(split_username) < 2:
|
||||
first_name = split_username[0]
|
||||
@@ -603,7 +615,7 @@ class HippoClient(BaseClientSessionManager):
|
||||
# TODO: What is this?
|
||||
"platform_version": "2.38.0",
|
||||
"read_critical": 0,
|
||||
"start": start_location,
|
||||
"start": str(start_location),
|
||||
"token": "",
|
||||
"version": version("hippolyzer"),
|
||||
"options": list(self._options),
|
||||
|
||||
Reference in New Issue
Block a user