Skip to content
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

If SMSD is not running, calls to InjectSMS and GetStatus cause python to quit #29

Open
Diftraku opened this issue Jul 20, 2018 · 2 comments
Labels

Comments

@Diftraku
Copy link

Diftraku commented Jul 20, 2018

To replicate:

  1. Install gammu-smsd (and gammu if needed)
  2. Install or compile the binary distribution of python-gammu
  3. Prepare a working gammu-smsdrc -file (depending on the distro)
  4. 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.

@nijel
Copy link
Member

nijel commented Jul 22, 2018

The problem is that Config->exit_on_failure is set by default by Gammu and python-gammu doesn't disable this.

@nijel nijel added the bug label Jul 22, 2018
@saeedhmt
Copy link

saeedhmt commented Apr 6, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants