From 5faaeb38911bb19f5e88da1c5cd9cf8e255255d3 Mon Sep 17 00:00:00 2001 From: ui-beam-9 Date: Tue, 22 Apr 2025 09:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E5=88=B0v20250414155609?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION.txt | 1 + download_auto_run.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 VERSION.txt diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..6d31a5d --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +v20250414155609 \ No newline at end of file diff --git a/download_auto_run.py b/download_auto_run.py index 056bdad..5c75b08 100644 --- a/download_auto_run.py +++ b/download_auto_run.py @@ -27,7 +27,7 @@ except: # 基本配置 #COS_URL = "http://cos.ui-beam.com/work_scripts/monitor/dev/latest/" -COS_URL = "https://gitea.ui-beam.cn/ui_beam/NetEaseDSMonitor/raw/branch/main/" +COS_URL = "https://gitea.ui-beam.cn/ui_beam/NetEaseDSMonitor/raw/branch/main" TEMP_DIR = os.path.join(os.path.expanduser("~"), "Desktop", "monitor_temp") LOG_FILE = os.path.join(TEMP_DIR, "download_log.txt") @@ -204,17 +204,43 @@ def download_file(url_path, local_path, use_proxy=False): 'https': 'http://CD-WEBPROXY02.yajuenet.internal:8080' }) opener = urllib2.build_opener(proxy_handler) + + # 添加基本身份验证 + username = "bug" + password = "123454678" + auth_string = base64.b64encode('%s:%s' % (username, password)) + opener.addheaders = [('Authorization', 'Basic %s' % auth_string)] + urllib2.install_opener(opener) else: - # 禁用代理 + # 禁用代理,但仍添加基本身份验证 proxy_handler = urllib2.ProxyHandler({}) opener = urllib2.build_opener(proxy_handler) + + # 添加基本身份验证 + username = "bug" + password = "12345678" + auth_string = base64.b64encode('%s:%s' % (username, password)) + opener.addheaders = [('Authorization', 'Basic %s' % auth_string)] + urllib2.install_opener(opener) # 下载文件 response = urllib2.urlopen(full_url, timeout=30) content = response.read() + # 检查是否是批处理文件,如果是则进行行尾转换 + is_batch_file = url_path.lower().endswith('.bat') or url_path.lower().endswith('.cmd') + + if is_batch_file: + log_message("[INFO] 批处理文件行尾转换: %s" % local_path) + # 将LF转换为CRLF + content_str = content.replace('\n', '\r\n') + # 确保没有重复的\r\n + content_str = content_str.replace('\r\r\n', '\r\n') + # 转回二进制 + content = content_str + # 写入文件 with open(full_local_path, 'wb') as f: f.write(content)