Skip to content

Commit 0d72603

Browse files
committed
hotfix for macos 15.4 , rsync -> openrsync
1 parent 48d5ec3 commit 0d72603

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

validphys2/src/validphys/uploadutils.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Uploader:
6060

6161
upload_host = _profile_key('upload_host')
6262
_profile = Loader().nnprofile
63+
_macos_compatibility = False
6364

6465
def get_relative_path(self, output_path):
6566
"""Return the relative path to the ``target_dir``."""
@@ -100,24 +101,36 @@ def check_rsync(self):
100101
"""Check that the rsync command exists"""
101102
if not shutil.which('rsync'):
102103
raise BadSSH("Could not find the rsync command. Please make sure it is installed.")
104+
if shutil.which("sw_vers") and not self._macos_compatibility:
105+
# In Mac 15.4 Sequoia rsync was swapped by openrsync and permissions work differently
106+
# we need to swap permissions in the output file manually
107+
cmd = ("sw_vers", "--productVersion")
108+
macV = subprocess.run(cmd, capture_output=True, text=True).stdout.strip()
109+
if macV >= "15.4":
110+
self._macos_compatibility = True
103111

104112
def upload_output(self, output_path):
105113
"""Rsync ``output_path`` to the server and print the resulting URL. If
106114
specific_file is given"""
115+
pout = pathlib.Path(output_path)
107116
# Set the date to now
108-
pathlib.Path(output_path).touch()
117+
pout.touch()
118+
if self._macos_compatibility:
119+
# Set the permission of the upload folder/file to ug+rwx,o+rx
120+
pout.chmod(0o775)
121+
109122
randname = self.get_relative_path(output_path)
110123
newdir = self.target_dir + randname
111124

112125
rsync_command = (
113126
'rsync',
114127
'-aLz',
115128
'--chmod=ug=rwx,o=rx',
116-
f"{output_path}/",
129+
f"{pout.as_posix()}/",
117130
f"{self.upload_host}:{newdir}",
118131
)
119132

120-
log.info(f"Uploading output ({output_path}) to {self.upload_host}")
133+
log.info(f"Uploading output ({pout}) to {self.upload_host}")
121134
try:
122135
subprocess.run(rsync_command, check=True)
123136
except subprocess.CalledProcessError as e:
@@ -132,8 +145,8 @@ def _print_output(self, name):
132145
def check_upload(self):
133146
"""Check that it looks possible to upload something.
134147
Raise an UploadError if not."""
135-
self.check_rsync()
136148
self.check_auth()
149+
self.check_rsync()
137150

138151
@contextlib.contextmanager
139152
def upload_context(self, output):

0 commit comments

Comments
 (0)