Skip to content

Commit

Permalink
Added copy_file function
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Moene <victor.moene@northern.tech>
  • Loading branch information
victormlg committed Dec 13, 2024
1 parent e43cd24 commit 09646be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cf_remote/commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from datetime import datetime
import os
import shutil
import sys
import time
from multiprocessing.dummy import Pool
Expand All @@ -23,6 +22,7 @@
cf_remote_packages_dir,
)
from cf_remote.utils import (
copy_file,
mkdir,
save_file,
strip_user,
Expand Down Expand Up @@ -308,11 +308,7 @@ def _iterate_over_packages(tags=None, version=None, edition=None, download=False

filename = os.path.basename(artifact.url)
output_path = os.path.join(output_dir, filename)
tmp_filename = '.{}.tmp'.format(filename)
tmp_output_path = os.path.join(output_dir, tmp_filename)

shutil.copyfile(package_path, tmp_output_path)
os.rename(tmp_output_path, output_path)
copy_file(package_path, output_path)
else:
print(artifact.url)
return 0
Expand Down
11 changes: 11 additions & 0 deletions cf_remote/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil
import sys
import re
import json
Expand Down Expand Up @@ -202,3 +203,13 @@ def whoami():
def print_progress_dot(*args):
print(".", end="")
sys.stdout.flush() # STDOUT is line-buffered

def copy_file(input_path, output_path) :
filename = os.path.basename(input_path)
output_dir = os.path.dirname(output_path)

tmp_filename = '.{}.tmp'.format(filename)
tmp_output_path = os.path.join(output_dir, tmp_filename)

shutil.copyfile(input_path, tmp_output_path)
os.rename(tmp_output_path, output_path)

0 comments on commit 09646be

Please sign in to comment.