fix macOS python 3.11, [Errno 8] nodename nor servname provided, or not known

master
Your Name 2024-04-02 12:15:12 +08:00
parent 9db9073faa
commit 13a6297149
6 changed files with 22 additions and 33 deletions

View File

@ -45,7 +45,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.03.18)" CONST_APP_VERSION = "MaxBot (2024.03.19)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -23,7 +23,7 @@ import sys
import threading import threading
import webbrowser import webbrowser
CONST_APP_VERSION = "MaxBot (2024.03.18)" CONST_APP_VERSION = "MaxBot (2024.03.19)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -11,7 +11,7 @@ import requests
import asyncio import asyncio
import nodriver as uc import nodriver as uc
CONST_APP_VERSION = "MaxBot (2024.03.18)" CONST_APP_VERSION = "MaxBot (2024.03.19)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"

View File

@ -29,7 +29,7 @@ from datetime import datetime
import requests import requests
CONST_APP_VERSION = "MaxBot (2024.03.18)" CONST_APP_VERSION = "MaxBot (2024.03.19)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json" CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json"

View File

@ -50,7 +50,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.03.18)" CONST_APP_VERSION = "MaxBot (2024.03.19)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -601,20 +601,26 @@ def load_translate():
return translate return translate
def get_ip_address(): def get_ip_address():
gethostname = None
try:
gethostname = socket.gethostname()
except Exception as exc:
print(exc)
gethostname = None
default_ip = "127.0.0.1" default_ip = "127.0.0.1"
ip = default_ip ip = default_ip
if not gethostname is None:
try: try:
ip = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] ip = [l for l in ([ip for ip in socket.gethostbyname_ex(gethostname)[2]
if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)),
s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)]][0][1]]) if l][0][0] socket.SOCK_DGRAM)]][0][1]]) if l][0][0]
except Exception as exc: except Exception as exc:
print(exc) print(exc)
try: ip = gethostname
ip = socket.gethostname()
except Exception as exc2: #print("get_ip_address:", ip)
print(exc2)
ip = default_ip
return ip return ip
def format_config_keyword_for_json(user_input): def format_config_keyword_for_json(user_input):
@ -3300,23 +3306,6 @@ def clean_tmp_file():
for filepath in remove_file_list: for filepath in remove_file_list:
force_remove_file(filepath) force_remove_file(filepath)
def get_ip_address():
default_ip = "127.0.0.1"
ip = default_ip
try:
ip = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2]
if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)),
s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)]][0][1]]) if l][0][0]
except Exception as exc:
print(exc)
try:
ip = socket.gethostname()
except Exception as exc2:
print(exc2)
ip = default_ip
return ip
def btn_copy_ip_clicked(): def btn_copy_ip_clicked():
local_ip = get_ip_address() local_ip = get_ip_address()
ip_address = "http://%s:%d/" % (local_ip,CONST_SERVER_PORT) ip_address = "http://%s:%d/" % (local_ip,CONST_SERVER_PORT)

View File

@ -419,5 +419,5 @@
] ]
} }
], ],
"version": "1.0.17" "version": "1.0.18"
} }