Skip to content

Commit

Permalink
fix(huawei): 修复windows系统下异常:embedded null byte
Browse files Browse the repository at this point in the history
- windows7 系统时间格式化含中文导致的异常
Closes #81
  • Loading branch information
lov3smu committed Oct 25, 2023
1 parent f6442f8 commit 4d33728
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions huawei.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# !/usr/bin/python
import locale
import os.path
import sys
import time
from datetime import datetime

Expand Down Expand Up @@ -603,6 +605,9 @@ def __get_sec_kill_time(self):
if tryTimes > 3:
break
try:
if sys.platform.startswith('win'):
locale.setlocale(locale.LC_ALL, 'en')
locale.setlocale(locale.LC_CTYPE, 'chinese')
countdownStr = self.browser.find_element(By.CSS_SELECTOR, "#pro-operation-countdown > p").text
countdownStr = datetime.now().strftime("%Y年") + countdownStr[:-3]
self.secKillTime = datetime.strptime(countdownStr, "%Y年%m月%d日 %H:%M")
Expand Down

0 comments on commit 4d33728

Please sign in to comment.