summaryrefslogtreecommitdiffstats
path: root/mountconfig/mountconfig.py
diff options
context:
space:
mode:
Diffstat (limited to 'mountconfig/mountconfig.py')
-rwxr-xr-xmountconfig/mountconfig.py152
1 files changed, 76 insertions, 76 deletions
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):