예제 #1
0
def scanDevice(mountpoint):
	scanner = [ ]

	for p in plugins.getPlugins(PluginDescriptor.WHERE_FILESCAN):
		l = p()
		if not isinstance(l, list):
			l = [l]
		scanner += l

	print "scanner:", scanner

	res = { }

	# merge all to-be-scanned paths, with priority to 
	# with_subdirs.

	paths_to_scan = set()

	# first merge them all...
	for s in scanner:
		paths_to_scan.update(set(s.paths_to_scan))

	# ...then remove with_subdir=False when same path exists
	# with with_subdirs=True
	for p in paths_to_scan:
		if p.with_subdirs == True and ScanPath(path=p.path) in paths_to_scan:
			paths_to_scan.remove(ScanPath(path=p.path))

	from Components.Harddisk import harddiskmanager	
	blockdev = mountpoint.rstrip("/").rsplit('/',1)[-1]
	error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(blockdev)

	# now scan the paths
	for p in paths_to_scan:
		path = os_path.join(mountpoint, p.path)

                cmd = "ls " + path
                system(cmd)
		for root, dirs, files in os_walk(path):
			for f in files:
				path = os_path.join(root, f)
				if is_cdrom and path.endswith(".wav") and path[-13:-6] == ("/track-"):
					sfile = ScanFile(path,"audio/x-cda")
				else:
					sfile = ScanFile(path)
				for s in scanner:
					s.handleFile(res, sfile)

			# if we really don't want to scan subdirs, stop here.
			if not p.with_subdirs:
				del dirs[:]

	# res is a dict with scanner -> [ScanFiles]
	return res
예제 #2
0
def scanDevice(mountpoint):
    scanner = []

    for p in plugins.getPlugins(PluginDescriptor.WHERE_FILESCAN):
        l = p()
        if not isinstance(l, list):
            l = [l]
        scanner += l

    print "scanner:", scanner

    res = {}

    # merge all to-be-scanned paths, with priority to
    # with_subdirs.

    paths_to_scan = set()

    # first merge them all...
    for s in scanner:
        paths_to_scan.update(set(s.paths_to_scan))

    # ...then remove with_subdir=False when same path exists
    # with with_subdirs=True
    for p in paths_to_scan:
        if p.with_subdirs == True and ScanPath(path=p.path) in paths_to_scan:
            paths_to_scan.remove(ScanPath(path=p.path))

    from Components.Harddisk import harddiskmanager
    blockdev = mountpoint.rstrip("/").rsplit('/', 1)[-1]
    error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(
        blockdev)

    # now scan the paths
    for p in paths_to_scan:
        path = os.path.join(mountpoint, p.path)

        for root, dirs, files in os.walk(path):
            for f in files:
                path = os.path.join(root, f)
                if (is_cdrom and f[-4:] == ".wav"
                        and f[:5] == "track") or f == "cdplaylist.cdpls":
                    sfile = ScanFile(path, "audio/x-cda")
                else:
                    sfile = ScanFile(path)
                for s in scanner:
                    s.handleFile(res, sfile)

            # if we really don't want to scan subdirs, stop here.
            if not p.with_subdirs:
                del dirs[:]

    # res is a dict with scanner -> [ScanFiles]
    return res
예제 #3
0
파일: Scanner.py 프로젝트: ostende/EGAMI-2
def scanDevice(mountpoint):
    scanner = []
    for p in plugins.getPlugins(PluginDescriptor.WHERE_FILESCAN):
        l = p()
        if not isinstance(l, list):
            l = [l]
        scanner += l

    print '[Scanner] ', scanner
    res = {}
    paths_to_scan = set()
    for s in scanner:
        paths_to_scan.update(set(s.paths_to_scan))

    for p in paths_to_scan:
        if p.with_subdirs == True and ScanPath(path=p.path) in paths_to_scan:
            paths_to_scan.remove(ScanPath(path=p.path))

    from Components.Harddisk import harddiskmanager
    blockdev = mountpoint.rstrip('/').rsplit('/', 1)[-1]
    error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(
        blockdev)
    for p in paths_to_scan:
        path = os.path.join(mountpoint, p.path)
        for root, dirs, files in os.walk(path):
            for f in files:
                path = os.path.join(root, f)
                if is_cdrom and f.endswith('.wav') and f.startswith(
                        'track') or f == 'cdplaylist.cdpls':
                    sfile = ScanFile(path, 'audio/x-cda')
                else:
                    sfile = ScanFile(path)
                for s in scanner:
                    s.handleFile(res, sfile)

            if not p.with_subdirs:
                del dirs[:]

    return res