From 13a6297149de4d6c25378fe8c611d97e10528371 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 2 Apr 2024 12:15:12 +0800 Subject: [PATCH] fix macOS python 3.11, [Errno 8] nodename nor servname provided, or not known --- chrome_tixcraft.py | 2 +- config_launcher.py | 2 +- kktix_signout.py | 2 +- kktix_status.py | 2 +- settings.py | 45 +++++++++--------------- webdriver/Maxbotplus_1.0.0/manifest.json | 2 +- 6 files changed, 22 insertions(+), 33 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index b03e0a7..91fe2c3 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -45,7 +45,7 @@ except Exception as exc: print(exc) 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_CONFIG_FILE = "settings.json" diff --git a/config_launcher.py b/config_launcher.py index 8f9a026..6cb716c 100644 --- a/config_launcher.py +++ b/config_launcher.py @@ -23,7 +23,7 @@ import sys import threading 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_CONFIG_FILE = "settings.json" diff --git a/kktix_signout.py b/kktix_signout.py index 0c90837..978f132 100644 --- a/kktix_signout.py +++ b/kktix_signout.py @@ -11,7 +11,7 @@ import requests import asyncio import nodriver as uc -CONST_APP_VERSION = "MaxBot (2024.03.18)" +CONST_APP_VERSION = "MaxBot (2024.03.19)" 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" diff --git a/kktix_status.py b/kktix_status.py index c69b951..acb6bfe 100644 --- a/kktix_status.py +++ b/kktix_status.py @@ -29,7 +29,7 @@ from datetime import datetime import requests -CONST_APP_VERSION = "MaxBot (2024.03.18)" +CONST_APP_VERSION = "MaxBot (2024.03.19)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json" diff --git a/settings.py b/settings.py index f3cc978..fa11b14 100644 --- a/settings.py +++ b/settings.py @@ -50,7 +50,7 @@ try: except Exception as exc: 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_CONFIG_FILE = "settings.json" @@ -601,20 +601,26 @@ def load_translate(): return translate def get_ip_address(): - default_ip = "127.0.0.1" - ip = default_ip + gethostname = None 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] + gethostname = socket.gethostname() except Exception as exc: print(exc) + gethostname = None + + default_ip = "127.0.0.1" + ip = default_ip + if not gethostname is None: try: - ip = socket.gethostname() - except Exception as exc2: - print(exc2) - ip = default_ip + 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)), + 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) + ip = gethostname + + #print("get_ip_address:", ip) return ip def format_config_keyword_for_json(user_input): @@ -3300,23 +3306,6 @@ def clean_tmp_file(): for filepath in remove_file_list: 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(): local_ip = get_ip_address() ip_address = "http://%s:%d/" % (local_ip,CONST_SERVER_PORT) diff --git a/webdriver/Maxbotplus_1.0.0/manifest.json b/webdriver/Maxbotplus_1.0.0/manifest.json index c3ca307..08e56b8 100644 --- a/webdriver/Maxbotplus_1.0.0/manifest.json +++ b/webdriver/Maxbotplus_1.0.0/manifest.json @@ -419,5 +419,5 @@ ] } ], - "version": "1.0.17" + "version": "1.0.18" } \ No newline at end of file