示例#1
0
def genlist(fullpath, convs):
    # BFT for all images under current barcode, in order
    # if we're at the top level, do a gencnames for all images, appending lists together
    flst = []
    mlst = []
    curdir = fullpath.split("/")[-1]
    brcd = (fullpath.split("/")[3]).split("_")[1]

    # Only async (flag test)
    mconv = []
    for l in convs:
        if l[-1]:
            mconv.append(l)

    # Modified from internal
    # if len(curdir) > 6 and brcd == curdir[6:]:
    try:
        for f in os.listdir(fullpath):
            if not f.startswith('.'):
                # Generate list of all files
                for i in bfswalk.gencnames(os.path.join(fullpath, f)):
                    m = hasher.md5sum(i, mconv)
                    if not m == '-1':
                        typestr = mimetypes.guess_type(i)[0]
                        #if i[-3:].lower() == 'doc' and
                        # commands.getoutput('file -i %s' % i).find('msword') == -1:
                        if i[-3:].lower(
                        ) == 'doc' and pymagic.file(i).find('ASCII') > -1:
                            pass
                        else:
                            flst.append(i)
                            # Inconsistent - removal of PDF ending
                            mlst.append("/tmp/migrated/" + brcd + "/" + m[:-4])
    except:
        pass

    # Make one list, before we call the converter
    flst += mlst

    if len(flst) > 0:
        if os.path.isdir("/tmp/migrated/" + brcd):
            pass
        elif os.path.isfile("/tmp/migrated/" + brcd):
            raise OSError("a file with that name already exists")
        else:
            os.mkdir("/tmp/migrated/" + brcd)

    return flst
示例#2
0
def genlist(fullpath, convs):
    # BFT for all images under current barcode, in order
    # if we're at the top level, do a gencnames for all images, appending lists together
    flst = []
    mlst = []
    curdir = fullpath.split("/")[-1]
    brcd = (fullpath.split("/")[3]).split("_")[1]

    # Only async (flag test)
    mconv = []
    for l in convs:
        if l[-1]:
            mconv.append(l)

    # Modified from internal
    # if len(curdir) > 6 and brcd == curdir[6:]:
    try:
        for f in os.listdir(fullpath):
            if not f.startswith('.'):
                # Generate list of all files
                for i in bfswalk.gencnames(os.path.join(fullpath, f)):
                    m = hasher.md5sum(i, mconv)
                    if not m == '-1':
                        typestr = mimetypes.guess_type(i)[0]
                        #if i[-3:].lower() == 'doc' and 
                        # commands.getoutput('file -i %s' % i).find('msword') == -1:
                        if i[-3:].lower() == 'doc' and pymagic.file(i).find('ASCII') > -1:
                            pass
                        else:
                            flst.append(i)
                            # Inconsistent - removal of PDF ending
                            mlst.append("/tmp/migrated/" + brcd + "/" + m[:-4])
    except:
        pass

    # Make one list, before we call the converter
    flst += mlst

    if len(flst) > 0:
        if os.path.isdir("/tmp/migrated/" + brcd):
            pass
        elif os.path.isfile("/tmp/migrated/" + brcd):
            raise OSError("a file with that name already exists")
        else:
            os.mkdir("/tmp/migrated/" + brcd)

    return flst
示例#3
0
def genlist(fullpath, convs):
    flst = []
    mlst = []
    curdir = fullpath.split("/")[-1]

    brcd = (fullpath.split("/")[3]).split("_")[1]

    mconv = []
    for l in convs:
        if l[-1]:
            mconv.append(l)

    for f in os.listdir(fullpath):

        if not f.startswith('.'):
            for i in bfswalk.gencnames(os.path.join(fullpath, f)):
                m = hasher.md5sum(i, mconv)

                if not m == '-1':
                    flst.append(i)
                    mlst.append("/tmp/migrated/" + brcd + "/" + m[:-4])

    flst += mlst
    if os.path.isdir("/tmp/migrated/" + brcd):
        pass
    elif os.path.isfile("/tmp/migrated/" + brcd):
        raise OSError("a file with that name already exists")
    else:
        os.mkdir("/tmp/migrated/" + brcd)

    if os.path.isdir("/tmp/video/" + brcd):
        pass
    elif os.path.isfile("/tmp/video/" + brcd):
        raise OSError("a file with that name already exists")
    else:
        os.mkdir("/tmp/video/" + brcd)

    return flst
示例#4
0
def genlist(fullpath, convs):
    flst = []
    mlst = []
    curdir = fullpath.split("/")[-1]

    brcd = (fullpath.split("/")[3]).split("_")[1]

    mconv = []
    for l in convs:
        if l[-1]:
            mconv.append(l)

    for f in os.listdir(fullpath):

        if not f.startswith("."):
            for i in bfswalk.gencnames(os.path.join(fullpath, f)):
                m = hasher.md5sum(i, mconv)

                if not m == "-1":
                    flst.append(i)
                    mlst.append("/tmp/migrated/" + brcd + "/" + m[:-4])

    flst += mlst
    if os.path.isdir("/tmp/migrated/" + brcd):
        pass
    elif os.path.isfile("/tmp/migrated/" + brcd):
        raise OSError("a file with that name already exists")
    else:
        os.mkdir("/tmp/migrated/" + brcd)

    if os.path.isdir("/tmp/video/" + brcd):
        pass
    elif os.path.isfile("/tmp/video/" + brcd):
        raise OSError("a file with that name already exists")
    else:
        os.mkdir("/tmp/video/" + brcd)

    return flst