from os import system, listdir, statvfs, popen, makedirs, stat, major, minor, path, access
-from Tools.Directories import SCOPE_HDD, resolveFilename
+# ikseong
+from Tools.Directories import SCOPE_HDD, resolveFilename, fileExists
+
from Tools.CList import CList
from SystemInfo import SystemInfo
import time
return ret
def diskSize(self):
- line = readFile(self.sysfsPath('size'))
+ # ikseong
+ try:
+ line = readFile(self.sysfsPath('size'))
+ except:
+ harddiskmanager.removeHotplugPartition(self.device)
+ print "error remove",self.device
+ return -1
try:
cap = int(line)
except:
return "%d.%03d GB" % (cap/1000, cap%1000)
def model(self):
- if self.device[:2] == "hd":
- return readFile('/proc/ide/' + self.device + '/model')
- elif self.device[:2] == "sd":
- vendor = readFile(self.sysfsPath('device/vendor'))
- model = readFile(self.sysfsPath('device/model'))
- return vendor + '(' + model + ')'
- else:
- assert False, "no hdX or sdX"
+ # ikseong
+ try:
+ if self.device[:2] == "hd":
+ return readFile('/proc/ide/' + self.device + '/model')
+ elif self.device[:2] == "sd":
+ vendor = readFile(self.sysfsPath('device/vendor'))
+ model = readFile(self.sysfsPath('device/model'))
+ return vendor + '(' + model + ')'
+ else:
+ assert False, "no hdX or sdX"
+ except:
+ harddiskmanager.removeHotplugPartition(self.device)
+ print "error remove",self.device
+ return -1
def free(self):
try:
res = system(cmd)
return (res >> 8)
+ def checkPartionPath(self, path):
+ import time, os
+ for i in range(1,10):
+ if os.path.exists(path):
+ return True
+ time.sleep(1)
+ return False
+
def createPartition(self):
- cmd = 'printf "0,\n;\n;\n;\ny\n" | sfdisk -f ' + self.disk_path
+ cmd = 'printf "8,\n;0,0\n;0,0\n;0,0\ny\n" | sfdisk -f -uS ' + self.disk_path
res = system(cmd)
+ if not self.checkPartionPath(self.partitionPath("1")):
+ print "no exist : ", self.partitionPath("1")
+ return 1
return (res >> 8)
def mkfs(self):
return (res >> 8)
def createMovieFolder(self):
+# ikseong
try:
+ if not fileExists("/hdd", 0):
+ print "not found /hdd"
+ system("ln -s /media/hdd /hdd")
+#
makedirs(resolveFilename(SCOPE_HDD))
except OSError:
return -1
idle_time = t - self.last_access
stats = self.readStats()
+ # ikseong
+ if stats == -1:
+ self.setIdleTime(0)
+ return
print "nr_read", stats[0], "nr_write", stats[1]
l = sum(stats)
print "sum", l, "prev_sum", self.last_stat
def getAutofsMountpoint(self, device):
return "/autofs/%s/" % (device)
+
def is_hard_mounted(self, device):
mounts = file('/proc/mounts').read().split('\n')
for x in mounts:
def HDDList(self):
list = [ ]
for hd in self.hdd:
+ # ikseong
+ if hd.model() == -1:
+ continue
hdd = hd.model() + " - " + hd.bus()
cap = hd.capacity()
if cap != "":