import sys
sys.path.append("..")

import os
from proj.tasks import img_reproce


def write_redis(source_path, target_path):
    i = 0
    while i < 3:
        try:
            r = img_reproce.apply_async(args=[source_path, target_path])
            return r
        except:
            i += 1


def main():
    path = '/srv/apps/maskrcnn-benchmark/strangecrop/'
    rs = os.listdir(path)
    for r in rs:
        source_file = path + r
        target_file = source_file.replace('crop', 'cropd')
        write_redis(source_file, target_file)
        print(source_file, target_file)



if __name__ == '__main__':
    main()
