ARC-MX / sgcc_electricity_new

HomeAssistant 国家电网电费查询
Apache License 2.0
337 stars 57 forks source link

运行时报错 #26

Open linfuluan opened 4 months ago

linfuluan commented 4 months ago

运行时报如下错误: sgcc_electricity | 2024-07-07 17:51:48 [INFO ] ---- The current repository version is v1.5.0, and the repository

address is https://github.com/ARC-MX/sgcc_electricity_new.git sgcc_electricity | 2024-07-07 17:51:48.681349512 [E:onnxruntime:Default, env.cc:254 ThreadMain] pthread_setaffinity_np

failed for thread: 14, index: 2, mask: {6, 7, }, error code: 22 error msg: Invalid argument. Specify the number of threads

explicitly so the affinity is not set. sgcc_electricity | 2024-07-07 17:51:48.681456788 [E:onnxruntime:Default, env.cc:254 ThreadMain] pthread_setaffinity_np

failed for thread: 15, index: 3, mask: {8, 9, }, error code: 22 error msg: Invalid argument. Specify the number of threads

explicitly so the affinity is not set. sgcc_electricity | 2024-07-07 17:51:48.688967032 [E:onnxruntime:Default, env.cc:254 ThreadMain] pthread_setaffinity_np

failed for thread: 16, index: 4, mask: {10, 11, }, error code: 22 error msg: Invalid argument. Specify the number of

threads explicitly so the affinity is not set.

然后进行登录并获取到几个月的用电数据,再报如下错误: Traceback (most recent call last): File "/app/data_fetcher.py", line 244, in fetch return self._fetch() File "/app/data_fetcher.py", line 279, in _fetch last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list, month_list, month_usage_list, month_charge_list = self._get_other_data(driver, user_id_list) File "/app/data_fetcher.py", line 427, in _get_other_data self.save_usage_data(driver, user_id_list[i - 1]) File "/app/data_fetcher.py", line 558, in save_usage_data self._click_button(driver, By.XPATH, "//[@id='pane-second']/div[1]/div/label[2]/span[1]") File "/app/data_fetcher.py", line 594, in _click_button click_element = driver.find_element(button_search_type, button_search_key) File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 856, in find_element return self.execute(Command.FIND_ELEMENT, { File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//[@id='pane-second']/div[1]/div/label[2]/span[1]"} (Session info: chrome=120.0.6099.224) Stacktrace:

0 0x560a17bee233

1 0x560a178b80fe

2 0x560a17901ba6

3 0x560a17901cc1

4 0x560a1794f204

5 0x560a1792f44d

6 0x560a1794c680

7 0x560a1792f1a3

8 0x560a178f413e

9 0x560a178f5712

10 0x560a17bc3534

11 0x560a17bc6759

12 0x560a17bc6238

13 0x560a17bc6c05

14 0x560a17bb5abf

15 0x560a17bc6f8e

16 0x560a17b9fc86

17 0x560a17bdf3e5

18 0x560a17bdf5cb

19 0x560a17bed7bf

20 0x7f0780bc0ea7 start_thread

Traceback (most recent call last): File "/app/main.py", line 61, in run_task user_id_list, balance_list, last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list, month_list, month_usage_list, month_charge_list = data_fetcher.fetch() TypeError: cannot unpack non-iterable NoneType object 2024-07-07 18:33:37 [ERROR ] ---- Webdriver quit abnormly, reason: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='pane-second']/div[1]/div/label[2]/span[1]"} (Session info: chrome=120.0.6099.224) Stacktrace:

0 0x560a17bee233

1 0x560a178b80fe

2 0x560a17901ba6

3 0x560a17901cc1

4 0x560a1794f204

5 0x560a1792f44d

6 0x560a1794c680

7 0x560a1792f1a3

8 0x560a178f413e

9 0x560a178f5712

10 0x560a17bc3534

11 0x560a17bc6759

12 0x560a17bc6238

13 0x560a17bc6c05

14 0x560a17bb5abf

15 0x560a17bc6f8e

16 0x560a17b9fc86

17 0x560a17bdf3e5

18 0x560a17bdf5cb

19 0x560a17bed7bf

20 0x7f0780bc0ea7 start_thread

. 5 retry times left. 2024-07-07 18:33:37 [ERROR ] ---- state-refresh task failed, reason is cannot unpack non-iterable NoneType object

我的运行环境为:proxmox 虚拟环境下的lxc容器中安装debian11

ARC-MX commented 4 months ago

参考 https://github.com/ARC-MX/sgcc_electricity_new/issues/7

linfuluan commented 4 months ago

看了https://github.com/ARC-MX/sgcc_electricity_new/issues/7,看了帐号密码没有出现“”,网络也没问题,没有安装梯子,也调大了超时连接的时间为120,但还是不行。感觉是在拿某个网页时没有找到//*[@id='pane-second']/div[1]/div/label[2]/span[1]那个元素。

image

image

改成DEBUG模式,可以看到前面的连接状态还是200,到后面获取元素的时候,状态变成了404,网页都打不开了。 image

是否和最前面的onnxruntime环境错误有关系? image

ARC-MX commented 4 months ago

和onnx无关,你这是获取日用电量时出错,在网页打开日用电量,手动查看一下。问题参考//*[@id='pane-second']/div[1]/div/label[2]/span[1]

linfuluan commented 4 months ago

已解决,我没有签约智能交费,无法获取30天的日电费信息,但我在.env配置文件中把DATA_RETENTION_DAYS=7改成30了,导致出错,改回7就可以了。