Drop python2 support.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
master
Slávek Banko 2 years ago
parent 92dc134f1b
commit 695b918fbb
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -65,7 +65,7 @@ Xgl: True in Xgl'''
else:
failsafe_str = ''
print ' * Detected Session: %s%s' %(failsafe_str, self.desktop)
print(' * Detected Session: %s%s' %(failsafe_str, self.desktop))
## Save the output of glxinfo and xvinfo for later use:
@ -74,7 +74,7 @@ Xgl: True in Xgl'''
if run(['which', 'glxinfo'], 'call', quiet=True) == 0:
self.glxinfo = run('glxinfo', 'output')
else:
raise SystemExit, ' * Error: glxinfo not installed!'
raise SystemExit(' * Error: glxinfo not installed!')
# make a temp environment
indirect_environ = os.environ.copy()
@ -84,7 +84,7 @@ Xgl: True in Xgl'''
if run(['which', 'xvinfo'], 'call', quiet=True) == 0:
self.xvinfo = run('xvinfo', 'output')
else:
raise SystemExit, ' * Error: xvinfo not installed!'
raise SystemExit(' * Error: xvinfo not installed!')
line = [l for l in self.glxinfo.splitlines() if 'client glx vendor string:' in l]
if line:
@ -113,33 +113,33 @@ Xgl: True in Xgl'''
# Check for Intel and export INTEL_BATCH
if 'Intel' in self.glxinfo:
print ' * Intel detected, exporting: INTEL_BATCH=1'
print(' * Intel detected, exporting: INTEL_BATCH=1')
os.environ['INTEL_BATCH'] = '1'
# Check TFP and export LIBGL_ALWAYS_INDIRECT if needed
if self.tfp != 'direct':
print ' * No %s with direct rendering context' %tfp
print(' * No %s with direct rendering context' %tfp)
if self.tfp == 'indirect':
print ' ... present with indirect rendering, exporting: LIBGL_ALWAYS_INDIRECT=1'
print(' ... present with indirect rendering, exporting: LIBGL_ALWAYS_INDIRECT=1')
os.environ['LIBGL_ALWAYS_INDIRECT'] = '1'
else:
print ' ... nor with indirect rendering, this isn\'t going to work!'
print(' ... nor with indirect rendering, this isn\'t going to work!')
# If using Xgl with a proprietary driver, exports LD_PRELOAD=<mesa libGL>
if self.Xgl and self.glx_vendor != 'SGI':
print ' * Non-mesa driver on Xgl detected'
from data import mesa_libgl_locations
print(' * Non-mesa driver on Xgl detected')
from .data import mesa_libgl_locations
location = [l for l in mesa_libgl_locations if os.path.exists(l)]
if location:
print ' ... exporting: LD_PRELOAD=%s' %location[0]
print(' ... exporting: LD_PRELOAD=%s' %location[0])
os.environ['LD_PRELOAD'] = location[0]
else:
# kindly let the user know... but don't abort (maybe it will work :> )
print ' ... no mesa libGL found for preloading, this may not work!'
print(' ... no mesa libGL found for preloading, this may not work!')
# Check for nvidia on Xorg
if not self.Xgl and self.glx_vendor == 'NVIDIA Corporation':
print ' * NVIDIA on Xorg detected, exporting: __GL_YIELD=NOTHING'
print(' * NVIDIA on Xorg detected, exporting: __GL_YIELD=NOTHING')
os.environ['__GL_YIELD'] = 'NOTHING'
env = Environment()

@ -30,26 +30,26 @@ interfaces={
def import_interface(interface):
try:
if interface in interfaces:
print ' * Using the', interfaces[interface], 'Interface'
print(' * Using the', interfaces[interface], 'Interface')
__import__('FusionIcon.interface_%s' %interface)
else:
print ' *** Error: "%s" interface is invalid, this should not happen' %interface
print(' *** Error: "%s" interface is invalid, this should not happen' %interface)
raise SystemExit
except ImportError, e:
except ImportError as e:
if [i for i in interfaces if 'interface_%s' %i in str(e)]:
print ' * Interface not installed'
print(' * Interface not installed')
else:
print ' *', e
print(' *', e)
#doesn't work so remove it from the dict
del interfaces[interface]
if interfaces:
print ' ... Trying another interface'
print(' ... Trying another interface')
choose_interface()
else:
print ' *** Error: All interfaces failed, aborting!'
print(' *** Error: All interfaces failed, aborting!')
raise SystemExit
def choose_interface(try_first=None):
@ -61,7 +61,7 @@ def choose_interface(try_first=None):
if try_first in interfaces:
chosen_interface = try_first
else:
raise SystemExit, ' *** Error: No such interface: %s' %try_first
raise SystemExit(' *** Error: No such interface: %s' %try_first)
else:
# gtk for everybody for now
@ -83,7 +83,7 @@ def choose_interface(try_first=None):
# interfaces is empty
else:
raise SystemExit, ' *** no available interfaces, this should not happen'
raise SystemExit(' *** no available interfaces, this should not happen')
import_interface(chosen_interface)

@ -22,7 +22,7 @@ import os
import gtk
if gtk.pygtk_version < (2,10,0):
# raise an ImportError here to trigger the Except statement in interface.py
raise ImportError, 'PyGtk 2.10.0 or later required'
raise ImportError('PyGtk 2.10.0 or later required')
import time
from FusionIcon.start import wms, apps, options, decorators, init

@ -27,9 +27,9 @@ def init():
# Do not restart the wm if it's already running
if wms.active == wms.active == wms.old != 'compiz':
#always restart compiz since we can't know compiz was started correctly
print ' * %s is already running' %wms[wms.active].label
print(' * %s is already running' %wms[wms.active].label)
else:
print ' * Starting %s' %wms[wms.active].label
print(' * Starting %s' %wms[wms.active].label)
wms.start()
config.check()
@ -38,18 +38,18 @@ config.check()
if not parser_options.force_compiz:
if wms.active not in wms:
print ' * "%s" not installed' %wms.active
print(' * "%s" not installed' %wms.active)
if wms.fallback:
print ' ... setting to fallback...'
print(' ... setting to fallback...')
else:
print ' ... No fallback window manager chosen'
print(' ... No fallback window manager chosen')
wms.active = wms.fallback
# if in a failsafe session, don't start with compiz (provides an easy way to make sure metacity starts for gnome users if compiz breaks)
if wms.active == 'compiz' and env.failsafe:
if wms.fallback:
print ' * Failsafe session, setting to fallback...'
print(' * Failsafe session, setting to fallback...')
else:
print ' ... No fallback window manager chosen'
print(' ... No fallback window manager chosen')
wms.active = wms.fallback
@ -57,7 +57,7 @@ elif 'compiz' in wms:
wms.active = 'compiz'
else:
raise SystemExit, ' *** Error: "--force-compiz" used and compiz not installed!'
raise SystemExit(' *** Error: "--force-compiz" used and compiz not installed!')
# Set True if using Xorg AIGLX since the '--indirect-rendering' option has no effect in that situation.
env.set()

@ -18,7 +18,7 @@
# Author(s): crdlb
# Copyright 2007 Christopher Williams <christopherw@verizon.net>
import os, compizconfig, ConfigParser, time
import os, compizconfig, configparser, time
import data as _data
from parser import options as parser_options
from environment import env
@ -44,7 +44,7 @@ class Application(object):
self.label = installed.apps[name][2]
def launch(self):
print ' * Launching %s' %self.label
print(' * Launching %s' %self.label)
run(self.command)
class Applications(dict):
@ -69,7 +69,7 @@ class CompizOption(object):
return self.config.getboolean('compiz options', self.name)
def __set(self, value):
print ' * Setting option %s to %s' %(self.label, value)
print(' * Setting option %s to %s' %(self.label, value))
self.config.set('compiz options', self.name, str(bool(value)).lower())
self.config.write(open(self.config.config_file, 'w'))
@ -112,7 +112,7 @@ class WindowManagers(dict):
self.fallback = wm[0]
elif self:
self.fallback = self.keys()[0]
self.fallback = list(self.keys())[0]
self.__set_old()
@ -128,9 +128,9 @@ class WindowManagers(dict):
def __set(self, value):
if value in wms:
print ' * Setting window manager to', wms[value].label
print(' * Setting window manager to', wms[value].label)
elif not value:
print ' * Setting window manager to empty value'
print(' * Setting window manager to empty value')
self.config.set('window manager', 'active wm', str(value))
self.config.write(open(self.config.config_file, 'w'))
@ -171,22 +171,22 @@ class WindowManagers(dict):
time.sleep(0.5)
# do it
print ' ... executing:', ' '.join(compiz_command)
print(' ... executing:', ' '.join(compiz_command))
run(compiz_command, quiet=False)
elif self.active:
run(self[self.active].command)
else:
print ' * No active WM set; not going to do anything.'
print(' * No active WM set; not going to do anything.')
def restart(self):
if wms.active:
print ' * Reloading %s' %wms.active
print(' * Reloading %s' %wms.active)
self.start()
else:
print ' * Not reloading, no active window manager set'
print(' * Not reloading, no active window manager set')
active = property(__get, __set)
@ -213,7 +213,7 @@ class CompizDecorators(dict):
# Open CompizConfig context
if parser_options.verbose:
print ' * Opening CompizConfig context'
print(' * Opening CompizConfig context')
try:
context = compizconfig.Context( \
@ -236,24 +236,24 @@ class CompizDecorators(dict):
self.default = 'emerald'
elif self:
self.default = self.keys()[0]
self.default = list(self.keys())[0]
def __set(self, decorator):
if decorator in self:
self.command.Plugin.Context.ProcessEvents()
print ' * Setting decorator to %s ("%s")' \
%(self[decorator].label, self[decorator].command)
print(' * Setting decorator to %s ("%s")' \
%(self[decorator].label, self[decorator].command))
self.command.Value = self[decorator].command
self.command.Plugin.Context.Write()
elif not decorator:
print ' * Not setting decorator to none'
print(' * Not setting decorator to none')
def __get(self):
_decorator = [d for d in self if self.command.Value == self[d].command]
if _decorator:
decorator = _decorator[0]
else:
print ' * Decorator "%s" is invalid.' %self.command.Value
print(' * Decorator "%s" is invalid.' %self.command.Value)
self.active = self.default
decorator = self.command.Value
return decorator
@ -263,7 +263,7 @@ class CompizDecorators(dict):
class Installed(object):
def __init__(self, data):
print ' * Searching for installed applications...'
print(' * Searching for installed applications...')
### Compiz Detection
bins = {}
@ -326,7 +326,7 @@ class Installed(object):
del self.apps[app]
if parser_options.verbose:
print output.rstrip()
print(output.rstrip())
compiz_optionlist = []
@ -343,11 +343,11 @@ class Installed(object):
if data.options[option][1] not in compiz_optionlist:
del self.options[option]
class Configuration(ConfigParser.ConfigParser):
class Configuration(configparser.ConfigParser):
def __init__(self, data):
ConfigParser.ConfigParser.__init__(self)
configparser.ConfigParser.__init__(self)
self.config_folder = data.config_folder
self.config_file = data.config_file
@ -356,12 +356,12 @@ class Configuration(ConfigParser.ConfigParser):
# Configuration file setup
if not os.path.exists(self.config_folder):
if parser_options.verbose:
print ' * Creating configuration folder...'
print(' * Creating configuration folder...')
os.makedirs(self.config_folder)
if not os.path.exists(self.config_file):
if parser_options.verbose:
print ' * Creating configuration file...'
print(' * Creating configuration file...')
self.create_config_file()
try:
@ -374,9 +374,9 @@ class Configuration(ConfigParser.ConfigParser):
except:
# back it up and make a new one
print ' * Configuration file (%s) invalid' %self.config_file
print(' * Configuration file (%s) invalid' %self.config_file)
self.reset_config_file()
print ' * Generating new configuration file'
print(' * Generating new configuration file')
self.create_config_file()
def create_config_file(self):
@ -405,9 +405,9 @@ class Configuration(ConfigParser.ConfigParser):
config_backup = '%s.backup.%s' \
%(self.config_file, time.strftime('%Y%m%d%H%M%S'))
os.rename(self.config_file, config_backup)
print ' ... backed up to:', config_backup
print(' ... backed up to:', config_backup)
else:
print ' ... no configuration file found'
print(' ... no configuration file found')
# Instantiate...
_installed = Installed(_data)

@ -30,24 +30,24 @@ from FusionIcon.parser import options
if options.reset:
try:
from FusionIcon.data import config_file
print ' * Configuration file (%s) being reset' %config_file
print(' * Configuration file (%s) being reset' %config_file)
if os.path.exists(config_file):
config_backup = '%s.backup.%s' %(config_file, time.strftime('%Y%m%d%H%M%S'))
os.rename(config_file, config_backup)
print ' ... backed up to:', config_backup
print(' ... backed up to:', config_backup)
else:
print ' ... no configuration file found'
print(' ... no configuration file found')
except:
print ' *** Error: configuration reset failed:'
print(' *** Error: configuration reset failed:')
raise SystemExit
sys.exit()
if options.seconds and 0 < options.seconds <= 60:
print ' * Sleeping for %s seconds' %options.seconds
print(' * Sleeping for %s seconds' %options.seconds)
time.sleep(options.seconds)
if options.no_interface:

@ -34,7 +34,7 @@ class uninstall(_install):
return
for f in files:
print 'Uninstalling %s' %f.strip()
print('Uninstalling %s' %f.strip())
try:
os.unlink(f.strip())
except:
@ -57,7 +57,7 @@ available_interfaces = {
# packages.append(available_interfaces[interface])
#else:
packages.extend(available_interfaces.values())
packages.extend(list(available_interfaces.values()))
data_files = [
@ -110,9 +110,9 @@ if sys.argv[1] == 'install':
%s/share/icons/hicolor''' % prefix
root_specified = [s for s in sys.argv if s.startswith('--root')]
if not root_specified or root_specified[0] == '--root=/':
print 'Updating Gtk icon cache.'
print('Updating Gtk icon cache.')
os.system(gtk_update_icon_cache)
else:
print '''*** Icon cache not updated. After install, run this:
*** %s''' % gtk_update_icon_cache
print('''*** Icon cache not updated. After install, run this:
*** %s''' % gtk_update_icon_cache)

Loading…
Cancel
Save