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

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

@ -22,7 +22,7 @@ import os
import gtk import gtk
if gtk.pygtk_version < (2,10,0): if gtk.pygtk_version < (2,10,0):
# raise an ImportError here to trigger the Except statement in interface.py # 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 import time
from FusionIcon.start import wms, apps, options, decorators, init 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 # Do not restart the wm if it's already running
if wms.active == wms.active == wms.old != 'compiz': if wms.active == wms.active == wms.old != 'compiz':
#always restart compiz since we can't know compiz was started correctly #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: else:
print ' * Starting %s' %wms[wms.active].label print(' * Starting %s' %wms[wms.active].label)
wms.start() wms.start()
config.check() config.check()
@ -38,18 +38,18 @@ config.check()
if not parser_options.force_compiz: if not parser_options.force_compiz:
if wms.active not in wms: if wms.active not in wms:
print ' * "%s" not installed' %wms.active print(' * "%s" not installed' %wms.active)
if wms.fallback: if wms.fallback:
print ' ... setting to fallback...' print(' ... setting to fallback...')
else: else:
print ' ... No fallback window manager chosen' print(' ... No fallback window manager chosen')
wms.active = wms.fallback 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 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.active == 'compiz' and env.failsafe:
if wms.fallback: if wms.fallback:
print ' * Failsafe session, setting to fallback...' print(' * Failsafe session, setting to fallback...')
else: else:
print ' ... No fallback window manager chosen' print(' ... No fallback window manager chosen')
wms.active = wms.fallback wms.active = wms.fallback
@ -57,7 +57,7 @@ elif 'compiz' in wms:
wms.active = 'compiz' wms.active = 'compiz'
else: 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. # Set True if using Xorg AIGLX since the '--indirect-rendering' option has no effect in that situation.
env.set() env.set()

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

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

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

Loading…
Cancel
Save