summaryrefslogtreecommitdiffstats
path: root/mountconfig
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2023-01-19 18:01:26 +0100
committerMichele Calgaro <[email protected]>2023-01-20 13:05:37 +0900
commit94f5a3f12e1c61aa2f3cde2d7b260c08489336ac (patch)
tree9062a30a1d81a1a97e9397548e4ec48ae63c18a4 /mountconfig
parentb9c0b6996a6da72f93baf50121a1be4a6fa48d2e (diff)
downloadtde-guidance-94f5a3f12e1c61aa2f3cde2d7b260c08489336ac.tar.gz
tde-guidance-94f5a3f12e1c61aa2f3cde2d7b260c08489336ac.zip
Drop python2 support.
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'mountconfig')
-rwxr-xr-xmountconfig/MicroHAL.py76
-rw-r--r--mountconfig/SMBShareSelectDialog.py20
-rw-r--r--mountconfig/SimpleCommandRunner.py8
-rw-r--r--mountconfig/fuser.py28
-rwxr-xr-xmountconfig/mountconfig.py152
-rw-r--r--mountconfig/sizeview.py15
6 files changed, 150 insertions, 149 deletions
diff --git a/mountconfig/MicroHAL.py b/mountconfig/MicroHAL.py
index 9a913fa..3d6fce5 100755
--- a/mountconfig/MicroHAL.py
+++ b/mountconfig/MicroHAL.py
@@ -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()
diff --git a/mountconfig/SMBShareSelectDialog.py b/mountconfig/SMBShareSelectDialog.py
index e97a577..617ee04 100644
--- a/mountconfig/SMBShareSelectDialog.py
+++ b/mountconfig/SMBShareSelectDialog.py
@@ -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()]
diff --git a/mountconfig/SimpleCommandRunner.py b/mountconfig/SimpleCommandRunner.py
index 4eafedd..a6767b5 100644
--- a/mountconfig/SimpleCommandRunner.py
+++ b/mountconfig/SimpleCommandRunner.py
@@ -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())
diff --git a/mountconfig/fuser.py b/mountconfig/fuser.py
index 9780555..06cf1a9 100644
--- a/mountconfig/fuser.py
+++ b/mountconfig/fuser.py
@@ -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")
diff --git a/mountconfig/mountconfig.py b/mountconfig/mountconfig.py
index d433c0b..f348aa6 100755
--- a/mountconfig/mountconfig.py
+++ b/mountconfig/mountconfig.py
@@ -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):
diff --git a/mountconfig/sizeview.py b/mountconfig/sizeview.py
index a4169c4..49ce9f6 100644
--- a/mountconfig/sizeview.py
+++ b/mountconfig/sizeview.py
@@ -62,7 +62,7 @@ class SizeView(TQDialog):
self.readSize()
self.readSwaps()
- partitions = self.partitions.keys()
+ partitions = list(self.partitions.keys())
partitions.sort()
number=1
@@ -99,7 +99,7 @@ class SizeView(TQDialog):
rows = int(n/cols)+1
else:
rows = int(n/cols)
- if n is 1: rows = 2
+ if n == 1: rows = 2
# Build main Gridlayout.
total_rows = rows+2
@@ -209,7 +209,7 @@ class DiskGroup(TQGroupBox):
self.diskview.setScaledContents(1)
DiskViewGroupLayout.addWidget(self.diskview)
- parts = self.partitions.keys()
+ parts = list(self.partitions.keys())
parts.sort()
self.percentages()
@@ -247,11 +247,11 @@ class DiskGroup(TQGroupBox):
def percentages(self):
p_t = 0
- for p in self.partitions.values():
+ for p in list(self.partitions.values()):
p_t += int(p)
self.perc = {}
- for p in self.partitions.keys():
+ for p in list(self.partitions.keys()):
self.perc[p] = float(float(self.partitions[p])/float(p_t))
return self.perc
@@ -408,7 +408,8 @@ class DiskPixmap(TQPixmap):
linewidth = 2 # Width of surrounding frame
- def __init__(self,percents,colors,(w,h)):
+ def __init__(self,percents,colors, xxx_todo_changeme):
+ (w,h) = xxx_todo_changeme
self.percents = percents
self.w,self.h = w,h
self.colors = colors
@@ -425,7 +426,7 @@ class DiskPixmap(TQPixmap):
# Paint background, this is interesting for empty partitions.
p.fillRect(0,0,w,h,TQBrush(TQColor("white")))
- parts = self.percents.keys()
+ parts = list(self.percents.keys())
parts.sort()
xa = wa = 0
for part in parts: