From 4cb9b30466b0bf79f2bcb2baaf7f1ac3b3b153b5 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Mon, 5 Nov 2012 20:52:51 +0200 Subject: [PATCH] use the first python version found when starting the scripts --- app/solaar.py | 19 ++++++++----------- app/ui/__init__.py | 11 +++++------ app/ui/action.py | 20 +++++++++++++------- bin/hidconsole | 3 ++- bin/scan | 3 ++- bin/solaar | 4 ++-- lib/logitech/unifying_receiver/listener.py | 4 ++-- 7 files changed, 34 insertions(+), 30 deletions(-) diff --git a/app/solaar.py b/app/solaar.py index d6f70676..efd20fa9 100644 --- a/app/solaar.py +++ b/app/solaar.py @@ -1,8 +1,9 @@ #!/usr/bin/env python -APPNAME = 'Solaar' +NAME = 'Solaar' +VERSION = '0.7.1' __author__ = "Daniel Pavel " -__version__ = '0.7' +__version__ = VERSION __license__ = "GPL" # @@ -11,7 +12,7 @@ __license__ = "GPL" def _parse_arguments(): import argparse - arg_parser = argparse.ArgumentParser(prog=APPNAME.lower()) + arg_parser = argparse.ArgumentParser(prog=NAME.lower()) arg_parser.add_argument('-v', '--verbose', action='count', default=0, help='increase the logger verbosity (may be repeated)') @@ -43,18 +44,13 @@ if __name__ == '__main__': # check if the notifications are available and enabled args.notifications &= args.systray - if ui.notify.available and ui.notify.init(APPNAME): + if ui.notify.available and ui.notify.init(NAME): ui.action.toggle_notifications.set_active(args.notifications) else: ui.action.toggle_notifications = None - from receiver import (ReceiverListener, DUMMY) - - window = ui.main_window.create(APPNAME, - DUMMY.name, - DUMMY.max_devices, - args.systray) - + from receiver import DUMMY + window = ui.main_window.create(NAME, DUMMY.name, DUMMY.max_devices, args.systray) if args.systray: menu_actions = (ui.action.toggle_notifications, ui.action.about) @@ -79,6 +75,7 @@ if __name__ == '__main__': GObject.timeout_add(5000, check_for_listener) listener = None + from receiver import ReceiverListener def check_for_listener(retry=True): global listener, notify_missing diff --git a/app/ui/__init__.py b/app/ui/__init__.py index ffdf545a..0c5d7f02 100644 --- a/app/ui/__init__.py +++ b/app/ui/__init__.py @@ -1,18 +1,17 @@ # pass -APPNAME = 'Solaar' -APPVERSION = '0.7' - from . import (notify, status_icon, main_window, pair_window, action) from gi.repository import (GObject, Gtk) GObject.threads_init() +from solaar import NAME as _NAME +_APP_ICONS = (_NAME + '-fail', _NAME + '-init', _NAME) def appicon(receiver_status): - return (APPNAME + '-fail' if receiver_status < 0 else - APPNAME + '-init' if receiver_status < 1 else - APPNAME) + return (_APP_ICONS[0] if receiver_status < 0 else + _APP_ICONS[1] if receiver_status < 1 else + _APP_ICONS[2]) _ICON_THEME = Gtk.IconTheme.get_default() diff --git a/app/ui/action.py b/app/ui/action.py index c1db5133..8f5fb858 100644 --- a/app/ui/action.py +++ b/app/ui/action.py @@ -2,9 +2,13 @@ # # +# from sys import version as PYTTHON_VERSION from gi.repository import Gtk -import ui +import ui.notify +import ui.pair_window +from solaar import NAME as _NAME +from solaar import VERSION as _VERSION def _action(name, label, function, *args): @@ -27,7 +31,7 @@ def _toggle_action(name, label, function, *args): def _toggle_notifications(action): if action.get_active(): - ui.notify.init(ui.APPNAME) + ui.notify.init(_NAME) else: ui.notify.uninit() action.set_sensitive(ui.notify.available) @@ -36,16 +40,18 @@ toggle_notifications = _toggle_action('notifications', 'Notifications', _toggle_ def _show_about_window(action): about = Gtk.AboutDialog() - about.set_icon_name(ui.APPNAME) - about.set_program_name(ui.APPNAME) - about.set_logo_icon_name(ui.APPNAME) - about.set_version(ui.APPVERSION) + about.set_icon_name(_NAME) + about.set_program_name(_NAME) + about.set_logo_icon_name(_NAME) + about.set_version(_VERSION) about.set_license_type(Gtk.License.GPL_2_0) about.set_authors(('Daniel Pavel http://github.com/pwr', )) about.set_website('http://github.com/pwr/Solaar/wiki') + about.set_website_label('Solaar Wiki') + # about.set_comments('Using Python %s\n' % PYTTHON_VERSION.split(' ')[0]) about.run() about.destroy() -about = _action('help-about', 'About ' + ui.APPNAME, _show_about_window) +about = _action('help-about', 'About ' + _NAME, _show_about_window) quit = _action('exit', 'Quit', Gtk.main_quit) diff --git a/bin/hidconsole b/bin/hidconsole index 40196281..743aaf61 100755 --- a/bin/hidconsole +++ b/bin/hidconsole @@ -4,4 +4,5 @@ LIB=`dirname "$0"`/../lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`arch` export PYTHONPATH=$LIB -exec python -OOu -m hidapi.hidconsole "$@" +PYTHON=`which python python2 python3 | head -n 1` +exec $PYTHON -OOu -m hidapi.hidconsole "$@" diff --git a/bin/scan b/bin/scan index b81e0242..20e87ba4 100755 --- a/bin/scan +++ b/bin/scan @@ -4,4 +4,5 @@ LIB=`dirname "$0"`/../lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`arch` export PYTHONPATH=$LIB -exec python -OOu -m logitech.scanner "$@" +PYTHON=`which python python2 python3 | head -n 1` +exec $PYTHON -OOu -m logitech.scanner "$@" diff --git a/bin/solaar b/bin/solaar index 7d9608bb..fdf11a30 100755 --- a/bin/solaar +++ b/bin/solaar @@ -9,5 +9,5 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`arch` export PYTHONPATH=$APP:$LIB export XDG_DATA_DIRS=$SHARE:$XDG_DATA_DIRS -exec python -OOu -m solaar "$@" -#exec python -OOu -m profile -o $TMPDIR/profile.log app/solaar.py "$@" +PYTHON=`which python python2 python3 | head -n 1` +exec $PYTHON -OOu -m solaar "$@" diff --git a/lib/logitech/unifying_receiver/listener.py b/lib/logitech/unifying_receiver/listener.py index 0a3ef737..3871b844 100644 --- a/lib/logitech/unifying_receiver/listener.py +++ b/lib/logitech/unifying_receiver/listener.py @@ -140,6 +140,6 @@ class EventsListener(_Thread): _log.info("queueing unhandled event %s", event) self._events.put(event) - def __nonzero__(self): + def __bool__(self): return bool(self._active and self._handle) - __bool__ = __nonzero__ + __nonzero__ = __bool__