Drop python2 support.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/5/head
Slávek Banko 1 year ago
parent a0703b4ec7
commit f5eacfc30f
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -27,17 +27,17 @@ from optparse import OptionParser
import subprocess import subprocess
# for compiz-kde package checking # for compiz-kde package checking
import apt_pkg import apt_pkg
from apt.progress import OpProgress from apt.progress.base import OpProgress
import gettext import gettext
def _(str): def _(s):
return unicode(gettext.gettext(str), 'UTF-8') return str(gettext.gettext(s), 'UTF-8')
def __(catalog,str): def __(catalog, s):
return unicode(gettext.dgettext(catalog, str), 'UTF-8') return str(gettext.dgettext(catalog, s), 'UTF-8')
def utf8(str): def utf8(s):
if isinstance(str, unicode): if isinstance(s, str):
return str return s
return unicode(str, 'UTF-8') return str(s, 'UTF-8')
class DesktopEffectsCommon(object): class DesktopEffectsCommon(object):
def __init__(self): def __init__(self):
@ -57,18 +57,18 @@ class DesktopEffectsCommon(object):
return False return False
def checkEnabled(self): def checkEnabled(self):
'''checks if the compizasWM file is present, and if so, reads what mode we are in''' '''checks if the compizasWM file is present, and if so, reads what mode we are in'''
if os.path.exists(os.path.expanduser("~/.trinity/share/config/compizasWM")): if os.path.exists(os.path.expanduser("~/.trinity/share/config/compizasWM")):
compizasWM = open(os.path.expanduser("~/.trinity/share/config/compizasWM")) compizasWM = open(os.path.expanduser("~/.trinity/share/config/compizasWM"))
state = compizasWM.readline() state = compizasWM.readline()
return state return state
else: else:
return False return False
def check(self): def check(self):
''' checks the state and changes the UI accordingly. ''' ''' checks the state and changes the UI accordingly. '''
self.installed = self.checkInstalled() self.installed = self.checkInstalled()
self.enabled = self.checkEnabled() self.enabled = self.checkEnabled()
if(self.installed == True): if(self.installed == True):
self.ibText = _("&Remove Desktop Effects") self.ibText = _("&Remove Desktop Effects")
self.showWarning() self.showWarning()
@ -104,25 +104,24 @@ class DesktopEffectsCommon(object):
def done(self): def done(self):
''' action to be done after the user clicks the "cancel" button ''' ''' action to be done after the user clicks the "cancel" button '''
print "signalled" # DEBUG print("signalled") # DEBUG
self.close() self.close()
def apply(self): def apply(self):
''' action to be done after the user clicks the "apply button ''' ''' action to be done after the user clicks the "apply button '''
print "apply clicked" #DEBUG print("apply clicked") #DEBUG
if self.action > 0: if self.action > 0:
if self.action == 1: if self.action == 1:
self.disableEffects() self.disableEffects()
elif self.action == 2: elif self.action == 2:
self.enableStandardEffects() self.enableStandardEffects()
elif self.action == 3: elif self.action == 3:
self.enableExtraEffects() self.enableExtraEffects()
elif self.action == 4: elif self.action == 4:
self.enableCustomEffects() self.enableCustomEffects()
if not self.enabled and not self.action == 1: if not self.enabled and not self.action == 1:
os.spawnl(os.P_NOWAIT, "/opt/trinity/bin/compiz", "--replace") os.spawnl(os.P_NOWAIT, "/opt/trinity/bin/compiz", "--replace")
self.enabled = True self.enabled = True
def btnInstallClicked(self): def btnInstallClicked(self):
if self.installed == True: if self.installed == True:
@ -138,18 +137,18 @@ class DesktopEffectsCommon(object):
# the functions toggled by radio boxes # the functions toggled by radio boxes
def noEffects(self): def noEffects(self):
print "radio toggled" # DEBUG print("radio toggled") # DEBUG
self.action = 1 self.action = 1
# self.apply() # self.apply()
def standardEffects(self): def standardEffects(self):
print "radio toggled" # DEBUG print("radio toggled") # DEBUG
self.action = 2 self.action = 2
# self.apply() # self.apply()
def extraEffects(self): def extraEffects(self):
print "radio toggled" # DEBUG print("radio toggled") # DEBUG
self.action = 3 self.action = 3
def customEffects(self): def customEffects(self):
print "radio toggled" # DEBUG print("radio toggled") # DEBUG
self.action = 4 self.action = 4
# self.apply() # self.apply()
@ -161,70 +160,68 @@ class DesktopEffectsCommon(object):
subprocess.call(['tdesudo', '-c' '/opt/trinity/bin/adept_batch remove compiz-kde-trinity compiz-fusion-plugins-main-trinity compiz-fusion-plugins-extra-trinity']) subprocess.call(['tdesudo', '-c' '/opt/trinity/bin/adept_batch remove compiz-kde-trinity compiz-fusion-plugins-main-trinity compiz-fusion-plugins-extra-trinity'])
except: except:
subprocess.call(['kdialog', '--sorry', 'Adept Batch is not installed on this system']) subprocess.call(['kdialog', '--sorry', 'Adept Batch is not installed on this system'])
def disableEffects(self): def disableEffects(self):
'''remove compiz as the default WM''' '''remove compiz as the default WM'''
os.remove(os.path.expanduser("~/.trinity/share/config/compizasWM")) os.remove(os.path.expanduser("~/.trinity/share/config/compizasWM"))
self.enabled = False self.enabled = False
def enableStandardEffects(self): def enableStandardEffects(self):
'''copy the .ini to Default.ini and enable compiz as default WM''' '''copy the .ini to Default.ini and enable compiz as default WM'''
code = os.system('mkdir -p ~/.config/compiz/compizconfig') code = os.system('mkdir -p ~/.config/compiz/compizconfig')
try: try:
enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"w") enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"w")
if enable.readline() == "custom": if enable.readline() == "custom":
customeffects = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"r") customeffects = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"r")
backupfile = open(os.path.expanduser("~/.config/compiz/compizconfig/Custom.ini"),"w") backupfile = open(os.path.expanduser("~/.config/compiz/compizconfig/Custom.ini"),"w")
backupfile.write(customeffects) backupfile.write(customeffects)
backupfile.close() backupfile.close()
customeffects.close() customeffects.close()
except: except:
print "error" print("error")
enable.write("standardeffects") enable.write("standardeffects")
enable.close() enable.close()
config = open(os.path.join(self.DATADIR,"MediumEffects.ini"),"r") config = open(os.path.join(self.DATADIR,"MediumEffects.ini"),"r")
dest = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"w") dest = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"w")
dest.write(config.read()) dest.write(config.read())
dest.close() dest.close()
config.close() config.close()
print "standardEffects enabled" #DEBUG print("standardEffects enabled") #DEBUG
def enableExtraEffects(self): def enableExtraEffects(self):
''' copy the extraeffects.ini to Default.ini and enable compiz as defaultWM''' ''' copy the extraeffects.ini to Default.ini and enable compiz as defaultWM'''
code = os.system('mkdir -p ~/.config/compiz/compizconfig') code = os.system('mkdir -p ~/.config/compiz/compizconfig')
if os.path.exists(os.path.expanduser("~/.trinity/share/config/compizasWM")): if os.path.exists(os.path.expanduser("~/.trinity/share/config/compizasWM")):
enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"r") enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"r")
if enable.readline() == "custom": if enable.readline() == "custom":
customeffects = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"r") customeffects = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"r")
backupfile = open(os.path.expanduser("~/.config/compiz/compizconfig/Custom.ini"),"w") backupfile = open(os.path.expanduser("~/.config/compiz/compizconfig/Custom.ini"),"w")
backupfile.write(customeffects) backupfile.write(customeffects)
backupfile.close() backupfile.close()
customeffects.close() customeffects.close()
enable.close() enable.close()
enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"w") enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"w")
enable.write("extraeffects") enable.write("extraeffects")
enable.close() enable.close()
config = open(os.path.join(self.DATADIR,"HighEffects.ini"),"r") config = open(os.path.join(self.DATADIR,"HighEffects.ini"),"r")
dest = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"w") dest = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"w")
dest.write(config.read()) dest.write(config.read())
dest.close() dest.close()
config.close() config.close()
print "extraEffects enabled" #DEBUG print("extraEffects enabled") #DEBUG
def enableCustomEffects(self): def enableCustomEffects(self):
code = os.system('mkdir -p ~/.config/compiz/compizconfig') code = os.system('mkdir -p ~/.config/compiz/compizconfig')
try: try:
config = open(os.path.expanduser("~/.config/compiz/compizconfig/Custom.ini"),"r") config = open(os.path.expanduser("~/.config/compiz/compizconfig/Custom.ini"),"r")
except: except:
print "no custom effects file, creating blank .ini" #DEBUG print("no custom effects file, creating blank .ini") #DEBUG
config = open(os.path.join(self.DATADIR,"BlankEffects.ini"),"r") config = open(os.path.join(self.DATADIR,"BlankEffects.ini"),"r")
enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"w") enable = open(os.path.expanduser("~/.trinity/share/config/compizasWM"),"w")
enable.write("custom") enable.write("custom")
enable.close() enable.close()
dest = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"w") dest = open(os.path.expanduser("~/.config/compiz/compizconfig/Default.ini"),"w")
dest.write(config.read()) dest.write(config.read())
dest.close() dest.close()
config.close() config.close()

@ -2736,31 +2736,31 @@ class DesktopEffectsDialog(TQDialog):
def closeButtonClicked(self): def closeButtonClicked(self):
print "DesktopEffectsDialog.closeButtonClicked(): Not implemented yet" print("DesktopEffectsDialog.closeButtonClicked(): Not implemented yet")
def installButtonClicked(self): def installButtonClicked(self):
print "DesktopEffectsDialog.installButtonClicked(): Not implemented yet" print("DesktopEffectsDialog.installButtonClicked(): Not implemented yet")
def noEffects(self): def noEffects(self):
print "DesktopEffectsDialog.noEffects(): Not implemented yet" print("DesktopEffectsDialog.noEffects(): Not implemented yet")
def standardEffects(self): def standardEffects(self):
print "DesktopEffectsDialog.standardEffects(): Not implemented yet" print("DesktopEffectsDialog.standardEffects(): Not implemented yet")
def extraEffects(self): def extraEffects(self):
print "DesktopEffectsDialog.extraEffects(): Not implemented yet" print("DesktopEffectsDialog.extraEffects(): Not implemented yet")
def customEffects(self): def customEffects(self):
print "DesktopEffectsDialog.customEffects(): Not implemented yet" print("DesktopEffectsDialog.customEffects(): Not implemented yet")
def apply(self): def apply(self):
print "DesktopEffectsDialog.apply(): Not implemented yet" print("DesktopEffectsDialog.apply(): Not implemented yet")
def cancel(self): def cancel(self):
print "DesktopEffectsDialog.cancel(): Not implemented yet" print("DesktopEffectsDialog.cancel(): Not implemented yet")
def __tr(self,s,c = None): def __tr(self,s,c = None):
return tqApp.translate("DesktopEffectsDialog",s,c) return tqApp.translate(b"DesktopEffectsDialog",s.encode(),c)
if __name__ == "__main__": if __name__ == "__main__":
appname = "" appname = ""

@ -27,20 +27,20 @@ from tdecore import *
import subprocess import subprocess
# for compiz-kde package checking # for compiz-kde package checking
import apt_pkg import apt_pkg
from apt.progress import OpProgress from apt.progress.base import OpProgress
from DesktopEffectsDialog import DesktopEffectsDialog from DesktopEffectsDialog import DesktopEffectsDialog
from DesktopEffectsCommon import DesktopEffectsCommon from DesktopEffectsCommon import DesktopEffectsCommon
import gettext import gettext
def _(str): def _(s):
return unicode(gettext.gettext(str), 'UTF-8') return str(gettext.gettext(s), 'UTF-8')
def __(catalog,str): def __(catalog, s):
return unicode(gettext.dgettext(catalog, str), 'UTF-8') return str(gettext.dgettext(catalog, s), 'UTF-8')
def utf8(str): def utf8(s):
if isinstance(str, unicode): if isinstance(s, str):
return str return s
return unicode(str, 'UTF-8') return str(s, 'UTF-8')
class DesktopEffectsTDE(DesktopEffectsDialog, DesktopEffectsCommon): class DesktopEffectsTDE(DesktopEffectsDialog, DesktopEffectsCommon):
def __init__(self): def __init__(self):
@ -75,7 +75,7 @@ class DesktopEffectsTDE(DesktopEffectsDialog, DesktopEffectsCommon):
self.applyButton.setIconSet(TDEGlobal.iconLoader().loadIconSet("apply", self.applyButton.setIconSet(TDEGlobal.iconLoader().loadIconSet("apply",
TDEIcon.NoGroup, TDEIcon.SizeSmall)) TDEIcon.NoGroup, TDEIcon.SizeSmall))
# Close # Close
self.cancelButton.setText(__("tdelibs","&Cancel")) self.cancelButton.setText(__("tdelibs","&Cancel"))
self.cancelButton.setIconSet(TDEGlobal.iconLoader().loadIconSet("cancel", self.cancelButton.setIconSet(TDEGlobal.iconLoader().loadIconSet("cancel",
TDEIcon.NoGroup, TDEIcon.SizeSmall)) TDEIcon.NoGroup, TDEIcon.SizeSmall))

Loading…
Cancel
Save