renhai-lab / sgcc_electricity

本应用可以帮助你将国网的电费、用电量数据接入homeassistant,并且储存到数据库。
159 stars 45 forks source link

最新的1.3.3版本X86 openwrt docker部署有问题,用arm的设备部署1.3.3没有问题。 #28

Open fengshutao opened 11 months ago

fengshutao commented 11 months ago

Attaching to sgcc_electricity sgcc_electricity | 2023-10-06 15:50:47 [INFO ] ---- 程序开始,当前仓库版本 为1.3.3,仓库地址为https://github.com/renhai-lab/sgcc_electricity sgcc_electricity | 2023-10-06 15:50:48 [INFO ] ---- chromium-driver version is 90 sgcc_electricity | 2023-10-06 15:50:48 [INFO ] ---- enable_database_storage 为false,不会储存到数据库 sgcc_electricity | 2023-10-06 15:50:48 [INFO ] ---- 当前登录的用户名为: xxxxxxxxxxxxxx,homeassistant地址为http://192.168.2.244:8123/,程序将在每天04:00 执行 sgcc_electricity | 2023-10-06 15:50:48 [INFO ] ---- 此次为首次运行,等待时 间(FIRST_SLEEP_TIME)为10秒,可在.env中设置 sgcc_electricity | 2023-10-06 15:50:58 [INFO ] ---- patching driver executable /usr/bin/chromedriver sgcc_electricity | 2023-10-06 15:50:58 [INFO ] ---- Webdriver initialized. sgcc_electricity | Traceback (most recent call last): sgcc_electricity | File "/app/data_fetcher.py", line 90, in fetch sgcc_electricity | return self._fetch() sgcc_electricity | File "/app/data_fetcher.py", line 107, in _fetch sgcc_electricity | self._login(driver) sgcc_electricity | File "/app/data_fetcher.py", line 142, in _login sgcc_electricity | driver.get(LOGIN_URL) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/undetected_chromedriver/init.py", line 621, in get_wrapped sgcc_electricity | return orig_get(*args, **kwargs) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/undetected_chromedriver/init.py", line 657, in get sgcc_electricity | return super().get(url) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 441, in get sgcc_electricity | self.execute(Command.GET, {'url': url}) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute sgcc_electricity | self.error_handler.check_response(response) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response sgcc_electricity | raise exception_class(message, screen, stacktrace) sgcc_electricity | selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_CONNECTION_REFUSED sgcc_electricity | (Session info: headless chrome=90.0.4430.212)

以下为DEBUG信息 Attaching to sgcc_electricity sgcc_electricity | 2023-10-06 16:56:02 [INFO ] ---- 程序开始,当前仓库版本为1.3.3,仓库地址为https://github.com/renhai-lab/sgcc_electricity sgcc_electricity | 2023-10-06 16:56:02 [INFO ] ---- chromium-driver version is 90 sgcc_electricity | 2023-10-06 16:56:02 [INFO ] ---- enable_database_storage为false,不会储存到数据库 sgcc_electricity | 2023-10-06 16:56:02 [INFO ] ---- 当前登录的用户名为: xxxxxxxxx,homeassistant地址为http://192.168.2.244:8123/,程序将在每天04:00执行 sgcc_electricity | 2023-10-06 16:56:02 [INFO ] ---- 此次为首次运行,等待时间(FIRST_SLEEP_TIME)为10秒,可在.env中设置 sgcc_electricity | 2023-10-06 16:56:12 [INFO ] ---- patching driver executable /usr/bin/chromedriver sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- found block: sgcc_electricity | b'{window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;}' sgcc_electricity | replacing with: sgcc_electricity | b'{console.log("undetected chromedriver 1337!")} ' sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- patching took us 0.14 seconds sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "chrome", "pageLoadStrategy": "normal", "goog:chromeOptions": {"extensions": [], "binary": "/usr/bin/chromium", "args": ["--incognito", "--window-size=4000,1600", "--no-sandbox", "--disable-gpu", "--disable-dev-shm-usage", "--remote-debugging-host=127.0.0.1", "--remote-debugging-port=43869", "--headless", "--user-data-dir=/tmp/tmp19ddw_xr", "--lang=en-US", "--no-default-browser-check", "--no-first-run", "--no-sandbox", "--test-type", "--headless=chrome", "--window-size=1920,1080", "--start-maximized", "--no-sandbox", "--log-level=0"], "debuggerAddress": "127.0.0.1:43869"}}}} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"90.0.4430.212","chrome":{"chromedriverVersion":"90.0.4430.212 (e3cd97fc771b893b7fd1879196d1215b622c2bed-refs/branch-heads/4430@{#1429})"},"goog:chromeOptions":{"debuggerAddress":"127.0.0.1:43869"},"pageLoadStrategy":"normal","platformName":"","proxy":{},"setWindowRect":false,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"d39ff563b8ed2ba68c3950fc17986fef"}} | headers=HTTPHeaderDict({'Content-Length': '634', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/timeouts {"implicit": 60000} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [INFO ] ---- Webdriver initialized. sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/execute/sync {"script": "return navigator.webdriver", "args": []} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":true} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/goog/cdp/execute {"cmd": "Page.addScriptToEvaluateOnNewDocument", "params": {"source": "\n\n Object.defineProperty(window, \"navigator\", {\n Object.defineProperty(window, \"navigator\", {\n value: new Proxy(navigator, {\n has: (target, key) => (key === \"webdriver\" ? false : key in target),\n get: (target, key) =>\n key === \"webdriver\"\n ? false\n : typeof target[key] === \"function\"\n ? target[key].bind(target)\n : target[key],\n }),\n });\n "}} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":{"identifier":"2"}} | headers=HTTPHeaderDict({'Content-Length': '28', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/execute/sync {"script": "return navigator.userAgent", "args": []} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4430.212 Safari/537.36"} | headers=HTTPHeaderDict({'Content-Length': '125', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/goog/cdp/execute {"cmd": "Network.setUserAgentOverride", "params": {"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"}} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":{}} | headers=HTTPHeaderDict({'Content-Length': '12', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/goog/cdp/execute {"cmd": "Page.addScriptToEvaluateOnNewDocument", "params": {"source": "\n Object.defineProperty(navigator, 'maxTouchPoints', {get: () => 1});\n Object.defineProperty(navigator.connection, 'rtt', {get: () => 100});\n\n // https://github.com/microlinkhq/browserless/blob/master/packages/goto/src/evasions/chrome-runtime.js\n window.chrome = {\n app: {\n isInstalled: false,\n InstallState: {\n DISABLED: 'disabled',\n INSTALLED: 'installed',\n NOT_INSTALLED: 'not_installed'\n },\n RunningState: {\n CANNOT_RUN: 'cannot_run',\n READY_TO_RUN: 'ready_to_run',\n RUNNING: 'running'\n }\n },\n runtime: {\n OnInstalledReason: {\n CHROME_UPDATE: 'chrome_update',\n INSTALL: 'install',\n SHARED_MODULE_UPDATE: 'shared_module_update',\n UPDATE: 'update'\n },\n OnRestartRequiredReason: {\n APP_UPDATE: 'app_update',\n OS_UPDATE: 'os_update',\n PERIODIC: 'periodic'\n },\n PlatformArch: {\n ARM: 'arm',\n ARM64: 'arm64',\n MIPS: 'mips',\n MIPS64: 'mips64',\n X86_32: 'x86-32',\n X86_64: 'x86-64'\n },\n PlatformNaclArch: {\n ARM: 'arm',\n MIPS: 'mips',\n MIPS64: 'mips64',\n X86_32: 'x86-32',\n X86_64: 'x86-64'\n },\n PlatformOs: {\n ANDROID: 'android',\n CROS: 'cros',\n LINUX: 'linux',\n MAC: 'mac',\n OPENBSD: 'openbsd',\n WIN: 'win'\n },\n RequestUpdateCheckStatus: {\n NO_UPDATE: 'no_update',\n THROTTLED: 'throttled',\n UPDATE_AVAILABLE: 'update_available'\n }\n }\n }\n\n // https://github.com/microlinkhq/browserless/blob/master/packages/goto/src/evasions/navigator-permissions.js\n if (!window.Notification) {\n window.Notification = {\n permission: 'denied'\n }\n }\n\n const originalQuery = window.navigator.permissions.query\n window.navigator.permissions.proto.query = parameters =>\n parameters.name === 'notifications'\n ? Promise.resolve({ state: window.Notification.permission })\n : originalQuery(parameters)\n\n const oldCall = Function.prototype.call\n function call() {\n return oldCall.apply(this, arguments)\n }\n Function.prototype.call = call\n\n const nativeToStringFunctionString = Error.toString().replace(/Error/g, 'toString')\n const oldToString = Function.prototype.toString\n\n function functionToString() {\n if (this === window.navigator.permissions.query) {\n return 'function query() { [native code] }'\n }\n if (this === functionToString) {\n return nativeToStringFunctionString\n }\n return oldCall.call(oldToString, this)\n }\n // eslint-disable-next-line\n Function.prototype.toString = functionToString\n "}} sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Remote response: status=200 | data={"value":{"identifier":"3"}} | headers=HTTPHeaderDict({'Content-Length': '28', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- Finished Request sgcc_electricity | 2023-10-06 16:56:13 [DEBUG ] ---- POST http://localhost:57407/session/d39ff563b8ed2ba68c3950fc17986fef/url {"url": "https://www.95598.cn/osgweb/login"} sgcc_electricity | 2023-10-06 16:56:14 [DEBUG ] ---- Remote response: status=500 | data={"value":{"error":"unknown error","message":"unknown error: net::ERR_CONNECTION_REFUSED\n (Session info: headless chrome=90.0.4430.212)","stacktrace":"#0 0x55c5c31c07f9 \u003Cunknown>\n#1 0x55c5c31603b3 \u003Cunknown>\n#2 0x55c5c2ea8016 \u003Cunknown>\n#3 0x55c5c2ea5d4f \u003Cunknown>\n#4 0x55c5c2e931f9 \u003Cunknown>\n#5 0x55c5c2e94045 \u003Cunknown>\n#6 0x55c5c2e93541 \u003Cunknown>\n#7 0x55c5c2e92aba \u003Cunknown>\n#8 0x55c5c2e91ae7 \u003Cunknown>\n#9 0x55c5c2e91f51 \u003Cunknown>\n#10 0x55c5c2eaa0d7 \u003Cunknown>\n#11 0x55c5c2f10d27 \u003Cunknown>\n#12 0x55c5c2effdc2 \u003Cunknown>\n#13 0x55c5c2f109e1 \u003Cunknown>\n#14 0x55c5c2effc93 \u003Cunknown>\n#15 0x55c5c2ed1ce4 \u003Cunknown>\n#16 0x55c5c2ed34d2 \u003Cunknown>\n#17 0x55c5c318c542 \u003Cunknown>\n#18 0x55c5c319bce7 \u003Cunknown>\n#19 0x55c5c319b9e4 \u003Cunknown>\n#20 0x55c5c31a013a \u003Cunknown>\n#21 0x55c5c319c5b9 \u003Cunknown>\n#22 0x55c5c3181e00 \u003Cunknown>\n#23 0x55c5c31b35d2 \u003Cunknown>\n#24 0x55c5c31b3778 \u003Cunknown>\n#25 0x55c5c31cba1f \u003Cunknown>\n#26 0x7f863f859fa3 start_thread\n#27 0x7f863eab006f clone\n"}} | headers=HTTPHeaderDict({'Content-Length': '1114', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) sgcc_electricity | 2023-10-06 16:56:14 [DEBUG ] ---- Finished Request sgcc_electricity | Traceback (most recent call last): sgcc_electricity | File "/app/data_fetcher.py", line 90, in fetch sgcc_electricity | return self._fetch() sgcc_electricity | File "/app/data_fetcher.py", line 107, in _fetch sgcc_electricity | self._login(driver) sgcc_electricity | File "/app/data_fetcher.py", line 142, in _login sgcc_electricity | driver.get(LOGIN_URL) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/undetected_chromedriver/init.py", line 621, in get_wrapped sgcc_electricity | return orig_get(*args, **kwargs) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/undetected_chromedriver/init.py", line 657, in get sgcc_electricity | return super().get(url) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 441, in get sgcc_electricity | self.execute(Command.GET, {'url': url}) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute sgcc_electricity | self.error_handler.check_response(response) sgcc_electricity | File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response sgcc_electricity | raise exception_class(message, screen, stacktrace) sgcc_electricity | selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_CONNECTION_REFUSED sgcc_electricity | (Session info: headless chrome=90.0.4430.212) sgcc_electricity | Stacktrace:

renhai-lab commented 11 months ago

我用windows系统的docker运行镜像1.3.3没有问题,检查一下你的设备的网络、防火墙以及env配置文件

fengshutao commented 11 months ago

我一台arm设备docker跑1.3.3没有问题,X86 istoreos的docker跑的1.3.3就出这个问题

fengshutao commented 11 months ago

是不是要求宿主机安装python3.8以上的环境?我arm宿主机安装有python3.09,X86宿主机没有python

renhai-lab commented 11 months ago

docker容器是一个单独的环境,不会受宿主机python环境的影响。你的问题可能出在网络上吧。

fengshutao commented 11 months ago

arm主机和X86主机同一个网络,配置都是一样的,搞不清楚是哪里的问题,我看其他的issue也有同样的问题

sunjunyan commented 11 months ago

能出个32位的镜像嘛,谢谢啦。