Skip to main content

飞牛fnOS的Python SDK。

Project description

pyfnos

PyPI GitHub

飞牛fnOS的Python SDK。

注意:这个SDK非官方提供。

项目信息

上手

import asyncio
import argparse

def on_message_handler(message):
    """消息回调处理函数"""
    print(f"收到消息: {message}")


async def main():
    # 解析命令行参数
    parser = argparse.ArgumentParser(description='Fnos客户端')
    parser.add_argument('--user', type=str, required=True, help='用户名')
    parser.add_argument('--password', type=str, required=True, help='密码')
    parser.add_argument('-e', '--endpoint', type=str, default='your-custom-endpoint.com:5666', help='服务器地址 (默认: your-custom-endpoint.com:5666)')
    
    args = parser.parse_args()
    
    client = FnosClient()
    
    # 设置消息回调
    client.on_message(on_message_handler)
    
    # 连接到服务器(必须指定endpoint)
    await client.connect(args.endpoint)

    # 等待连接建立
    await asyncio.sleep(3)

    # 登录
    result = await client.login(args.user, args.password)
    print("登录结果:", result)

    # 发送请求
    await client.request_payload("user.info", {})
    print("已发送请求,等待响应...")
    # 等待一段时间以接收响应
    await asyncio.sleep(5)
    
    # 关闭连接
    await client.close()

# 运行异步主函数
if __name__ == "__main__":
    asyncio.run(main())

参考

类名 方法名 简介
FnosClient __init__ 初始化客户端
FnosClient connect 连接到WebSocket服务器(必填参数:endpoint)
FnosClient login 用户登录方法
FnosClient get_decrypted_secret 获取解密后的secret
FnosClient on_message 设置消息回调函数
FnosClient request 发送请求
FnosClient request_payload 以payload为主体发送请求
FnosClient request_payload_with_response 以payload为主体发送请求并返回响应
FnosClient close 关闭WebSocket连接
Store __init__ 初始化Store类
Store general 请求存储通用信息
ResourceMonitor __init__ 初始化ResourceMonitor类
ResourceMonitor cpu 请求CPU资源监控信息
ResourceMonitor gpu 请求GPU资源监控信息
ResourceMonitor memory 请求内存资源监控信息
SAC __init__ 初始化SAC类
SAC ups_status 请求UPS状态信息
SystemInfo __init__ 初始化SystemInfo类
SystemInfo get_host_name 请求主机名信息
SystemInfo get_trim_version 请求Trim版本信息
SystemInfo get_machine_id 请求机器ID信息
SystemInfo get_hardware_info 请求硬件信息
SystemInfo get_uptime 请求系统运行时间信息

命令行参数

示例程序支持以下命令行参数:

  • --user: 用户名(必填)
  • --password: 密码(必填)
  • -e, --endpoint: 服务器地址(可选,默认为 your-custom-endpoint.com:5666)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fnos-0.4.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fnos-0.4.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file fnos-0.4.0.tar.gz.

File metadata

  • Download URL: fnos-0.4.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for fnos-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3c859b70e1cb26f171671d477599f49ee59625aa3c3b9bc9ac940169a625639d
MD5 ea2a095926b7d812a1412fb80d4acacf
BLAKE2b-256 d851679e9a328e272ebc76c59bc551ecd5da2c7e9d8f312187c65ab286101b39

See more details on using hashes here.

File details

Details for the file fnos-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: fnos-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for fnos-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bdc0a732eb5b7686ed38734c85078be551796a099ee58155e0ee005ce51771e
MD5 970e069e9ba192dd2e065506d9e263cb
BLAKE2b-256 f27229b1384bc1fa62690fc411deaa6ad611e118f3865a21ae8ba783bf90827d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page