diff --git a/blueberry.spec b/blueberry.spec index fe9c46c..fbf01bc 100644 --- a/blueberry.spec +++ b/blueberry.spec @@ -3,22 +3,23 @@ %global _python_bytecompile_extra 1 # bytecompile with Python 2 -%global __python %{__python2} +%global __python %{__python3} Name: blueberry Version: 1.2.5 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Bluetooth configuration tool License: GPLv3+ URL: https://github.com/linuxmint/%{name} Source0: %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch0: %{name}_py3.patch BuildArch: noarch BuildRequires: desktop-file-utils BuildRequires: gettext -BuildRequires: python2-devel +BuildRequires: python3-devel Requires: bluez-obexd Requires: bluez-tools @@ -33,9 +34,9 @@ Requires: dbus-python Requires: pygobject3 Requires: python-setproctitle %else -Requires: python2-dbus -Requires: python2-gobject -Requires: python2-setproctitle +Requires: python3-dbus +Requires: python3-gobject +Requires: python3-setproctitle %endif %description @@ -59,20 +60,20 @@ Cinnamon applet for %{name}. for file in .%{_bindir}/* $(%{_bindir}/find .%{_prefix} -name '*.py' -type f) do %{__sed} -i.orig \ - -e 's~#![ \t]*%{_bindir}/python$~#!%{__python2}~'\ - -e 's~#![ \t]*%{_bindir}/env[ \t]*python[2]*$~#!%{__python2}~' \ + -e 's~#![ \t]*%{_bindir}/python$~#!%{__python3}~'\ + -e 's~#![ \t]*%{_bindir}/env[ \t]*python[3]*$~#!%{__python3}~' \ ${file} /bin/touch -r ${file}.orig ${file} %{__rm} -f ${file}.orig done -for f in $(%{__grep} -Rl '#!.*python3') ; do - %{__sed} -e 's~#!.*python3~#!/usr/bin/python2~g' < ${f} > ${f}.new - /bin/touch -r ${f}.new ${f} - mode="$(%{_bindir}/stat -c '%a' ${f})" - %{__mv} -f ${f}.new ${f} - %{__chmod} -c ${mode} ${f} -done +#for f in $(%{__grep} -Rl '#!.*python3') ; do +# %{__sed} -e 's~#!.*python3~#!/usr/bin/python2~g' < ${f} > ${f}.new +# /bin/touch -r ${f}.new ${f} +# mode="$(%{_bindir}/stat -c '%a' ${f})" +# %{__mv} -f ${f}.new ${f} +# %{__chmod} -c ${mode} ${f} +#done %build @@ -82,7 +83,7 @@ done %install %{__mkdir} -p %{buildroot} %{__cp} -a .%{_prefix} .%{_sysconfdir} %{buildroot} -%{__grep} -RZl '#!%{__python2}' %{buildroot}%{_prefix}/lib/%{name}/* | \ +%{__grep} -RZl '#!%{__python3}' %{buildroot}%{_prefix}/lib/%{name}/* | \ %{_bindir}/xargs -0 %{__chmod} -c 0755 for file in $(%{_bindir}/find %{buildroot} -name '*.desktop' -type f) do @@ -132,6 +133,9 @@ fi %changelog +* Sat Mar 23 2019 Mukundan Ragavan - 1.2.5-2 +- Add path to build with python3 + * Tue Feb 12 2019 Mukundan Ragavan - 1.2.5-1 - Update to 1.2.5 diff --git a/blueberry_py3.patch b/blueberry_py3.patch new file mode 100644 index 0000000..a500dc8 --- /dev/null +++ b/blueberry_py3.patch @@ -0,0 +1,189 @@ +From e9bf40966b15d9de7ce05020cca0c1afdaac66c5 Mon Sep 17 00:00:00 2001 +From: Sebastiaan Lokhorst +Date: Sat, 11 Aug 2018 04:07:04 +0200 +Subject: [PATCH] Convert everything to use Python 3 + +--- + usr/lib/blueberry/BlueberrySettingsWidgets.py | 8 ++++---- + usr/lib/blueberry/blueberry-obex-agent.py | 8 +------- + usr/lib/blueberry/blueberry-tray.py | 2 +- + usr/lib/blueberry/blueberry.py | 18 +++++++++--------- + usr/lib/blueberry/rfkillMagic.py | 7 +++---- + usr/lib/blueberry/safechild | 4 ++-- + 6 files changed, 20 insertions(+), 27 deletions(-) + +diff --git a/usr/lib/blueberry/BlueberrySettingsWidgets.py b/usr/lib/blueberry/BlueberrySettingsWidgets.py +index 8d92fbc..ddf2cf5 100644 +--- a/usr/lib/blueberry/BlueberrySettingsWidgets.py ++++ b/usr/lib/blueberry/BlueberrySettingsWidgets.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python2 ++#!/usr/bin/env python3 + + import gi + gi.require_version('Gtk', '3.0') +@@ -54,9 +54,9 @@ def __init__(self, title): + separator_context = toolbar_separator.get_style_context() + frame_color = frame_style.get_border_color(Gtk.StateFlags.NORMAL).to_string() + css_provider = Gtk.CssProvider() +- css_provider.load_from_data(".separator { -GtkWidget-wide-separators: 0; \ +- color: %s; \ +- }" % frame_color) ++ css_provider.load_from_data(".separator {{ -GtkWidget-wide-separators: 0; \ ++ color: {}; \ ++ }}".format(frame_color).encode()) + separator_context.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + + self.list_box = Gtk.ListBox() +diff --git a/usr/lib/blueberry/blueberry-obex-agent.py b/usr/lib/blueberry/blueberry-obex-agent.py +index 899475c..50381a0 100755 +--- a/usr/lib/blueberry/blueberry-obex-agent.py ++++ b/usr/lib/blueberry/blueberry-obex-agent.py +@@ -1,9 +1,4 @@ +-#!/usr/bin/python2 +- +-from __future__ import print_function +-from __future__ import division +-from __future__ import absolute_import +-from __future__ import unicode_literals ++#!/usr/bin/python3 + + # CREDITS + # -------- +@@ -28,7 +23,6 @@ + + from datetime import datetime + from gi.types import GObjectMeta +-from inspect import isclass + + gi.require_version("Gtk", "3.0") + gi.require_version('Notify', '0.7') +diff --git a/usr/lib/blueberry/blueberry-tray.py b/usr/lib/blueberry/blueberry-tray.py +index 041c5ec..4665d84 100755 +--- a/usr/lib/blueberry/blueberry-tray.py ++++ b/usr/lib/blueberry/blueberry-tray.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python2 ++#!/usr/bin/env python3 + + import sys + import gettext +diff --git a/usr/lib/blueberry/blueberry.py b/usr/lib/blueberry/blueberry.py +index 88210cf..2667823 100755 +--- a/usr/lib/blueberry/blueberry.py ++++ b/usr/lib/blueberry/blueberry.py +@@ -1,10 +1,10 @@ +-#!/usr/bin/env python2 ++#!/usr/bin/env python3 + +-import sys, os, commands ++import sys, os + import gettext + import rfkillMagic + import subprocess +-from BlueberrySettingsWidgets import SettingsPage, SettingsBox, SettingsRow ++from BlueberrySettingsWidgets import SettingsPage, SettingsRow + import gi + gi.require_version('Gtk', '3.0') + gi.require_version('GnomeBluetooth', '1.0') +@@ -36,7 +36,7 @@ def on_activate(self, data=None): + self.create_window() + + def detect_desktop_environment(self): +- wm_info = commands.getoutput("wmctrl -m") ++ wm_info = subprocess.getoutput("wmctrl -m") + if "XDG_CURRENT_DESKTOP" in os.environ: + xdg_current_desktop = os.environ["XDG_CURRENT_DESKTOP"] + else: +@@ -66,7 +66,7 @@ def detect_desktop_environment(self): + self.configuration_tools = {"sound": "pavucontrol", "keyboard": "lxinput", "mouse": "lxinput"} + else: + self.de = "Unknown" +- print "Warning: DE could not be detected!" ++ print("Warning: DE could not be detected!") + self.configuration_tools = {} + if os.path.exists("/usr/bin/pavucontrol"): + self.configuration_tools["sound"] = "pavucontrol" +@@ -154,7 +154,7 @@ def create_window(self): + if adapter_name is not None: + self.adapter_name_entry.set_text(adapter_name) + self.adapter_name_entry.connect("changed", self.on_adapter_name_changed) +- row = SettingsRow(Gtk.Label(_("Name")), self.adapter_name_entry) ++ row = SettingsRow(Gtk.Label(label=_("Name")), self.adapter_name_entry) + row.set_tooltip_text(_("This is the Bluetooth name of your computer")) + section.add_row(row) + +@@ -192,7 +192,7 @@ def create_window(self): + + def panel_changed(self, widget, panel): + if not panel in self.configuration_tools: +- print "Warning, no configuration tool known for panel '%s'" % panel ++ print("Warning, no configuration tool known for panel '%s'" % panel) + else: + os.system("%s &" % self.configuration_tools[panel]) + +@@ -228,7 +228,7 @@ def add_stack_page(self, message, name): + def get_default_adapter_name(self): + name = None + try: +- output = subprocess.check_output(["timeout", "2s", "bt-adapter", "-i"]).strip() ++ output = subprocess.check_output(["timeout", "2s", "bt-adapter", "-i"]).decode("utf-8").strip() + for line in output.split("\n"): + line = line.strip() + if line.startswith("Alias: "): +@@ -260,7 +260,7 @@ def update_status(self, path=None, iter=None, data=None): + else: + explanation_label.set_label("") + except Exception as e: +- print (e) ++ print(e) + return None + + def update_ui_callback(self): +diff --git a/usr/lib/blueberry/rfkillMagic.py b/usr/lib/blueberry/rfkillMagic.py +index 03aaed5..b3c7384 100644 +--- a/usr/lib/blueberry/rfkillMagic.py ++++ b/usr/lib/blueberry/rfkillMagic.py +@@ -1,7 +1,6 @@ + +-import thread ++import _thread as thread + import subprocess +-import os + import re + from gi.repository import GLib + +@@ -32,7 +31,7 @@ def __init__(self, output_callback, debug): + self.start_event_monitor() + + def adapter_check(self): +- res = subprocess.check_output(RFKILL_CHK) ++ res = subprocess.check_output(RFKILL_CHK).decode('utf-8') + + ''' + Assume the output of: +@@ -69,7 +68,7 @@ def start_event_monitor(self): + def event_monitor_thread(self, data): + self.tproc = subprocess.Popen(RFKILL_EVENT_MONITOR, stdout=subprocess.PIPE, stdin=subprocess.PIPE) + while self.tproc.poll() is None and not self.monitor_killer: +- l = self.tproc.stdout.readline() # This blocks until it receives a newline. ++ l = self.tproc.stdout.readline().decode('utf-8') # This blocks until it receives a newline. + self.update_state(l) + + self.tproc = None +diff --git a/usr/lib/blueberry/safechild b/usr/lib/blueberry/safechild +index 9d6918c..20034f5 100755 +--- a/usr/lib/blueberry/safechild ++++ b/usr/lib/blueberry/safechild +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python2 ++#!/usr/bin/env python3 + + import subprocess + import sys +@@ -32,4 +32,4 @@ try: + proc.wait() + break + except Exception as e: +- print "safechild exception: ", e ++ print("safechild exception: ", e)