From a163721e4850a47f26bab088ac3c41e8167f718b Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Tue, 31 Mar 2020 15:13:24 +0200 Subject: Switch to python3 --- README | 1 + src/ppm/accountdb.py | 1 + src/ppm/modemproxy.py | 8 ++++---- src/ppm/provider.py | 5 +++-- src/ppm/providerdb.py | 5 +++-- src/prepaid-manager-applet.in | 2 +- src/prepaid-manager-applet.py | 10 +++++++--- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README b/README index 82211bb..0437510 100644 --- a/README +++ b/README @@ -10,6 +10,7 @@ by the built in 3G chipset in your laptop/netbook. Requirements ------------ +* Python3 * ModemManager with ussd support (>= 1.4) * mobile-broadband-provider-info with top-up support (>= 20110319) * GTK+ >= 3.22, Debian package: libgtk+-3-0 diff --git a/src/ppm/accountdb.py b/src/ppm/accountdb.py index e0a22a3..4b70a2a 100644 --- a/src/ppm/accountdb.py +++ b/src/ppm/accountdb.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +from builtins import object from gi.repository import Gio from gi.repository import GObject import logging diff --git a/src/ppm/modemproxy.py b/src/ppm/modemproxy.py index 6284af1..15f77fd 100644 --- a/src/ppm/modemproxy.py +++ b/src/ppm/modemproxy.py @@ -92,10 +92,10 @@ class ModemManagerProxy(GObject.GObject): def mm_request(func): def wrapped_f( self, *args, **kw): - self.request = "%s" % func.func_name - if kw.has_key('reply_func'): + self.request = "%s" % func.__name__ + if 'reply_func' in kw: self.reply_func = kw['reply_func'] - if kw.has_key('error_func'): + if 'error_func' in kw: self.error_func = kw['error_func'] self.emit('request-started', self) func(self, *args, **kw) @@ -135,7 +135,7 @@ class ModemManagerProxy(GObject.GObject): def get_modems(self): modems = [] self.get_objects() - for path, obj in self.objects().iteritems(): + for path, obj in self.objects().items(): if self.MM_DBUS_INTERFACE_MODEM in obj: modems.append(path) return modems diff --git a/src/ppm/provider.py b/src/ppm/provider.py index ccdf810..fbcbcbd 100644 --- a/src/ppm/provider.py +++ b/src/ppm/provider.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +from builtins import object import logging class ProviderError(Exception): @@ -48,14 +49,14 @@ class Provider(object): def has_fetch_balance_cmd(self): # Only USSD for now - if self.fetch_balance_cmds.has_key('ussd'): + if 'ussd' in self.fetch_balance_cmds: return True else: return False def has_top_up_cmd(self): # Only USSD for now - if self.top_up_cmds.has_key('ussd'): + if 'ussd' in self.top_up_cmds: return True else: return False diff --git a/src/ppm/providerdb.py b/src/ppm/providerdb.py index 0e35b59..bc90139 100644 --- a/src/ppm/providerdb.py +++ b/src/ppm/providerdb.py @@ -14,11 +14,12 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +from builtins import object import os import logging from lxml import etree -from provider import Provider +from . provider import Provider class ProviderDB(object): """Proxy to mobile broadband provider database""" @@ -50,7 +51,7 @@ class ProviderDB(object): def _load_countries(self): try: - for line in file(self.country_codes, 'r'): + for line in open(self.country_codes, 'r'): if line[0] != '#': (code, country) = line.split('\t',2) self.__countries[code.lower()] = country.strip() diff --git a/src/prepaid-manager-applet.in b/src/prepaid-manager-applet.in index 561c09c..0ab4839 100755 --- a/src/prepaid-manager-applet.in +++ b/src/prepaid-manager-applet.in @@ -1,3 +1,3 @@ #!/bin/sh -exec python "@PYTHONDIR@/@PACKAGE@.py" "$@" +exec python3 "@PYTHONDIR@/@PACKAGE@.py" "$@" diff --git a/src/prepaid-manager-applet.py b/src/prepaid-manager-applet.py index f0fe9a3..ab47f88 100755 --- a/src/prepaid-manager-applet.py +++ b/src/prepaid-manager-applet.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +from builtins import str +from builtins import range +from past.utils import old_div +from builtins import object import gettext import gi from gi.repository import GObject @@ -410,8 +414,8 @@ class PPMDialog(GObject.GObject, PPMObject): sensitive = True if self.code_len > 0: - self.entry_code.set_progress_fraction(float(cur_len) / - self.code_len) + self.entry_code.set_progress_fraction(old_div(float(cur_len), + self.code_len)) if cur_len != self.code_len: sensitive = False self.button_top_up.set_sensitive(sensitive) @@ -569,7 +573,7 @@ class PPMNoModemFoundInfoBar(PPMInfoBar): class PPMProviderAssistant(PPMObject): - PAGE_INTRO, PAGE_COUNTRIES, PAGE_PROVIDERS, PAGE_CONFIRM = range(0, 4) + PAGE_INTRO, PAGE_COUNTRIES, PAGE_PROVIDERS, PAGE_CONFIRM = list(range(0, 4)) def __init__(self, main_dialog): PPMObject.__init__(self, main_dialog, "ppm-provider-assistant") -- cgit v1.2.3