summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYegor Yefremov <yegorslists@googlemail.com>2021-02-24 16:43:48 +0100
committerAleksander Morgado <aleksander@aleksander.es>2021-02-25 14:14:55 +0100
commit297a8c85ae2b52bbcbf53daa40ab96fb406ca32c (patch)
tree38bfc73209d357b04f5bee967cb9c7c8db5acf79 /examples
parentaba237df4ed9c465282ed9be0cba1ee6be0c9c13 (diff)
downloadModemManager-297a8c85ae2b52bbcbf53daa40ab96fb406ca32c.tar.gz
examples: sms: resolve PEP8 issues
Use autopep8 utility to resolve issues like spaces before brackets and wrong hanging indentation. Also treat objects like boolean variables to check whether they are None or not.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/sms-python/sms-python18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/sms-python/sms-python b/examples/sms-python/sms-python
index 569db376d..46d5e692e 100755
--- a/examples/sms-python/sms-python
+++ b/examples/sms-python/sms-python
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
#
# This program is free software; you can redistribute it and/or modify it under
@@ -25,7 +25,8 @@ gi.require_version('ModemManager', '1.0')
from gi.repository import Gio, GLib, GObject, ModemManager
-if __name__ == "__main__":
+def main():
+ """Main routine."""
# Process input arguments
if len(sys.argv) != 3:
@@ -34,14 +35,15 @@ if __name__ == "__main__":
sys.exit(1)
# Prepare SMS properties
- sms_properties = ModemManager.SmsProperties.new ()
+ sms_properties = ModemManager.SmsProperties.new()
sms_properties.set_number(sys.argv[1])
sms_properties.set_text(sys.argv[2])
# Connection to ModemManager
- connection = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
- manager = ModemManager.Manager.new_sync (connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
- if manager.get_name_owner() is None:
+ connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
+ manager = ModemManager.Manager.new_sync(
+ connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
+ if not manager.get_name_owner():
sys.stderr.write('ModemManager not found in bus')
sys.exit(2)
@@ -51,3 +53,7 @@ if __name__ == "__main__":
sms = messaging.create_sync(sms_properties)
sms.send_sync()
print('%s: sms sent' % messaging.get_object_path())
+
+
+if __name__ == "__main__":
+ main()