Skip to content

Commit

Permalink
Fix cli to use country instead of region
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks committed May 7, 2023
1 parent 218600f commit d74c007
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
27 changes: 13 additions & 14 deletions karcher/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def __init__(
self,
debug: int = 0,
output: str = 'json',
region: Region = Region.EU):
country: str = 'GB'):
self.debug = debug
self.output = output
self.region = region
self.country = country

def print(self, result):
data_variable = getattr(result, 'data', None)
Expand All @@ -64,21 +64,20 @@ def print(self, result):
default='json',
help='Output format. Default: "json"')
@click.option(
'-r',
'--region',
type=click.Choice([Region.EU, Region.US, Region.CN]),
default=Region.EU,
help='Region of the server to query. Default: "eu"')
'-c',
'--country',
default='GB',
help='Country of the server to query. Default: "GB"')
@click.pass_context
def cli(ctx: click.Context, debug: int, output: str, region: Region):
def cli(ctx: click.Context, debug: int, output: str, country: str):
"""Tool for connectiong and getting information from Kärcher Home Robots."""
level = logging.INFO
if debug > 0:
level = logging.DEBUG

logging.basicConfig(level=level)

ctx.obj = GlobalContextObject(debug=debug, output=output, region=region)
ctx.obj = GlobalContextObject(debug=debug, output=output, country=country.upper())


def safe_cli():
Expand All @@ -96,9 +95,9 @@ def safe_cli():
@click.pass_context
@coro
async def urls(ctx: click.Context):
"""Get region information."""
"""Get URL information."""

kh = await KarcherHome.create(region=ctx.obj.region)
kh = await KarcherHome.create(country=ctx.obj.country)
d = await kh.get_urls()

ctx.obj.print(d)
Expand All @@ -112,7 +111,7 @@ async def urls(ctx: click.Context):
async def login(ctx: click.Context, username: str, password: str):
"""Get user session tokens."""

kh = await KarcherHome.create(region=ctx.obj.region)
kh = await KarcherHome.create(country=ctx.obj.country)
ctx.obj.print(kh.login(username, password))


Expand All @@ -125,7 +124,7 @@ async def login(ctx: click.Context, username: str, password: str):
async def devices(ctx: click.Context, username: str, password: str, auth_token: str):
"""List all devices."""

kh = await KarcherHome.create(region=ctx.obj.region)
kh = await KarcherHome.create(country=ctx.obj.country)
if auth_token is not None:
kh.login_token(auth_token, '')
elif username is not None and password is not None:
Expand Down Expand Up @@ -160,7 +159,7 @@ async def device_properties(
device_id: str):
"""Get device properties."""

kh = await KarcherHome.create(region=ctx.obj.region)
kh = await KarcherHome.create(country=ctx.obj.country)
if auth_token is not None:
kh.login_token(auth_token, mqtt_token)
elif username is not None and password is not None:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
name='karcher-home',
packages=['karcher'],
include_package_data=True,
version='0.4',
version='0.4.1',
license='MIT',
description='Kärcher Home Robots client',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Lauris BH',
author_email='[email protected]',
url='https://github.com/lafriks/python-karcher',
download_url='https://github.com/lafriks/python-karcher/releases/download/v0.4/karcher-home-0.4.tar.gz',
download_url='https://github.com/lafriks/python-karcher/releases/download/v0.4.1/karcher-home-0.4.1.tar.gz',
platforms='any',
install_requires=[
'click',
Expand Down

0 comments on commit d74c007

Please sign in to comment.