python-gammu 3.2.5__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gammu/__init__.py ADDED
@@ -0,0 +1,25 @@
1
+ # vim: expandtab sw=4 ts=4 sts=4:
2
+ #
3
+ # Copyright © 2003 - 2018 Michal Čihař <michal@cihar.com>
4
+ #
5
+ # This file is part of python-gammu <https://wammu.eu/python-gammu/>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with this program; if not, write to the Free Software Foundation, Inc.,
19
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
+ #
21
+ """Phone communication library - python wrapper for Gammu library."""
22
+
23
+ from gammu._gammu import * # noqa: F403
24
+
25
+ __version__ = "Gammu {}, python-gammu {}".format(*Version()) # noqa: F405
Binary file
gammu/asyncworker.py ADDED
@@ -0,0 +1,171 @@
1
+ # Copyright © 2003 - 2018 Michal Čihař <michal@cihar.com>
2
+ #
3
+ # This file is part of python-gammu <https://wammu.eu/python-gammu/>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along
16
+ # with this program; if not, write to the Free Software Foundation, Inc.,
17
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
+ #
19
+ """Async extensions for gammu."""
20
+
21
+ import asyncio
22
+
23
+ import gammu
24
+ import gammu.worker
25
+
26
+
27
+ class GammuAsyncThread(gammu.worker.GammuThread):
28
+ """Thread for phone communication."""
29
+
30
+ def __init__(self, queue, config, callback, pull_func) -> None:
31
+ """Initialize thread."""
32
+ super().__init__(queue, config, callback, pull_func)
33
+
34
+ def _do_command(self, future, cmd, params, percentage=100) -> None:
35
+ """Execute single command on phone."""
36
+ func = getattr(self._sm, cmd)
37
+ result = None
38
+ try:
39
+ if params is None:
40
+ result = func()
41
+ elif isinstance(params, dict):
42
+ result = func(**params)
43
+ else:
44
+ result = func(*params)
45
+ except gammu.GSMError as info:
46
+ errcode = info.args[0]["Code"]
47
+ error = gammu.ErrorNumbers[errcode]
48
+ self._callback(future, result, error, percentage)
49
+ # pylint: disable-next=broad-except
50
+ except Exception as exception: # noqa: BLE001
51
+ self._callback(future, None, exception, percentage)
52
+ else:
53
+ self._callback(future, result, None, percentage)
54
+
55
+
56
+ def gammu_pull_device(sm) -> None:
57
+ sm.ReadDevice()
58
+
59
+
60
+ class GammuAsyncWorker(gammu.worker.GammuWorker):
61
+ """Extend gammu worker class for async operations."""
62
+
63
+ def worker_callback(self, name, result, error, percents) -> None:
64
+ """Execute command from the thread worker."""
65
+ future = None
66
+ if name == "Init" and self._init_future is not None:
67
+ future = self._init_future
68
+ elif name == "Terminate" and self._terminate_future is not None:
69
+ # Set _kill to true on the base class to avoid waiting for termination
70
+ self._thread._kill = True # pylint: disable=protected-access
71
+ future = self._terminate_future
72
+ elif hasattr(name, "set_result"):
73
+ future = name
74
+
75
+ if future is not None:
76
+ if error is None:
77
+ self._loop.call_soon_threadsafe(future.set_result, result)
78
+ else:
79
+ exception = error
80
+ if not isinstance(error, Exception):
81
+ exception = gammu.GSMError(error)
82
+ self._loop.call_soon_threadsafe(future.set_exception, exception)
83
+
84
+ def __init__(self, pull_func=gammu_pull_device) -> None:
85
+ """
86
+ Initialize the worker class.
87
+
88
+ @param callback: See L{GammuThread.__init__} for description.
89
+ """
90
+ super().__init__(self.worker_callback, pull_func)
91
+ self._loop = asyncio.get_event_loop()
92
+ self._init_future = None
93
+ self._terminate_future = None
94
+ self._thread = None
95
+ self._pull_func = pull_func
96
+
97
+ async def init_async(self) -> None:
98
+ """Connect to phone."""
99
+ self._init_future = self._loop.create_future()
100
+
101
+ self._thread = GammuAsyncThread(
102
+ self._queue, self._config, self._callback, self._pull_func
103
+ )
104
+ self._thread.start()
105
+
106
+ await self._init_future
107
+ self._init_future = None
108
+
109
+ async def get_imei_async(self):
110
+ """Get the IMEI of the device."""
111
+ future = self._loop.create_future()
112
+ self.enqueue(future, commands=[("GetIMEI", ())])
113
+ return await future
114
+
115
+ async def get_network_info_async(self):
116
+ """Get the network info in the device."""
117
+ future = self._loop.create_future()
118
+ self.enqueue(future, commands=[("GetNetworkInfo", ())])
119
+ return await future
120
+
121
+ async def get_manufacturer_async(self):
122
+ """Get the manufacturer of the device."""
123
+ future = self._loop.create_future()
124
+ self.enqueue(future, commands=[("GetManufacturer", ())])
125
+ return await future
126
+
127
+ async def get_model_async(self):
128
+ """Get the model of the device."""
129
+ future = self._loop.create_future()
130
+ self.enqueue(future, commands=[("GetModel", ())])
131
+ return await future
132
+
133
+ async def get_firmware_async(self):
134
+ """Get the firmware version of the device."""
135
+ future = self._loop.create_future()
136
+ self.enqueue(future, commands=[("GetFirmware", ())])
137
+ return await future
138
+
139
+ async def get_signal_quality_async(self):
140
+ """Get signal quality from phone."""
141
+ future = self._loop.create_future()
142
+ self.enqueue(future, commands=[("GetSignalQuality", ())])
143
+ return await future
144
+
145
+ async def send_sms_async(self, message):
146
+ """Send sms message via the phone."""
147
+ future = self._loop.create_future()
148
+ self.enqueue(future, commands=[("SendSMS", [message])])
149
+ return await future
150
+
151
+ async def set_incoming_callback_async(self, callback):
152
+ """Set the callback to call from phone."""
153
+ future = self._loop.create_future()
154
+ self.enqueue(future, commands=[("SetIncomingCallback", [callback])])
155
+ return await future
156
+
157
+ async def set_incoming_sms_async(self):
158
+ """Activate SMS notifications from phone."""
159
+ future = self._loop.create_future()
160
+ self.enqueue(future, commands=[("SetIncomingSMS", ())])
161
+ return await future
162
+
163
+ async def terminate_async(self) -> None:
164
+ """Terminate phone communication."""
165
+ self._terminate_future = self._loop.create_future()
166
+ self.enqueue("Terminate")
167
+ await self._terminate_future
168
+
169
+ await asyncio.to_thread(self._thread.join)
170
+
171
+ self._thread = None
gammu/data.py ADDED
@@ -0,0 +1,494 @@
1
+ # vim: expandtab sw=4 ts=4 sts=4:
2
+ #
3
+ # Copyright © 2003 - 2018 Michal Čihař <michal@cihar.com>
4
+ #
5
+ # This file is part of python-gammu <https://wammu.eu/python-gammu/>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with this program; if not, write to the Free Software Foundation, Inc.,
19
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
+ #
21
+ """
22
+ Some static data.
23
+
24
+ @var Connections: List of connection types.
25
+ @var MemoryValueTypes: Types of memory entry values.
26
+ @var CalendarTypes: Types of calendar entries.
27
+ @var CalendarValueTypes: Types of calendar entry values.
28
+ @var TodoPriorities: Todo priorities.
29
+ @var TodoValueTypes: Types of todo entry values.
30
+ @var InternationalPrefixes: List of known internaltional prefixes.
31
+ """
32
+
33
+ from gammu import ErrorNumbers, Errors
34
+
35
+ Connections = [
36
+ "at",
37
+ "at19200",
38
+ "at115200",
39
+ "fbus",
40
+ "dlr3",
41
+ "dku2",
42
+ "dku5",
43
+ "fbuspl2303",
44
+ "mbus",
45
+ "irdaphonet",
46
+ "irdaat",
47
+ "irdaobex",
48
+ "irdagnapbus",
49
+ "bluerffbus",
50
+ "bluefbus",
51
+ "bluerfphonet",
52
+ "bluephonet",
53
+ "blueat",
54
+ "bluerfat",
55
+ "blueobex",
56
+ "bluerfobex",
57
+ "fbusblue",
58
+ "fbusirda",
59
+ "phonetblue",
60
+ "bluerfgnapbus",
61
+ ]
62
+
63
+ MemoryValueTypes = [
64
+ "Number_General",
65
+ "Number_Mobile",
66
+ "Number_Work",
67
+ "Number_Fax",
68
+ "Number_Home",
69
+ "Number_Pager",
70
+ "Number_Other",
71
+ "Text_Note",
72
+ "Text_Postal",
73
+ "Text_WorkPostal",
74
+ "Text_Email",
75
+ "Text_Email2",
76
+ "Text_URL",
77
+ "Date",
78
+ "Caller_Group",
79
+ "Text_Name",
80
+ "Text_LastName",
81
+ "Text_FirstName",
82
+ "Text_Company",
83
+ "Text_JobTitle",
84
+ "Category",
85
+ "Private",
86
+ "Text_StreetAddress",
87
+ "Text_City",
88
+ "Text_State",
89
+ "Text_Zip",
90
+ "Text_Country",
91
+ "Text_WorkStreetAddress",
92
+ "Text_WorkCity",
93
+ "Text_WorkState",
94
+ "Text_WorkZip",
95
+ "Text_WorkCountry",
96
+ "Text_Custom1",
97
+ "Text_Custom2",
98
+ "Text_Custom3",
99
+ "Text_Custom4",
100
+ "RingtoneID",
101
+ "PictureID",
102
+ "Text_UserID",
103
+ "CallLength",
104
+ "Text_LUID",
105
+ "LastModified",
106
+ "Text_NickName",
107
+ "Text_FormalName",
108
+ "PushToTalkID",
109
+ "Photo",
110
+ "Number_Mobile_Home",
111
+ "Number_Mobile_Work",
112
+ "Text_SecondName",
113
+ "Text_VOIP",
114
+ "Text_SIP",
115
+ "Text_DTMF",
116
+ "Number_Video",
117
+ "Text_SWIS",
118
+ "Text_WVID",
119
+ "Text_NamePrefix",
120
+ "Text_NameSuffix",
121
+ ]
122
+
123
+ CalendarTypes = [
124
+ "REMINDER",
125
+ "CALL",
126
+ "MEETING",
127
+ "BIRTHDAY",
128
+ "MEMO",
129
+ "TRAVEL",
130
+ "VACATION",
131
+ "T_ATHL",
132
+ "T_BALL",
133
+ "T_CYCL",
134
+ "T_BUDO",
135
+ "T_DANC",
136
+ "T_EXTR",
137
+ "T_FOOT",
138
+ "T_GOLF",
139
+ "T_GYM",
140
+ "T_HORS",
141
+ "T_HOCK",
142
+ "T_RACE",
143
+ "T_RUGB",
144
+ "T_SAIL",
145
+ "T_STRE",
146
+ "T_SWIM",
147
+ "T_TENN",
148
+ "T_TRAV",
149
+ "T_WINT",
150
+ "ALARM",
151
+ "DAILY_ALARM",
152
+ "SHOPPING",
153
+ ]
154
+
155
+ CalendarValueTypes = [
156
+ "START_DATETIME",
157
+ "END_DATETIME",
158
+ "TONE_ALARM_DATETIME",
159
+ "SILENT_ALARM_DATETIME",
160
+ "TEXT",
161
+ "DESCRIPTION",
162
+ "LOCATION",
163
+ "PHONE",
164
+ "PRIVATE",
165
+ "CONTACTID",
166
+ "REPEAT_DAYOFWEEK",
167
+ "REPEAT_DAY",
168
+ "REPEAT_WEEKOFMONTH",
169
+ "REPEAT_MONTH",
170
+ "REPEAT_FREQUENCY",
171
+ "REPEAT_STARTDATE",
172
+ "REPEAT_STOPDATE",
173
+ "LUID",
174
+ "LAST_MODIFIED",
175
+ ]
176
+
177
+ TodoPriorities = [
178
+ "High",
179
+ "Medium",
180
+ "Low",
181
+ "None",
182
+ ]
183
+
184
+ TodoValueTypes = [
185
+ "END_DATETIME",
186
+ "START_DATETIME",
187
+ "COMPLETED_DATETIME",
188
+ "COMPLETED",
189
+ "ALARM_DATETIME",
190
+ "SILENT_ALARM_DATETIME",
191
+ "TEXT",
192
+ "DESCRIPTION",
193
+ "LOCATION",
194
+ "LUID",
195
+ "PRIVATE",
196
+ "CATEGORY",
197
+ "CONTACTID",
198
+ "PHONE",
199
+ "LAST_MODIFIED",
200
+ ]
201
+
202
+ InternationalPrefixes = [
203
+ "+1",
204
+ "+20",
205
+ "+210",
206
+ "+211",
207
+ "+212",
208
+ "+213",
209
+ "+214",
210
+ "+215",
211
+ "+216",
212
+ "+217",
213
+ "+218",
214
+ "+219",
215
+ "+220",
216
+ "+221",
217
+ "+222",
218
+ "+223",
219
+ "+224",
220
+ "+225",
221
+ "+226",
222
+ "+227",
223
+ "+228",
224
+ "+229",
225
+ "+230",
226
+ "+231",
227
+ "+232",
228
+ "+233",
229
+ "+234",
230
+ "+235",
231
+ "+236",
232
+ "+237",
233
+ "+238",
234
+ "+239",
235
+ "+240",
236
+ "+241",
237
+ "+242",
238
+ "+243",
239
+ "+244",
240
+ "+245",
241
+ "+246",
242
+ "+247",
243
+ "+248",
244
+ "+249",
245
+ "+250",
246
+ "+251",
247
+ "+252",
248
+ "+253",
249
+ "+254",
250
+ "+255",
251
+ "+256",
252
+ "+257",
253
+ "+258",
254
+ "+259",
255
+ "+260",
256
+ "+261",
257
+ "+262",
258
+ "+263",
259
+ "+264",
260
+ "+265",
261
+ "+266",
262
+ "+267",
263
+ "+268",
264
+ "+269",
265
+ "+27",
266
+ "+28",
267
+ "+290",
268
+ "+291",
269
+ "+292",
270
+ "+293",
271
+ "+294",
272
+ "+295",
273
+ "+296",
274
+ "+297",
275
+ "+298",
276
+ "+299",
277
+ "+30",
278
+ "+31",
279
+ "+32",
280
+ "+33",
281
+ "+34",
282
+ "+350",
283
+ "+351",
284
+ "+352",
285
+ "+353",
286
+ "+354",
287
+ "+355",
288
+ "+356",
289
+ "+357",
290
+ "+358",
291
+ "+359",
292
+ "+36",
293
+ "+370",
294
+ "+371",
295
+ "+372",
296
+ "+373",
297
+ "+374",
298
+ "+375",
299
+ "+376",
300
+ "+377",
301
+ "+378",
302
+ "+379",
303
+ "+380",
304
+ "+381",
305
+ "+382",
306
+ "+383",
307
+ "+384",
308
+ "+385",
309
+ "+386",
310
+ "+387",
311
+ "+388",
312
+ "+389",
313
+ "+39",
314
+ "+40",
315
+ "+41",
316
+ "+420",
317
+ "+421",
318
+ "+422",
319
+ "+423",
320
+ "+424",
321
+ "+425",
322
+ "+426",
323
+ "+427",
324
+ "+428",
325
+ "+429",
326
+ "+43",
327
+ "+44",
328
+ "+45",
329
+ "+46",
330
+ "+47",
331
+ "+48",
332
+ "+49",
333
+ "+500",
334
+ "+501",
335
+ "+502",
336
+ "+503",
337
+ "+504",
338
+ "+505",
339
+ "+506",
340
+ "+507",
341
+ "+508",
342
+ "+509",
343
+ "+51",
344
+ "+52",
345
+ "+53",
346
+ "+54",
347
+ "+55",
348
+ "+56",
349
+ "+57",
350
+ "+58",
351
+ "+590",
352
+ "+591",
353
+ "+592",
354
+ "+593",
355
+ "+594",
356
+ "+595",
357
+ "+596",
358
+ "+597",
359
+ "+598",
360
+ "+599",
361
+ "+60",
362
+ "+61",
363
+ "+62",
364
+ "+63",
365
+ "+64",
366
+ "+65",
367
+ "+66",
368
+ "+670",
369
+ "+671",
370
+ "+672",
371
+ "+673",
372
+ "+674",
373
+ "+675",
374
+ "+676",
375
+ "+677",
376
+ "+678",
377
+ "+679",
378
+ "+680",
379
+ "+681",
380
+ "+682",
381
+ "+683",
382
+ "+684",
383
+ "+685",
384
+ "+686",
385
+ "+687",
386
+ "+688",
387
+ "+689",
388
+ "+690",
389
+ "+691",
390
+ "+692",
391
+ "+693",
392
+ "+694",
393
+ "+695",
394
+ "+696",
395
+ "+697",
396
+ "+698",
397
+ "+699",
398
+ "+7",
399
+ "+800",
400
+ "+801",
401
+ "+802",
402
+ "+803",
403
+ "+804",
404
+ "+805",
405
+ "+806",
406
+ "+807",
407
+ "+808",
408
+ "+809",
409
+ "+81",
410
+ "+82",
411
+ "+83",
412
+ "+84",
413
+ "+850",
414
+ "+851",
415
+ "+852",
416
+ "+853",
417
+ "+854",
418
+ "+855",
419
+ "+856",
420
+ "+857",
421
+ "+858",
422
+ "+859",
423
+ "+86",
424
+ "+870",
425
+ "+871",
426
+ "+872",
427
+ "+873",
428
+ "+874",
429
+ "+875",
430
+ "+876",
431
+ "+877",
432
+ "+878",
433
+ "+879",
434
+ "+880",
435
+ "+881",
436
+ "+882",
437
+ "+883",
438
+ "+884",
439
+ "+885",
440
+ "+886",
441
+ "+887",
442
+ "+888",
443
+ "+889",
444
+ "+89",
445
+ "+90",
446
+ "+91",
447
+ "+92",
448
+ "+93",
449
+ "+94",
450
+ "+95",
451
+ "+960",
452
+ "+961",
453
+ "+962",
454
+ "+963",
455
+ "+964",
456
+ "+965",
457
+ "+966",
458
+ "+967",
459
+ "+968",
460
+ "+969",
461
+ "+970",
462
+ "+971",
463
+ "+972",
464
+ "+973",
465
+ "+974",
466
+ "+975",
467
+ "+976",
468
+ "+977",
469
+ "+978",
470
+ "+979",
471
+ "+98",
472
+ "+990",
473
+ "+991",
474
+ "+992",
475
+ "+993",
476
+ "+994",
477
+ "+995",
478
+ "+996",
479
+ "+997",
480
+ "+998",
481
+ "+999",
482
+ ]
483
+
484
+ __all__ = [
485
+ "CalendarTypes",
486
+ "CalendarValueTypes",
487
+ "Connections",
488
+ "ErrorNumbers",
489
+ "Errors",
490
+ "InternationalPrefixes",
491
+ "MemoryValueTypes",
492
+ "TodoPriorities",
493
+ "TodoValueTypes",
494
+ ]