更新
This commit is contained in:
18
get_machine_code.py
Normal file
18
get_machine_code.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import platform
|
||||||
|
import uuid
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
|
def get_machine_id() -> str:
|
||||||
|
"""生成机器码。
|
||||||
|
|
||||||
|
根据当前系统信息(平台、架构、MAC地址)生成唯一机器码,
|
||||||
|
使用 SHA256 取前16位并转大写,前缀为 HERTZ_STUDIO_。
|
||||||
|
"""
|
||||||
|
system_info = f"{platform.platform()}-{platform.machine()}-{uuid.getnode()}"
|
||||||
|
return 'HERTZ_STUDIO_' + hashlib.sha256(system_info.encode()).hexdigest()[:16].upper()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
machine_code = get_machine_id()
|
||||||
|
print(f"您的机器码是: {machine_code}")
|
||||||
36
setup.py
36
setup.py
@@ -1,9 +1,5 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
import sys
|
import sys
|
||||||
import platform
|
|
||||||
import uuid
|
|
||||||
import hashlib
|
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
package_name = 'hertz_studio_django_xxx'
|
package_name = 'hertz_studio_django_xxx'
|
||||||
@@ -17,23 +13,15 @@ def read_requirements():
|
|||||||
with open("requirements.txt", "r", encoding="utf-8") as f:
|
with open("requirements.txt", "r", encoding="utf-8") as f:
|
||||||
return [line.strip() for line in f if line.strip() and not line.startswith("#")]
|
return [line.strip() for line in f if line.strip() and not line.startswith("#")]
|
||||||
|
|
||||||
# 机器码验证请求
|
|
||||||
def request_verify_machine_code(package_name, machine_code):
|
|
||||||
"""请求验证机器码"""
|
|
||||||
url = "http://activate.hzsystems.cn/api/activate_machine"
|
|
||||||
data = {"package_name": package_name, "machine_code": machine_code}
|
|
||||||
try:
|
|
||||||
response = requests.post(url, json=data, timeout=10)
|
|
||||||
return response.json()
|
|
||||||
except requests.RequestException as e:
|
|
||||||
print(f"机器码验证请求失败: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
# 机器码验证功能
|
# 机器码验证功能
|
||||||
def verify_machine_license():
|
def verify_machine_license():
|
||||||
"""验证机器码"""
|
"""验证机器码"""
|
||||||
|
import platform
|
||||||
|
import uuid
|
||||||
|
import hashlib
|
||||||
|
|
||||||
print("\n" + "="*60)
|
print("\n" + "="*60)
|
||||||
print("欢迎使用 Hertz System xxx!")
|
print("欢迎使用 Hertz System Xxx!")
|
||||||
print("="*60)
|
print("="*60)
|
||||||
print("本软件需要机器码验证才能安装。")
|
print("本软件需要机器码验证才能安装。")
|
||||||
print("请联系作者获取安装权限:hertz studio(563161210@qq.com)")
|
print("请联系作者获取安装权限:hertz studio(563161210@qq.com)")
|
||||||
@@ -47,8 +35,18 @@ def verify_machine_license():
|
|||||||
print("请将此机器码发送给作者进行注册。")
|
print("请将此机器码发送给作者进行注册。")
|
||||||
|
|
||||||
# 请求验证机器码
|
# 请求验证机器码
|
||||||
response = request_verify_machine_code(package_name, machine_id)
|
import requests
|
||||||
if response.get('success') == True:
|
url = "http://activate.hzsystems.cn/api/activate_machine"
|
||||||
|
data = {"package_name": package_name, "machine_code": machine_id}
|
||||||
|
try:
|
||||||
|
response = requests.post(url, json=data, timeout=10)
|
||||||
|
result = response.json()
|
||||||
|
success = result.get('success') == True
|
||||||
|
except requests.RequestException as e:
|
||||||
|
print(f"机器码验证请求失败: {e}")
|
||||||
|
success = False
|
||||||
|
|
||||||
|
if success:
|
||||||
print("=" * 60)
|
print("=" * 60)
|
||||||
print("机器码验证成功!")
|
print("机器码验证成功!")
|
||||||
print("=" * 60)
|
print("=" * 60)
|
||||||
|
|||||||
35
使用手册.md
35
使用手册.md
@@ -1,4 +1,10 @@
|
|||||||
# APP打包步骤
|
# APP打包教程
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
请先运行get_license.py脚本获取机器码!!!
|
||||||
|
并将机器码交给机器码管理人员负责授权!!!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -107,8 +113,29 @@ project_urls={
|
|||||||
|
|
||||||
完成上述的修改后,在终端的项目输入以下命令并回车进行打包
|
完成上述的修改后,在终端的项目输入以下命令并回车进行打包
|
||||||
|
|
||||||
```
|
```bash
|
||||||
python setup.py sdist
|
python setup.py sdist bdist_wheel
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成后会在dist目录下生成一个打包过后的文件
|
运行完成后会在dist目录下生成两个文件,如:
|
||||||
|
|
||||||
|
hertz_studio_django_yolo-1.0.1.tar.gz和hertz_studio_django_yolo-1.0.1-py3-none-any.whl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 七、测试pip下载
|
||||||
|
|
||||||
|
测试时请将下面的hertz_studio_django_yolo-1.0.1-py3-none-any.whl换成你自己生成的文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install dist/hertz_studio_django_yolo-1.0.1-py3-none-any.whl
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 八、将生成的两个文件交给仓库源管理人员上传
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user