Exemple #1
0
                               filetype=types[options.test_type]['file_type'])

configs = open(config_name).read()

search = re.search(
    '{0}.*?(\d+.\d+.\d+)'.format(types[options.test_type]['name']), configs)
if not search:
    print("Error: Can not find version!")
    exit(1)
version = search.group(1)
print(types[options.test_type]['name'], version)
cmd1 = "cd {}".format(tool)
directory = "{0}{1}result{1}{2}-{3}-{4}-{5}".format(tool, os.sep,
                                                    options.test_type, now,
                                                    options.data_type, version)
data_common.check_directory(directory)
shutil.copyfile(
    file_name, "{}{}{}".format(directory, os.sep, os.path.basename(file_name)))
shutil.copyfile(
    label_name, "{}{}{}".format(directory, os.sep,
                                os.path.basename(label_name)))
shutil.copyfile(
    config_name, "{}{}{}".format(directory, os.sep,
                                 os.path.basename(config_name)))

cmd = "{} && {}".format(cmd1, types[options.test_type]['cmd'])
print(cmd)
subprocess.call(cmd, shell=True)

time.sleep(5)
Exemple #2
0
description = '''

功能:旋转图片

示例: $ python3 rotate.py /home/andrew/code/tmp_photos2 /home/andrew/code/tmp_photos3 -a 270
'''

parser = argparse.ArgumentParser(description=description,
                                 formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('src', action="store", help=u'源目录')
parser.add_argument('dst', action="store", help=u'目的目录')
parser.add_argument('-t',
                    action="store",
                    dest="type",
                    default="jpg",
                    help=u'文件扩展名, 默认为jpg')
parser.add_argument('-a',
                    action="store",
                    dest="angle",
                    default=90,
                    type=int,
                    help=u'旋转角度,默认为90度,方向都为逆时针。')
parser.add_argument('--version',
                    action='version',
                    version='%(prog)s 1.0 Rongzhong xu 2018 04 26')
options = parser.parse_args()

data_common.check_directory(options.dst)
files = data_common.find_files_by_type(options.src, filetype=options.type)
photos.rotate(files, options.dst, options.angle)