Python client library for AXIS real-time information delivery service by Prioris
Project description
axis.py
AXIS リアルタイム情報配信サービス用のPythonクライアントライブラリです。
特徴
- シンプルなデコレータAPI —
@client.on("channel")でメッセージハンドラを登録 - 自動再接続 — Exponential Backoff アルゴリズムによる再接続
- 型付きメッセージモデル — 各チャンネルのメッセージを
dataclassで型定義 - トークン管理 — トークンリフレッシュAPIに対応
対応チャンネル
| チャンネル | 説明 | モデル |
|---|---|---|
eew |
緊急地震速報 (beta) | EEWMessage |
quake-one |
地震概要・震度情報 | QuakeOneMessage |
breaking-news |
ニュース速報 (beta) | BreakingNewsMessage |
jmx-seismology |
気象庁電文(地震) | JMXSeismologyMessage |
jmx-meteorology |
気象庁電文(気象) | JMXMeteorologyMessage |
jmx-volcanology |
気象庁電文(火山) | JMXVolcanologyMessage |
インストール
pip install axis-prioris
使い方
基本
from axis import AxisClient
client = AxisClient(token="YOUR_TOKEN")
@client.on("eew")
def on_eew(message):
print(f"緊急地震速報: M{message.Magnitude} {message.Hypocenter.Name}")
@client.on("quake-one")
def on_quake(message):
print(f"地震情報: {message.headline}")
@client.on("breaking-news")
def on_news(message):
print(f"速報: {message.Title}")
for line in message.Text:
print(f" {line}")
client.start() # ブロッキング接続
全チャンネルの受信
@client.on_all
def on_any(channel, message):
print(f"[{channel}] {message}")
非ブロッキング接続
thread = client.start_async()
# ... 他の処理 ...
client.stop()
thread.join()
接続イベント
@client.on_connect
def connected():
print("AXIS に接続しました")
@client.on_error
def error(err):
print(f"エラー: {err}")
@client.on_close
def closed(code, msg):
print(f"切断 (code={code})")
トークンリフレッシュ
try:
new_token = client.refresh_token()
print(f"トークンを更新しました")
except AxisTokenExpiredError:
print("契約が期限切れです。Webサイトで再発行してください。")
設定オプション
client = AxisClient(
token="YOUR_TOKEN",
auto_reconnect=True, # 自動再接続 (デフォルト: True)
max_retries=10, # 最大再接続回数 (デフォルト: 10)
ping_interval=60, # Heartbeat間隔 秒 (デフォルト: 60)
)
ログ
標準の logging モジュールを使用しています:
import logging
logging.basicConfig(level=logging.INFO)
ライセンス
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file axis_prioris-0.2.1.tar.gz.
File metadata
- Download URL: axis_prioris-0.2.1.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46fab9bfd7886309e347471eb6284e5c83a0618e5eb11aa94c5ad65ac6be1125
|
|
| MD5 |
051277a6460c1e365be13552d9cad2c7
|
|
| BLAKE2b-256 |
3629efd1d85e7cd8978526b430394280599b3c33785f632b3db24732ea7b6471
|
Provenance
The following attestation bundles were made for axis_prioris-0.2.1.tar.gz:
Publisher:
publish.yml on mugicomugi/axis.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
axis_prioris-0.2.1.tar.gz -
Subject digest:
46fab9bfd7886309e347471eb6284e5c83a0618e5eb11aa94c5ad65ac6be1125 - Sigstore transparency entry: 1568434536
- Sigstore integration time:
-
Permalink:
mugicomugi/axis.py@5841a75faadeb0d3339062895879ce74258a986e -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mugicomugi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5841a75faadeb0d3339062895879ce74258a986e -
Trigger Event:
push
-
Statement type:
File details
Details for the file axis_prioris-0.2.1-py3-none-any.whl.
File metadata
- Download URL: axis_prioris-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c946db97205b7ae7b8659471ec25f83da1f92dc36834ad23a962c1d915a204c
|
|
| MD5 |
08fa24871bfa33d2636eaad8f015b46d
|
|
| BLAKE2b-256 |
9a89f9e8deb9e90df1e804f143e9825da2de58babd71a63a1dff7024afbbb927
|
Provenance
The following attestation bundles were made for axis_prioris-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on mugicomugi/axis.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
axis_prioris-0.2.1-py3-none-any.whl -
Subject digest:
7c946db97205b7ae7b8659471ec25f83da1f92dc36834ad23a962c1d915a204c - Sigstore transparency entry: 1568434544
- Sigstore integration time:
-
Permalink:
mugicomugi/axis.py@5841a75faadeb0d3339062895879ce74258a986e -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mugicomugi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5841a75faadeb0d3339062895879ce74258a986e -
Trigger Event:
push
-
Statement type: