-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting Authentication Failure (cannot access local variable 'driver' where it is not associated with a value) #116
Comments
Same error also happens running in docker |
Workaround is to upgrade Chrome (google-chrome-stable). Here's how I did it in docker:
BEFORE:
AFTER:
|
Since the dockerfile doesn't pin package versions, presumably the docker image just needs to be rebuilt and the apt command will pull the later version of the package... Edit: This will rebuild you a new working docker container and tag it: Then you can run the freshly built localsafeway:latest image you just created. Edit2: for future reference for those not as familiar with docker, to cleanup once the main package is updated and you want to delete the local version you just built you can run this to remove and untag the image you created: |
Thanks guys for the local fix, it does work and I updated to use the localsafeway image. |
Not working for me. Current driver version: |
Try in your docker-compose.yaml to change the line: |
Should have been more verbose. I've been cloning the repo, main branch, and building and running it from the locally built version. I do get some build errors when I do the process as you've described but I don't think that matters so much since cloning the repo and building it is effectively the same thing, unless I'm mistaken. |
For those of you using Docker Compose and using the hosted image you can temporarily add the following to get the image updated before
|
I also the method suggested by @tuxthepenguin84 As far as I can tell the chrome debugger doesn't open the listening port. `netstat -lnp `Clipping coupons for Safeway account [email protected] Safeway account: [email protected] During handling of the above exception, another exception occurred: Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): |
I had multiple issues. One of which was PID limits causing the process to not be able to spawn. The recommended solution to build the project locally and deploy that image did end up resolve the base issue. |
Rebuilding like @jvasa mentioned #116 (comment) fixed the issue. |
following @jvasa suggestion in #116 (comment) also fixed it for me (it should also fix #115). originally i was using v0.2.12 and getting this error when i exec'd into the container to run it manually:
when you build from scratch instead of using the prebuilt container, you get a new version of ChromeDriver. since this seems to be a recurring issue, would it make sense to factor out the ChromeDriver install and make it so that it can be upgraded without touching the rest of the safeway-coupon's code? Would it be possible to make a container that keeps ChromeDriver up to date, saving it into a volume that can also be mounted/shared into safeway-coupons container? That way we wouldn't have to rebuild everything from scratch every time. apparently there's some auto updaters like these: https://stackoverflow.com/questions/66018451/how-to-get-the-chromedriver-automatically-updated-through-python-selenium-after but i dont know if these will fit our use case. let me know if i'm on the right track, the next time this breaks, i'll try to automate it. |
This is how I fixed it and setup a connection to the SMTP email account I use:
I have a wrapper script to use |
Applied updates from upstream project template commits: smkent/cookie-python@ef0eb85...7025e55 * 7025e55 Merge pull request #116 from smkent/python-versions |\ | * 0679182 Set python version constraints to exclude 4.0 and above |/ * 2db1e07 Merge pull request #115 from smkent/pypi-fix |\ | * fea08ad Fix cruft metadata, disable test PyPI publishing |/ * 8b31163 Merge pull request #114 from smkent/manage-cookie |\ | * b94ce61 Update project template cruft, dependencies |/ * 45a5e60 Merge pull request #113 from smkent/pypi |\ | * 5a7067d Configure PyPI trusted publishing |/ * b1f4625 Merge pull request #112 from smkent/pypi |\ | * 25c7106 Update `gh-action-pypi-publish` argument names to resolve warnings |/ * 1e22b05 Merge pull request #111 from smkent/python3.13 |\ | * b8f3c04 Add Python 3.13 to CI jobs |/ * 51f6060 Merge pull request #110 from smkent/manage-cookie |\ | * 44dc53a Update project template cruft, dependencies |/ * 2921bf1 Merge pull request #109 from smkent/poetry |\ | * 3ebdf29 Set `pyupgrade` minimum Python version to 3.9 | * 695dd72 Update README for poetry-dynamic-versioning | * d67bbc5 Require `toml` dependency on Python < 3.11 | * 024fe58 Clean up Poetry environments at end of `manage-cookie update` | * 3cb4ee6 Clean up Poetry environments at end of `new_cookie` fixture | * f6bdc98 Migrate `new_cookie` fixture to `conftest.py` | * c375378 Convert `temp_dir` to `Path` in unit tests | * 145dc85 Update virtual env management in unit tests for Poetry 2.0 | * eda1848 Migrate to Poetry 2.0 |/ * dee411e Merge pull request #107 from smkent/poetry |\ | * 42c4a3b Update Poetry to version 1.8 in CI workflows * | 8831a68 Merge pull request #108 from smkent/manage |\ \ | |/ |/| | * 296f6b5 Fix CODECOV_TOKEN reference rendering in template CI workflow |/ * 9404738 Merge pull request #106 from smkent/manage |\ | * c3a564f Add get_branch() to mock repo response in manage unit tests | * b4dd69d Add html_url to mock repo response in manage unit tests | * ae30c7c Improve GitHub API/repo interactions in manage-cookie * | 36c238b Merge pull request #105 from smkent/manage-cookie |\ \ | |/ |/| | * b0dc20f Update project template cruft, dependencies |/ * 9cedf76 Merge pull request #104 from smkent/actions |\ | * c85a1a5 Add CODECOV_TOKEN to codecov action in CI workflow | * 6624aeb Update Github action versions |/ * 9e52fa1 Merge pull request #103 from smkent/manage-cookie |\ | * 36078ed Update dependencies |/ * 9313b3e Merge pull request #102 from smkent/temp-cache-dir |\ | * 4f47bdc Use temp dir for Poetry cache directory in manage-cookie |/ * 95be994 Merge pull request #101 from smkent/manage-cookie |\ | * 22e3bcf Apply automatic linting fixes | * 4faeb9b Update dependencies |/ * b7ed95d Merge pull request #100 from smkent/manage-cookie * 97c1031 Update project template cruft, dependencies Updated project dependencies via `poetry update`: Package operations: 2 installs, 53 updates, 1 removal - Removing setuptools (69.1.1) - Updating attrs (23.2.0 -> 24.3.0) - Updating idna (3.6 -> 3.10) - Updating six (1.16.0 -> 1.17.0) - Updating certifi (2024.2.2 -> 2024.12.14) - Updating charset-normalizer (3.3.2 -> 3.4.1) - Updating markupsafe (2.1.5 -> 3.0.2) - Updating pygments (2.17.2 -> 2.19.1) - Updating smmap (5.0.1 -> 5.0.2) - Updating trio (0.24.0 -> 0.28.0) - Updating types-python-dateutil (2.8.19.20240106 -> 2.9.0.20241206) - Updating urllib3 (2.2.1 -> 2.3.0) - Updating click (8.1.7 -> 8.1.8) - Updating distlib (0.3.8 -> 0.3.9) - Updating filelock (3.13.1 -> 3.16.1) - Updating gitdb (4.0.11 -> 4.0.12) - Updating jinja2 (3.1.3 -> 3.1.5) - Updating pbr (6.0.0 -> 6.1.0) - Updating platformdirs (4.2.0 -> 4.3.6) - Updating packaging (23.2 -> 24.2) - Updating pycodestyle (2.9.1 -> 2.12.1) - Updating pyflakes (2.5.0 -> 3.2.0) - Updating pluggy (1.4.0 -> 1.5.0) - Updating requests (2.31.0 -> 2.32.3) - Updating pyyaml (6.0.1 -> 6.0.2) - Updating rich (13.7.1 -> 13.9.4) - Installing shellingham (1.5.4) - Updating typing-extensions (4.10.0 -> 4.12.2) - Installing websocket-client (1.8.0) - Updating coverage (7.4.3 -> 7.6.10) - Updating flake8 (5.0.4 -> 7.1.1) - Updating gitpython (3.1.42 -> 3.1.44) - Updating identify (2.5.35 -> 2.6.5) - Updating marshmallow (3.21.1 -> 3.25.1) - Updating nodeenv (1.8.0 -> 1.9.1) - Updating pytest (8.0.2 -> 8.3.4) - Updating selenium (4.18.1 -> 4.27.1) - Updating stevedore (5.2.0 -> 5.4.0) - Updating termcolor (2.4.0 -> 2.5.0) - Updating typer (0.9.0 -> 0.15.1) - Updating virtualenv (20.25.1 -> 20.28.1) - Updating websockets (12.0 -> 14.1) - Updating bandit (1.7.7 -> 1.8.2) - Updating black (24.2.0 -> 24.10.0) - Updating cruft (2.15.0 -> 2.16.0) - Updating dataclasses-json (0.6.4 -> 0.6.7) - Updating flake8-bugbear (23.3.12 -> 24.12.12) - Updating mypy (1.8.0 -> 1.14.1) - Updating pep8-naming (0.13.3 -> 0.14.1) - Updating poethepoet (0.25.0 -> 0.32.1) - Updating pre-commit (3.5.0 -> 4.0.1) - Updating pytest-cov (4.1.0 -> 6.0.0) - Updating pytest-mock (3.12.0 -> 3.14.0) - Updating responses (0.25.0 -> 0.25.6) - Updating types-requests (2.31.0.20240218 -> 2.32.0.20241016) - Updating webdriver-manager (3.9.1 -> 4.0.2) Writing lock file
Getting this error:
Error: Authentication Failure (cannot access local variable 'driver' where it is not associated with a value)
<<<<<<
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/session.py", line 69, in _chrome_driver
with chrome_driver(headless=headless) as driver:
File "/usr/local/lib/python3.12/contextlib.py", line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/chrome_driver.py", line 38, in chrome_driver
driver = uc.Chrome(options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/undetected_chromedriver/init.py", line 466, in init
super(Chrome, self).init(
File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in init
super().init(
File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 61, in init
super().init(command_executor=executor, options=options)
File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in init
self.start_session(capabilities)
File "/usr/local/lib/python3.12/site-packages/undetected_chromedriver/init.py", line 724, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:60161
from session not created: This version of ChromeDriver only supports Chrome version 123
Current browser version is 122.0.6261.94
Stacktrace:
#0 0x556b10a59993
#1 0x556b10754136
#2 0x556b1078e3bb
#3 0x556b1078d585
#4 0x556b10783ebb
#5 0x556b107cd239
#6 0x556b107c0a73
#7 0x556b10791c93
#8 0x556b1079265e
#9 0x556b10a1e08b
#10 0x556b10a22005
#11 0x556b10a0c491
#12 0x556b10a22b92
#13 0x556b109f19ef
#14 0x556b10a48df8
#15 0x556b10a48fcb
#16 0x556b10a58ae4
#17 0x7fafa5a8a134
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/session.py", line 58, in init
self._login(account)
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/session.py", line 95, in _login
with self._chrome_driver() as driver:
File "/usr/local/lib/python3.12/contextlib.py", line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/session.py", line 76, in _chrome_driver
driver.save_screenshot(path)
^^^^^^
UnboundLocalError: cannot access local variable 'driver' where it is not associated with a value
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/safeway-coupons", line 8, in
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/app.py", line 125, in main
sc.clip_for_account(account)
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/safeway.py", line 38, in clip_for_account
swy = SafewayClient(account, self.debug_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/client.py", line 17, in init
self.session = LoginSession(account, debug_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/safeway_coupons/session.py", line 64, in init
raise AuthenticationFailure(e, account) from e
safeway_coupons.errors.AuthenticationFailure: Authentication Failure (cannot access local variable 'driver' where it is not associated with a value)
The text was updated successfully, but these errors were encountered: