aliyun-controller 0.2.4__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/PKG-INFO +1 -1
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/__init__.py +1 -1
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/dns.py +20 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/screens/dns.py +30 -11
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/PKG-INFO +1 -1
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/pyproject.toml +1 -1
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/README.md +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/app.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/app.tcss +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/billing.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/client.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/config.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/main.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/screens/__init__.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/screens/billing.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/screens/home.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/screens/settings.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/screens/setup.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/ui.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller/widgets.py +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/SOURCES.txt +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/dependency_links.txt +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/entry_points.txt +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/requires.txt +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/top_level.txt +0 -0
- {aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aliyun_controller
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: A Textual TUI for managing Alibaba Cloud services including billing queries and DNS management
|
|
5
5
|
Author-email: Moha-Master <hongkongreporter@outlook.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -128,6 +128,26 @@ def validate_dns_record(rr: str, record_type: str, value: str, ttl: int) -> str
|
|
|
128
128
|
return None
|
|
129
129
|
|
|
130
130
|
|
|
131
|
+
def record_content_changed(record: dict, rr: str, record_type: str, value: str, ttl: int) -> bool:
|
|
132
|
+
"""编辑后的内容是否与现有记录不同。
|
|
133
|
+
|
|
134
|
+
阿里云 UpdateDomainRecord 在 RR/Type/Value 与原记录完全相同时会返回
|
|
135
|
+
``DomainRecordDuplicate``(解析记录已存在),因此调用方必须先做差异判断,
|
|
136
|
+
内容未变化时跳过更新。
|
|
137
|
+
"""
|
|
138
|
+
current_ttl = record.get("TTL")
|
|
139
|
+
try:
|
|
140
|
+
same_ttl = int(current_ttl) == int(ttl)
|
|
141
|
+
except (TypeError, ValueError):
|
|
142
|
+
same_ttl = str(current_ttl) == str(ttl)
|
|
143
|
+
return not (
|
|
144
|
+
str(record.get("RR", "")).strip() == str(rr).strip()
|
|
145
|
+
and str(record.get("Type", "")).upper() == str(record_type).upper()
|
|
146
|
+
and str(record.get("Value", "")).strip() == str(value).strip()
|
|
147
|
+
and same_ttl
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
131
151
|
def sort_records(records: list, sort_type: int, sort_order: int) -> list:
|
|
132
152
|
"""返回排序后的新列表。sort_type: 0 创建时间 / 1 二级域名 / 2 首字母;sort_order: 0 逆序 / 1 正序。"""
|
|
133
153
|
records = list(records)
|
|
@@ -15,6 +15,7 @@ from ..dns import (
|
|
|
15
15
|
DNS_RECORD_TYPES,
|
|
16
16
|
SORT_ORDER_LABELS,
|
|
17
17
|
SORT_TYPE_LABELS,
|
|
18
|
+
record_content_changed,
|
|
18
19
|
sort_records,
|
|
19
20
|
validate_dns_record,
|
|
20
21
|
)
|
|
@@ -364,29 +365,47 @@ class RecordListScreen(PageScreen):
|
|
|
364
365
|
@work(exclusive=True)
|
|
365
366
|
async def _save_record(self, record: dict | None, is_new: bool, data: dict) -> None:
|
|
366
367
|
dns = self.app.get_dns()
|
|
368
|
+
record = record or {}
|
|
367
369
|
enabled = bool(data.get("status", True))
|
|
370
|
+
content_changed = False
|
|
371
|
+
status_changed = False
|
|
372
|
+
if not is_new:
|
|
373
|
+
# 内容与状态分开处理:内容未变化时不调 UpdateDomainRecord,
|
|
374
|
+
# 否则阿里云会以 DomainRecordDuplicate(解析记录已存在)拒绝请求。
|
|
375
|
+
content_changed = record_content_changed(
|
|
376
|
+
record, data["rr"], data["type"], data["value"], data["ttl"]
|
|
377
|
+
)
|
|
378
|
+
status_changed = enabled != _is_enabled(record)
|
|
379
|
+
if not content_changed and not status_changed:
|
|
380
|
+
self.app.notify_warn("未做任何修改")
|
|
381
|
+
return
|
|
368
382
|
|
|
369
|
-
def _apply() ->
|
|
383
|
+
def _apply() -> str:
|
|
370
384
|
if is_new:
|
|
371
385
|
rid = dns.add_domain_record(self.domain_name, data["rr"], data["type"], data["value"], data["ttl"])
|
|
372
386
|
if rid and not enabled:
|
|
373
387
|
dns.set_domain_record_status(rid, "Disable")
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
388
|
+
return "已新增解析记录" if enabled else "已新增解析记录(已禁用)"
|
|
389
|
+
record_id = record.get("RecordId")
|
|
390
|
+
if content_changed:
|
|
391
|
+
dns.update_domain_record(record_id, data["rr"], data["type"], data["value"], data["ttl"])
|
|
392
|
+
if status_changed:
|
|
393
|
+
dns.set_domain_record_status(record_id, "Enable" if enabled else "Disable")
|
|
394
|
+
if content_changed and status_changed:
|
|
395
|
+
return "已更新解析记录并调整启用状态"
|
|
396
|
+
if content_changed:
|
|
397
|
+
return "已更新解析记录"
|
|
398
|
+
return "已启用解析记录" if enabled else "已禁用解析记录"
|
|
382
399
|
|
|
383
400
|
try:
|
|
384
401
|
async with busy(self.app, "正在保存解析记录…", mode="bar"):
|
|
385
|
-
await asyncio.to_thread(_apply)
|
|
402
|
+
message = await asyncio.to_thread(_apply)
|
|
386
403
|
except AliyunApiError as e:
|
|
387
404
|
self.app.notify_err(str(e))
|
|
405
|
+
# 内容与状态是两次独立调用,失败时可能已部分生效;重载列表以反映实际状态
|
|
406
|
+
self._load()
|
|
388
407
|
return
|
|
389
|
-
self.app.notify_ok(
|
|
408
|
+
self.app.notify_ok(message)
|
|
390
409
|
self._load()
|
|
391
410
|
|
|
392
411
|
def _delete_record(self, record: dict) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aliyun_controller
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: A Textual TUI for managing Alibaba Cloud services including billing queries and DNS management
|
|
5
5
|
Author-email: Moha-Master <hongkongreporter@outlook.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aliyun_controller"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.5"
|
|
8
8
|
description = "A Textual TUI for managing Alibaba Cloud services including billing queries and DNS management"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{aliyun_controller-0.2.4 → aliyun_controller-0.2.5}/aliyun_controller.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|