remove_bad_files(source) source_count = 0 for root, directories, filenames in os.walk(source): for files in filenames: source_count +=1 #works in windows at least if os.path.isfile(manifest): count_in_manifest = manifest_file_count(manifest) if source_count != count_in_manifest: print 'This manifest may be outdated as the number of files in your directory does not match the number of files in the manifest' generate_log(log_name_source, 'EVENT = Existing source manifest check - Failure - The number of files in the source directory is not equal to the number of files in the source manifest ') sys.exit() source_manifest_start_time = time.time() if not os.path.isfile(manifest): try: print 'Generating source manifest' make_manifest(source_parent_dir, relative_path,manifest) generate_log(log_name_source, 'EVENT = Generating source manifest') except OSError: print 'You do not have access to this directory. Perhaps it is read only, or the wrong file system\n' sys.exit() else: generate_log(log_name_source, 'EVENT = Existing source manifest check - Source manifest already exists. Script will exit. ') source_manifest_time = time.time() - source_manifest_start_time print source_manifest_time
if not file_check(source_directory) == 'TIFF': append_csv(csv_report_filename, (source_directory,'EMPTY DIRECTORY - SKIPPED', 'n/a', 'n/a')) continue root_dir = os.path.dirname(os.path.dirname(root)) general_log = root_dir + '/logs/image/%s_image_log.log' % os.path.basename(root_dir) generate_log(general_log, 'Input = %s' % root) remove_bad_files(source_directory) source_parent_dir = os.path.dirname(source_directory) normpath = os.path.normpath(source_directory) relative_path = normpath.split(os.sep)[-1] split_path = os.path.split(os.path.basename(source_directory))[1] start = datetime.datetime.now() source_manifest = root_dir + '/%s_manifest.md5' % relative_path generate_log(general_log, 'Generating source manifest via md5deep and storing as %s' % source_manifest) make_manifest(root_dir, root_dir, source_manifest) info = make_framemd5(source_directory, 'tiff', 'tiff_framemd5') output_dirname = info[0] source_textfile = info[1] fmd5copy = root_dir + '/metadata/image' shutil.copy(source_textfile,fmd5copy ) image_seq_without_container = info[2] output_parent_directory = info[3] tiff_filename = image_seq_without_container + "%06d.tiff" dpx_filename = image_seq_without_container + "%06d.dpx" logfile = output_dirname + '/image/logs/%sdpx_transcode.log' % image_seq_without_container env_dict = set_environment(logfile) generate_log(general_log, 'Starting TIFF to DPX transcode') tiff2dpx = ['ffmpegnometadata','-report','-f','image2','-framerate','24', '-i', tiff_filename ,output_dirname + '/image/dpx_files' '/' + dpx_filename] print tiff2dpx subprocess.call(tiff2dpx,env=env_dict)
for files in filenames: source_count += 1 #works in windows at least if os.path.isfile(manifest): count_in_manifest = manifest_file_count(manifest) if source_count != count_in_manifest: print 'This manifest may be outdated as the number of files in your directory does not match the number of files in the manifest' generate_log( log_name_source, 'EVENT = Existing source manifest check - Failure - The number of files in the source directory is not equal to the number of files in the source manifest ' ) sys.exit() source_manifest_start_time = time.time() if not os.path.isfile(manifest): try: print 'Generating source manifest' make_manifest(source_parent_dir, relative_path, manifest) generate_log(log_name_source, 'EVENT = Generating source manifest') except OSError: print 'You do not have access to this directory. Perhaps it is read only, or the wrong file system\n' sys.exit() else: generate_log( log_name_source, 'EVENT = Existing source manifest check - Source manifest already exists. Script will exit. ' ) source_manifest_time = time.time() - source_manifest_start_time print source_manifest_time