diff options
author | TingPing <tingping@tingping.se> | 2013-12-29 19:41:10 -0500 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-01-01 14:11:11 -0500 |
commit | 8768ba76f8b6aa760822e1c83ba82477ae601314 (patch) | |
tree | e96047211ddc4d05578ed9bbe2cfc17e593e6abc | |
parent | Merge pull request #19 from TingPing/patch-1 (diff) | |
download | redshift-ng-8768ba76f8b6aa760822e1c83ba82477ae601314.tar.gz redshift-ng-8768ba76f8b6aa760822e1c83ba82477ae601314.tar.bz2 redshift-ng-8768ba76f8b6aa760822e1c83ba82477ae601314.tar.xz |
Port redshift-gtk to Python3
Python 2 is no longer supported
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/redshift-gtk/Makefile.am | 7 | ||||
-rw-r--r-- | src/redshift-gtk/redshift-gtk.in (renamed from src/redshift-gtk/redshift-gtk) | 6 | ||||
-rw-r--r-- | src/redshift-gtk/statusicon.py | 10 |
4 files changed, 16 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac index e82ee03..550ed0f 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ PKG_CHECK_MODULES([GEOCLUE], [geoclue], [have_geoclue=yes], [have_geoclue=no]) AC_CHECK_HEADER([windows.h], [have_windows_h=yes], [have_windows_h=no]) # Check for Python -AM_PATH_PYTHON([2.6], [have_python=yes], [have_python=no]) +AM_PATH_PYTHON([3.3], [have_python=yes], [have_python=no]) # Check RANDR method AC_MSG_CHECKING([whether to enable RANDR method]) diff --git a/src/redshift-gtk/Makefile.am b/src/redshift-gtk/Makefile.am index 9eb0cdb..96d7718 100644 --- a/src/redshift-gtk/Makefile.am +++ b/src/redshift-gtk/Makefile.am @@ -11,11 +11,14 @@ redshift_gtkdir = $(pythondir)/redshift_gtk dist_bin_SCRIPTS = redshift-gtk endif -EXTRA_DIST = defs.py.in -CLEANFILES = defs.py +EXTRA_DIST = defs.py.in redshift-gtk.in +CLEANFILES = defs.py redshift-gtk # Local python definitions defs.py: defs.py.in $(AM_V_GEN)sed -e "s|\@bindir\@|$(bindir)|g" \ -e "s|\@localedir\@|$(localedir)|g" $< > $@ + +redshift-gtk: redshift-gtk.in + $(AM_V_GEN)sed -e "s|\@pythondir\@|$(pythondir)|g" $< > $@ diff --git a/src/redshift-gtk/redshift-gtk b/src/redshift-gtk/redshift-gtk.in index 3ec3010..ba6e1ac 100644 --- a/src/redshift-gtk/redshift-gtk +++ b/src/redshift-gtk/redshift-gtk.in @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # redshift-gtk -- GTK+ Redshift launcher script # This file is part of Redshift. @@ -17,6 +17,10 @@ # Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> +import sys + +# Some non-standard install paths may need to be added +sys.path.append('@pythondir@') if __name__ == '__main__': from redshift_gtk.statusicon import run diff --git a/src/redshift-gtk/statusicon.py b/src/redshift-gtk/statusicon.py index 15a822b..626b9e3 100644 --- a/src/redshift-gtk/statusicon.py +++ b/src/redshift-gtk/statusicon.py @@ -34,8 +34,8 @@ try: except ImportError: appindicator = None -import defs -import utils +from . import defs +from . import utils _ = gettext.gettext @@ -99,7 +99,7 @@ class RedshiftStatusIcon(object): try: autostart_item.set_active(utils.get_autostart()) except IOError as strerror: - print strerror + print(strerror) autostart_item.set_property('sensitive', False) else: autostart_item.connect('toggled', self.autostart_cb) @@ -185,7 +185,7 @@ class RedshiftStatusIcon(object): # Start child process with C locale so we can parse the output env = os.environ.copy() env['LANG'] = env['LANGUAGE'] = env['LC_ALL'] = env['LC_MESSAGES'] = 'C' - self.process = GLib.spawn_async(args, envp=['{}={}'.format(k,v) for k, v in env.iteritems()], + self.process = GLib.spawn_async(args, envp=['{}={}'.format(k,v) for k, v in env.items()], flags=GLib.SPAWN_DO_NOT_REAP_CHILD, standard_output=True, standard_error=True) @@ -299,7 +299,7 @@ class RedshiftStatusIcon(object): def child_data_cb(self, f, cond, data): stdout, ib = data - ib.buf += os.read(f, 256) + ib.buf += os.read(f, 256).decode('utf-8') # Split input at line break sep = True |