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():
    rs = os.walk('../fashionbase/images/dataset_0520/weiyi')
    for a, b, files in rs:
        for file in files:
            dir = source_path.replace('dataset_0520', 'dataset_0520_10000')
            fold = os.exit(dir)
            if not fold:
                os.mkdir(dir)
            source_path = '../fashionbase/images/dataset_0520/weiyi/' + file
            target_path = source_path.replace('dataset_0520', 'dataset_0520_10000')
            print(source_path)
            print(target_path)
            #write_redis(source_path, target_path)


if __name__ == '__main__':
    main()
