Dominique Leuenberger 2021-05-10 13:38:43 +00:00 committed by Git OBS Bridge
commit 75da2a86be
4 changed files with 1059 additions and 1 deletions

View File

@ -0,0 +1,437 @@
From 3ad188744cd404705a4ab43c998f4e5f8fef7d7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= <michal@cihar.com>
Date: Tue, 30 Mar 2021 13:03:35 +0200
Subject: [PATCH] Docs: Adjust attributes order to avoid bugs in breathe/sphinx
Using "unsigned const char" crashes it, but "const unsigned char" works.
---
include/gammu-unicode.h | 8 ++++----
libgammu/device/devfunc.c | 2 +-
libgammu/device/devfunc.h | 2 +-
libgammu/gsmstate.c | 16 ++++++++--------
libgammu/gsmstate.h | 14 +++++++-------
libgammu/misc/coding/coding.c | 2 +-
libgammu/misc/coding/coding.h | 2 +-
libgammu/misc/coding/md5.c | 4 ++--
libgammu/phone/alcatel/alcatel.c | 4 ++--
libgammu/phone/nokia/wd2/n3650.c | 4 ++--
libgammu/protocol/alcatel/alcabus.c | 2 +-
libgammu/protocol/at/at.c | 2 +-
libgammu/protocol/nokia/fbus2.c | 4 ++--
libgammu/protocol/nokia/mbus2.c | 2 +-
libgammu/protocol/nokia/phonet.c | 2 +-
libgammu/protocol/obex/obex.c | 2 +-
libgammu/protocol/s60/s60.c | 2 +-
libgammu/protocol/symbian/gnapbus.c | 2 +-
tests/atgen/test_helper.c | 6 +++---
19 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/include/gammu-unicode.h b/include/gammu-unicode.h
index cfd7913aa..56b86665a 100644
--- a/include/gammu-unicode.h
+++ b/include/gammu-unicode.h
@@ -116,22 +116,22 @@ void EncodeHexUnicode(char *dest, const unsigned char *src, size_t len);
*
* \ingroup Unicode
*/
-gboolean mywstrncmp(unsigned const char *a, unsigned const char *b, int num);
+gboolean mywstrncmp(const unsigned char *a, const unsigned char *b, int num);
/**
* Locates unicode substring.
*
* \ingroup Unicode
*/
-unsigned char *mywstrstr(unsigned const char *haystack,
- unsigned const char *needle);
+unsigned char *mywstrstr(const unsigned char *haystack,
+ const unsigned char *needle);
/**
* Compares two unicode strings case insensitive.
*
* \ingroup Unicode
*/
-gboolean mywstrncasecmp(unsigned const char *a, unsigned const char *b, int num);
+gboolean mywstrncasecmp(const unsigned char *a, const unsigned char *b, int num);
/**
* Encode text to UTF-8.
diff --git a/libgammu/device/devfunc.c b/libgammu/device/devfunc.c
index 631afb5c2..d1d4b0800 100644
--- a/libgammu/device/devfunc.c
+++ b/libgammu/device/devfunc.c
@@ -165,7 +165,7 @@ int socket_read(GSM_StateMachine *s UNUSED, void *buf, size_t nbytes, socket_typ
return result;
}
-int socket_write(GSM_StateMachine *s, unsigned const char *buf, size_t nbytes, socket_type hPhone)
+int socket_write(GSM_StateMachine *s, const unsigned char *buf, size_t nbytes, socket_type hPhone)
{
int ret;
size_t actual = 0;
diff --git a/libgammu/device/devfunc.h b/libgammu/device/devfunc.h
index 941e83241..3f6d9da5e 100644
--- a/libgammu/device/devfunc.h
+++ b/libgammu/device/devfunc.h
@@ -16,7 +16,7 @@ int bluetooth_checkservicename(GSM_StateMachine *s, const char *name);
int socket_read(GSM_StateMachine *s, void *buf, size_t nbytes, socket_type hPhone);
-int socket_write(GSM_StateMachine *s, unsigned const char *buf, size_t nbytes, socket_type hPhone);
+int socket_write(GSM_StateMachine *s, const unsigned char *buf, size_t nbytes, socket_type hPhone);
GSM_Error socket_close(GSM_StateMachine *s, socket_type hPhone);
diff --git a/libgammu/gsmstate.c b/libgammu/gsmstate.c
index 0260cc37f..4833a73ab 100644
--- a/libgammu/gsmstate.c
+++ b/libgammu/gsmstate.c
@@ -992,7 +992,7 @@ GSM_Error GSM_AbortOperation(GSM_StateMachine * s)
return ERR_NONE;
}
-GSM_Error GSM_WaitForOnce(GSM_StateMachine *s, unsigned const char *buffer,
+GSM_Error GSM_WaitForOnce(GSM_StateMachine *s, const unsigned char *buffer,
size_t length, int type, int timeout)
{
GSM_Phone_Data *Phone = &s->Phone.Data;
@@ -1035,7 +1035,7 @@ GSM_Error GSM_WaitForOnce(GSM_StateMachine *s, unsigned const char *buffer,
return ERR_TIMEOUT;
}
-GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned const char *buffer,
+GSM_Error GSM_WaitFor (GSM_StateMachine *s, const unsigned char *buffer,
size_t length, int type, int timeout,
GSM_Phone_RequestID request)
{
@@ -1719,7 +1719,7 @@ fail:
return error;
}
-void GSM_DumpMessageText_Custom(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type, const char *text)
+void GSM_DumpMessageText_Custom(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type, const char *text)
{
GSM_Debug_Info *curdi;
@@ -1736,17 +1736,17 @@ void GSM_DumpMessageText_Custom(GSM_StateMachine *s, unsigned const char *messag
}
}
-void GSM_DumpMessageText(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
+void GSM_DumpMessageText(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type)
{
GSM_DumpMessageText_Custom(s, message, messagesize, type, "SENDING frame");
}
-void GSM_DumpMessageTextRecv(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
+void GSM_DumpMessageTextRecv(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type)
{
GSM_DumpMessageText_Custom(s, message, messagesize, type, "RECEIVED frame");
}
-void GSM_DumpMessageBinary_Custom(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type, int direction)
+void GSM_DumpMessageBinary_Custom(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type, int direction)
{
size_t i=0;
GSM_Debug_Info *curdi;
@@ -1764,12 +1764,12 @@ void GSM_DumpMessageBinary_Custom(GSM_StateMachine *s, unsigned const char *mess
}
}
}
-void GSM_DumpMessageBinary(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
+void GSM_DumpMessageBinary(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type)
{
GSM_DumpMessageBinary_Custom(s, message, messagesize, type, 0x01);
}
-void GSM_DumpMessageBinaryRecv(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
+void GSM_DumpMessageBinaryRecv(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type)
{
GSM_DumpMessageBinary_Custom(s, message, messagesize, type, 0x02);
}
diff --git a/libgammu/gsmstate.h b/libgammu/gsmstate.h
index a19071a79..4cfe0a150 100644
--- a/libgammu/gsmstate.h
+++ b/libgammu/gsmstate.h
@@ -408,7 +408,7 @@ typedef struct {
/**
* Writes message to device.
*/
- GSM_Error (*WriteMessage) (GSM_StateMachine *s, unsigned const char *buffer,
+ GSM_Error (*WriteMessage) (GSM_StateMachine *s, const unsigned char *buffer,
size_t length, int type);
/**
* This one is called when character is received from device.
@@ -1511,7 +1511,7 @@ struct _GSM_StateMachine {
*/
GSM_Error GSM_RegisterAllPhoneModules (GSM_StateMachine *s);
-GSM_Error GSM_WaitForOnce (GSM_StateMachine *s, unsigned const char *buffer,
+GSM_Error GSM_WaitForOnce (GSM_StateMachine *s, const unsigned char *buffer,
size_t length, int type, int timeout);
/**
@@ -1526,7 +1526,7 @@ GSM_Error GSM_WaitForOnce (GSM_StateMachine *s, unsigned const char *buffer,
*
* \return Error code, ERR_NONE on sucecss.
*/
-GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned const char *buffer,
+GSM_Error GSM_WaitFor (GSM_StateMachine *s, const unsigned char *buffer,
size_t length, int type, int timeout,
GSM_Phone_RequestID request) WARNUNUSED;
@@ -1548,10 +1548,10 @@ GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned const char *buffer,
GSM_Error GSM_DispatchMessage (GSM_StateMachine *s);
-void GSM_DumpMessageText (GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type);
-void GSM_DumpMessageTextRecv (GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type);
-void GSM_DumpMessageBinary (GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type);
-void GSM_DumpMessageBinaryRecv(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type);
+void GSM_DumpMessageText (GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type);
+void GSM_DumpMessageTextRecv (GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type);
+void GSM_DumpMessageBinary (GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type);
+void GSM_DumpMessageBinaryRecv(GSM_StateMachine *s, const unsigned char *message, size_t messagesize, int type);
void GSM_OSErrorInfo(GSM_StateMachine *s, const char *description);
diff --git a/libgammu/misc/coding/coding.c b/libgammu/misc/coding/coding.c
index 7785ccdac..233012333 100644
--- a/libgammu/misc/coding/coding.c
+++ b/libgammu/misc/coding/coding.c
@@ -1506,7 +1506,7 @@ gboolean mywstrncmp(unsigned const char *a, unsigned const char *b, int num)
}
/* FreeBSD boxes 4.7-STABLE does't have it, although it's ANSI standard */
-gboolean myiswspace(unsigned const char *src)
+gboolean myiswspace(const unsigned char *src)
{
#ifndef HAVE_ISWSPACE
int o;
diff --git a/libgammu/misc/coding/coding.h b/libgammu/misc/coding/coding.h
index 7b57a1266..0a1649b64 100644
--- a/libgammu/misc/coding/coding.h
+++ b/libgammu/misc/coding/coding.h
@@ -30,7 +30,7 @@ typedef unsigned long gammu_int_t;
#endif
/* ---------------------------- Unicode ------------------------------------ */
-gboolean myiswspace (unsigned const char *src);
+gboolean myiswspace (const unsigned char *src);
void ReverseUnicodeString (unsigned char *String);
diff --git a/libgammu/misc/coding/md5.c b/libgammu/misc/coding/md5.c
index d7c9a7869..8877a4119 100644
--- a/libgammu/misc/coding/md5.c
+++ b/libgammu/misc/coding/md5.c
@@ -30,7 +30,7 @@ struct MD5Context {
};
void MD5Init(struct MD5Context *);
-void MD5Update(struct MD5Context *, unsigned const char *, unsigned);
+void MD5Update(struct MD5Context *, const unsigned char *, unsigned);
void MD5Final(unsigned char digest[16], struct MD5Context *);
void MD5Transform(uint32 buf[4], uint32 const in[16]);
@@ -83,7 +83,7 @@ void MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
-void MD5Update(struct MD5Context *ctx, unsigned const char *buf, unsigned len)
+void MD5Update(struct MD5Context *ctx, const unsigned char *buf, unsigned len)
{
uint32 t;
diff --git a/libgammu/phone/alcatel/alcatel.c b/libgammu/phone/alcatel/alcatel.c
index d926f6951..2bc8aae02 100644
--- a/libgammu/phone/alcatel/alcatel.c
+++ b/libgammu/phone/alcatel/alcatel.c
@@ -839,7 +839,7 @@ static GSM_Error ALCATEL_GetFields(GSM_StateMachine *s, int id) {
return ERR_NONE;
}
-static void ALCATEL_DecodeString(GSM_StateMachine *s, unsigned const char *buffer, unsigned char *target, int maxlen)
+static void ALCATEL_DecodeString(GSM_StateMachine *s, const unsigned char *buffer, unsigned char *target, int maxlen)
{
GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
int len;
@@ -864,7 +864,7 @@ static void ALCATEL_DecodeString(GSM_StateMachine *s, unsigned const char *buffe
}
}
-static GSM_Error ALCATEL_EncodeString(GSM_StateMachine *s, unsigned const char *buffer, unsigned char *target, GSM_Alcatel_FieldType type)
+static GSM_Error ALCATEL_EncodeString(GSM_StateMachine *s, const unsigned char *buffer, unsigned char *target, GSM_Alcatel_FieldType type)
{
GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
size_t len;
diff --git a/libgammu/phone/nokia/wd2/n3650.c b/libgammu/phone/nokia/wd2/n3650.c
index 6427db97a..a2515f63c 100644
--- a/libgammu/phone/nokia/wd2/n3650.c
+++ b/libgammu/phone/nokia/wd2/n3650.c
@@ -48,7 +48,7 @@ static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Han
unsigned int len=10,i;
GSM_Error error;
unsigned char *req;
- unsigned const char StartReq[11] = {
+ const unsigned char StartReq[11] = {
N7110_FRAME_HEADER, 0x0D, 0x10, 0x01, 0x07,
0x24, /* len1 */
0x12, /* len2 */
@@ -158,7 +158,7 @@ static GSM_Error N3650_GetFolderInfo(GSM_StateMachine *s, GSM_File *File)
{
int len=10;
unsigned char *req;
- unsigned const char template[11] = {
+ const unsigned char template[11] = {
N7110_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x07,
0x18, /* folder name length + 6 */
0x12, /* folder name length */
diff --git a/libgammu/protocol/alcatel/alcabus.c b/libgammu/protocol/alcatel/alcabus.c
index ea741e8dd..23003050c 100644
--- a/libgammu/protocol/alcatel/alcabus.c
+++ b/libgammu/protocol/alcatel/alcabus.c
@@ -15,7 +15,7 @@
#include "../../gsmcomon.h"
#include "alcabus.h"
-static GSM_Error ALCABUS_WriteMessage (GSM_StateMachine *s, unsigned const char *data, size_t len, int type)
+static GSM_Error ALCABUS_WriteMessage (GSM_StateMachine *s, const unsigned char *data, size_t len, int type)
{
GSM_Protocol_ALCABUSData *d = &s->Protocol.Data.ALCABUS;
unsigned char buffer[1024];
diff --git a/libgammu/protocol/at/at.c b/libgammu/protocol/at/at.c
index 74507168e..eaaadcd85 100644
--- a/libgammu/protocol/at/at.c
+++ b/libgammu/protocol/at/at.c
@@ -11,7 +11,7 @@
#include "../../gsmcomon.h"
#include "at.h"
-static GSM_Error AT_WriteMessage (GSM_StateMachine *s, unsigned const char *buffer,
+static GSM_Error AT_WriteMessage (GSM_StateMachine *s, const unsigned char *buffer,
size_t length, int type)
{
size_t sent=0, i=0;
diff --git a/libgammu/protocol/nokia/fbus2.c b/libgammu/protocol/nokia/fbus2.c
index 1add22d9c..fe3e2d36a 100644
--- a/libgammu/protocol/nokia/fbus2.c
+++ b/libgammu/protocol/nokia/fbus2.c
@@ -28,7 +28,7 @@
static GSM_Error FBUS2_Initialise(GSM_StateMachine *s);
static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s,
- unsigned const char *MsgBuffer,
+ const unsigned char *MsgBuffer,
int MsgLength,
unsigned char MsgType)
{
@@ -76,7 +76,7 @@ static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s,
}
static GSM_Error FBUS2_WriteMessage (GSM_StateMachine *s,
- unsigned const char *MsgBuffer,
+ const unsigned char *MsgBuffer,
size_t MsgLength,
int MsgType)
{
diff --git a/libgammu/protocol/nokia/mbus2.c b/libgammu/protocol/nokia/mbus2.c
index d732b4968..ab6d254a6 100644
--- a/libgammu/protocol/nokia/mbus2.c
+++ b/libgammu/protocol/nokia/mbus2.c
@@ -13,7 +13,7 @@
#include "mbus2.h"
static GSM_Error MBUS2_WriteMessage (GSM_StateMachine *s,
- unsigned const char *MsgBuffer,
+ const unsigned char *MsgBuffer,
size_t MsgLength,
int MsgType)
{
diff --git a/libgammu/protocol/nokia/phonet.c b/libgammu/protocol/nokia/phonet.c
index e483616a4..09bad3b8b 100644
--- a/libgammu/protocol/nokia/phonet.c
+++ b/libgammu/protocol/nokia/phonet.c
@@ -25,7 +25,7 @@
#include "phonet.h"
static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s,
- unsigned const char *MsgBuffer,
+ const unsigned char *MsgBuffer,
size_t MsgLength,
int MsgType)
{
diff --git a/libgammu/protocol/obex/obex.c b/libgammu/protocol/obex/obex.c
index 0d558e171..57f0d7364 100644
--- a/libgammu/protocol/obex/obex.c
+++ b/libgammu/protocol/obex/obex.c
@@ -13,7 +13,7 @@
#include "../../misc/coding/coding.h"
#include "obex.h"
-static GSM_Error OBEX_WriteMessage (GSM_StateMachine *s, unsigned const char *MsgBuffer,
+static GSM_Error OBEX_WriteMessage (GSM_StateMachine *s, const unsigned char *MsgBuffer,
size_t MsgLength, int type)
{
unsigned char *buffer=NULL;
diff --git a/libgammu/protocol/s60/s60.c b/libgammu/protocol/s60/s60.c
index 5df3c6d97..ef3d08b86 100644
--- a/libgammu/protocol/s60/s60.c
+++ b/libgammu/protocol/s60/s60.c
@@ -28,7 +28,7 @@
#include "s60.h"
#include "s60-ids.h"
-static GSM_Error S60_WriteMessage (GSM_StateMachine *s, unsigned const char *MsgBuffer,
+static GSM_Error S60_WriteMessage (GSM_StateMachine *s, const unsigned char *MsgBuffer,
size_t MsgLength, int MsgType)
{
unsigned char *buffer=NULL;
diff --git a/libgammu/protocol/symbian/gnapbus.c b/libgammu/protocol/symbian/gnapbus.c
index 6c945c170..26538fe8d 100644
--- a/libgammu/protocol/symbian/gnapbus.c
+++ b/libgammu/protocol/symbian/gnapbus.c
@@ -11,7 +11,7 @@
#include "../../gsmcomon.h"
#include "gnapbus.h"
-static GSM_Error GNAPBUS_WriteMessage (GSM_StateMachine *s, unsigned const char *MsgBuffer,
+static GSM_Error GNAPBUS_WriteMessage (GSM_StateMachine *s, const unsigned char *MsgBuffer,
size_t MsgLength, int MsgType)
{
unsigned char *buffer=NULL;
diff --git a/tests/atgen/test_helper.c b/tests/atgen/test_helper.c
index 027c4b33d..6c201561f 100644
--- a/tests/atgen/test_helper.c
+++ b/tests/atgen/test_helper.c
@@ -8,7 +8,7 @@
#include "test_helper.h"
ssize_t _ResponseReadDevice(GSM_StateMachine *s, void *buf, size_t nbytes);
-GSM_Error _ResponseWriteMessage(GSM_StateMachine *s, unsigned const char *buffer, size_t length, int type);
+GSM_Error _ResponseWriteMessage(GSM_StateMachine *s, const unsigned char *buffer, size_t length, int type);
#define _BUFFER_SIZE 512
@@ -56,7 +56,7 @@ const unsigned char* last_command(void)
return _echo_buffer.echo;
}
-void set_echo(unsigned const char *buf, const size_t len)
+void set_echo(const unsigned char *buf, const size_t len)
{
if(buf && len > 0) {
memccpy(_echo_buffer.echo, buf, sizeof(*buf), len);
@@ -96,7 +96,7 @@ ssize_t _ResponseReadDevice(GSM_StateMachine *s UNUSED, void *buf, size_t nbytes
return read_len;
}
-GSM_Error _ResponseWriteMessage(GSM_StateMachine *s UNUSED, unsigned const char *buffer, size_t length, int type UNUSED)
+GSM_Error _ResponseWriteMessage(GSM_StateMachine *s UNUSED, const unsigned char *buffer, size_t length, int type UNUSED)
{
if(length) {
GSM_DumpMessageText(s, buffer, length, type);
--
2.30.2

View File

@ -0,0 +1,610 @@
From f57176b3fa30fe224e8792fc58b4c18d5d5fe86a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= <michal@cihar.com>
Date: Tue, 30 Mar 2021 13:27:44 +0200
Subject: [PATCH] Update Python scripts to Python 3
---
admin/generate-gsmnet | 14 +--
contrib/s60/default.py | 168 +++++++++++++++++-----------------
contrib/usbsnoop/decode.py | 4 +-
contrib/usbsnoop/decodexml.py | 6 +-
4 files changed, 96 insertions(+), 96 deletions(-)
diff --git a/admin/generate-gsmnet b/admin/generate-gsmnet
index 2f47d87cd..ad892e895 100755
--- a/admin/generate-gsmnet
+++ b/admin/generate-gsmnet
@@ -17,7 +17,7 @@
# Copyright (c) 2015 - 2018 Michal Cihar <michal@cihar.com>
#
"""Generates gsmnet databse from wikipedia"""
-import urllib
+import urllib.request, urllib.parse, urllib.error
import re
from unidecode import unidecode
@@ -42,10 +42,10 @@ def parse_line(line):
def print_out(result):
for code, name in sorted(result):
- print '\t{{"{0}", "{1}"}},'.format(
+ print('\t{{"{0}", "{1}"}},'.format(
code,
unidecode(name.decode('utf-8')).replace('&amp;', '&')
- )
+ ))
def print_countries(data):
@@ -102,12 +102,12 @@ def print_networks(data):
def main():
- handle = urllib.urlopen(URL)
+ handle = urllib.request.urlopen(URL)
data = handle.read()
print_countries(data)
- print
- print '-' * 80
- print
+ print()
+ print('-' * 80)
+ print()
print_networks(data)
diff --git a/contrib/s60/default.py b/contrib/s60/default.py
index c020e027b..ccb335cdf 100644
--- a/contrib/s60/default.py
+++ b/contrib/s60/default.py
@@ -35,7 +35,7 @@ else:
import socket
import socket as pysocket
-import cPickle
+import pickle
VERSION = '0.6.0'
@@ -98,13 +98,13 @@ class Mobile(object):
def loadConfig(self):
try:
f = file(self.getConfigFilename(), 'rb')
- conf = cPickle.load(f)
+ conf = pickle.load(f)
f.close()
if 'port' in conf:
self.port = conf['port']
if 'useCanvas' in conf:
self.useCanvas = conf['useCanvas']
- except IOError, r:
+ except IOError as r:
pass
def saveConfig(self):
@@ -114,13 +114,13 @@ class Mobile(object):
'port': self.port,
'useCanvas': self.useCanvas,
}
- cPickle.dump(conf, f)
+ pickle.dump(conf, f)
f.close()
- except IOError, r:
+ except IOError as r:
pass
def initUi(self):
- app.title = u"Gammu S60 Remote"
+ app.title = "Gammu S60 Remote"
if self.useCanvas:
self.canvas = Canvas(redraw_callback=self.statusUpdate)
@@ -130,10 +130,10 @@ class Mobile(object):
app.exit_key_handler = self.exitHandler
app.screen = 'normal'
app.menu = [
- (u'About', self.aboutHandler),
- (u'Change port', self.portHandler),
- (u'Toggle Bluetooth', self.toggleHandler),
- (u'Exit', self.exitHandler),
+ ('About', self.aboutHandler),
+ ('Change port', self.portHandler),
+ ('Toggle Bluetooth', self.toggleHandler),
+ ('Exit', self.exitHandler),
]
def statusUpdate(self, rect=None):
@@ -142,14 +142,14 @@ class Mobile(object):
self.canvas.clear((255,255,255))
if self.service:
- self.canvas.text((1,14),u"Service started at port %s" % self.port,0xff0000)
+ self.canvas.text((1,14),"Service started at port %s" % self.port,0xff0000)
else:
- self.canvas.text((1,14),u"Service stopped",0xff0000)
+ self.canvas.text((1,14),"Service stopped",0xff0000)
if self.connected:
- self.canvas.text((1,34), u"Connected to: " + self.client[1], 0x0000ff)
+ self.canvas.text((1,34), "Connected to: " + self.client[1], 0x0000ff)
else:
- self.canvas.text((1,34), u"No active connection", 0x0000ff)
+ self.canvas.text((1,34), "No active connection", 0x0000ff)
def startService(self):
self.service = True
@@ -160,8 +160,8 @@ class Mobile(object):
self.sock.listen(1)
socket.set_security(self.sock, socket.AUTH | socket.AUTHOR)
- socket.bt_advertise_service(u"pys60_remote", self.sock, True, socket.RFCOMM)
- note(u'Listenning on port %d' % self.port)
+ socket.bt_advertise_service("pys60_remote", self.sock, True, socket.RFCOMM)
+ note('Listenning on port %d' % self.port)
self.listen()
@@ -170,7 +170,7 @@ class Mobile(object):
self.service = False
self.statusUpdate()
- socket.bt_advertise_service(u"pys60_remote", self.sock, False, socket.RFCOMM)
+ socket.bt_advertise_service("pys60_remote", self.sock, False, socket.RFCOMM)
self.sock.close()
self.sock = None
@@ -209,7 +209,7 @@ class Mobile(object):
self.connected = True
self.statusUpdate()
address = str(self.client[1])
- note(u'Connected client %s' % address)
+ note('Connected client %s' % address)
self.fos = self.client[0].makefile("w")
self.fis = self.client[0].makefile("r")
@@ -223,16 +223,16 @@ class Mobile(object):
pass
self.disconnect()
- note(u'Disconnected client %s' % address)
+ note('Disconnected client %s' % address)
def send(self, header, *message):
new_message = ""
if len(message) == 1:
- new_message = unicode(message[0])
+ new_message = str(message[0])
else:
for part in message:
- new_message += unicode(part) + str(NUM_SEPERATOR)
+ new_message += str(part) + str(NUM_SEPERATOR)
length = 1000
if len(new_message) > length:
@@ -247,7 +247,7 @@ class Mobile(object):
sentParts += 1
return
- self.fos.write(unicode(str(header) + str(NUM_END_HEADER) + new_message + str(NUM_END_TEXT)).encode("utf8") )
+ self.fos.write(str(str(header) + str(NUM_END_HEADER) + new_message + str(NUM_END_TEXT)).encode("utf8") )
self.fos.flush()
def wait(self):
@@ -256,7 +256,7 @@ class Mobile(object):
parts = data.split(NUM_END_HEADER)
header = int(parts[0])
- message = unicode(parts[1], "utf8")
+ message = str(parts[1], "utf8")
message_parts = message.split(NUM_SEPERATOR)
if (header != NUM_PARTIAL_MESSAGE and self.__partialMessage):
@@ -315,21 +315,21 @@ class Mobile(object):
elif (header == NUM_CONTACTS_DELETE):
id = int(message)
- if id in self.contactDb.keys():
+ if id in list(self.contactDb.keys()):
del self.contactDb[id]
elif (header == NUM_CONTACTS_CHANGE_ADDFIELD):
id = int(message_parts[0])
- type = unicode(message_parts[1])
- location = unicode(message_parts[2])
- value = unicode(message_parts[3])
+ type = str(message_parts[1])
+ location = str(message_parts[2])
+ value = str(message_parts[3])
self.modifyContact("add", id, type, location, value)
elif (header == NUM_CONTACTS_CHANGE_REMOVEFIELD):
id = int(message_parts[0])
- type = unicode(message_parts[1])
- location = unicode(message_parts[2])
- value = unicode(message_parts[3])
+ type = str(message_parts[1])
+ location = str(message_parts[2])
+ value = str(message_parts[3])
self.modifyContact("remove", id, type, location, value)
elif (header == NUM_CALENDAR_REQUEST_COUNT):
@@ -366,8 +366,8 @@ class Mobile(object):
elif (header == NUM_CALENDAR_ENTRY_ADD):
type = str(message_parts[0])
- content = unicode(message_parts[1])
- location = unicode(message_parts[2])
+ content = str(message_parts[1])
+ location = str(message_parts[2])
#start = float(message_parts[3]) if message_parts[3] else 0
if message_parts[3]:
start = float(message_parts[3])
@@ -429,10 +429,10 @@ class Mobile(object):
self.sendMessagesCount()
elif (header == NUM_MESSAGE_SEND_REQUEST):
- name = unicode(message_parts[0])
- phone = unicode(message_parts[1])
+ name = str(message_parts[0])
+ phone = str(message_parts[1])
enc = str(message_parts[2])
- msg = unicode(message_parts[3]).decode('string_escape')
+ msg = str(message_parts[3]).decode('string_escape')
self.sendMessage(name, phone, enc, msg)
elif (header == NUM_SET_READ):
@@ -459,7 +459,7 @@ class Mobile(object):
self.send(NUM_SYSINFO_REPLY_LINE, "free_ram", sysinfo.free_ram())
self.send(NUM_SYSINFO_REPLY_LINE, "pys60_version", e32.pys60_version)
- if sysinfo.active_profile() == u"offline":
+ if sysinfo.active_profile() == "offline":
# Return an error code if the phone is in offline mode
self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", -1)
self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", -1)
@@ -467,7 +467,7 @@ class Mobile(object):
self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", sysinfo.signal_dbm())
self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", sysinfo.signal_bars())
- for drive, free in sysinfo.free_drivespace().iteritems():
+ for drive, free in sysinfo.free_drivespace().items():
self.send(NUM_SYSINFO_REPLY_LINE, "free_drivespace", str(drive) + str(free))
if full:
@@ -484,7 +484,7 @@ class Mobile(object):
fn = self.getScreenshotFilename()
shot = graphics.screenshot()
shot.save(fn)
- note(u'Saved screenshot as %s' % fn)
+ note('Saved screenshot as %s' % fn)
f = file(fn, 'rb')
self.send(NUM_SCREENSHOT_REPLY, f.read().encode('base64'))
f.close()
@@ -498,7 +498,7 @@ class Mobile(object):
self.send(NUM_LOCATION_REPLY, '%03d' % mcc, '%02d' % mnc, '%X' % lac, '%X' % cellid)
def contactDict(self):
- keys = self.contactDb.keys()
+ keys = list(self.contactDb.keys())
contactDict = dict()
for key in keys:
@@ -514,8 +514,8 @@ class Mobile(object):
for field in contact:
_type = field.type
value = field.value
- value = unicode(value)
- value = value.replace(u'\u2029', u'\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)
+ value = str(value)
+ value = value.replace('\u2029', '\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)
location = field.location
if _type == "unknown":
@@ -538,10 +538,10 @@ class Mobile(object):
def sendContactHash(self):
contacts = self.contactDict()
- keys = contacts.keys()
+ keys = list(contacts.keys())
keys.sort()
- hash = unicode()
+ hash = str()
for key in keys:
hash += str(key)
@@ -559,11 +559,11 @@ class Mobile(object):
self.send(NUM_CONTACTS_REPLY_HASH_SINGLE_START)
contacts = self.contactDict()
- keys = contacts.keys()
+ keys = list(contacts.keys())
keys.sort()
for key in keys:
- hash = unicode()
+ hash = str()
for _type, location, value in contacts[key]:
hash += _type + INFO_SEP + location + INFO_SEP + value
hash += FIELD_SEP
@@ -575,7 +575,7 @@ class Mobile(object):
self.send(NUM_CONTACTS_REPLY_HASH_SINGLE_END)
def sendAllContacts(self):
- keys = self.contactDb.keys()
+ keys = list(self.contactDb.keys())
for key in keys:
contact = self.contactDb[key]
@@ -598,8 +598,8 @@ class Mobile(object):
for field in contact:
_type = field.type
value = field.value
- value = unicode(value)
- value = value.replace(u'\u2029', u'\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)
+ value = str(value)
+ value = value.replace('\u2029', '\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)
location = field.location
if _type == "unknown":
@@ -623,13 +623,13 @@ class Mobile(object):
except:
return
- if type == u"thumbnail_image":
+ if type == "thumbnail_image":
if modification == "remove":
self.setContactThumbnail(contact)
else:
self.setContactThumbnail(contact, value)
return
- elif type == u"date":
+ elif type == "date":
if modification == "remove":
self.setContactBirthday(contact)
else:
@@ -655,7 +655,7 @@ class Mobile(object):
def getDetailFromVcard(self, contact, detail, delimiter='\r\n'):
# This is an ugly hack, needed for some fields that cannot be handled using the contact object
try:
- value = unicode(contact.as_vcard(), 'utf8')
+ value = str(contact.as_vcard(), 'utf8')
value = value.split(detail + ":")[1].split(delimiter)[0]
return value
except:
@@ -665,7 +665,7 @@ class Mobile(object):
# This is an ugly hack, needed for some fields that cannot be handled using the contact object
card = contact.as_vcard()
- new = u""
+ new = ""
for line in card.split("\r\n"):
if line.startswith("BEGIN:") or line.startswith("VERSION:") or line.startswith("REV:") or line.startswith("UID:"):
new += line + "\r\n"
@@ -728,18 +728,18 @@ class Mobile(object):
line = entryType + sep + entry.content + sep + entry.location + sep
if entry.start_time:
# None if the start datetime of the entry is not set
- line += str(long(entry.start_time)) # entry.start_time is of type float
+ line += str(int(entry.start_time)) # entry.start_time is of type float
line += sep
if entry.end_time:
- line += str(long(entry.end_time))
+ line += str(int(entry.end_time))
line += sep
- line += str(long(entry.last_modified)) + sep
+ line += str(int(entry.last_modified)) + sep
line += entry.replication + sep # open, private or restricted
if entry.alarm:
- line += str(long(entry.alarm)) # The alarm datetime value (float) for the entry
+ line += str(int(entry.alarm)) # The alarm datetime value (float) for the entry
line += sep
line += str(entry.priority) + sep
@@ -768,11 +768,11 @@ class Mobile(object):
# example: on second Tuesday and last Monday of the month
# days is: [{'week': 1, 'day': 1}, {'week': 4, 'day': 0}]
# results in: 'week:1,day:1;week:4,day:0'
- line += ";".join([",".join([key + ":" + str(value) for key, value in entry.items()]) for entry in days])
+ line += ";".join([",".join([key + ":" + str(value) for key, value in list(entry.items())]) for entry in days])
elif isinstance(days, dict):
# for example: {'week': 1, 'day': 1, 'month': 1}
# results in: 'week:1,day:1,month:1'
- line += ",".join([key + ":" + str(value) for key, value in days.iteritems()])
+ line += ",".join([key + ":" + str(value) for key, value in days.items()])
line += sep
if repeated and "exceptions" in repeat:
@@ -780,13 +780,13 @@ class Mobile(object):
line += sep
if repeated and "start" in repeat:
- line += str(long(repeat["start"]))
+ line += str(int(repeat["start"]))
line += sep
if repeated and "end" in repeat:
- end = long(repeat["end"])
+ end = int(repeat["end"])
end -= time.timezone
- if end == 4102441200L:
+ if end == 4102441200:
# 4102441200L = 2100-01-01T00:00:00
# There is a bug in PyS60, which causes that None as end date throws as error
# As workarond, we use 2100-01-01 as end date for eternal repeats
@@ -805,7 +805,7 @@ class Mobile(object):
line += str(int(bool(entry.crossed_out))) + sep
if entry.cross_out_time:
- line += str(long(entry.cross_out_time))
+ line += str(int(entry.cross_out_time))
line += sep
# TODO lists no more supported!
@@ -840,10 +840,10 @@ class Mobile(object):
def sendCalendarHash(self):
calendarDict = self.calendarDict()
- keys = calendarDict.keys()
+ keys = list(calendarDict.keys())
keys.sort()
- hash = unicode()
+ hash = str()
for key in keys:
hash += str(key)
hash += FIELD_SEP
@@ -901,7 +901,7 @@ class Mobile(object):
entry.commit()
- self.send(NUM_CALENDAR_ENTRY_CHANGE_REPLY_TIME, id, str(long(entry.last_modified)))
+ self.send(NUM_CALENDAR_ENTRY_CHANGE_REPLY_TIME, id, str(int(entry.last_modified)))
def addCalendarEntry(self, type, content, location, start, end, replication, alarm, priority, repeat_type,
repeat_days, repeat_exceptions, repeat_start, repeat_end, repeat_interval):
@@ -922,7 +922,7 @@ class Mobile(object):
entry.commit()
- self.send(NUM_CALENDAR_ENTRY_ADD_REPLY, entry.id, str(long(entry.last_modified)))
+ self.send(NUM_CALENDAR_ENTRY_ADD_REPLY, entry.id, str(int(entry.last_modified)))
def modifyCalendarEntryFields(self, entry, content, location, start, end, replication, alarm, priority, repeat_type,
repeat_days, repeat_exceptions, repeat_start, repeat_end, repeat_interval):
@@ -1012,7 +1012,7 @@ class Mobile(object):
return
address = self.inbox.address(sms)
content = self.inbox.content(sms)
- content = content.replace(u'\u2029', u'\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)
+ content = content.replace('\u2029', '\n') # PARAGRAPH SEPARATOR (\u2029) replaced by LINE FEED (\u000a)
if self.inbox.unread(sms):
unread = '1'
@@ -1072,7 +1072,7 @@ class Mobile(object):
def sendMessage(self, name, phone, encoding, msg):
try:
messaging.sms_send(phone, msg, encoding, self.sentMessage, name)
- except RuntimeError, detail:
+ except RuntimeError as detail:
if str(detail) == "Already sending":
# Workaround for the "Already sending" bug:
# http://discussion.forum.nokia.com/forum/showthread.php?t=141083
@@ -1162,7 +1162,7 @@ class Mobile(object):
app.set_exit()
def portHandler(self):
- ret = query(u'Enter bluetooth port to use', 'number', self.port)
+ ret = query('Enter bluetooth port to use', 'number', self.port)
if ret is not None:
self.port = ret
self.quit()
@@ -1170,42 +1170,42 @@ class Mobile(object):
self.startService()
def aboutHandler(self):
- query(u'Gammu S60 Remote\nVersion %s\nhttps://wammu.eu/' % (VERSION) , 'query')
+ query('Gammu S60 Remote\nVersion %s\nhttps://wammu.eu/' % (VERSION) , 'query')
def toggleHandler(self):
- e32.start_exe(u'BtToggleApp.exe','')
+ e32.start_exe('BtToggleApp.exe','')
# Debug of SIS applications
try:
mobile = Mobile()
-except Exception, e:
+except Exception as e:
# Oops, something wrong. Report problems to user
# and ask him/her to send them to you.
import traceback
- new_line = u"\u2029"
+ new_line = "\u2029"
# Collecting call stack info
info = sys.exc_info()
# Show the last 4 lines of the call stack
- call_stack = u""
+ call_stack = ""
for filename, lineno, function, text in traceback.extract_tb(info[2]):
- call_stack += filename + u": " + str(lineno) + u" - " + function + new_line
- call_stack += u" " + repr(text) + new_line
- call_stack += u"%s: %s" % info[:2]
+ call_stack += filename + ": " + str(lineno) + " - " + function + new_line
+ call_stack += " " + repr(text) + new_line
+ call_stack += "%s: %s" % info[:2]
# Creating a friendly user message with exception details
- err_msg = u"This programs was unexpectedly closed due to the following error: "
- err_msg += unicode(repr(e)) + new_line
- err_msg += u"Please, copy and paste the text presented here and "
- err_msg += u"send it to gammu-users@lists.sourceforge.net. "
- err_msg += u"Thanks in advance and sorry for this inconvenience." + new_line*2
- err_msg += u"Call stack:" + new_line + call_stack
+ err_msg = "This programs was unexpectedly closed due to the following error: "
+ err_msg += str(repr(e)) + new_line
+ err_msg += "Please, copy and paste the text presented here and "
+ err_msg += "send it to gammu-users@lists.sourceforge.net. "
+ err_msg += "Thanks in advance and sorry for this inconvenience." + new_line*2
+ err_msg += "Call stack:" + new_line + call_stack
# Small PyS60 application
lock = e32.Ao_lock()
app.body = Text(err_msg)
app.body.set_pos(0)
- app.menu = [(u"Exit", lambda: lock.signal())]
+ app.menu = [("Exit", lambda: lock.signal())]
lock.wait()
diff --git a/contrib/usbsnoop/decode.py b/contrib/usbsnoop/decode.py
index c6d680a56..1185957f4 100755
--- a/contrib/usbsnoop/decode.py
+++ b/contrib/usbsnoop/decode.py
@@ -10,7 +10,7 @@ This is probably only useful for AT commands.
import sys
if len(sys.argv) < 2:
- print 'Usage: decode.py LOGFILE'
+ print('Usage: decode.py LOGFILE')
sys.exit(1)
f = open(sys.argv[1])
@@ -21,7 +21,7 @@ for line in f:
pos, data = line.split(':')
if pos == '00000000':
if output != '':
- print output.decode('hex')
+ print(output.decode('hex'))
output = ''
data = ''.join(data.strip().split(' '))
output += data
diff --git a/contrib/usbsnoop/decodexml.py b/contrib/usbsnoop/decodexml.py
index 27459b796..e58c0ef2e 100755
--- a/contrib/usbsnoop/decodexml.py
+++ b/contrib/usbsnoop/decodexml.py
@@ -10,7 +10,7 @@ This is probably only useful for AT commands.
import sys
if len(sys.argv) < 2:
- print 'Usage: decode.py LOGFILE'
+ print('Usage: decode.py LOGFILE')
sys.exit(1)
f = open(sys.argv[1])
@@ -18,6 +18,6 @@ output = ""
for line in f:
if line[:14] == '<payloadbytes>':
line = line[14:-17]
- print line
- print line.decode('hex')
+ print(line)
+ print((line.decode('hex')))
--
2.30.2

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Apr 6 09:39:34 UTC 2021 - Martin Hauke <mardnh@gmx.de>
- Add patches to fix build failures in Tumbleweed:
* 0001-Update-Python-scripts-to-Python-3.patch
* 0001-Docs-Adjust-attributes-order-to-avoid-bugs-in-breath.patch
-------------------------------------------------------------------
Sun Oct 4 09:47:33 UTC 2020 - Martin Hauke <mardnh@gmx.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package gammu
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -29,6 +29,8 @@ Source0: https://dl.cihar.com/gammu/releases/%{name}-%{version}.tar.xz
# PATCH-FIX-OPENSUSE gammu-remove-gplv3-files.patch idoenmez@suse.de -- Remove GPLv3 files bnc#775397
Patch1: gammu-remove-gplv3-files.patch
Patch2: 0001-Enable-fPIE-pie.patch
Patch3: 0001-Update-Python-scripts-to-Python-3.patch
Patch4: 0001-Docs-Adjust-attributes-order-to-avoid-bugs-in-breath.patch
BuildRequires: cmake >= 2.8
BuildRequires: doxygen
BuildRequires: gettext
@ -185,6 +187,8 @@ This package contains the Gammu SMS daemon shared library.
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
# GPL-3.0 licensed files, bnc#775397
rm -rf contrib/sms-gammu2android