Fails to load email provider in docker container
tsudmi opened this issue ยท 4 comments
Describe the bug
Hi,
The library requires a user to be created in a container, otherwise, it will fail with the following error on load:
File "/application/main.py", line 4, in <module>
from notifiers import get_notifier
File "/pyroot/lib/python3.7/site-packages/notifiers/__init__.py", line 2, in <module>
from .core import *
File "/pyroot/lib/python3.7/site-packages/notifiers/core.py", line 331, in <module>
from .providers import _all_providers
File "/pyroot/lib/python3.7/site-packages/notifiers/providers/__init__.py", line 1, in <module>
from . import (
File "/pyroot/lib/python3.7/site-packages/notifiers/providers/email.py", line 15, in <module>
DEFAULT_FROM = f"{getpass.getuser()}@{socket.getfqdn()}"
File "/usr/local/lib/python3.7/getpass.py", line 169, in getuser
return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 1001'
Expected behavior
It would be nice to be able to use the library without creating the user.
Additional context
Python version: 3.7.5
Docker image: python:3.7.5-alpine3.10
Thanks for opening your first issue here! Be sure to follow the issue template! ๐๐๐
Thanks for this! Should be an easy fix, I'll jus change the default in case there's no user.
When 1.2.2 will be released ? I am also facing KeyError: 'getpwuid(): uid not found error.
@tsudmi
Use any of these env variable.
'LOGNAME', 'USER', 'LNAME', 'USERNAME'
getuser() will fetch username from these env variables firsts then it will check with pwd.getpwuid(os.getuid())[0].