Пример #1
0
def prepare_ftp_and_os_indexes(ftp_con, src, dest):
    if not change_ftp_dir(ftp_con, src):
        return False
    MyGlobals.mkdir_p(dest)
    if MyGlobals.isVerbose:
        print("Created dir: {}".format(dest))
    os.chdir(dest)
    return True
Пример #2
0
def download_ftp_file(ftp_con, file_name, dest_path, create_dirs=False):
    if MyGlobals.isVerbose:
        cur_loc = ftp_get_pwd(ftp_con)
        if cur_loc:
            print('Downloading file: {} to: {}'.format(
                cur_loc + '/' + file_name, dest_path))
        else:
            print('Downloading file: {} to: {}'.format(file_name, dest_path))
    if create_dirs:
        if not MyGlobals.mkdir_p(dest_path):
            return None

    if not change_local_dir(dest_path):
        return False

    download_result = _download_ftp_file(ftp_con, file_name, dest_path)
    if download_result and MyGlobals.isRemoveSrc:
        return ftp_delete_file(ftp_con, file_name)

    return download_result