本文整理匯總了Python中MountPoints.MountPoints.write方法的典型用法代碼示例。如果您正苦於以下問題:Python MountPoints.write方法的具體用法?Python MountPoints.write怎麽用?Python MountPoints.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MountPoints.MountPoints
的用法示例。
在下文中一共展示了MountPoints.write方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: initialaze
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
def initialaze(self, result):
if result != 5:
self.result = result
self.formatted = 0
mp = MountPoints()
mp.read()
mp.deleteDisk(self.mdisks.disks[self.sindex][0])
mp.write()
self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, _('Partitioning...'), _('Initialize disk'), self.fdisk)
示例2: checkDefault
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
def checkDefault(self):
mp = MountPoints()
mp.read()
if not mp.exist('/hdd'):
mp.add(self.mdisks.disks[self.sindex][0], 1, '/hdd')
mp.write()
mp.mount(self.mdisks.disks[self.sindex][0], 1, '/hdd')
os.system('/bin/mkdir /hdd/movie')
os.system('/bin/mkdir /hdd/music')
os.system('/bin/mkdir /hdd/picture')
示例3: initialaze
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
def initialaze(self, result):
if not self.isExt4Supported():
result += 1
if result != 6:
self.fsresult = result
self.formatted = 0
mp = MountPoints()
mp.read()
mp.deleteDisk(self.mdisks.disks[self.sindex][0])
mp.write()
self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, _("Partitioning..."), _("Initialize disk"), self.fdisk)
示例4: checkDefault
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
def checkDefault(self):
mp = MountPoints()
mp.read()
if self.asHDD and not mp.exist("/media/hdd"):
mp.add(self.mdisks.disks[self.sindex][0], 1, "/media/hdd")
mp.write()
mp.mount(self.mdisks.disks[self.sindex][0], 1, "/media/hdd")
os.system("mkdir -p /media/hdd/movie")
message = _("Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?")
mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO)
mbox.setTitle(_("Restart STB"))
示例5: HddMount
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
#.........這裏部分代碼省略.........
elif selected == 2:
self.setMountPoint("/media/hdd2")
elif selected == 3:
self.setMountPoint("/media/hdd3")
elif selected == 4:
self.setMountPoint("/media/hdd4")
elif selected == 5:
self.setMountPoint("/media/hdd5")
elif selected == 6:
self.setMountPoint("/media/usb")
elif selected == 7:
self.setMountPoint("/media/usb1")
elif selected == 8:
self.setMountPoint("/media/usb2")
elif selected == 9:
self.setMountPoint("/media/usb3")
elif selected == 10:
self.setMountPoint("/media/usb4")
elif selected == 11:
self.setMountPoint("/media/usb5")
elif selected == 12:
self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = _("/media/custom"))
def green(self):
self.fast = True
selected = self["menu"].getSelectedIndex()
if selected == 0:
self.setMountPoint("/media/hdd")
elif selected == 1:
self.setMountPoint("/media/hdd1")
elif selected == 2:
self.setMountPoint("/media/hdd2")
elif selected == 3:
self.setMountPoint("/media/hdd3")
elif selected == 4:
self.setMountPoint("/media/hdd4")
elif selected == 5:
self.setMountPoint("/media/hdd5")
elif selected == 6:
self.setMountPoint("/media/usb")
elif selected == 7:
self.setMountPoint("/media/usb1")
elif selected == 8:
self.setMountPoint("/media/usb2")
elif selected == 9:
self.setMountPoint("/media/usb3")
elif selected == 10:
self.setMountPoint("/media/usb4")
elif selected == 11:
self.setMountPoint("/media/usb5")
elif selected == 12:
self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = _("/media/custom"))
def customPath(self, result):
if result and len(result) > 0:
result = result.rstrip("/")
os.system("mkdir -p %s" % result)
self.setMountPoint(result)
def setMountPoint(self, path):
self.cpath = path
if self.mountpoints.exist(path):
self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, _("Selected mount point is already used by another drive."), _("Mount point exist!"),
[ [ _("Change old drive with this new drive"), "ok.png" ],
[ _("Keep old drive"), "cancel.png" ],
])
else:
self.setMountPointCb(0)
def setMountPointCb(self, result):
if result == 0:
if self.mountpoints.isMounted(self.cpath):
if not self.mountpoints.umount(self.cpath):
self.session.open(MessageBox, _("Cannot umount current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR)
self.close()
return
self.mountpoints.delete(self.cpath)
if not self.fast:
self.mountpoints.add(self.device, self.partition, self.cpath)
self.mountpoints.write()
if not self.mountpoints.mount(self.device, self.partition, self.cpath):
self.session.open(MessageBox, _("Cannot mount new drive.\nPlease check filesystem or format it and try again"), MessageBox.TYPE_ERROR)
elif self.cpath == "/media/hdd":
os.system("/bin/mkdir -p /media/hdd/movie")
if not self.fast:
message = _("Device Fixed Mount Point change needs a system restart in order to take effect.\nRestart your %s %s now?") % (getMachineBrand(), getMachineName())
mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO)
mbox.setTitle(_("Restart %s %s") % (getMachineBrand(), getMachineName()))
else:
self.close()
def restartBox(self, answer):
if answer is True:
self.session.open(TryQuitMainloop, 2)
else:
self.close()
def quit(self):
self.close()
示例6: HddPartitions
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
#.........這裏部分代碼省略.........
self.fstype = 1
self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs)
elif self.disk[5][self.index][3] == "7":
if result < 1:
self.fstype = 2
self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs)
elif self.disk[5][self.index][3] == "b":
if result < 1:
self.fstype = 3
self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs)
def green(self):
if len(self.disk[5]) > 0:
index = self["menu"].getIndex()
if self.disk[5][index][3] == "83" or self.disk[5][index][3] == "7" or self.disk[5][index][3] == "b":
self.index = index
if self.disk[5][index][3] == "83":
self.fstype = 0
elif self.disk[5][index][3] == "7":
self.fstype = 2
elif self.disk[5][index][3] == "b":
self.fstype = 3
self.session.open(ExtraActionBox, _("Checking disk %s") % self.disk[5][index][0], _("Checking disk"), self.chkfs)
def yellow(self):
if len(self.disk[5]) > 0:
self.index = self["menu"].getIndex()
if self.disk[5][self.index][3] == "83":
if self.isExt4Supported():
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"),
[ [ "Ext4", "partitionmanager.png" ],
[ "Ext3", "partitionmanager.png" ],
[ _("Cancel"), "cancel.png" ],
], 1, 2)
else:
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"),
[ [ "Ext3", "partitionmanager.png" ],
[ _("Cancel"), "cancel.png" ],
], 1, 1)
elif self.disk[5][self.index][3] == "7":
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"),
[ [ "NTFS", "partitionmanager.png" ],
[ _("Cancel"), "cancel.png" ],
], 1, 1)
elif self.disk[5][self.index][3] == "b":
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"),
[ [ "Fat32", "partitionmanager.png" ],
[ _("Cancel"), "cancel.png" ],
], 1, 1)
def refreshMP(self, uirefresh = True):
self.partitions = []
self.mountpoints = MountPoints()
self.mountpoints.read()
count = 1
for part in self.disk[5]:
capacity = "%d MB" % (part[1] / (1024 * 1024))
mp = self.mountpoints.get(self.disk[0], count)
rmp = self.mountpoints.getRealMount(self.disk[0], count)
if len(mp) > 0:
self.partitions.append(PartitionEntry("P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity))
elif len(rmp) > 0:
self.partitions.append(PartitionEntry("P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity))
else:
self.partitions.append(PartitionEntry("P. %d - %s" % (count, part[2]), capacity))
count += 1
if uirefresh:
self["menu"].setList(self.partitions)
self.selectionChanged()
def blue(self):
if len(self.disk[5]) > 0:
index = self["menu"].getIndex()
if self.disk[5][index][3] != "83" and self.disk[5][index][3] != "7" and self.disk[5][index][3] != "b":
return
if len(self.partitions) > 0:
self.sindex = self['menu'].getIndex()
if self.mounted:
mp = self.mountpoints.get(self.disk[0], self.sindex+1)
rmp = self.mountpoints.getRealMount(self.disk[0], self.sindex+1)
if len(mp) > 0:
if self.mountpoints.isMounted(mp):
if self.mountpoints.umount(mp):
self.mountpoints.delete(mp)
self.mountpoints.write()
else:
self.session.open(MessageBox, _("Cannot umount current device.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR)
else:
self.mountpoints.delete(mp)
self.mountpoints.write()
elif len(rmp) > 0:
self.mountpoints.umount(rmp)
self.refreshMP()
else:
self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex+1)
def quit(self):
self.close()
示例7: HddPartitions
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
#.........這裏部分代碼省略.........
self.session.open(MessageBox, _('Cannot format current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR)
else:
self.session.open(MessageBox, _('Error formatting disk. The disk may be damaged'), MessageBox.TYPE_ERROR)
def isExt4Supported(self):
return 'ext4' in open('/proc/filesystems').read()
def domkfs(self, result):
if self.disk[5][self.index][3] == '83':
if self.isExt4Supported():
if result < 2:
self.fstype = result
self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs)
elif result < 1:
self.fstype = 1
self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs)
elif self.disk[5][self.index][3] == '7':
if result < 1:
self.fstype = 2
self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs)
elif self.disk[5][self.index][3] == 'b':
if result < 1:
self.fstype = 3
self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs)
def green(self):
if len(self.disk[5]) > 0:
index = self['menu'].getIndex()
if self.disk[5][index][3] == '83' or self.disk[5][index][3] == '7' or self.disk[5][index][3] == 'b':
self.index = index
if self.disk[5][index][3] == '83':
self.fstype = 0
elif self.disk[5][index][3] == '7':
self.fstype = 2
elif self.disk[5][index][3] == 'b':
self.fstype = 3
self.session.open(ExtraActionBox, _('Checking disk %s') % self.disk[5][index][0], _('Checking disk'), self.chkfs)
def yellow(self):
if len(self.disk[5]) > 0:
self.index = self['menu'].getIndex()
if self.disk[5][self.index][3] == '83':
if self.isExt4Supported():
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Ext4', 'partitionmanager.png'], ['Ext3', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 2)
else:
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Ext3', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 1)
elif self.disk[5][self.index][3] == '7':
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['NTFS', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 1)
elif self.disk[5][self.index][3] == 'b':
self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Fat32', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 1)
def refreshMP(self, uirefresh = True):
self.partitions = []
self.mountpoints = MountPoints()
self.mountpoints.read()
count = 1
for part in self.disk[5]:
capacity = '%d MB' % (part[1] / 1048576)
mp = self.mountpoints.get(self.disk[0], count)
rmp = self.mountpoints.getRealMount(self.disk[0], count)
if len(mp) > 0:
self.partitions.append(PartitionEntry('P. %d - %s (Fixed: %s)' % (count, part[2], mp), capacity))
elif len(rmp) > 0:
self.partitions.append(PartitionEntry('P. %d - %s (Fast: %s)' % (count, part[2], rmp), capacity))
else:
self.partitions.append(PartitionEntry('P. %d - %s' % (count, part[2]), capacity))
count += 1
if uirefresh:
self['menu'].setList(self.partitions)
self.selectionChanged()
def red(self):
if len(self.disk[5]) > 0:
index = self['menu'].getIndex()
if self.disk[5][index][3] != '83' and self.disk[5][index][3] != '7' and self.disk[5][index][3] != 'b':
return
if len(self.partitions) > 0:
self.sindex = self['menu'].getIndex()
if self.mounted:
mp = self.mountpoints.get(self.disk[0], self.sindex + 1)
rmp = self.mountpoints.getRealMount(self.disk[0], self.sindex + 1)
if len(mp) > 0:
if self.mountpoints.isMounted(mp):
if self.mountpoints.umount(mp):
self.mountpoints.delete(mp)
self.mountpoints.write()
else:
self.session.open(MessageBox, _('Cannot umount current device.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR)
else:
self.mountpoints.delete(mp)
self.mountpoints.write()
elif len(rmp) > 0:
self.mountpoints.umount(rmp)
self.refreshMP()
else:
self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex + 1)
def quit(self):
self.close()
示例8: HddMount
# 需要導入模塊: from MountPoints import MountPoints [as 別名]
# 或者: from MountPoints.MountPoints import write [as 別名]
class HddMount(Screen):
skin = '\n\t<screen name="HddMount" position="center,center" size="560,430" title="Hard Drive Mount">\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />\n\t\t<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t<widget name="menu" position="20,45" scrollbarMode="showOnDemand" size="520,380" transparent="1" />\n\t</screen>'
def __init__(self, session, device, partition):
Screen.__init__(self, session)
self.device = device
self.partition = partition
self.mountpoints = MountPoints()
self.mountpoints.read()
self.fast = False
self.list = []
self.list.append(_('Mount as /universe'))
self.list.append(_('Mount as /media/usb'))
self.list.append(_('Mount as /media/hdd'))
self.list.append('Mount as /media/cf')
self.list.append('Mount as /media/mmc1')
self.list.append('Mount on custom path')
self['menu'] = MenuList(self.list)
self['key_red'] = Button(_('Fixed mount'))
self['key_green'] = Button('Fast mount')
self['key_blue'] = Button(_('Exit'))
self['key_yellow'] = Button('')
self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'blue': self.quit,
'green': self.green,
'ok': self.ok,
'red': self.ok,
'cancel': self.quit}, -2)
self.onShown.append(self.setWindowTitle)
def setWindowTitle(self):
self.setTitle(_('Mountpoints'))
def ok(self):
self.fast = False
selected = self['menu'].getSelectedIndex()
if selected == 0:
self.setMountPoint('/universe')
elif selected == 1:
self.setMountPoint('/media/usb')
elif selected == 2:
self.setMountPoint('/media/hdd')
elif selected == 3:
self.setMountPoint('/media/cf')
elif selected == 4:
self.setMountPoint('/media/mmc1')
elif selected == 5:
self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom')
def green(self):
self.fast = True
selected = self['menu'].getSelectedIndex()
if selected == 0:
self.setMountPoint('/universe')
elif selected == 1:
self.setMountPoint('/media/usb')
elif selected == 2:
self.setMountPoint('/media/hdd')
elif selected == 3:
self.setMountPoint('/media/cf')
elif selected == 4:
self.setMountPoint('/media/mmc1')
elif selected == 5:
self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom')
def customPath(self, result):
if result and len(result) > 0:
result = result.rstrip('/')
os.system('mkdir -p %s' % result)
self.setMountPoint(result)
def setMountPoint(self, path):
self.cpath = path
if self.mountpoints.exist(path):
self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, 'Selected mount point is already used by another drive.', 'Mount point exist!', [['Change old drive with this new drive', 'ok.png'], ['Mantain old drive', 'cancel.png']])
else:
self.setMountPointCb(0)
def setMountPointCb(self, result):
if result == 0:
if not self.mountpoints.isMounted(self.cpath) and self.mountpoints.umount(self.cpath):
self.session.open(MessageBox, _('Cannot umount current drive.\nA record in progress, timeshit or some external tools (like samba and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR)
self.close()
return None
self.mountpoints.delete(self.cpath)
if not self.fast:
self.mountpoints.add(self.device, self.partition, self.cpath)
self.mountpoints.write()
if not self.mountpoints.mount(self.device, self.partition, self.cpath):
self.session.open(MessageBox, _('Cannot mount new drive.\nPlease check filesystem or format it and try again'), MessageBox.TYPE_ERROR)
elif self.cpath == '/media/hdd':
os.system('/bin/mkdir /hdd/movie')
os.system('/bin/mkdir /hdd/music')
os.system('/bin/mkdir /hdd/picture')
self.close()
def restartBox(self, answer):
if answer is True:
self.session.open(TryQuitMainloop, 2)
else:
self.close()
#.........這裏部分代碼省略.........