kopia lustrzana https://codeberg.org/argrento/huami-token
main: add wheel build
* rearrange folder structure * ci tests for wheel and module callpip-support
rodzic
4c555ee971
commit
2cc2f4f848
|
@ -7,4 +7,5 @@ __pycache__
|
||||||
*.fw
|
*.fw
|
||||||
*.bin
|
*.bin
|
||||||
venv
|
venv
|
||||||
.mypy_cache
|
.mypy_cache
|
||||||
|
dist
|
|
@ -9,7 +9,7 @@ pipeline:
|
||||||
- python -m pip install pylint flake8 mypy>=0.971
|
- python -m pip install pylint flake8 mypy>=0.971
|
||||||
- python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
- python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
- mypy --strict ./
|
- mypy --strict ./
|
||||||
- python -m pylint -f parseable ./*.py
|
- python -m pylint -f parseable huami_token/*.py
|
||||||
|
|
||||||
unit_tests:
|
unit_tests:
|
||||||
image: python:${TAG}-buster
|
image: python:${TAG}-buster
|
||||||
|
@ -24,9 +24,50 @@ pipeline:
|
||||||
- pytest tests/
|
- pytest tests/
|
||||||
secrets: [ amazfit_email, amazfit_password ]
|
secrets: [ amazfit_email, amazfit_password ]
|
||||||
|
|
||||||
|
wheel_build:
|
||||||
|
image: python:${TAG}-buster
|
||||||
|
commands:
|
||||||
|
- python -m pip install --upgrade pip build wheel
|
||||||
|
- python -m pip install -r requirements.txt
|
||||||
|
- python -m build
|
||||||
|
|
||||||
|
wheel_test:
|
||||||
|
image: python:${TAG}-buster
|
||||||
|
commands:
|
||||||
|
- python -m pip install --upgrade pip
|
||||||
|
- python -m pip install dist/*.whl
|
||||||
|
- python -m pip install pytest
|
||||||
|
- pytest tests/test_amazfit.py
|
||||||
|
- python -m huami_token -m amazfit -e $AMAZFIT_EMAIL -p $AMAZFIT_PASSWORD -b >/dev/null 2>&1
|
||||||
|
secrets: [ amazfit_email, amazfit_password ]
|
||||||
|
|
||||||
|
publish_release:
|
||||||
|
image: woodpeckerci/plugin-gitea-release
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: api_token
|
||||||
|
base_url: https://codeberg.org
|
||||||
|
files:
|
||||||
|
- "dist/*"
|
||||||
|
target: master
|
||||||
|
checksum: md5
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
secrets: [ api_token ]
|
||||||
|
|
||||||
|
upload_to_index:
|
||||||
|
image: python:3.8-buster
|
||||||
|
commands:
|
||||||
|
- python -m pip install twine
|
||||||
|
- python -m twine check dist/*
|
||||||
|
- python -m twine upload dist/*
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
secrets: [ twine_username, twine_password ]
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
TAG:
|
TAG:
|
||||||
- 3.8
|
- 3.8
|
||||||
- 3.9
|
# - 3.9
|
||||||
- 3.10
|
# - 3.10
|
||||||
- 3.11
|
# - 3.11
|
||||||
|
|
|
@ -29,9 +29,8 @@ because only this login methods are supported. If not, create new Amazfit accoun
|
||||||
with e-mail and password.
|
with e-mail and password.
|
||||||
2. Pair, sync and update your watch with Amazfit App. Your pairing key will be stored on
|
2. Pair, sync and update your watch with Amazfit App. Your pairing key will be stored on
|
||||||
Huami servers.
|
Huami servers.
|
||||||
3. Clone this repo:
|
3. `pip3 install huami_token`
|
||||||
```git clone https://codeberg.org/argrento/huami-token.git```
|
4. Use like this: `python3 -m huami_token ...`
|
||||||
4. Install requirements: `pip3 install -r requirements.txt`
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
"""
|
||||||
|
The huami_token module provides functionalities to retrieve the Bluetooth
|
||||||
|
access token for the watch or band from Huami servers and also to download the
|
||||||
|
AGPS data packs, cep_alm_pak.zip and cep_7days.zip.
|
||||||
|
|
||||||
|
This module consists of the following main components:
|
||||||
|
- HuamiAmazfit: A class that encapsulates all the operations related to
|
||||||
|
token retrieval and AGPS data downloading.
|
||||||
|
- ERRORS: A dictionary mapping error codes to their descriptions.
|
||||||
|
- URLS, PAYLOADS: Constants used for making requests to Huami servers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .huami_token import HuamiAmazfit
|
||||||
|
from .errors import ERRORS
|
||||||
|
from .urls import URLS, PAYLOADS
|
||||||
|
|
||||||
|
__all__ = ["HuamiAmazfit", "ERRORS", "URLS", "PAYLOADS"]
|
|
@ -0,0 +1,8 @@
|
||||||
|
"""
|
||||||
|
Entry point when using huami_token as a module
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .huami_token import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes, too-many-branches
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name, too-many-statements, too-many-locals
|
||||||
|
# pylint: disable=too-many-nested-blocks
|
||||||
# Copyright (c) 2020 Kirill Snezhko
|
# Copyright (c) 2020 Kirill Snezhko
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -31,8 +32,7 @@ import zlib
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import errors
|
from . import errors, urls
|
||||||
import urls
|
|
||||||
|
|
||||||
def encode_uint32(value: int) -> bytes:
|
def encode_uint32(value: int) -> bytes:
|
||||||
"""Convert 4-bytes value into a list with 4 bytes"""
|
"""Convert 4-bytes value into a list with 4 bytes"""
|
||||||
|
@ -295,7 +295,8 @@ class HuamiAmazfit:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main() -> None:
|
||||||
|
""" Main Entry Point """
|
||||||
parser = argparse.ArgumentParser(description="Obtain Bluetooth Auth key from Amazfit "
|
parser = argparse.ArgumentParser(description="Obtain Bluetooth Auth key from Amazfit "
|
||||||
"servers and download AGPS data.")
|
"servers and download AGPS data.")
|
||||||
parser.add_argument("-m",
|
parser.add_argument("-m",
|
||||||
|
@ -417,3 +418,7 @@ if __name__ == "__main__":
|
||||||
print("\nLogged out.")
|
print("\nLogged out.")
|
||||||
else:
|
else:
|
||||||
print("\nError logging out.")
|
print("\nError logging out.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -0,0 +1,33 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["flit_core>=3.4"]
|
||||||
|
build-backend = "flit_core.buildapi"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "huami_token"
|
||||||
|
version = "0.7"
|
||||||
|
authors = [
|
||||||
|
{ name="Kirill Snezhko", email="kirill.snezhko@pm.me" },
|
||||||
|
]
|
||||||
|
description = "This script retrieves the Bluetooth access token for the watch or band from Huami servers. Additionally, it downloads the AGPS data packs, cep_alm_pak.zip and cep_7days.zip."
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.7"
|
||||||
|
classifiers = [
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
]
|
||||||
|
dependencies = [
|
||||||
|
"requests == 2.25.1",
|
||||||
|
"types-requests == 2.25.1"
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
"Homepage" = "https://codeberg.org/argrento/huami-token"
|
||||||
|
"Bug Tracker" = "https://codeberg.org/argrento/huami-token/issues"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
huami_token = "huami_token:main"
|
||||||
|
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
test = ["pytest-pylint==0.18.0", "pytest-flake8==1.0.6"]
|
Ładowanie…
Reference in New Issue