本文整理汇总了Python中Components.Harddisk类的典型用法代码示例。如果您正苦于以下问题:Python Harddisk类的具体用法?Python Harddisk怎么用?Python Harddisk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Harddisk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTrashFolder
def getTrashFolder(path = None):
try:
if path is None or os.path.realpath(path) == '/media/autofs':
print 'path is none'
return ''
if '/movie' in path:
mountpoint = Harddisk.findMountPoint(os.path.realpath(path))
trashcan = os.path.join(mountpoint, 'movie')
else:
trashcan = Harddisk.findMountPoint(os.path.realpath(path))
return os.path.realpath(os.path.join(trashcan, '.Trash'))
except:
return
示例2: getTrashFolder
def getTrashFolder(path=None):
# Returns trash folder without symlinks
try:
if path is None:
print 'path is none'
else:
if path.find('/movie') >0:
mountpoint = Harddisk.findMountPoint(os.path.realpath(path))
trashcan = os.path.join(mountpoint, 'movie')
else:
trashcan = Harddisk.findMountPoint(os.path.realpath(path))
return os.path.realpath(os.path.join(trashcan, ".Trash"))
except:
return ""
示例3: getTrashFolder
def getTrashFolder(path=None):
# Returns trash folder without symlinks
try:
print "PATH:", path
if path is None or os.path.realpath(path) == "/media/autofs":
print "path is none"
else:
if "/movie" in path:
mountpoint = Harddisk.findMountPoint(os.path.realpath(path))
trashcan = os.path.join(mountpoint, "movie")
else:
trashcan = Harddisk.findMountPoint(os.path.realpath(path))
return os.path.realpath(os.path.join(trashcan, ".Trash"))
except:
return ""
示例4: getTrashFolder
def getTrashFolder(path=None):
# Returns trash folder without symlinks
try:
if path is None or os.path.realpath(path) == '/media/autofs':
print 'path is none'
return ""
else:
if '/movie' in path:
mountpoint = Harddisk.findMountPoint(os.path.realpath(path))
trashcan = os.path.join(mountpoint, 'movie')
else:
trashcan = Harddisk.findMountPoint(os.path.realpath(path))
return os.path.realpath(os.path.join(trashcan, ".Trash"))
except:
return None
示例5: defaultRecordingLocation
def defaultRecordingLocation(candidate=None):
if candidate and os.path.exists(candidate):
return candidate
# First, try whatever /hdd points to, or /media/hdd
try:
path = os.path.realpath("/hdd")
except:
path = '/media/hdd'
if not os.path.exists(path):
path = ''
# Find the largest local disk
from Components import Harddisk
mounts = [m for m in Harddisk.getProcMounts() if m[1].startswith('/media/')]
# Search local devices first, use the larger one
path = bestRecordingLocation([m for m in mounts if m[0].startswith('/dev/')])
# If we haven't found a viable candidate yet, try remote mounts
if not path:
path = bestRecordingLocation(mounts)
if path:
# If there's a movie subdir, we'd probably want to use that.
movie = os.path.join(path, 'movie')
if os.path.isdir(movie):
path = movie
if not path.endswith('/'):
path += '/' # Bad habits die hard, old code relies on this
return path
示例6: __init__
def __init__(self,session,testitem):
Screen.__init__(self, session)
self.testitem = testitem
self.devpath = "mmcblk0"
self.usbdevice = Harddisk(self.devpath)
self.usbdevicename = self.usbdevice.model()
self.usbsize= self.usbdevice.capacity()
# self.usbfreesize = (stat.f_bfree/1000) * (stat.f_bsize/1000)
self.usbfreesize = self.usbdevice.free()
print "usbdevicename:",self.usbdevicename
print "usbsize:",self.usbsize
print "usbfreesize",self.usbfreesize
self["usbtitle"] = StaticText("SDCard Device:"+self.usbdevicename)
self["usbname"] = StaticText("CardInfor: "+self.usbdevicename)
self["usbsize"] = StaticText("Card Size: "+self.usbsize)
self["usbfreesize"]=StaticText(_("Free Size: %d M") % (self.usbfreesize))
self["actions"] = ActionMap(["SetupActions", "ColorActions"],
{
"cancel": self.testfinish,
"ok": self.testfinish
})
示例7: getTrashFolder
def getTrashFolder(path):
# Returns trash folder without symlinks. Path may be file or directory or whatever.
mountpoint = Harddisk.findMountPoint(os.path.realpath(path))
movie = os.path.join(mountpoint, 'movie')
if os.path.isdir(movie):
mountpoint = movie
return os.path.join(mountpoint, ".Trash")
示例8: defaultRecordingLocation
def defaultRecordingLocation(candidate=None):
if candidate and os.path.exists(candidate):
return candidate
# First, try whatever /hdd points to, or /media/hdd
try:
path = os.readlink('/hdd')
except:
path = '/media/hdd'
if not os.path.exists(path):
path = ''
# Find the largest local disk
from Components import Harddisk
mounts = [m for m in Harddisk.getProcMounts() if m[1].startswith('/media/')]
biggest = 0
havelocal = False
for candidate in mounts:
try:
islocal = candidate[1].startswith('/dev/') # Good enough
stat = os.statvfs(candidate[1])
# Free space counts double
size = (stat.f_blocks + stat.f_bavail) * stat.f_bsize
if (islocal and not havelocal) or (islocal or not havelocal and size > biggest):
path = candidate[1]
havelocal = islocal
biggest = size
except Exception, e:
print "[DRL]", e
示例9: defaultRecordingLocation
def defaultRecordingLocation(candidate = None):
if candidate and os.path.exists(candidate):
return candidate
try:
path = os.readlink('/hdd')
except:
path = '/media/hdd'
if not os.path.exists(path):
path = ''
from Components import Harddisk
mounts = [ m for m in Harddisk.getProcMounts() if m[1].startswith('/media/') ]
biggest = 0
havelocal = False
for candidate in mounts:
try:
islocal = candidate[1].startswith('/dev/')
stat = os.statvfs(candidate[1])
size = (stat.f_blocks + stat.f_bavail) * stat.f_bsize
if islocal and not havelocal or islocal or not havelocal and size > biggest:
path = candidate[1]
havelocal = islocal
biggest = size
except Exception as e:
print '[DRL]', e
if path:
movie = os.path.join(path, 'movie')
if os.path.isdir(movie):
path = movie
if not path.endswith('/'):
path += '/'
return path
示例10: save
def save(self):
print "[MultiBootStartup] select new startup: ", self.list[self.selection]
ret = system("cp -f '/boot/%s' /boot/STARTUP" %self.list[self.selection])
if ret:
self.session.open(MessageBox, _("File '/boot/%s' copy to '/boot/STARTUP' failed!") %self.list[self.selection], MessageBox.TYPE_ERROR)
self.getCurrent()
return
writeoption = already = failboot = False
newboot = boot = self.readlineFile('/boot/STARTUP')
if self.checkBootEntry(boot):
failboot = True
elif self.option_enabled:
for x in self.optionsList:
if (x[0] + "'" in boot or x[0] + " " in boot) and x[0] != self.optionsList[self.option][0]:
newboot = boot.replace(x[0],self.optionsList[self.option][0])
writeoption = True
break
elif (x[0] + "'" in boot or x[0] + " " in boot) and x[0] == self.optionsList[self.option][0]:
already = True
break
if not (writeoption or already):
if "boxmode" in boot:
failboot = True
elif self.option:
newboot = boot.replace("rootwait", "rootwait hd51_4.%s" %(self.optionsList[self.option][0]))
writeoption = True
if self.enable_bootnamefile:
if failboot:
self.writeFile('/boot/bootname', 'STARTUP_1=STARTUP_1')
else:
self.writeFile('/boot/bootname', '%s=%s' %('STARTUP_%s' %boot[22:23], self.list[self.selection]))
message = _("Do you want to reboot now with selected image?")
if failboot:
print "[MultiBootStartup] wrong bootsettings: " + boot
if '/dev/mmcblk0p3' in Harddisk.getextdevices("ext4"):
if self.writeFile('/boot/STARTUP', "boot emmcflash0.kernel1 'root=/dev/mmcblk0p3 rw rootwait'"):
txt = _("Next boot will start from Image 1.")
else:
txt =_("Can not repair file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
else:
txt = _("Alternative Image 1 partition for boot repair not found.") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
message = _("Wrong Bootsettings detected!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
elif writeoption:
if not self.writeFile('/boot/STARTUP', newboot):
txt = _("Can not write file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
message = _("Write error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
#verify boot
if failboot or writeoption:
boot = self.readlineFile('/boot/STARTUP')
if self.checkBootEntry(boot):
txt = _("Error in file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
message = _("Command line error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
self.session.openWithCallback(self.restartBOX,MessageBox, message, MessageBox.TYPE_YESNO)
示例11: SDCardTest
class SDCardTest(Screen):
skin = """
<screen name="SDCardTest" position="220,57" size="840,605" title="SDCardTest" flags="wfNoBorder">
<ePixmap position="0,0" zPosition="-10" size="1100,605" pixmap="DMConcinnity-HD-Transp/menu/setupbg.png" />
<widget source="global.CurrentTime" render="Label" position="20,20" size="80,25" font="Regular;23" foregroundColor="black" backgroundColor="grey" transparent="1">
<convert type="ClockToText">Default</convert>
</widget>
<widget source="global.CurrentTime" render="Label" position="110,20" size="140,25" font="Regular;23" foregroundColor="blue" backgroundColor="grey" transparent="1">
<convert type="ClockToText">Format:%d.%m.%Y</convert>
</widget>
<eLabel text="USB information" position="270,20" size="540,43" font="Regular;35" halign="right" foregroundColor="black" backgroundColor="grey" transparent="1" />
<widget source="usbtitle" render="Label" position="110,145" size="700,35" font="Regular;26" foregroundColor="yellow" backgroundColor="transpBlack" transparent="1" />
<widget source="usbname" render="Label" position="140,190" size="700,30" font="Regular;24" backgroundColor="transpBlack" transparent="1" />
<widget source="usbsize" render="Label" position="140,220" size="700,30" font="Regular;24" backgroundColor="transpBlack" transparent="1" />
<widget source="usbfreesize" render="Label" position="140,250" size="700,30" font="Regular;24" backgroundColor="transpBlack" transparent="1" />
</screen>"""
def __init__(self,session,testitem):
Screen.__init__(self, session)
self.testitem = testitem
self.devpath = "mmcblk0"
self.usbdevice = Harddisk(self.devpath)
self.usbdevicename = self.usbdevice.model()
self.usbsize= self.usbdevice.capacity()
# self.usbfreesize = (stat.f_bfree/1000) * (stat.f_bsize/1000)
self.usbfreesize = self.usbdevice.free()
print "usbdevicename:",self.usbdevicename
print "usbsize:",self.usbsize
print "usbfreesize",self.usbfreesize
self["usbtitle"] = StaticText("SDCard Device:"+self.usbdevicename)
self["usbname"] = StaticText("CardInfor: "+self.usbdevicename)
self["usbsize"] = StaticText("Card Size: "+self.usbsize)
self["usbfreesize"]=StaticText(_("Free Size: %d M") % (self.usbfreesize))
self["actions"] = ActionMap(["SetupActions", "ColorActions"],
{
"cancel": self.testfinish,
"ok": self.testfinish
})
def testfinish(self):
self.testitem.setTestResult(FactoryTestItem.TESTRESULT_OK)
self.close()
示例12: list_files
def list_files(self, PATH):
files = []
self.path = PATH
for name in listdir(self.path):
if path.isfile(path.join(self.path, name)):
cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
if cmdline in Harddisk.getextdevices("ext4") and not name == "STARTUP":
files.append(name)
return files
示例13: list_files
def list_files(self, PATH):
files = []
for name in listdir(PATH):
if path.isfile(path.join(PATH, name)):
try:
cmdline = self.read_startup("/boot/" + name).split("=",3)[3].split(" ",1)[0]
except IndexError:
continue
if cmdline in Harddisk.getextdevices("ext4") and not name == "STARTUP":
files.append(name)
return files
示例14: list_files
def list_files(self, PATH):
files = []
if SystemInfo["HaveMultiBoot"]:
self.path = PATH
for name in listdir(self.path):
if path.isfile(path.join(self.path, name)):
cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
if cmdline in Harddisk.getextdevices("ext4"):
files.append(name)
files.append("Recovery")
return files
示例15: enumTrashFolders
def enumTrashFolders():
# Walk through all Trash folders. This may access network
# drives and similar, so might block for minutes.
for mount in Harddisk.getProcMounts():
if mount[1].startswith('/media/'):
mountpoint = mount[1]
movie = os.path.join(mountpoint, 'movie')
if os.path.isdir(movie):
mountpoint = movie
result = os.path.join(mountpoint, ".Trash")
if os.path.isdir(result):
yield result