Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Ruff

on:
push:
branches: ["master"]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
lint:
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Ruff
run: pip install ruff

- name: Format code
run: ruff --config pyproject.toml format .

- name: Fix lint issues
run: ruff --config pyproject.toml check --fix --exit-zero .

- name: Ensure no remaining lint issues
run: ruff --config pyproject.toml check .
8 changes: 3 additions & 5 deletions netpulse-client/examples/sdk_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
from netpulse_client import NetPulseClient, Device
from netpulse_client import Device, NetPulseClient

# 配置信息
ENDPOINT = "http://localhost:9000"
Expand All @@ -19,7 +18,7 @@

def basic_operations():
print("=== 基础操作示例 ===")

with NetPulseClient(ENDPOINT, API_KEY) as np_client:
# 1. 执行命令
print("\n1. 执行命令")
Expand All @@ -35,6 +34,5 @@ def basic_operations():
print(result.request_id)



if __name__ == "__main__":
basic_operations()
basic_operations()
49 changes: 23 additions & 26 deletions netpulse-client/netpulse_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
NetPulse Client - 网络设备自动化客户端

提供同步和异步的网络设备操作接口支持命令执行和配置推送。
提供同步和异步的网络设备操作接口, 支持命令执行和配置推送。

核心方法与API端点对应):
核心方法 (与API端点对应) :
- exec_command(): 同步执行命令 -> /device/execute
- exec_config(): 同步推送配置 -> /device/execute
- exec_config(): 同步推送配置 -> /device/execute
- bulk_command(): 同步批量执行命令 -> /device/bulk
- bulk_config(): 同步批量推送配置 -> /device/bulk
- aexec_command(): 异步执行命令 -> /device/execute
Expand All @@ -23,34 +23,34 @@
"""

# 核心客户端类
from .async_client import AsyncJobHandle, AsyncNetPulseClient
from .client import NetPulseClient
from .async_client import AsyncNetPulseClient, AsyncJobHandle

# 数据模型
from .models import (
ConnectionArgs, # 主要的连接参数模型
Device, # 向后兼容的Device别名
CommandResult,
ConfigResult,
BatchResult,
JobInfo,
WorkerInfo,
HealthCheckResult,
ConnectionTestResult,
)

# 工具函数
from .models import create_device_request, create_batch_device_request

# 异常类
from .exceptions import (
NetPulseError,
AuthenticationError,
ConnectionError,
JobError,
NetPulseError,
SDKValidationError,
TimeoutError,
ValidationError,
SDKValidationError,
)

# 数据模型
# 工具函数
from .models import (
BatchResult,
CommandResult,
ConfigResult,
ConnectionArgs, # 主要的连接参数模型
ConnectionTestResult,
Device, # 向后兼容的Device别名
HealthCheckResult,
JobInfo,
WorkerInfo,
create_batch_device_request,
create_device_request,
)

__version__ = "0.1.0"
Expand All @@ -60,7 +60,6 @@
"NetPulseClient",
"AsyncNetPulseClient",
"AsyncJobHandle",

# 数据模型
"ConnectionArgs", # 主要的连接参数模型
"Device", # 向后兼容的Device别名
Expand All @@ -71,11 +70,9 @@
"WorkerInfo",
"HealthCheckResult",
"ConnectionTestResult",

# 工具函数
"create_device_request",
"create_batch_device_request",

# 异常类
"NetPulseError",
"AuthenticationError",
Expand All @@ -84,4 +81,4 @@
"TimeoutError",
"ValidationError",
"SDKValidationError",
]
]
Loading