Drop python2 support.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/8/head
Slávek Banko 2 months ago committed by Michele Calgaro
parent b9c0b6996a
commit 94f5a3f12e
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -75,8 +75,8 @@ class GrubConfigAppClass(programbase):
#--- Load menu.lst using the load_menulst() method
self.load_menulst()
print self.globalvars
print self.itemslist
print(self.globalvars)
print(self.itemslist)
# - GRUB Options Tab -
if standalone:
@ -273,12 +273,12 @@ class GrubConfigAppClass(programbase):
self.oslistview.setSelected(self.oslistviewitems[0],True)
ops_list = self.load_osprobe()
print ops_list # mhb debug
print(ops_list) # mhb debug
#######################################################################
# reload listviews, because they have changed
def reloadListViews(self,name):
print "reloaded"
print("reloaded")
# you should repaint the one that is not changed on screen
if name == "oslist":
self.oslistview.clear()
@ -298,7 +298,7 @@ class GrubConfigAppClass(programbase):
for item in self.itemslist:
try:
if self.itemslist.index(item) == int(self.globalvars['default'][0]):
print "bam!"
print("bam!")
self.itemslistviewitems.append(BoldListViewItem(self.itemslistview,self.itemslistview.lastItem(),item['title'][0]))
else:
self.itemslistviewitems.append(TDEListViewItem(self.itemslistview,self.itemslistview.lastItem(),item['title'][0]))
@ -349,12 +349,12 @@ class GrubConfigAppClass(programbase):
self.customoptions.setText(customoptions[:-1])
self.updatingGUI = False
print "oslistview item selected" #mhb debug
print("oslistview item selected") #mhb debug
pass
#######################################################################
def slotDisplayNameLabelChanged(self, string):
if(self.updatingGUI == False):
print "display name changed" #mhb debug
print("display name changed") #mhb debug
i = self.oslistviewitems.index(self.oslistview.selectedItem())
self.itemslist[i]["title"][0] = string
self.oslistview.selectedItem().setText(0,string)
@ -362,7 +362,7 @@ class GrubConfigAppClass(programbase):
pass
#######################################################################
def slotUpButtonClicked(self):
print "UpButton clicked" #mhb debug
print("UpButton clicked") #mhb debug
i = self.itemslistviewitems.index(self.itemslistview.selectedItem())
self.itemslistview.selectedItem().itemAbove().moveItem(self.itemslistview.selectedItem())
# itemslist should have the same i for the same option
@ -375,7 +375,7 @@ class GrubConfigAppClass(programbase):
#######################################################################
def slotDownButtonClicked(self):
print "DownButton clicked" #mhb debug
print("DownButton clicked") #mhb debug
i = self.itemslistviewitems.index(self.itemslistview.selectedItem())
self.itemslistview.selectedItem().moveItem(self.itemslistview.selectedItem().itemBelow())
if(i != len(self.itemslist)-1):
@ -387,7 +387,7 @@ class GrubConfigAppClass(programbase):
#######################################################################
def slotSetDefaultButtonClicked(self):
print "SetDefaultButton cliicked" #mhb debug
print("SetDefaultButton cliicked") #mhb debug
try:
defaultn = int(self.globalvars["default"][0])
except ValueError:
@ -419,7 +419,7 @@ class GrubConfigAppClass(programbase):
#self.__updateGroupList()
self.updatingGUI = False
programbase.exec_loop(self)
print "done"
print("done")
#######################################################################
@ -453,7 +453,7 @@ class GrubConfigAppClass(programbase):
for line in menufd:
# Checks if the first non-white char in a line is a #
if re.search(r'^(/s)*#',line) or re.search(r'^(/s)*$',line):
print "a commented line" # mhb debug
print("a commented line") # mhb debug
if itemlock == 1:
itemlock = 0
currentitem += 1
@ -499,7 +499,7 @@ class GrubConfigAppClass(programbase):
pass
# okay, it's not commented
else:
print "a not commented line" # mhb debug
print("a not commented line") # mhb debug
self.modifiedlines.append(linenum)
# we presume the first character is already a name
var_name = line.split()[0]
@ -509,7 +509,7 @@ class GrubConfigAppClass(programbase):
if var_name in parsable:
# cat 0 - a title - triggers itemlock, has a name and a value, which should be stored as text
if var_name == "title":
print line.split(None,1)
print(line.split(None,1))
var_value.append(line.split(None,1)[1][:-1])
itemlock = 1
self.itemslist.append({})
@ -561,7 +561,7 @@ class GrubConfigAppClass(programbase):
#print "it has no value" # mhb debug
# print "parsed another line" # mhb debug
linenum += 1;
print "load_menulst() called" # mhb debug
print("load_menulst() called") # mhb debug
return "not working yet"
#######################################################################
@ -576,7 +576,7 @@ class GrubConfigAppClass(programbase):
# 2. writing the lines in another list (or something more efficient
output = {}
# the globals first
for unit, value in self.globalvars.items():
for unit, value in list(self.globalvars.items()):
lines.append(value[-1])
temp_str=""
temp_str+=(str(unit)+" ")
@ -586,7 +586,7 @@ class GrubConfigAppClass(programbase):
# itemslist next (abattoir)
for item in self.itemslist:
for unit, value in reversed(item.items()):
for unit, value in reversed(list(item.items())):
lines.append(value[-1])
temp_str=""
temp_str+=(str(unit)+" ")
@ -605,8 +605,8 @@ class GrubConfigAppClass(programbase):
# read the menu.lst again (or rather its copy, to prevent the file being changed)
# line by line write it in the output file (to be exact, to a file in /tmp)
linenum = 0
print linecontent
print lines
print(linecontent)
print(lines)
# foreach file as line:
for originalline in trfile:
# if its number isn't in the location list, simply write it
@ -627,7 +627,7 @@ class GrubConfigAppClass(programbase):
# mhb TODO: Exception handling
os.remove(self.readfilename)
print "save_menulst() called" # mhb debug
print("save_menulst() called") # mhb debug
return "not working yet"
@ -637,10 +637,10 @@ class GrubConfigAppClass(programbase):
detected = os.popen('os-prober').readlines()
ops_list = []
for ops in detected:
ops = string.replace(ops,"\n","")
ops = ops.replace("\n","")
temp_list = ops.split(':')
partition = temp_list[0]
temp_list[0] = string.replace(temp_list[0],"/dev/","")
temp_list[0] = temp_list[0].replace("/dev/","")
re_obj = re.search(r'([sh]d)([a-z])([0-9])*$',temp_list[0])
disk = ord(re_obj.group(2))%97
part = int(re_obj.group(3))-1
@ -662,7 +662,7 @@ class GrubConfigAppClass(programbase):
linux_os = os.popen('linux-boot-prober '+partition).readlines()
linux_list = []
for lops in linux_os:
lops = string.replace(lops,"\n","")
lops = lops.replace("\n","")
temp_linux_list = lops.split(':')
linux_list.append(temp_linux_list)
temp_list.append(linux_list)
@ -680,7 +680,7 @@ def create_grubconfig(parent,name):
##########################################################################
def MakeAboutData():
aboutdata = TDEAboutData("guidance", programname, version,
unicode(i18n("Boot Loader Configuration Tool")).encode(locale.getpreferredencoding()),
str(i18n("Boot Loader Configuration Tool")).encode(locale.getpreferredencoding()),
TDEAboutData.License_GPL, "Copyright (C) 2006-2007 Martin Böhm")
aboutdata.addAuthor("Martin Böhm", "Developer", "martin.bohm@kubuntu.org", "http://mhb.ath.cx/")
aboutdata.addAuthor("Simon Edwards", "Developer", "simon@simonzone.com", "http://www.simonzone.com/software/")

@ -44,8 +44,8 @@ class XF86Screen(object):
(rc,x,y) = ixf86misc.XRRQueryExtension(self.display)
if rc==0:
return
except AttributeError, errmsg:
print "Trapped AttributeError:", errmsg, " - attempting to continue."
except AttributeError as errmsg:
print("Trapped AttributeError:", errmsg, " - attempting to continue.")
return
self.screenconfig = ixf86misc.XRRGetScreenInfo(self.display, ixf86misc.RootWindow(self.display, self.screenid))
@ -140,7 +140,7 @@ class XF86Server(object):
self.displayname = displayname
self.display = ixf86misc.XOpenDisplay(displayname)
if self.display is None:
raise XF86Error, "Couldn't connect to X server."
raise XF86Error("Couldn't connect to X server.")
self._defaultscreen = ixf86misc.DefaultScreen(self.display)
@ -169,29 +169,29 @@ class XF86Error(Exception):
if __name__=='__main__':
xg = XF86Server()
xs = xg.getDefaultScreen()
print "Number of screens:",str(len(xg.screens))
print "Idle seconds:",xs.getIdleSeconds()
print
print "Gamma:"+str(xs.getGamma())
print
print("Number of screens:",str(len(xg.screens)))
print("Idle seconds:",xs.getIdleSeconds())
print()
print("Gamma:"+str(xs.getGamma()))
print()
if xg.resolutionSupportAvailable():
print "SizeID:"+str(xs.getSizeID())
print "Size:"+str(xs.getSize())
print("SizeID:"+str(xs.getSizeID()))
print("Size:"+str(xs.getSize()))
sizes = xs.getAvailableSizes()
print "Available Sizes:" + str(sizes)
print
print "Rotation:" + str(xs.getRotation())
print "Available Rotations:" + str(xs.getAvailableRotations())
print
print "Refresh rate:" + str(xs.getRefreshRate())
print "Refresh rates for the current screen:"+str(xs.getAvailableRefreshRates(xs.getSizeID()))
print("Available Sizes:" + str(sizes))
print()
print("Rotation:" + str(xs.getRotation()))
print("Available Rotations:" + str(xs.getAvailableRotations()))
print()
print("Refresh rate:" + str(xs.getRefreshRate()))
print("Refresh rates for the current screen:"+str(xs.getAvailableRefreshRates(xs.getSizeID())))
for i in range(len(sizes)):
print "All Refresh Rates:"+str(xs.getAvailableRefreshRates(i))
print("All Refresh Rates:"+str(xs.getAvailableRefreshRates(i)))
xs.setScreenConfigAndRate(0,1,75)
print "SizeID:"+str(xs.getSizeID())
print "Size:"+str(xs.getSize())
print("SizeID:"+str(xs.getSizeID()))
print("Size:"+str(xs.getSize()))
sizes = xs.getAvailableSizes()
print "Available Sizes:" + str(sizes)
print("Available Sizes:" + str(sizes))
else:
print "(no resolution / randr support available)"
print("(no resolution / randr support available)")

@ -326,8 +326,8 @@ class MicroHAL__(object):
# but it might be built as module, so we try to load that.
retval, msg = SimpleCommandRunner().run(["/sbin/modprobe",module])
if retval > 0:
print msg
print "Couldn't load driver " + module + " for filesystem " + fs
print(msg)
print("Couldn't load driver " + module + " for filesystem " + fs)
# Force refresh of list of supported filesystems
self.supportedfs = None
return proc in self.getSupportedFileSystems()
@ -632,73 +632,73 @@ class MicroHAL(object):
# Detect the end of this block of device data.
state = READING_TOP
if u"info.category" in parsed_hash:
if "info.category" in parsed_hash:
new_device = None
capabilities_string = u" ".join(parsed_hash[u"info.capabilities"])
capabilities_string = " ".join(parsed_hash["info.capabilities"])
capabilities = self._parseStringList(capabilities_string)
category = self._parseString(' '.join(parsed_hash[u"info.category"]))
if category==u"volume":
category = self._parseString(' '.join(parsed_hash["info.category"]))
if category=="volume":
# Is it a volume?
is_disc = parsed_hash.get(u"volume.is_disc")
is_disc = parsed_hash.get("volume.is_disc")
if is_disc is not None and is_disc[0]=='true':
continue
is_partition = parsed_hash.get(u"volume.is_partition")
is_partition = parsed_hash.get("volume.is_partition")
if is_partition is not None:
is_partition = is_partition[0]
if is_partition=='true':
new_device = Partition()
new_device.num = int(parsed_hash[u"volume.partition.number"][0])
new_device.num = int(parsed_hash["volume.partition.number"][0])
partition_to_uid[new_device] = current_uid
if u"info.parent" in parsed_hash:
parent_uid = self._parseString(' '.join(parsed_hash[u"info.parent"]))
if "info.parent" in parsed_hash:
parent_uid = self._parseString(' '.join(parsed_hash["info.parent"]))
partition_to_uid[new_device] = parent_uid
else:
new_device = Disk()
uid_to_disk[current_uid] = new_device
if u"volume.uuid" in parsed_hash:
new_device.uuid = self._parseString(' '.join(parsed_hash[u"volume.uuid"]))
if "volume.uuid" in parsed_hash:
new_device.uuid = self._parseString(' '.join(parsed_hash["volume.uuid"]))
if u"volume.label" in parsed_hash:
new_device.label = self._parseString(parsed_hash[u"volume.label"][0])
if "volume.label" in parsed_hash:
new_device.label = self._parseString(parsed_hash["volume.label"][0])
# If HAL returns label beginning with '#', it usually means that the
# actual label contains an Unix path. So we replace '#' with '/'.
if len(new_device.label) and new_device.label[0]=='%':
new_device.label = new_device.label.replace('%', '/')
if u"volume.size" in parsed_hash:
size = parsed_hash[u"volume.size"][0]
if "volume.size" in parsed_hash:
size = parsed_hash["volume.size"][0]
new_device.size = self.formatSizeBytes(int(size))
else:
new_device.size = "?"
# is it a storage device?
elif category==u"storage":
storage_model = self._parseString(' '.join(parsed_hash[u"storage.model"]))
storage_removable = parsed_hash[u"storage.removable"][0]==u"true"
elif category=="storage":
storage_model = self._parseString(' '.join(parsed_hash["storage.model"]))
storage_removable = parsed_hash["storage.removable"][0]=="true"
if u"storage.cdrom" in capabilities:
if "storage.cdrom" in capabilities:
if u"storage.cdrom.cdrw" in parsed_hash \
and parsed_hash[u"storage.cdrom.cdrw"][0]==u"true":
if "storage.cdrom.cdrw" in parsed_hash \
and parsed_hash["storage.cdrom.cdrw"][0]=="true":
new_device = BurnerDisk()
else:
new_device= RemovableDisk()
elif u"storage.floppy" in capabilities:
elif "storage.floppy" in capabilities:
new_device = FloppyDevice()
else:
if u"storage.bus" in parsed_hash \
and self._parseString(' '.join(parsed_hash[u"storage.bus"]))==u"usb":
if "storage.bus" in parsed_hash \
and self._parseString(' '.join(parsed_hash["storage.bus"]))=="usb":
new_device = USBDisk()
else:
@ -711,8 +711,8 @@ class MicroHAL(object):
continue
# Handle the generic properties.
new_device.dev = self._parseString(' '.join(parsed_hash[u"block.device"]))
new_device.major = int(parsed_hash[u"block.major"][0])
new_device.dev = self._parseString(' '.join(parsed_hash["block.device"]))
new_device.major = int(parsed_hash["block.major"][0])
self.devices.append(new_device)
@ -722,9 +722,9 @@ class MicroHAL(object):
parsed_hash[ parts[0] ] = parts[2:]
# Attach the partitions to thier devices.
for partition in partition_to_uid.keys():
for partition in list(partition_to_uid.keys()):
parent = partition_to_uid[partition]
if parent in uid_to_disk.keys():
if parent in list(uid_to_disk.keys()):
parent_device = uid_to_disk[parent]
parent_device.appendPartition(partition)
self.devices.remove(partition)
@ -819,8 +819,8 @@ class MicroHAL(object):
# but it might be built as module, so we try to load that.
retval, msg = SimpleCommandRunner().run(["/sbin/modprobe",module])
if retval > 0:
print msg
print "Couldn't load driver " + module + " for filesystem " + fs
print(msg)
print("Couldn't load driver " + module + " for filesystem " + fs)
# Force refresh of list of supported filesystems
self.supportedfs = None
return proc in self.getSupportedFileSystems()
@ -842,7 +842,7 @@ class MicroHAL(object):
for partition in item.partitions:
if partition.dev==device:
return partition.label
print "No Label found for ",device
print("No Label found for ",device)
return ""
def getUUIDByDevice(self, device):
@ -851,7 +851,7 @@ class MicroHAL(object):
#print partition, partition.getUUID()
if partition.dev==device:
return partition.uuid
print "No UUID found for ",device
print("No UUID found for ",device)
return ""
def getDeviceByUUID(self, uuid):
@ -870,19 +870,19 @@ class MicroHAL(object):
if __name__=='__main__':
hal = MicroHAL()
for item in hal.getDevices():
print(str(item))
print((str(item)))
print
print()
#"""
for item in hal.getDevices():
for partition in item.partitions:
print partition, partition.getLabel()
print(partition, partition.getLabel())
#"""
#realhal = RealHAL()
#for item in realhal.getDevices():
# print(str(item))
print
print()

@ -204,8 +204,8 @@ class SMBShareSelectDialog(KDialogBase):
########################################################################
def slotNewItems(self,items):
for entry in items:
newitem = SMBShareListViewItem(self.lookupqueue[0], unicode(entry.name()), KURL(entry.url()), self)
self.url_to_list_item_map[unicode(entry.url().prettyURL())] = newitem
newitem = SMBShareListViewItem(self.lookupqueue[0], str(entry.name()), KURL(entry.url()), self)
self.url_to_list_item_map[str(entry.url().prettyURL())] = newitem
# Notice how I copied the KURL object and TQString (to a python string)
########################################################################
@ -225,7 +225,7 @@ class SMBShareSelectDialog(KDialogBase):
########################################################################
def slotDirListRedirection(self,oldUrl,newUrl):
list_item = self.url_to_list_item_map[unicode(oldUrl.prettyURL())]
list_item = self.url_to_list_item_map[str(oldUrl.prettyURL())]
list_item.setURL(KURL(newUrl)) # The copy is important.
# Reselect the selected node. (This will force a refresh).
@ -317,7 +317,7 @@ class SMBShareSelectDialog(KDialogBase):
self.usernameedit.setEnabled(False)
selectedurl = self.selecteditem.getURL()
self.reconnectbutton.setEnabled(unicode(selectedurl.user())!="")
self.reconnectbutton.setEnabled(str(selectedurl.user())!="")
self.updatinggui = False
@ -333,11 +333,11 @@ class SMBShareSelectDialog(KDialogBase):
self.passwordedit.setEnabled(True)
self.usernameedit.setEnabled(True)
username = unicode(self.usernameedit.text())
password = unicode(self.passwordedit.text())
username = str(self.usernameedit.text())
password = str(self.passwordedit.text())
selectedurl = self.selecteditem.getURL()
if username!="" and password!="" and \
((unicode(selectedurl.user())!=username) or (unicode(selectedurl.pass_())!=password)):
((str(selectedurl.user())!=username) or (str(selectedurl.pass_())!=password)):
self.reconnectbutton.setEnabled(True)
else:
self.reconnectbutton.setEnabled(False)
@ -404,10 +404,10 @@ class SMBShareListViewItem(TDEListViewItem):
self.setExpandable(True)
if url.hasPath() and url.path(-1)!="/":
parts = [x for x in unicode(url.path(-1)).split("/") if x!=""]
parts = [x for x in str(url.path(-1)).split("/") if x!=""]
self.component = parts[-1].lower()
elif url.hasHost():
self.component = unicode(url.host()).lower()
self.component = str(url.host()).lower()
else:
self.component = None
@ -502,7 +502,7 @@ class SMBShareListViewItem(TDEListViewItem):
# Another wrinkle is that the treeview contains a level of workgroups while
# a given URL omits the workgroup a jumps directly to the machine name.
def selectURL(self,targeturl):
path = unicode(targeturl.path(-1))
path = str(targeturl.path(-1))
parts = [x for x in path.split("/") if x!=""]
if targeturl.hasHost():
tmp = [targeturl.host()]

@ -40,9 +40,9 @@ class SimpleCommandRunner(TQObject):
is the output from stdout and stderr.
"""
global debug
if debug: print cmdlist
if debug: print(cmdlist)
self.STDOUT_only = STDOUT_only
self.output = u""
self.output = ""
proc = TDEProcess()
proc.setEnvironment("LANG","US")
proc.setEnvironment("LC_ALL","US")
@ -58,12 +58,12 @@ class SimpleCommandRunner(TQObject):
########################################################################
def slotStdout(self,proc,buffer,buflen):
global debug
if debug: print "slotStdout() |"+buffer+"|"
if debug: print("slotStdout() |"+buffer+"|")
self.output += buffer.decode(locale.getpreferredencoding())
########################################################################
def slotStderr(self,proc,buffer,buflen):
global debug
if debug: print "slotStderr() |"+buffer+"|"
if debug: print("slotStderr() |"+buffer+"|")
if not self.STDOUT_only:
self.output += buffer.decode(locale.getpreferredencoding())

@ -73,7 +73,7 @@ class FileProcess(TQListViewItem):
""" Parses a signal string representation or a signal number and sends it to
the process."""
if not self.isparent:
print "Item is not a process, only a filedescriptor."
print("Item is not a process, only a filedescriptor.")
return
try:
signal_int = int(signal)
@ -81,17 +81,17 @@ class FileProcess(TQListViewItem):
try:
signal_int = self.signals[signal]
except IndexError:
print "No known signal received ", signal
print("No known signal received ", signal)
return False
try:
rc = os.kill(int(self.pid),signal_int) # TODO: Catch OSError
except OSError, message:
print "OSError: Couldn't %s %s %s" % (signal,self.pname,self.pid)
print message
except OSError as message:
print("OSError: Couldn't %s %s %s" % (signal,self.pname,self.pid))
print(message)
if not rc:
print "Successfully sent signal ", signal_int, " to process ", self.pid
print("Successfully sent signal ", signal_int, " to process ", self.pid)
return True
print "Signal %i didn't succeed" % signal_int
print("Signal %i didn't succeed" % signal_int)
return False
def fillColumns(self):
@ -125,7 +125,7 @@ class FUser(FUserUI):
self.umountbutton.setEnabled(False)
self.explanationlabel.setText(
unicode(i18n("""The volume %s is in use and can not be disabled.<br>
str(i18n("""The volume %s is in use and can not be disabled.<br>
<br>
The processes that are blocking %s are listed below. These processes must be closed
before %s can be disabled.
@ -159,7 +159,7 @@ class FUser(FUserUI):
if os.path.isfile(path):
self.lsof_bin = path
else:
print path, " is not a valid binary, keeping %s", self.lsof_bin
print(path, " is not a valid binary, keeping %s", self.lsof_bin)
def readPixmaps(self):
self.pix = {
@ -185,7 +185,7 @@ class FUser(FUserUI):
type = line[0]
info = line[1:]
if type is "p":
if type == "p":
pid = info
parentproc = FileProcess(self.processlist,pid,True)
self.processes.append(parentproc)
@ -243,7 +243,7 @@ class FUser(FUserUI):
self.processlist.selectedItem().sendSignal("KILL")
self.refreshProcesslist()
except AttributeError:
print "No killable item selected."
print("No killable item selected.")
def slotKillallButtonClicked(self):
for process in self.realprocesses:
@ -266,17 +266,17 @@ class FUser(FUserUI):
SimpleCommandRunner
rc, output = SimpleCommandRunner().run(['/bin/umount',self.device])
if rc == 0:
print "%s successfully unmounted." % self.device
print("%s successfully unmounted." % self.device)
# Close dialog and return 0 - sucessfully umounted.
self.done(0)
else:
print "Unmounting %s failed: %s" % (self.device,output[:-1])
print("Unmounting %s failed: %s" % (self.device,output[:-1]))
self.isMounted()
################################################################################################
if standalone:
device = "/dev/hda1"
print 'Device is ', device
print('Device is ', device)
cmd_args = TDECmdLineArgs.init(sys.argv, "FUser",
"A graphical frontend to fuser, but without using it :-)", "0.2")

@ -183,8 +183,8 @@ class MountEntryExt(object):
# object.
def __init__(self,base=None):
if base==None:
self.device = unicode(i18n("<device>"))
self.mountpoint = unicode(i18n("<mount point>"))
self.device = str(i18n("<device>"))
self.mountpoint = str(i18n("<mount point>"))
self.mounttype = 'ext2'
self.uuid = ""
self.label = ""
@ -319,13 +319,13 @@ class MountEntryExt(object):
if self.label != "":
return MountEntry.encodeMountEntryString("LABEL="+self.label)
else:
print "No Label set, preventing you from shooting yourself in the foot"
print("No Label set, preventing you from shooting yourself in the foot")
elif self.getUseAsDevice() == "uuid":
if self.uuid != "":
return "UUID="+self.uuid
return MountEntry.encodeMountEntryString("UUID="+self.uuid)
else:
print "No UUID set, preventing you from shooting yourself in the foot"
print("No UUID set, preventing you from shooting yourself in the foot")
return MountEntry.encodeMountEntryString(self.device)
########################################################################
@ -364,10 +364,10 @@ class MountEntryExt(object):
options.append(o.strip())
return self.getDeviceString() + \
u" " + MountEntry.encodeMountEntryString(self.mountpoint.replace("%20","\040")) + \
u" " + MountEntry.encodeMountEntryString(self.mounttype) + \
u" " + MountEntry.encodeMountEntryString(u",".join(options)) + \
u" " + unicode(self.fs_freq) + u" " + unicode(self.fs_passno)
" " + MountEntry.encodeMountEntryString(self.mountpoint.replace("%20","\040")) + \
" " + MountEntry.encodeMountEntryString(self.mounttype) + \
" " + MountEntry.encodeMountEntryString(",".join(options)) + \
" " + str(self.fs_freq) + " " + str(self.fs_passno)
########################################################################
def getCategory(self):
@ -412,22 +412,22 @@ class MountEntryExt(object):
self.mountpoint).arg(output)
captionmsg = i18n("Unable to disable %1").arg(self.mountpoint)
extramsg = unicode(i18n("Return code from mount was %1.\n").arg(rc))
extramsg = str(i18n("Return code from mount was %1.\n").arg(rc))
if (rc & 1)!=0:
extramsg += unicode(i18n("\"incorrect invocation or permissions\"\n"))
extramsg += str(i18n("\"incorrect invocation or permissions\"\n"))
if (rc & 2)!=0:
extramsg += unicode(i18n("\"system error (out of memory, cannot fork, no more loop devices)\"\n"))
extramsg += str(i18n("\"system error (out of memory, cannot fork, no more loop devices)\"\n"))
if (rc & 4)!=0:
extramsg += unicode(i18n("\"internal mount bug or missing nfs support in mount\"\n"))
extramsg += str(i18n("\"internal mount bug or missing nfs support in mount\"\n"))
if (rc & 8)!=0:
extramsg += unicode(i18n("\"user interrupt\"\n"))
extramsg += str(i18n("\"user interrupt\"\n"))
if (rc & 16)!=0:
extramsg += unicode(i18n("\"problems writing or locking /etc/mtab\"\n"))
extramsg += str(i18n("\"problems writing or locking /etc/mtab\"\n"))
if (rc & 32)!=0:
extramsg += unicode(i18n("\"mount failure\"\n"))
extramsg += str(i18n("\"mount failure\"\n"))
if (rc & 64)!=0:
extramsg += unicode(i18n("\"some mount succeeded\"\n"))
extramsg += str(i18n("\"some mount succeeded\"\n"))
in_use = False
if not mount_action:
@ -444,10 +444,10 @@ class MountEntryExt(object):
fuser.exec_loop()
in_use_message = ""
if fuser.result() != 0:
in_use_message = unicode(i18n("Unmounting %1 failed or was cancelled.").arg(self.device))
in_use_message = str(i18n("Unmounting %1 failed or was cancelled.").arg(self.device))
extramsg += in_use_message
else:
extramsg += unicode(i18n("(none)"))
extramsg += str(i18n("(none)"))
if not in_use:
KMessageBox.detailedSorry(parentdialog, msg, extramsg, captionmsg)
@ -723,8 +723,8 @@ class MountEntryExtAlien(MountEntryExt):
def getFstabOptions(self):
# Construct the options field.
options = super(MountEntryExtAlien,self).getFstabOptions()
options.append('uid='+unicode(self.uid))
options.append('gid='+unicode(self.gid))
options.append('uid='+str(self.uid))
options.append('gid='+str(self.gid))
options.append(['noauto','auto'][self.auto])
options.append(['ro','rw'][self.writeable])
options.append(['nouser','user','users','owner'][self.allowusermount])
@ -877,15 +877,15 @@ class MountEntryExtSMB(MountEntryExtAlien):
# Write out the credentials file
if self.credentialsfile is None:
i = 1
while os.path.exists(self.CREDENTIALSBASENAME+unicode(i)):
while os.path.exists(self.CREDENTIALSBASENAME+str(i)):
i += 1
self.credentialsfile = self.CREDENTIALSBASENAME+unicode(i)
fd = os.open(self.credentialsfile,os.O_WRONLY|os.O_CREAT,0600)
self.credentialsfile = self.CREDENTIALSBASENAME+str(i)
fd = os.open(self.credentialsfile,os.O_WRONLY|os.O_CREAT,0o600)
fhandle = os.fdopen(fd,'w')
fhandle.write((u"username = %s\npassword = %s\n" % (self.username,self.password))
fhandle.write(("username = %s\npassword = %s\n" % (self.username,self.password))
.encode(locale.getpreferredencoding(),'replace') )
fhandle.close()
options.append(u"credentials="+self.credentialsfile)
options.append("credentials="+self.credentialsfile)
return options
########################################################################
@ -938,7 +938,7 @@ class MountEntryExtSwap(MountEntryExt):
options.remove('defaults')
except ValueError:
pass
self.extraoptions = u",".join(options)
self.extraoptions = ",".join(options)
########################################################################
def copy(self,newobject=None):
@ -1092,7 +1092,7 @@ class MountEntry(object):
self.extension = self.MountTypes[self.mounttype][0](base)
self.extensionObjects[self.mounttype] = self.extension
except (KeyError,IndexError):
raise InvalidMountEntryError, u"Unable to parse mount entry:"+unicode(base)
raise InvalidMountEntryError("Unable to parse mount entry:"+str(base))
########################################################################
def getMountType(self):
@ -1104,7 +1104,7 @@ class MountEntry(object):
try:
self.extensionObjects[newtypename] = self.MountTypes[newtypename][0](self.extension)
except KeyError:
raise NotImplementedError, "Unknown mounttype:"+newtypename
raise NotImplementedError("Unknown mounttype:"+newtypename)
self.mounttype = newtypename
self.extension = self.extensionObjects[newtypename]
self.extension.setMountType(newtypename)
@ -1136,8 +1136,8 @@ class MountEntry(object):
def __getattr__(self,name):
try:
return getattr(self.extension,name)
except AttributeError, a:
print a
except AttributeError as a:
print(a)
########################################################################
# FIXME
@ -1150,7 +1150,7 @@ class MountEntry(object):
########################################################################
def getMountTypes():
return MountEntry.MountTypes.keys()
return list(MountEntry.MountTypes.keys())
getMountTypes = staticmethod(getMountTypes)
########################################################################
@ -1160,7 +1160,7 @@ class MountEntry(object):
########################################################################
def encodeMountEntryString(string):
newstring = u""
newstring = ""
for c in string:
if c==' ':
newstring += "\\040"
@ -1263,13 +1263,13 @@ class MountTable(object):
fhandle.close()
if not sysfs_in_fstab:
sysfsentry = MountEntry(u"sysfs /sys sysfs defaults 0 0")
sysfsentry = MountEntry("sysfs /sys sysfs defaults 0 0")
sysfsentry.notInFstab = True
sysfsentry.maydisable = False
#self.append(sysfsentry)
if not usbdevfs_in_fstab:
usbdevfsentry = MountEntry(u"procbususb /proc/bus/usb usbdevfs defaults 0 0")
usbdevfsentry = MountEntry("procbususb /proc/bus/usb usbdevfs defaults 0 0")
usbdevfsentry.notInFstab = True
usbdevfsentry.maydisable = False
self.append(usbdevfsentry)
@ -1314,8 +1314,8 @@ class MountTable(object):
for entry in self.allentries:
if not entry.notInFstab:
line = entry.getFstabLine()
fhandle.write(line+u"\n")
print line
fhandle.write(line+"\n")
print(line)
fhandle.close()
fhandle = None
@ -1335,7 +1335,7 @@ class MountTable(object):
return self.entries.__contains(item)
########################################################################
def __delitem__(self,key):
raise NotImplementedError, "No __delitem__ on MountTable."
raise NotImplementedError("No __delitem__ on MountTable.")
########################################################################
def __getitem__(self,key):
@ -1349,7 +1349,7 @@ class MountTable(object):
return self.entries.__len__()
########################################################################
def __setitem__(self,key,value):
raise NotImplementedError, "No __setitem__ on MountTable."
raise NotImplementedError("No __setitem__ on MountTable.")
############################################################################
class MountEntryDialogOptions(TQWidget):
@ -1547,20 +1547,20 @@ class MountEntryDialogOptions(TQWidget):
########################################################################
def undisplayMountEntry(self,entry):
if self.showmountpoint:
entry.setMountPoint( unicode(self.mountpointlineedit.text()) )
entry.setMountPoint( str(self.mountpointlineedit.text()) )
if self.showdevice:
entry.setDevice( unicode(self.devicelineedit.text()) )
entry.setDevice( str(self.devicelineedit.text()) )
if self.showuuid and self.showdevice:
if self.devicecheckbox.isChecked():
entry.setUUID(None)
else:
entry.setUUID( unicode(self.uuidlineedit.text()) )
entry.setUUID( str(self.uuidlineedit.text()) )
if self.showlabel and self.showdevice:
if self.devicecheckbox.isChecked():
entry.setLabel(None)
else:
entry.setLabel( unicode(self.labellineedit.text()) )
entry.setLabel( str(self.labellineedit.text()) )
if allowuuid and self.showuuid:
if self.uuidcheckbox.isChecked():
@ -1572,7 +1572,7 @@ class MountEntryDialogOptions(TQWidget):
if self.devicecheckbox.isChecked():
entry.setUseAsDevice("devicenode")
entry.setExtraOptions( unicode(self.optionslineedit.text()) )
entry.setExtraOptions( str(self.optionslineedit.text()) )
if self.showfs_freq:
entry.setFSFreq(self.fsfreqspinbox.value())
if self.showfs_passno:
@ -1597,7 +1597,7 @@ class MountEntryDialogOptions(TQWidget):
########################################################################
def slotUUIDCheckboxClicked(self):
if self.uuidlineedit.text() == "":
label = microhal.getUUIDByDevice(unicode(self.devicelineedit.text()))
label = microhal.getUUIDByDevice(str(self.devicelineedit.text()))
self.uuidlineedit.setText(label)
self.devicecheckbox.setChecked(False)
self.devicelineedit.setEnabled(False)
@ -1607,7 +1607,7 @@ class MountEntryDialogOptions(TQWidget):
def slotLabelCheckboxClicked(self):
if self.labellineedit.text() == "":
label = microhal.getLabelByDevice(unicode(self.devicelineedit.text()))
label = microhal.getLabelByDevice(str(self.devicelineedit.text()))
self.labellineedit.setText(label)
self.uuidcheckbox.setChecked(False)
self.devicelineedit.setEnabled(False)
@ -1775,24 +1775,24 @@ class MountEntryDialogOptionsCommonUnix(MountEntryDialogOptions):
########################################################################
def undisplayMountEntry(self,entry):
entry.setDevice( unicode(self.devicelineedit.text()) )
entry.setDevice( str(self.devicelineedit.text()) )
if self.showuuid:
if self.devicecheckbox.isChecked() or self.labelcheckbox.isChecked():
entry.setUUID(None)
else:
entry.setUUID( unicode(self.uuidlineedit.text()) )
entry.setUUID( str(self.uuidlineedit.text()) )
if self.showlabel:
if self.devicecheckbox.isChecked() or self.uuidcheckbox.isChecked():
entry.setLabel(None)
else:
entry.setLabel( unicode(self.labellineedit.text()) )
entry.setLabel( str(self.labellineedit.text()) )
if not self.showlabel and not self.showuuid:
if self.uuidcheckbox.isChecked() or self.labelcheckbox.isChecked():
entry.setLabel(None)
else:
entry.setLabel( unicode(self.devicelineedit.text()) )
entry.setLabel( str(self.devicelineedit.text()) )
if allowuuid:
if self.uuidcheckbox.isChecked():
@ -1803,7 +1803,7 @@ class MountEntryDialogOptionsCommonUnix(MountEntryDialogOptions):
if self.devicecheckbox.isChecked():
entry.setUseAsDevice("devicenode")
entry.setMountPoint( unicode(self.mountpointlineedit.text()) )
entry.setMountPoint( str(self.mountpointlineedit.text()) )
entry.setExtraOptions(self.options)
entry.setFSFreq(self.fsfreq)
entry.setFSPassno(self.fspassno)
@ -1833,7 +1833,7 @@ class MountEntryDialogOptionsCommonUnix(MountEntryDialogOptions):
########################################################################
def slotUUIDCheckboxClicked(self):
if self.uuidlineedit.text() == "":
label = microhal.getUUIDByDevice(unicode(self.devicelineedit.text()))
label = microhal.getUUIDByDevice(str(self.devicelineedit.text()))
self.uuidlineedit.setText(label)
self.devicecheckbox.setChecked(False)
self.devicelineedit.setEnabled(False)
@ -1843,7 +1843,7 @@ class MountEntryDialogOptionsCommonUnix(MountEntryDialogOptions):
def slotLabelCheckboxClicked(self):
if self.labellineedit.text() == "":
label = microhal.getLabelByDevice(unicode(self.devicelineedit.text()))
label = microhal.getLabelByDevice(str(self.devicelineedit.text()))
self.labellineedit.setText(label)
self.devicecheckbox.setChecked(False)
self.devicelineedit.setEnabled(False)
@ -2073,11 +2073,11 @@ class MountEntryDialogOptionsVFAT(MountEntryDialogOptions):
else:
if allowlabel:
if self.labelcheckbox.isChecked():
entry.setLabel( unicode(self.labellineedit.text()) )
entry.setLabel( str(self.labellineedit.text()) )
else:
entry.setUUID( unicode(self.uuidlineedit.text()) )
entry.setUUID( str(self.uuidlineedit.text()) )
else:
entry.setUUID( unicode(self.uuidlineedit.text()) )
entry.setUUID( str(self.uuidlineedit.text()) )
if allowlabel:
if self.devicecheckbox.isChecked():
@ -2085,15 +2085,15 @@ class MountEntryDialogOptionsVFAT(MountEntryDialogOptions):
else:
if allowuuid:
if self.uuidcheckbox.isChecked():
entry.setUUID( unicode(self.uuidlineedit.text()) )
entry.setUUID( str(self.uuidlineedit.text()) )
else:
entry.setLabel( unicode(self.labellineedit.text()) )
entry.setLabel( str(self.labellineedit.text()) )
else:
entry.setLabel( unicode(self.labellineedit.text()) )
entry.setLabel( str(self.labellineedit.text()) )
entry.setDevice( unicode(self.devicelineedit.text()) )
entry.setDevice( str(self.devicelineedit.text()) )
entry.setMountPoint( unicode(self.mountpointlineedit.text()) )
entry.setMountPoint( str(self.mountpointlineedit.text()) )
entry.setExtraOptions(self.options)
entry.setFSFreq(self.fsfreq)
entry.setFSPassno(self.fspassno)
@ -2118,7 +2118,7 @@ class MountEntryDialogOptionsVFAT(MountEntryDialogOptions):
########################################################################
def slotUUIDCheckboxClicked(self):
if self.uuidlineedit.text() == "":
label = microhal.getUUIDByDevice(unicode(self.devicelineedit.text()))
label = microhal.getUUIDByDevice(str(self.devicelineedit.text()))
self.uuidlineedit.setText(label)
self.devicecheckbox.setChecked(False)
self.devicelineedit.setEnabled(False)
@ -2249,8 +2249,8 @@ class MountEntryDialogOptionsSMB(MountEntryDialogOptions):
self.selectsmbdialog = SMBShareSelectDialog(None)
# This just converts a \\zootv\data\ share name to smb:/zootv/data
parts = [x.replace("/",'\\') for x in unicode(self.devicelineedit.text()).split('\\') if x!=""]
oldurl = u"smb:/"+("/".join(parts) )
parts = [x.replace("/",'\\') for x in str(self.devicelineedit.text()).split('\\') if x!=""]
oldurl = "smb:/"+("/".join(parts) )
urlobj = KURL(oldurl)
if self.userradio.isChecked():
@ -2262,7 +2262,7 @@ class MountEntryDialogOptionsSMB(MountEntryDialogOptions):
plainurl = KURL(newurlobj)
plainurl.setUser(TQString.null)
plainurl.setPass(TQString.null)
parts = [x.replace('\\',"/") for x in unicode(plainurl.url())[4:].split("/") if x !=""]
parts = [x.replace('\\',"/") for x in str(plainurl.url())[4:].split("/") if x !=""]
#convert the first part to an IP address
nmboutput = subprocess.Popen(["nmblookup",parts[0]], stdout=subprocess.PIPE).stdout
nmboutput.readline()
@ -2317,8 +2317,8 @@ class MountEntryDialogOptionsSMB(MountEntryDialogOptions):
########################################################################
def undisplayMountEntry(self,entry):
entry.setDevice( unicode(self.devicelineedit.text()) )
entry.setMountPoint( unicode(self.mountpointlineedit.text()) )
entry.setDevice( str(self.devicelineedit.text()) )
entry.setMountPoint( str(self.mountpointlineedit.text()) )
entry.setExtraOptions(self.options)
entry.setFSFreq(self.fsfreq)
entry.setFSPassno(self.fspassno)
@ -2332,8 +2332,8 @@ class MountEntryDialogOptionsSMB(MountEntryDialogOptions):
entry.setUsername(None)
entry.setPassword(None)
else:
entry.setUsername( unicode(self.usernameedit.text()) )
entry.setPassword( unicode(self.passwordedit.text()) )
entry.setUsername( str(self.usernameedit.text()) )
entry.setPassword( str(self.passwordedit.text()) )
########################################################################
def slotAdvancedClicked(self):
@ -2455,7 +2455,7 @@ class MountEntryDialog(KDialogBase):
# Disk types
ROListBoxItem(self.mounttypecombo.listBox(),UserIcon("hi16-hdd"),i18n("Disk Filesystems"))
self.comboIndexToMountType.append(None)
items = self.MountTypeEditorsDisk.keys()
items = list(self.MountTypeEditorsDisk.keys())
items.sort()
for mounttype in items:
self.mounttypecombo.insertItem(MountEntry.getMountTypeLongName(mounttype))
@ -2464,7 +2464,7 @@ class MountEntryDialog(KDialogBase):
# Network types
ROListBoxItem(self.mounttypecombo.listBox(),UserIcon("hi16-network"),i18n("Network Filesystems"))
self.comboIndexToMountType.append(None)
items = self.MountTypeEditorsNetwork.keys()
items = list(self.MountTypeEditorsNetwork.keys())
items.sort()
for mounttype in items:
self.mounttypecombo.insertItem(MountEntry.getMountTypeLongName(mounttype))
@ -2473,7 +2473,7 @@ class MountEntryDialog(KDialogBase):
# System types
ROListBoxItem(self.mounttypecombo.listBox(),UserIcon("hi16-blockdevice"),i18n("Operating System"))
self.comboIndexToMountType.append(None)
items = self.MountTypeEditorsSystem.keys()
items = list(self.MountTypeEditorsSystem.keys())
items.sort()
for mounttype in items:
self.mounttypecombo.insertItem(MountEntry.getMountTypeLongName(mounttype))
@ -2597,7 +2597,7 @@ class MountEntryDialog(KDialogBase):
i18n("Mountpoint already in use"))!=KMessageBox.Continue:
return
if self.currentMountEntry.getMountType() in MountEntryDialog.MountTypeEditorsDisk.keys():
if self.currentMountEntry.getMountType() in list(MountEntryDialog.MountTypeEditorsDisk.keys()):
# If device is not in /dev and it's no bind mount, ask if that's meant this way ...
options = self.currentMountEntry.getFstabOptions()
if (not self.currentMountEntry.getDevice().startswith("/dev/")
@ -2696,7 +2696,7 @@ class MountEntryAdvancedCommonUnixDialog(KDialogBase):
self.allowexecutablecheckbox.isChecked(),
self.allowsuidcheckbox.isChecked(),
self.usedevpointscheckbox.isChecked(),
unicode(self.optionslineedit.text()),
str(self.optionslineedit.text()),
self.fsfreqspinbox.value(),
self.fspassnospinbox.value())
@ -2724,7 +2724,7 @@ class MountEntryAdvancedPlainDialog(KDialogBase):
self.fsfreqspinbox.setValue(fsfreq)
self.fspassnospinbox.setValue(fspassno)
self.exec_loop()
return (unicode(self.optionslineedit.text()), self.fsfreqspinbox.value(), self.fspassnospinbox.value())
return (str(self.optionslineedit.text()), self.fsfreqspinbox.value(), self.fspassnospinbox.value())
############################################################################
class MountListViewItem(TDEListViewItem):
@ -3091,13 +3091,13 @@ class MountConfigApp(programbase):
blk = hal_device.getDev()
devicepath, devicename = ('/'.join(blk.split('/')[0:-1])+'/', blk.split('/')[-1])
# We keep a dict with those widgets, that saves us some time reading out all the values.
if devicename not in self.sizeviewdialogs.keys():
if devicename not in list(self.sizeviewdialogs.keys()):
self.sizeviewdialogs[devicename] = sizeview.SizeView(self,devicename,devicepath)
self.sizeviewdialogs[devicename].exec_loop()
else:
self.sizeviewdialogs[devicename].exec_loop()
else:
print "Sizeview doesn't support",blk.__class__," yet."
print("Sizeview doesn't support",blk.__class__," yet.")
########################################################################
def slotListClicked(self,item):