TNO Intern

Commit cfd54de7 authored by Arjo Segers's avatar Arjo Segers
Browse files

Use 'shutil.move' instead of 'os.rename' for move over filesystem.

parent 77b203db
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
# 2025-02, Arjo Segers
#   Support user defined directory creation mode.
#
# 2025-02, Arjo Segers
#   Use 'shutil.move' instead of 'os.rename' for move over filesystem.
#


########################################################################
@@ -840,9 +843,9 @@ class CSO_DataSpace_Downloader(object):
                            # info ..
                            logging.info(f"{indent}store ...")
                            # create target dir if necessary:
                            cso_file.CheckDir(output_file)
                            cso_file.CheckDir(output_file, dmode=dmode)
                            # move to destination:
                            os.rename(member, output_file)
                            shutil.move(member, output_file)
                            # remove directory tree:
                            shutil.rmtree(os.path.dirname(member))
                            # only one file in package; leave loop over members
@@ -866,9 +869,9 @@ class CSO_DataSpace_Downloader(object):
                        logging.info(f"{indent}product is no zipfile, rename to output file ...")
                        # this is probably the target file already;
                        # create target dir if necessary:
                        cso_file.CheckDir(output_file)
                        cso_file.CheckDir(output_file, dmode=dmode)
                        # rename to destination:
                        os.rename(product_file, output_file)
                        shutil.move(product_file, output_file)
                    else:
                        # quit with error:
                        raise
+5 −1
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@
# 2025-02, Arjo Segers
#   Initial version based on script by Lewis Blake.
#
# 2025-02, Arjo Segers
#   Use 'shutil.move' instead of 'os.rename' for move over filesystem.
#

########################################################################
###
@@ -483,6 +486,7 @@ class CSO_EarthAccess_Download(utopya.UtopyaRc):

        # modules:
        import os
        import shutil
        import datetime
        import earthaccess

@@ -657,7 +661,7 @@ class CSO_EarthAccess_Download(utopya.UtopyaRc):
                    # create directory if needed:
                    cso_file.CheckDir(arch_file, dmode=dmode)
                    # move:
                    os.rename(fname, arch_file)
                    shutil.move(fname, arch_file)
                # endif
            # endfor # filenames

+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@
#   Retry download if failed, with increasing waiting time between attempts.
#   Trap errors on write permissions.
#
# 2025-02, Arjo Segers
#   Use 'shutil.move' instead of 'os.rename' for move over filesystem.
#

########################################################################
###
@@ -389,6 +392,7 @@ class CSO_PAL_Downloader(object):
        # modules:
        import sys
        import os
        import shutil
        import time
        import requests

@@ -425,7 +429,7 @@ class CSO_PAL_Downloader(object):
                # create target dir if necessary:
                cso_file.CheckDir(output_file, dmode=dmode)
                # move to destination:
                os.rename(product_file, output_file)
                shutil.move(product_file, output_file)

                # all ok, leave retry loop:
                break