Skip to content

Commit

Permalink
CHG: Cleanup; MATLAB -> Python; documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TidbitSoftware committed Nov 19, 2024
1 parent b73355e commit c8d98c1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
26 changes: 12 additions & 14 deletions src/m/os/issmscpin.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,37 @@ function issmscpin(host, login,port,path, packages)
%
% usage: issmscpin(host,packages,path)
%
% NOTE: If users again have issues with file list (i.e.
%
% {<FILE1>,<FILE2>,...<FILEN>}
%
% ), note that this a bash'ism and default shell should be checked. View file
% history for potential fix (i.e. some combination of -O and -T options).
%

%first get hostname
hostname=oshostname();

%first be sure packages are not in the current directory, this could conflict with pscp on windows.
for i=1:numel(packages),
if exist(packages{i},'file')
delete(packages{i});
end
end

%if hostname and host are the same, do a simple copy
if strcmpi(hostname,host)
for i=1:numel(packages)
system(['cp ' path '/' packages{i} ' .']);
end
else
%just use standard unix scp string to copy multiple files using scp:
if numel(packages)==1,
string=packages{1};
fileliststr=packages{1};
else
string='\{';
fileliststr='\{';
for i=1:numel(packages)-1,
string=[string packages{i} ','];
fileliststr=[fileliststr packages{i} ','];
end
string=[string packages{end} '\}'];
fileliststr=[fileliststr packages{end} '\}'];
end

if port,
eval(['!scp -P ' num2str(port) ' ' login '@localhost:' path '/' string ' ./']);
eval(['!scp -P ' num2str(port) ' ' login '@localhost:' path '/' fileliststr ' ./']);
else
eval(['!scp ' login '@' host ':' path '/' string ' ./']);
eval(['!scp ' login '@' host ':' path '/' fileliststr ' ./']);
end

%check scp worked
Expand Down
34 changes: 17 additions & 17 deletions src/m/os/issmscpin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@


def issmscpin(host, login, port, path, packages):
"""ISSMSCPIN get packages from host, using scp on unix, and pscp on windows
"""issmscpin get packages from host using scp
Usage:
issmscpin(host, packages, path)
NOTE: If users again have issues with file list (i.e.
{<FILE1>,<FILE2>,...<FILEN>}
), note that this a bash'ism and default shell should be checked. View file
history for potential fix (i.e. some combination of -O and -T options).
"""

#first get hostname
# First get hostname
hostname = oshostname()
#first be sure packages are not in the current directory, this could conflict with pscp on windows.
#remove warnings in case the files do not exist
for package in packages:
try:
os.remove(package)
except OSError as e:
pass
#if hostname and host are the same, do a simple copy
if strcmpi(hostname, host): #hostname == host:

# If hostname and host are the same, do a simple copy
if strcmpi(hostname, host):
for package in packages:
try:
shutil.copy(os.path.join(path, package), os.getcwd()) #keep going, even if success = 0
shutil.copy(os.path.join(path, package), os.getcwd()) # keep going, even if success == 0
except OSError as e:
pass
else:
#just use standard unix scp string to copy multiple files using scp
filelist = [os.path.join(directory, x) for x in packages]
fileliststr = ' '.join([str(x) for x in filelist])
if port:
subprocess.call('scp -OT -P {} {}@localhost:"{}" {}'.format(port, login, fileliststr, os.getcwd()), shell=True)
subprocess.call('scp -P {} {}@localhost:"{}" {}'.format(port, login, fileliststr, os.getcwd()), shell=True)
else:
subprocess.call('scp -OT {}@{}:"{}" {}'.format(login, host, fileliststr, os.getcwd()), shell=True)
#check scp worked
subprocess.call('scp {}@{}:"{}" {}'.format(login, host, fileliststr, os.getcwd()), shell=True)
# Check scp worked
for package in packages:
if not os.path.exists(os.path.join('.', package)):
raise OSError("issmscpin error message: could not call scp on *nix system for file '{}'".format(package))
raise OSError('issmscpin error message: could not scp {}'.format(package))
2 changes: 1 addition & 1 deletion src/wrappers/matlab/io/ApiPrintf.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* \file ApiPrintf.c:
* \brief: API specific symbols from libISSMCore that we need to resolve here
* \brief: MATLAB API-specific symbols from libISSMCore that we need to resolve here
*/

#ifdef HAVE_CONFIG_H
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/matlab/io/matlabio.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*\file matlabio.h
*\brief: I/O for ISSM in matlab mode
*\brief: I/O for ISSM when running from MATLAB interface
*/

#ifndef _MATLAB_IO_H_
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/python/io/ApiPrintf.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* \file ApiPrintf.c:
* \brief: pyton api specific symbols which are unresolved from libISSMCore.a
* \brief: Python API-specific symbols which are unresolved from libISSMCore.a
*/

#ifdef HAVE_CONFIG_H
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/python/io/pythonio.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*\file pythonio.h
*\brief: I/O for ISSM in python mode
*\brief: I/O for ISSM when running from Python interface
*/

#ifndef _PYTHON_IO_H_
Expand Down

0 comments on commit c8d98c1

Please sign in to comment.