Ejemplo n.º 1
0
def defaultRecordingLocation(candidate=None):
    if candidate and pathExists(candidate):
        return candidate
    # First, try whatever /hdd points to, or /media/hdd.
    try:
        path = os.readlink("/hdd")
    except OSError:
        path = "/media/hdd"
    if not pathExists(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(
                [m for m in mounts if not m[0].startswith("/dev/")])
    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
Ejemplo n.º 2
0
def defaultRecordingLocation(candidate=None):
    if candidate:
        if os.path.exists(candidate):
            return candidate
        try:
            os.makedirs(candidate)
            return candidate
        except:
            pass
    # 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/')
        ]
        # 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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def defaultRecordingLocation(candidate=None):
    if candidate and pathExists(candidate):
        return candidate
    try:
        path = readlink(
            "/hdd")  # First, try whatever /hdd points to, or /media/hdd.
    except (IOError, OSError) as err:
        path = "/media/hdd"
    if not pathExists(path):  # Find the largest local disk.
        from Components import Harddisk
        mounts = [
            mount for mount in Harddisk.getProcMounts()
            if mount[1].startswith("/media/")
        ]
        path = bestRecordingLocation([
            mount for mount in mounts if mount[0].startswith("/dev/")
        ])  # Search local devices first, use the larger one.
        if not path:  # If we haven't found a viable candidate yet, try remote mounts.
            path = bestRecordingLocation([
                mount for mount in mounts if not mount[0].startswith("/dev/")
            ])
    if path:
        movie = pathjoin(
            path, "movie", ""
        )  # If there's a movie subdir, we'd probably want to use that (directories need to end in sep).
        if isdir(movie):
            path = movie
    return path
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
 def onRemoteRootFS(self):
     if self.remoteRootFS is None:
         from Components import Harddisk
         for parts in Harddisk.getProcMounts():
             if parts[1] == '/' and parts[2] == 'nfs':
                 self.remoteRootFS = True
                 break
         else:
             self.remoteRootFS = False
     return self.remoteRootFS
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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) or not os.path.ismount(path):
		path = ''
		from Components import Harddisk
		mounts = [m for m in Harddisk.getProcMounts() if m[1].startswith('/media/')]
		path = bestRecordingLocation([m for m in mounts if m[0].startswith('/dev/')])
	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
Ejemplo n.º 13
0
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 as e:
                print("[DRL]", e)
    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