Ejemplo n.º 1
0
def download_file(configs, filename, output_dir):
    file_path = output_dir + "/" + filename
    url = configs[filename]
    checksum = configs[filename + "_md5_checksum"]
    if not os.path.exists(file_path) or \
            bench_utils.file_checksum(file_path) != checksum:
        print("downloading %s..." % filename)
        urllib.urlretrieve(url, file_path)
    if bench_utils.file_checksum(file_path) != checksum:
        print("file %s md5 checksum not match" % filename)
        exit(1)
    return file_path
Ejemplo n.º 2
0
def ssh_push_file(src_file, dst_dir, username, address, silent=False):
    if not os.path.isfile(src_file):
        print("Not file, skip pushing " + src_file)
        return
    src_checksum = bench_utils.file_checksum(src_file)
    dst_file = os.path.join(dst_dir, os.path.basename(src_file))
    stdout_buff = []
    try:
        sh.ssh('%s@%s' % (username, address),
               "md5sum",
               dst_file,
               _out=lambda line: stdout_buff.append(line))
    except sh.ErrorReturnCode_1:
        print("Scp %s to %s" % (src_file, dst_dir))
        sh.ssh('%s@%s' % (username, address), "mkdir -p %s" % dst_dir)
        sh.scp(src_file, '%s@%s:%s' % (username, address, dst_dir))
    else:
        dst_checksum = stdout_buff[0].split()[0]
        if src_checksum == dst_checksum:
            if not silent:
                print("Equal checksum with %s and %s" % (src_file, dst_file))
        else:
            if not silent:
                print("Scp %s to %s" % (src_file, dst_dir))
            sh.scp(src_file, '%s@%s:%s' % (username, address, dst_dir))
Ejemplo n.º 3
0
def adb_push_file(src_file, dst_dir, serialno, silent=False):
    if not os.path.isfile(src_file):
        print("Not file, skip pushing " + src_file)
        return
    src_checksum = bench_utils.file_checksum(src_file)
    dst_file = os.path.join(dst_dir, os.path.basename(src_file))
    stdout_buff = []
    try:
        sh.adb("-s",
               serialno,
               "shell",
               "md5sum",
               dst_file,
               _out=lambda line: stdout_buff.append(line))
    except sh.ErrorReturnCode_1:
        print("Push %s to %s" % (src_file, dst_dir))
        sh.adb("-s", serialno, "push", src_file, dst_dir)
    else:
        dst_checksum = stdout_buff[0].split()[0]
        if src_checksum == dst_checksum:
            if not silent:
                print("Equal checksum with %s and %s" % (src_file, dst_file))
        else:
            if not silent:
                print("Push %s to %s" % (src_file, dst_dir))
            sh.adb("-s", serialno, "push", src_file, dst_dir)
Ejemplo n.º 4
0
def get_model_file(file_path, checksum, output_dir, push_list):
    filename = file_path.split('/')[-1]
    if file_path.startswith("http"):
        local_file_path = output_dir + '/' + filename
        if not os.path.exists(local_file_path) \
                or bench_utils.file_checksum(local_file_path) != checksum:
            print("downloading %s..." % filename)
            urllib.urlretrieve(file_path, local_file_path)
        aibench_check(
            bench_utils.file_checksum(local_file_path) == checksum,
            "file %s md5 checksum not match" % filename)
    else:
        local_file_path = file_path
        aibench_check(
            bench_utils.file_checksum(local_file_path) == checksum,
            "file %s md5 checksum not match" % filename)

    push_list.append(local_file_path)