Пример #1
0
def jp2_to_jpeg(_threads, _app, _source, _destination, _broken, _jpegs,
                _verbose):
    testApp(_app)

    t = ThreadPool(_threads)

    for (root, dirs, files) in os.walk(_destination):
        subpath = root.replace(_destination, '').lstrip('/')
        if _broken not in subpath:
            if any(".jp2" in s for s in files):
                print >> emaillog, 'Converting contents of ' + subpath + ' from JP2 to JPEG'
            for (output_file, size) in _jpegs:
                for file in files:
                    if file.endswith('.jp2'):
                        jp2 = os.path.join(root, file)
                        newfile = os.path.join(root,
                                  os.path.splitext(file)[0]) + '_' \
                                  + output_file
                        command = _app + ' -size ' + size + " " + jp2 \
                                  + ' -resize ' + size + ' ' + newfile
                        if _verbose == True:
                            print 'Creating ' + newfile
                        t.add_task(executeConversion, command, None, jp2,
                                   _source, _broken, file, newfile)
                t.await_completion()
Пример #2
0
def tif_to_jp2(_threads, _app, _source, _destination, _broken, _options,
               _verbose):

    testApp(_app)

    t = ThreadPool(_threads)

    for (root, dirs, files) in os.walk(_source):
        subpath = root.replace(_source, '').lstrip('/')
        if _broken not in subpath:
            jp2Path = os.path.join(_destination, subpath)
            makeDir(jp2Path)
            if any(".tif" in s for s in files):
                print >> emaillog, 'Converting contents of ' + subpath + ' from TIF to JP2'
            for file in files:
                if file.endswith('.tif'):
                    tiff = os.path.join(root, file)
                    jp2 = os.path.join(_destination, subpath,
                                       os.path.splitext(file)[0] + '.jp2')
                    tiffcopy = os.path.join(_destination, subpath, file)
                    command = _app + ' -i ' + tiff + ' -o ' + jp2 + ' ' \
                        + _options
                    command_post = 'shutil.move(\'' + tiff + '\',\'' + tiffcopy + '\')'
                    if _verbose == True:
                        print 'Creating ' + jp2
                    t.add_task(executeConversion, command, command_post, tiff,
                               _destination, _broken, file, jp2)
        t.await_completion()
Пример #3
0
def jp2_to_jpeg(
    _threads,
    _app,
    _source,
    _destination,
    _broken,
    _jpegs,
    _verbose
    ):
    testApp(_app)

    t = ThreadPool(_threads)

    for (root, dirs, files) in os.walk(_destination):
        subpath = root.replace(_destination, '').lstrip('/')
        if _broken not in subpath:
            if any(".jp2" in s for s in files):
                print >>emaillog, 'Converting contents of ' + subpath + ' from JP2 to JPEG'
	    for (output_file, size) in _jpegs:
                for file in files:
                    if file.endswith('.jp2'):
                        jp2 = os.path.join(root, file)
                        newfile = os.path.join(root,
                                  os.path.splitext(file)[0]) + '_' \
                                  + output_file
                        command = _app + ' -size ' + size + " " + jp2 \
                                  + ' -resize ' + size + ' ' + newfile
                        if _verbose == True:
                            print 'Creating ' + newfile
			t.add_task(executeConversion,command,None,jp2,_source,_broken,file,newfile)
	        t.await_completion()
Пример #4
0
def tif_to_jp2(
    _threads,
    _app,
    _source,
    _destination,
    _broken,
    _options,
    _verbose
    ):
 
    testApp(_app)

    t = ThreadPool(_threads)

    for (root, dirs, files) in os.walk(_source):
        subpath = root.replace(_source, '').lstrip('/')
        if _broken not in subpath:  
            jp2Path = os.path.join(_destination,subpath)
            makeDir(jp2Path)
            if any(".tif" in s for s in files):
                print >>emaillog, 'Converting contents of ' + subpath + ' from TIF to JP2'
            for file in files:
                if file.endswith('.tif'):
                    tiff = os.path.join(root, file)
                    jp2 = os.path.join(_destination, subpath,
                                       os.path.splitext(file)[0] + '.jp2')
		    tiffcopy = os.path.join(_destination,subpath,file)
                    command = _app + ' -i ' + tiff + ' -o ' + jp2 + ' ' \
                        + _options
                    command_post = 'shutil.move(\'' + tiff + '\',\'' + tiffcopy + '\')'
		    if _verbose == True:
			print 'Creating ' + jp2
	            t.add_task(executeConversion,command,command_post,tiff,_destination,_broken,file,jp2)
        t.await_completion()
Пример #5
0
def iterate(_source,_ignore,_patron,_patron_zip,_threads):
    print 'Descend into ' + _source
 
    t = ThreadPool(_threads)

    for (root, dirs, files) in os.walk(_source):
	t.add_task(patron_bundle,_patron,_patron_zip,root)
    t.await_completion()
Пример #6
0
def iterate(_source, _ignore, _patron, _patron_zip, _threads):
    print 'Descend into ' + _source

    t = ThreadPool(_threads)

    for (root, dirs, files) in os.walk(_source):
        t.add_task(patron_bundle, _patron, _patron_zip, root)
    t.await_completion()