Mys_Goods_Tool icon indicating copy to clipboard operation
Mys_Goods_Tool copied to clipboard

在AidLux中运行时时区错误

Open AITNR opened this issue 2 years ago • 20 comments

Screenshot_2022-05-08-07-23-59-860_com aidlux

AITNR avatar May 07 '22 23:05 AITNR

截图似乎没有上传完整,这里看不到

Ljzd-PRO avatar May 08 '22 04:05 Ljzd-PRO

python脚本时间和手机时间不一样,似乎是时区不对

AITNR avatar May 08 '22 04:05 AITNR

在电脑上是正常的

AITNR avatar May 08 '22 04:05 AITNR

这个是Termux吗

Ljzd-PRO avatar May 08 '22 10:05 Ljzd-PRO

可以先试试最新的,增加了互联网时间校对 https://github.com/Ljzd-PRO/Mys_Goods_Tool/actions/runs/2286519867

Ljzd-PRO avatar May 08 '22 10:05 Ljzd-PRO

是AidLux,酷安里面或者小米应用商城里有

AITNR avatar May 08 '22 11:05 AITNR

也算是Linux,而且AidLux的时间是正确的,只是python脚本的时间错误

AITNR avatar May 08 '22 11:05 AITNR

https://s1.328888.xyz/2022/05/08/4sJ7F.jpg 新版好像完全不行了啊

AITNR avatar May 08 '22 12:05 AITNR

Traceback (most recent call last): File "main.py", line 82, in NtpTime NTP_SERVER).tx_time - time.time() File "/usr/local/lib/python3.7/dist-packages/ntplib.py", line 296, in request addrinfo = socket.getaddrinfo(host, port)[0] File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -8] Servname not supported for ai_socktype

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 73, in class NtpTime(): File "main.py", line 90, in NtpTime print(to_log("WARN", traceback.format_exc())) File "main.py", line 65, in to_log now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(NtpTime.time())) NameError: name 'NtpTime' is not defined

AITNR avatar May 08 '22 12:05 AITNR

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 73, in class NtpTime(): File "main.py", line 90, in NtpTime print(to_log("WARN", traceback.format_exc())) File "main.py", line 65, in to_log now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(NtpTime.time())) NameError: name 'NtpTime' is not defined

这个是由于NtpTime类定义完成之前由于错误引发了日志输出,而日志输出用到了NtpTime的方法导致的。 AidLux我在我的安卓11运行会闪退,你可以测试一下吗?输入python3进入python3界面,然后:

import time
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))

看看两个输出是否正确

Ljzd-PRO avatar May 08 '22 12:05 Ljzd-PRO

如果你的手机root了就在面具隐藏里把AidLux全勾上

AITNR avatar May 08 '22 13:05 AITNR

可以输出,但时间依旧不对

AITNR avatar May 08 '22 13:05 AITNR

对了,好像可以将商品兑换时间提前8小时来将错就错

AITNR avatar May 08 '22 13:05 AITNR

https://s1.328888.xyz/2022/05/08/4TmUX.jpg 先运行export TZ=Asia/Shanghai指令 再输出时间好像就可以了

AITNR avatar May 08 '22 13:05 AITNR

但是新版本依旧运行不了

AITNR avatar May 08 '22 13:05 AITNR

https://s1.328888.xyz/2022/05/08/4T3mC.jpg 这样就正常了,新版本还是无法运行

AITNR avatar May 08 '22 13:05 AITNR

日志输出错误的问题已修复 https://github.com/Ljzd-PRO/Mys_Goods_Tool/commit/f913ab23841a1debb2769ed9100a818d27fe07b8 但是新版本无法获取互联网时间的问题还是不知道什么原因,stackoverflow上面的问题都是别人自己使用socket出错的,而这个可能是ntplib本身的问题。你的python版本和ntplib模块的版本分别是多少呢?

Ljzd-PRO avatar May 08 '22 20:05 Ljzd-PRO

python3.7.3 ntblib0.4.0

AITNR avatar May 08 '22 23:05 AITNR

我为AidLux隐藏了Magisk还是不行😂 可以在python3界面再试一下:

import ntplib
ntplib.NTPClient().request("ntp.aliyun.com").tx_time

看看能不能正常输出一串时间戳 我的ntplib版本也是一样0.4.0,如果不行的话,也可能是python3版本问题,我用的是3.10.0 实在不行的话,我看看自己做个获取NTP互联网时间方法,如果ntplib失败了就调用自己做的方法。

Ljzd-PRO avatar May 09 '22 11:05 Ljzd-PRO

Traceback (most recent call last): File "1.py", line 2, in ntplib.NTPClient().request("ntp.aliyun.com").tx_time File "/usr/local/lib/python3.7/dist-packages/ntplib.py", line 296, in request addrinfo = socket.getaddrinfo(host, port)[0] File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -8] Servname not supported for ai_socktype 依旧不行

AITNR avatar May 09 '22 12:05 AITNR