5 Commits

Author SHA1 Message Date
EillesWan
67ea8e1bf5 Merge branch 'master' of https://gitee.com/TriM-Organization/Linglun-Converter 2023-12-24 23:25:14 +08:00
EillesWan
5c2a56dd50 提供检查更新模块,非常人性化 2023-12-24 23:19:36 +08:00
Eilles Wan
0e36dd2418 临时修改测试用,一会更回去 update llc_win_wxPython.py.
Signed-off-by: Eilles Wan <w-yi_doctoryi@outlook.com>
2023-12-24 15:16:39 +00:00
Eilles Wan
50f1b08fc7 测试,等会改回去 update llc_win_wxPython.py.
Signed-off-by: Eilles Wan <w-yi_doctoryi@outlook.com>
2023-12-24 15:10:16 +00:00
Eilles Wan
68d93068bb update docs/download&start_EN/Windows.md.
ok呀,英文OK了

Signed-off-by: Eilles Wan <w-yi_doctoryi@outlook.com>
2023-11-10 11:49:15 +00:00
6 changed files with 206 additions and 46 deletions

1
.gitignore vendored
View File

@@ -11,6 +11,7 @@ __pycache__/
*.bdx
*.json
/Musicreater
/TrimLog
/logs
# C extensions

View File

@@ -1,8 +1,32 @@
## Install Runtime Environment
## Use a Pre-Built Release (Recommended)
### Install Python 3.6+
### 一、Download the Packed Program
1. First of all, you need to install the runtime environment of this library, *Python*. And a Installation Pack maybe the best choice:
1. Fne the newest release in [The Release Page](https://gitee.com/TriM-Organization/Linglun-Converter/releases)
<img src=https://foruda.gitee.com/images/1699105959996885442/be19644e_9911226.png>
Please consider a proper build release that satisfy your device.
### 二、Start Using
2. After downloading, extract the files and then double click `llc_win_wxPython.exe` to run.
<img src=https://foruda.gitee.com/images/1699106497816902973/48dc0942_9911226.png>
<img src=https://foruda.gitee.com/images/1699106542397488143/5638cd3e_9911226.png>
<img src=https://foruda.gitee.com/images/1699106557013748881/70f90fac_9911226.png>
3. Start to use now.
<img src=https://foruda.gitee.com/images/1699106948861444130/30c156bc_9911226.png>
## Run From Source Code (latest functions provided)
### Install Runtime Environment
#### Install Python 3.8+
1. First of all, you need to install the runtime environment of this library, *Python*. But please ensure that the version is above 3.8. Maybe a Installation Pack could be one of the choices:
> [Downloading Python 64-bit](https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe)
> [Downloading Python 32-bit](https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe)
@@ -22,7 +46,7 @@
<img src=https://foruda.gitee.com/images/1659972669907359295/cmd.png>
### Installing Requirements
#### Installing Requirements
1. It's better to open your *Terminal*(CMD/PowerShell/Bash/etc) under Administrator Mode.
@@ -42,14 +66,14 @@
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
## Downloading & Using of this tool
### Downloading & Using of this tool
1. Download This Package and Demo(s)
1. Download This Package
- If you use Git, you can clone this lib via the following commands:
```bash
git clone -b pkgver https://github.com/TriM-Organization/Musicreater.git
git clone https://github.com/TriM-Organization/Linglun-Converter.git
```
- If Git is not installed, you can download the zip package from the code page(from [GitHub](https://github.com/TriM-Organization/Musicreater.git) or [Gitee](https://gitee.com/TriM-Organization/Musicreater.git)). Or you are a Chinese fan having a QQ account, you can [Join the QQ Group 861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr) and get it from our GroupFiles.
@@ -59,9 +83,9 @@
But it should be noticed that you're clear instructed to choose the branch "pkgver" first instead of downloading it directly from the "master" branch, the master branch is now under developing and has no practical use.
2. Start Using Demo(s)
2. Start Using
You can directly double click `magicDemo.py` to run the demo, or follow instructions below using Terminal APP to run it.
You can directly double click `llc_xxx(_xxx).py` to run the demo, or follow instructions below using Terminal APP to run it.
Open your terminal in the directory of this, taking CMD, for example, just enter the directory and enter `cmd` in the path box:
@@ -71,11 +95,11 @@
And enter the commands below:
```bash
python ./magicDemo.py
python ./llc_win_wxPython.py
```
## Addition for Error(s) Using or Installing
### Addition for Error(s) Using or Installing
1. Environment Error of Microsoft Visual C++ Redistributable

View File

@@ -4,8 +4,8 @@
"""
伶伦转换器
Linglun Converter
伶伦转换器 命令行
Linglun Converter CLI
版权所有 © 2023 金羿 & 睿穆开发组
Copyright © 2023 EillesWan & TriM Org.

View File

@@ -1,5 +1,17 @@
# -*- coding: utf-8 -*-
"""
伶伦转换器 WXGUI
Linglun Converter WxPython GUI
版权所有 © 2023 金羿 & 睿穆开发组
Copyright © 2023 EillesWan & TriM Org.
开源相关声明请见 ./License.md
Terms & Conditions: ./Lisense.md
"""
# 导入所需库
import datetime
import os
@@ -19,49 +31,35 @@ from Musicreater.plugin.addonpack import (
)
from Musicreater.plugin.bdxfile import to_BDX_file_in_delay, to_BDX_file_in_score
# import TrimLog
import wx
# from TrimLog import Console, object_constants
from utils.io import myWords, osc, logger, object_constants, TrimLog, is_logging
from utils.update_check import check_update
# from utils.io import prt
# is_logging: bool = True
# osc = object_constants.ObjectStateConstant()
# logger = TrimLog.Logger(
# is_logging=is_logging,
# printing=not osc.isRelease,
# in_suffix=".llc",
# )
WHITE = (242, 244, 246) # F2F4F6
BLACK = (18, 17, 16) # 121110
try:
myWords = (
urllib.request.urlopen(
"https://gitee.com/TriM-Organization/LinglunStudio/raw/master/resources/myWords.txt"
)
.read()
.decode("utf-8")
.strip("\n")
.split("\n")
)
except (ConnectionError, urllib.error.HTTPError) as E:
# logger.warning(f"读取言·论信息发生 互联网连接 错误:\n{E}")
myWords = ["以梦想为驱使 创造属于自己的未来"]
# noinspection PyBroadException
except BaseException as E:
# logger.warning(f"读取言·论信息发生 未知 错误:\n{E}")
myWords = ["灵光焕发 深艺献心"]
__appname__ = "伶伦转换器"
__version__ = "WXGUI 0.0.2"
__version__ = "WXGUI 0.0.3"
__zhver__ = "WX图形界面 预代预版第三次修订"
osc.project_name = __appname__
osc.version = __version__
# osc = object_constants.ObjectStateConstant(
# logging_project_name=__appname__,
# logging_project_version=__version__,
# logging_exit_exec=lambda x: None,
# )
yanlun_length = len(myWords)
logger.info("加载窗口布局……")
# 创建应用程序类
class LinglunConverterApp(wx.App):
@@ -82,7 +80,7 @@ class LingLunMainFrame(wx.Frame):
self,
parent,
id=wx.ID_ANY,
title="{} {}".format(__appname__, __version__),
title="{} {}".format(__appname__, __zhver__),
pos=wx.DefaultPosition,
size=wx.Size(660, 780),
style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
@@ -955,9 +953,14 @@ class LingLunMainFrame(wx.Frame):
).ShowModal()
logger.info("执行应用。")
# 启动应用程序
if __name__ == "__main__":
app = LinglunConverterApp()
check_update(__appname__,"https://gitee.com/TriM-Organization/Linglun-Converter/raw/master/llc_win_wxPython.py",__version__,lambda text:wx.MessageDialog(None,text,"软件更新",wx.ICON_INFORMATION | wx.YES_DEFAULT,).ShowModal(),logger,__zhver__)
app.MainLoop()
# input("按下回车退出……")

View File

@@ -1,6 +1,20 @@
# -*- coding: utf-8 -*-
"""
伶伦转换器 命令行组件
Linglun Converter Command Line IO Component
版权所有 © 2023 金羿 & 睿穆开发组
Copyright © 2023 EillesWan & TriM Org.
开源相关声明请见 ./License.md
Terms & Conditions: ./Lisense.md
"""
import urllib.error
import urllib.request
from typing import Any, Callable, Dict, List, Literal, Optional, Set, TextIO, Tuple
from typing import Any, Callable, Dict, List, Literal, Optional, Set, TextIO, Tuple, Iterable, Sequence
import TrimLog
from TrimLog import Console, object_constants
@@ -11,7 +25,7 @@ MainConsole = Console()
osc = object_constants.ObjectStateConstant()
logger = TrimLog.Logger(
is_logging=is_logging,
printing=not osc.isRelease,
# printing=not osc.is_release,
in_suffix=".llc",
)

118
utils/update_check.py Normal file
View File

@@ -0,0 +1,118 @@
# -*- coding: utf-8 -*-
"""
伶伦转换器 版本检查组件
Linglun Converter Version Checking Component
版权所有 © 2023 金羿 & 睿穆开发组
Copyright © 2023 EillesWan & TriM Org.
开源相关声明请见 ./License.md
Terms & Conditions: ./Lisense.md
"""
from .io import TrimLog, urllib, Sequence, Iterable, Callable, Optional
def is_ver_char(text: str) -> bool:
return text.isnumeric() or text == "."
def cut_ver_str(text: str) -> str:
text += " "
len_of_text = len(text) - 1
i = 0
while i <= len_of_text:
if is_ver_char(text[i]) and (text[i + 1] if i < len_of_text else False):
j = i
while is_ver_char(text[j]) and j < len_of_text:
j += 1
temp_str = text[i:j].strip()
if ("." in temp_str) and (temp_str[0] != ".") and (temp_str[-1] != "."):
return temp_str
i = j
i += 1
return ""
def get_ver_str(text: str) -> Iterable[str]:
text += " "
all_ver_str = []
len_of_text = len(text) - 1
i = 0
while i <= len_of_text:
if is_ver_char(text[i]) and (text[i + 1] if i < len_of_text else False):
j = i
while is_ver_char(text[j]) and j < len_of_text:
j += 1
temp_str = text[i:j].strip()
if ("." in temp_str) and (temp_str[0] != ".") and (temp_str[-1] != "."):
all_ver_str.append(temp_str)
i = j
i += 1
return all_ver_str
def is_ver_bigger(ver_1: Sequence[int], ver_2: Sequence[int]) -> bool:
len_v1 = len(ver_1)
len_v2 = len(ver_2)
for i in range(min(len_v1, len_v2)):
if ver_1[i] == ver_2[i]:
continue
else:
return ver_1[i] > ver_2[i]
return len_v1 > len_v2
def check_update(
appname: str,
get_text_url: str,
version_now: str,
message_show_fun: Callable,
logger: TrimLog.Logger,
version_disp: Optional[str] = None,
):
if not version_disp:
version_disp = version_now
logger.info("当前版本信息:{}".format(version_now))
try:
code_content: str = urllib.request.urlopen(get_text_url).read().decode("utf-8")
except Exception as E: # noinspection PyBroadException
logger.warning("无法获取更新版本信息:{}".format(E))
return
code_content = code_content[code_content.find("__version__") :]
code_content = code_content[code_content.find('"') + 1 :]
version_content = code_content[: code_content.find('"')]
logger.info("已获取更新版本信息:{}".format(version_content))
if is_ver_bigger(
[int(v) for v in cut_ver_str(version_content).split(".")],
[int(v) for v in cut_ver_str(version_now).split(".")],
):
if "__zhver__" in code_content:
code_content = code_content[code_content.find("__zhver__") :]
code_content = code_content[code_content.find('"') + 1 :]
version_content = code_content[: code_content.find('"')]
message_show_fun(
"!有新版本!\n最新的 {app} 已经是 {latest} 版本,当前您正在使用的仍是 {current} 版本,您可以前往下载地址更新。".format(
app=appname, latest=version_content, current=version_disp
)
)
# code_content = code_content[code_content.find('"')+1:]
# version_content = code_content[:code_content.find('"')]
# version_content_len = len(version_content)
# for i in range(version_content_len):
# if is_ver_char(version_content[i]) and (version_content[i+1] if i < version_content.__len__() else False):
# j = i
# while is_ver_char(version_content[j]):j+=1
# return version_content[i:j]
# "".join([version_content[i] for i in range(version_content.__len__()) if is_ver_char(version_content[i]) and ((version_content[i-1] if i > 0 else False) or (version_content[i+1] if i < version_content.__len__() else False))]).split('.')