|
5 | 5 |
|
6 | 6 |
|
7 | 7 | def issmscpin(host, login, port, path, packages): |
8 | | - """ISSMSCPIN get packages from host, using scp on unix, and pscp on windows |
| 8 | + """issmscpin get packages from host using scp |
9 | 9 |
|
10 | 10 | Usage: |
11 | 11 | issmscpin(host, packages, path) |
| 12 | +
|
| 13 | + NOTE: If users again have issues with file list (i.e. |
| 14 | +
|
| 15 | + {<FILE1>,<FILE2>,...<FILEN>} |
| 16 | +
|
| 17 | + ), note that this a bash'ism and default shell should be checked. View file |
| 18 | + history for potential fix (i.e. some combination of -O and -T options). |
12 | 19 | """ |
13 | 20 |
|
14 | | - #first get hostname |
| 21 | + # First get hostname |
15 | 22 | hostname = oshostname() |
16 | | - #first be sure packages are not in the current directory, this could conflict with pscp on windows. |
17 | | - #remove warnings in case the files do not exist |
18 | | - for package in packages: |
19 | | - try: |
20 | | - os.remove(package) |
21 | | - except OSError as e: |
22 | | - pass |
23 | | - #if hostname and host are the same, do a simple copy |
24 | | - if strcmpi(hostname, host): #hostname == host: |
| 23 | + |
| 24 | + # If hostname and host are the same, do a simple copy |
| 25 | + if strcmpi(hostname, host): |
25 | 26 | for package in packages: |
26 | 27 | try: |
27 | | - shutil.copy(os.path.join(path, package), os.getcwd()) #keep going, even if success = 0 |
| 28 | + shutil.copy(os.path.join(path, package), os.getcwd()) # keep going, even if success == 0 |
28 | 29 | except OSError as e: |
29 | 30 | pass |
30 | 31 | else: |
31 | | - #just use standard unix scp string to copy multiple files using scp |
32 | 32 | filelist = [os.path.join(directory, x) for x in packages] |
33 | 33 | fileliststr = ' '.join([str(x) for x in filelist]) |
34 | 34 | if port: |
35 | | - subprocess.call('scp -OT -P {} {}@localhost:"{}" {}'.format(port, login, fileliststr, os.getcwd()), shell=True) |
| 35 | + subprocess.call('scp -P {} {}@localhost:"{}" {}'.format(port, login, fileliststr, os.getcwd()), shell=True) |
36 | 36 | else: |
37 | | - subprocess.call('scp -OT {}@{}:"{}" {}'.format(login, host, fileliststr, os.getcwd()), shell=True) |
38 | | - #check scp worked |
| 37 | + subprocess.call('scp {}@{}:"{}" {}'.format(login, host, fileliststr, os.getcwd()), shell=True) |
| 38 | + # Check scp worked |
39 | 39 | for package in packages: |
40 | 40 | if not os.path.exists(os.path.join('.', package)): |
41 | | - raise OSError("issmscpin error message: could not call scp on *nix system for file '{}'".format(package)) |
| 41 | + raise OSError('issmscpin error message: could not scp {}'.format(package)) |
0 commit comments