[Python-modules-commits] [python-gammu] 01/04: Imported Upstream version 2.5
Michal Cihar
nijel at moszumanska.debian.org
Tue Jan 19 14:42:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
nijel pushed a commit to branch master
in repository python-gammu.
commit 5198f127cb2e4de0bcf40487d19babf8ebc817a9
Author: Michal Čihař <michal at cihar.com>
Date: Tue Jan 19 15:33:29 2016 +0100
Imported Upstream version 2.5
---
NEWS.rst | 5 ++
PKG-INFO | 4 +-
README.rst | 2 +-
examples/sendlongsms.py | 2 +-
examples/service_numbers.py | 19 ++++++-
gammu/src/gammu.c | 91 ++++++++++++++++++++++++++------
gammu/src/smsd.c | 3 ++
python_gammu.egg-info/PKG-INFO | 4 +-
python_gammu.egg-info/SOURCES.txt | 4 +-
setup.py | 2 +-
test/data/.sqlite.sql.swp | Bin 0 -> 16384 bytes
test/data/{sqlite.sql => sqlite-14.sql} | 0
test/data/{sqlite.sql => sqlite-15.sql} | 3 +-
test/test_dummy.py | 9 +++-
test/test_smsd.py | 25 ++++++++-
15 files changed, 141 insertions(+), 32 deletions(-)
diff --git a/NEWS.rst b/NEWS.rst
index 777d8f0..13ef25a 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -1,3 +1,8 @@
+2.5
+===
+
+* Compatibility with Gammu >= 1.36.7
+
2.4
===
diff --git a/PKG-INFO b/PKG-INFO
index b6241e7..2d00a07 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-gammu
-Version: 2.4
+Version: 2.5
Summary: Gammu bindings
Home-page: http://wammu.eu/python-gammu/
Author: Michal Čihař
@@ -14,7 +14,7 @@ Description: python-gammu
:target: https://travis-ci.org/gammu/python-gammu
.. image:: https://www.codacy.com/project/badge/c7e87df480fb4609aa48482873f5c46b
- :target: https://www.codacy.com/public/michal_2/python-gammu_2
+ :target: https://www.codacy.com/public/nijel/python-gammu
.. image:: https://scrutinizer-ci.com/g/gammu/python-gammu/badges/quality-score.png?b=master
:target: https://scrutinizer-ci.com/g/gammu/python-gammu/?branch=master
diff --git a/README.rst b/README.rst
index 3b574ee..133c5ec 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@ python-gammu
:target: https://travis-ci.org/gammu/python-gammu
.. image:: https://www.codacy.com/project/badge/c7e87df480fb4609aa48482873f5c46b
- :target: https://www.codacy.com/public/michal_2/python-gammu_2
+ :target: https://www.codacy.com/public/nijel/python-gammu
.. image:: https://scrutinizer-ci.com/g/gammu/python-gammu/badges/quality-score.png?b=master
:target: https://scrutinizer-ci.com/g/gammu/python-gammu/?branch=master
diff --git a/examples/sendlongsms.py b/examples/sendlongsms.py
index 36c27fd..22a1d71 100755
--- a/examples/sendlongsms.py
+++ b/examples/sendlongsms.py
@@ -50,7 +50,7 @@ state_machine.Init()
# Create SMS info structure
smsinfo = {
- 'Class': 1,
+ 'Class': -1,
'Unicode': False,
'Entries': [
{
diff --git a/examples/service_numbers.py b/examples/service_numbers.py
index ab7f40a..90fc42d 100755
--- a/examples/service_numbers.py
+++ b/examples/service_numbers.py
@@ -28,15 +28,20 @@ from __future__ import print_function
import gammu
import sys
+REPLY = False
+
def callback(state_machine, callback_type, data):
'''
Callback on USSD data.
'''
+ global REPLY
if callback_type != 'USSD':
print('Unexpected event type: %s' % callback_type)
sys.exit(1)
+ REPLY = True
+
print('Network reply:')
print('Status: %s' % data['Status'])
print(data['Text'])
@@ -68,15 +73,25 @@ def do_service(state_machine):
'''
Main code to talk with worker.
'''
+ global REPLY
+
if len(sys.argv) >= 3:
code = sys.argv[2]
del sys.argv[2]
else:
- print('Enter code (empty string to end):', end=' ')
- code = input()
+ prompt = 'Enter code (empty string to end): '
+ try:
+ code = raw_input(prompt)
+ except NameError:
+ code = input(prompt)
if code != '':
print('Talking to network...')
+ REPLY = False
state_machine.DialService(code)
+ loops = 0
+ while not REPLY and loops < 10:
+ state_machine.ReadDevice()
+ loops += 1
def main():
diff --git a/gammu/src/gammu.c b/gammu/src/gammu.c
index d872743..9dfd0cf 100644
--- a/gammu/src/gammu.c
+++ b/gammu/src/gammu.c
@@ -199,7 +199,15 @@ gammu_set_debug(GSM_Debug_Info *di, PyObject *value, PyObject **debug_object)
*/
static void SendSMSStatus (GSM_StateMachine *s, int status, int mr, void *user) {
StateMachineObject *sm = (StateMachineObject *)user;
- if (sm == NULL) return;
+
+ if (sm == NULL) {
+ pyg_error("Received callback without user pointer!\n");
+ return;
+ }
+ if (sm->s != s) {
+ pyg_error("Callback user pointer doesn't match state machine!\n");
+ return;
+ }
sm->MessageReference = mr;
if (status == 0) {
@@ -216,9 +224,17 @@ static void SendSMSStatus (GSM_StateMachine *s, int status, int mr, void *user)
*/
static void IncomingCall (GSM_StateMachine *s, GSM_Call *call, void *user) {
StateMachineObject *sm = (StateMachineObject *)user;
+ GSM_Call *message;
int i = 0;
- if (sm == NULL) return;
+ if (sm == NULL) {
+ pyg_error("Received callback without user pointer!\n");
+ return;
+ }
+ if (sm->s != s) {
+ pyg_error("Callback user pointer doesn't match state machine!\n");
+ return;
+ }
while (i < MAX_EVENTS && sm->IncomingCallQueue[i] != NULL) i++;
@@ -227,10 +243,13 @@ static void IncomingCall (GSM_StateMachine *s, GSM_Call *call, void *user) {
return;
}
- sm->IncomingCallQueue[i] = (GSM_Call *)malloc(sizeof(GSM_Call));
- if (sm->IncomingCallQueue[i] == NULL) return;
+ message = malloc(sizeof(GSM_Call));
+ if (message == NULL) return;
- *(sm->IncomingCallQueue[i]) = *call;
+ *message = *call;
+
+ sm->IncomingCallQueue[i + 1] = NULL;
+ sm->IncomingCallQueue[i] = message;
}
/**
@@ -238,9 +257,17 @@ static void IncomingCall (GSM_StateMachine *s, GSM_Call *call, void *user) {
*/
static void IncomingSMS (GSM_StateMachine *s, GSM_SMSMessage *msg, void *user) {
StateMachineObject *sm = (StateMachineObject *)user;
+ GSM_SMSMessage *message;
int i = 0;
- if (sm == NULL) return;
+ if (sm == NULL) {
+ pyg_error("Received callback without user pointer!\n");
+ return;
+ }
+ if (sm->s != s) {
+ pyg_error("Callback user pointer doesn't match state machine!\n");
+ return;
+ }
while (i < MAX_EVENTS && sm->IncomingSMSQueue[i] != NULL) i++;
@@ -249,10 +276,13 @@ static void IncomingSMS (GSM_StateMachine *s, GSM_SMSMessage *msg, void *user) {
return;
}
- sm->IncomingSMSQueue[i] = (GSM_SMSMessage *)malloc(sizeof(GSM_SMSMessage));
- if (sm->IncomingSMSQueue[i] == NULL) return;
+ message = malloc(sizeof(GSM_SMSMessage));
+ if (message == NULL) return;
- *(sm->IncomingSMSQueue[i]) = *msg;
+ *message = *msg;
+
+ sm->IncomingSMSQueue[i + 1] = NULL;
+ sm->IncomingSMSQueue[i] = message;
}
/**
@@ -260,9 +290,17 @@ static void IncomingSMS (GSM_StateMachine *s, GSM_SMSMessage *msg, void *user) {
*/
static void IncomingCB (GSM_StateMachine *s, GSM_CBMessage *cb, void *user) {
StateMachineObject *sm = (StateMachineObject *)user;
+ GSM_CBMessage *message;
int i = 0;
- if (sm == NULL) return;
+ if (sm == NULL) {
+ pyg_error("Received callback without user pointer!\n");
+ return;
+ }
+ if (sm->s != s) {
+ pyg_error("Callback user pointer doesn't match state machine!\n");
+ return;
+ }
while (i < MAX_EVENTS && sm->IncomingCBQueue[i] != NULL) i++;
@@ -271,10 +309,13 @@ static void IncomingCB (GSM_StateMachine *s, GSM_CBMessage *cb, void *user) {
return;
}
- sm->IncomingCBQueue[i] = (GSM_CBMessage *)malloc(sizeof(GSM_CBMessage));
- if (sm->IncomingCBQueue[i] == NULL) return;
+ message = malloc(sizeof(GSM_CBMessage));
+ if (message == NULL) return;
+
+ *message = *cb;
- *(sm->IncomingCBQueue[i]) = *cb;
+ sm->IncomingCBQueue[i + 1] = NULL;
+ sm->IncomingCBQueue[i] = message;
}
/**
@@ -282,9 +323,17 @@ static void IncomingCB (GSM_StateMachine *s, GSM_CBMessage *cb, void *user) {
*/
static void IncomingUSSD (GSM_StateMachine *s, GSM_USSDMessage *ussd, void *user) {
StateMachineObject *sm = (StateMachineObject *)user;
+ GSM_USSDMessage *message;
int i = 0;
- if (sm == NULL) return;
+ if (sm == NULL) {
+ pyg_error("Received callback without user pointer!\n");
+ return;
+ }
+ if (sm->s != s) {
+ pyg_error("Callback user pointer doesn't match state machine!\n");
+ return;
+ }
while (i < MAX_EVENTS && sm->IncomingUSSDQueue[i] != NULL) i++;
@@ -293,10 +342,15 @@ static void IncomingUSSD (GSM_StateMachine *s, GSM_USSDMessage *ussd, void *user
return;
}
- sm->IncomingUSSDQueue[i] = (GSM_USSDMessage *)malloc(sizeof(GSM_USSDMessage));
- if (sm->IncomingUSSDQueue[i] == NULL) return;
+ pyg_warning("Adding USSD to queue, position %d\n", i);
- *(sm->IncomingUSSDQueue[i]) = *ussd;
+ message = malloc(sizeof(GSM_USSDMessage));
+ if (message == NULL) return;
+
+ *message = *ussd;
+
+ sm->IncomingUSSDQueue[i + 1] = NULL;
+ sm->IncomingUSSDQueue[i] = message;
}
/**
@@ -5533,6 +5587,9 @@ static PyTypeObject StateMachineType = {
0, /* tp_weaklist */
0, /* tp_del */
0, /* tp_version_tag */
+#ifdef Py_TPFLAGS_HAVE_FINALIZE
+ 0, /* tp_finalize */
+#endif
};
/* End of code for StateMachine objects */
diff --git a/gammu/src/smsd.c b/gammu/src/smsd.c
index 463701d..b9ea268 100644
--- a/gammu/src/smsd.c
+++ b/gammu/src/smsd.c
@@ -301,6 +301,9 @@ static PyTypeObject SMSDType = {
0, /* tp_weaklist */
0, /* tp_del */
0, /* tp_version_tag */
+#ifdef Py_TPFLAGS_HAVE_FINALIZE
+ 0, /* tp_finalize */
+#endif
};
/* End of code for SMSD objects */
diff --git a/python_gammu.egg-info/PKG-INFO b/python_gammu.egg-info/PKG-INFO
index b6241e7..2d00a07 100644
--- a/python_gammu.egg-info/PKG-INFO
+++ b/python_gammu.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-gammu
-Version: 2.4
+Version: 2.5
Summary: Gammu bindings
Home-page: http://wammu.eu/python-gammu/
Author: Michal Čihař
@@ -14,7 +14,7 @@ Description: python-gammu
:target: https://travis-ci.org/gammu/python-gammu
.. image:: https://www.codacy.com/project/badge/c7e87df480fb4609aa48482873f5c46b
- :target: https://www.codacy.com/public/michal_2/python-gammu_2
+ :target: https://www.codacy.com/public/nijel/python-gammu
.. image:: https://scrutinizer-ci.com/g/gammu/python-gammu/badges/quality-score.png?b=master
:target: https://scrutinizer-ci.com/g/gammu/python-gammu/?branch=master
diff --git a/python_gammu.egg-info/SOURCES.txt b/python_gammu.egg-info/SOURCES.txt
index baa81ed..0fcbabe 100644
--- a/python_gammu.egg-info/SOURCES.txt
+++ b/python_gammu.egg-info/SOURCES.txt
@@ -80,13 +80,15 @@ test/test_errors.py
test/test_sms.py
test/test_smsd.py
test/test_worker.py
+test/data/.sqlite.sql.swp
test/data/02.vcs
test/data/UK32Holidays.ics
test/data/bug-779.vcf
test/data/gammu.vcf
test/data/k770.vcs
test/data/rrule.ics
-test/data/sqlite.sql
+test/data/sqlite-14.sql
+test/data/sqlite-15.sql
test/data/gammu-dummy/calendar/2
test/data/gammu-dummy/calendar/22
test/data/gammu-dummy/fs/file5
diff --git a/setup.py b/setup.py
index bba7e05..4959f57 100755
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,7 @@ import os
import codecs
# some defines
-VERSION = '2.4'
+VERSION = '2.5'
GAMMU_REQUIRED = '1.34.0'
README_FILE = os.path.join(os.path.dirname(__file__), 'README.rst')
with codecs.open(README_FILE, 'r', 'utf-8') as readme:
diff --git a/test/data/.sqlite.sql.swp b/test/data/.sqlite.sql.swp
new file mode 100644
index 0000000..271311d
Binary files /dev/null and b/test/data/.sqlite.sql.swp differ
diff --git a/test/data/sqlite.sql b/test/data/sqlite-14.sql
similarity index 100%
copy from test/data/sqlite.sql
copy to test/data/sqlite-14.sql
diff --git a/test/data/sqlite.sql b/test/data/sqlite-15.sql
similarity index 98%
rename from test/data/sqlite.sql
rename to test/data/sqlite-15.sql
index 3dd2747..ab21635 100644
--- a/test/data/sqlite.sql
+++ b/test/data/sqlite-15.sql
@@ -7,7 +7,7 @@ CREATE TABLE gammu (
Version INTEGER NOT NULL DEFAULT '0'
);
-INSERT INTO gammu (Version) VALUES (14);
+INSERT INTO gammu (Version) VALUES (15);
CREATE TABLE inbox (
UpdatedInDB NUMERIC NOT NULL DEFAULT (datetime('now')),
@@ -50,6 +50,7 @@ CREATE TABLE outbox (
SendingTimeOut NUMERIC NOT NULL DEFAULT (datetime('now')),
DeliveryReport TEXT DEFAULT 'default',
CreatorID TEXT NOT NULL,
+ Retries INTEGER DEFAULT '0',
CHECK (Coding IN
('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression')),
CHECK (DeliveryReport IN ('default','yes','no'))
diff --git a/test/test_dummy.py b/test/test_dummy.py
index ebf5fd0..722061e 100644
--- a/test/test_dummy.py
+++ b/test/test_dummy.py
@@ -28,7 +28,7 @@ import datetime
import os.path
DUMMY_DIR = os.path.join(os.path.dirname(__file__), 'data', 'gammu-dummy')
-TEST_FILE = os.path.join(os.path.dirname(__file__), 'data', 'sqlite.sql')
+TEST_FILE = os.path.join(os.path.dirname(__file__), 'data', 'sqlite-14.sql')
CONFIGURATION = '''
# Configuration for Gammu testsuite
@@ -74,6 +74,8 @@ class DummyTest(unittest.TestCase):
class BasicDummyTest(DummyTest):
+ _called = False
+
def test_model(self):
state_machine = self.get_statemachine()
self.assertEqual(state_machine.GetModel()[1], 'Dummy')
@@ -227,15 +229,18 @@ class BasicDummyTest(DummyTest):
'''
Callback on USSD data.
'''
+ self._called = True
self.assertEqual(response, 'USSD')
self.assertEqual(data['Text'], 'Reply for 1234')
self.assertEqual(data['Status'], 'NoActionNeeded')
def test_ussd(self):
+ self._called = False
state_machine = self.get_statemachine()
state_machine.SetIncomingCallback(self.ussd_callback)
state_machine.SetIncomingUSSD()
state_machine.DialService('1234')
+ self.assertTrue(self._called)
def test_sendsms(self):
state_machine = self.get_statemachine()
@@ -254,7 +259,7 @@ class BasicDummyTest(DummyTest):
'from example python script. '
) * 10
smsinfo = {
- 'Class': 1,
+ 'Class': -1,
'Unicode': False,
'Entries': [
{
diff --git a/test/test_smsd.py b/test/test_smsd.py
index 292d9a1..87abb0a 100644
--- a/test/test_smsd.py
+++ b/test/test_smsd.py
@@ -27,7 +27,7 @@ import threading
import time
import sqlite3
-SQLITE_SCRIPT = os.path.join(os.path.dirname(__file__), 'data', 'sqlite.sql')
+
MESSAGE_1 = {
'Text': 'python-gammu testing message',
'SMSC': {'Location': 1},
@@ -40,13 +40,34 @@ MESSAGE_2 = {
}
+def get_script():
+ """Returns SQL script to create database
+
+ It returns correct script matching used Gammu version.
+ """
+ version = tuple(
+ [int(x) for x in gammu.Version()[0].split('.')]
+ )
+
+ if version < (1, 36, 7):
+ dbver = 14
+ else:
+ dbver = 15
+
+ return os.path.join(
+ os.path.dirname(__file__),
+ 'data',
+ 'sqlite-{0}.sql'.format(dbver)
+ )
+
+
class SMSDDummyTest(DummyTest):
def setUp(self):
super(SMSDDummyTest, self).setUp()
database = sqlite3.connect(
os.path.join(self.test_dir, 'smsd.db')
)
- with open(SQLITE_SCRIPT, 'r') as handle:
+ with open(get_script(), 'r') as handle:
database.executescript(handle.read())
def get_smsd(self):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-gammu.git
More information about the Python-modules-commits
mailing list