If SMSD is not running, calls to InjectSMS and GetStatus cause python to quit
To replicate:
- Install gammu-smsd (and gammu if needed)
- Install or compile the binary distribution of python-gammu
- Prepare a working gammu-smsdrc -file (depending on the distro)
- Run the following python code
import gammu
smsd = gammu.SMSD('/path/to/gammu-smsdrc')
smsd.GetStatus()
# Or alternatively, attempt to send an SMS
smsd.InjectSMS([ {
'Text': 'This is a test',
'SMSC': {'Location': 1},
'Number': '+1555123456'
}])
Expected results: python-gammu raises an exception or returns an appropriate error value. Actual results: the python interpreter exits. See below:
~ # ipython
Python 3.6.3 (default, Nov 21 2017, 14:55:19)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import gammu
In [2]: smsd = gammu.SMSD('/etc/gammu-smsdrc')
In [3]: smsd.GetStatus()
python-gammu[1065]: Failed to allocate shared memory segment!, Error 2: No such file or directory
~ #
# Exit code is 255
OS: Alpine Linux 3.7 Gammu SMSD version: 1.38.5 python-gammu version: 2.11 (installed from source via pip) Python version: 3.6.3
This is particularly annoying, since gammu.SMSD.Shutdown() raises an exception (ERR_NOTRUNNING) which is catchable. In the use case here, we cannot assume the SMSD is always running, thus GetStatus should indicate that without causing the whole program to quit.
The issue also occurs if the SHM is not accessible due to permissions, then the error returned is python-gammu[11522]: Failed to map shared memory segment!, Error 13: Permission denied.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The problem is that Config->exit_on_failure is set by default by Gammu and python-gammu doesn't disable this.
I'm trying to dockerize an app using python:3.6.8-alpine. but in my app I use python-gammu and I don't know how to install that in alpine. can you help me?