Skip to content

Commit 24003e6

Browse files
committed
utils: update remote-run for Python 3 compatibility
Make `remote-run` be compatible with python 2 and python 3. The changes are: - replace `viewitems` with `items` - replace `viewvalues` with `values` - replace `viewkeys` with `keys` - replace `haskey` with `in`
1 parent 451fd09 commit 24003e6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

utils/remote-run

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ class CommandRunner(object):
4141
def send(self, local_to_remote_files):
4242
# Prepare the remote directory structure.
4343
# FIXME: This could be folded into the sftp connection below.
44-
dirs_to_make = self._dirnames(local_to_remote_files.viewvalues())
44+
dirs_to_make = self._dirnames(local_to_remote_files.values())
4545
self.run_remote(['/bin/mkdir', '-p'] + dirs_to_make)
4646

4747
# Send the local files.
4848
sftp_commands = ("-put {0} {1}".format(quote(local_file),
4949
quote(remote_file))
5050
for local_file, remote_file
51-
in local_to_remote_files.viewitems())
51+
in local_to_remote_files.items())
5252
self.run_sftp(sftp_commands)
5353

5454
def fetch(self, local_to_remote_files):
5555
# Prepare the local directory structure.
56-
dirs_to_make = self._dirnames(local_to_remote_files.viewkeys())
56+
dirs_to_make = self._dirnames(local_to_remote_files.keys())
5757
mkdir_command = ['/bin/mkdir', '-p'] + dirs_to_make
5858
if self.verbose:
5959
print(' '.join(mkdir_command), file=sys.stderr)
@@ -64,11 +64,11 @@ class CommandRunner(object):
6464
sftp_commands = ("-get {0} {1}".format(quote(remote_file),
6565
quote(local_file))
6666
for local_file, remote_file
67-
in local_to_remote_files.viewitems())
67+
in local_to_remote_files.items())
6868
self.run_sftp(sftp_commands)
6969

7070
def run_remote(self, command, remote_env={}):
71-
env_strings = ['{0}={1}'.format(k,v) for k,v in remote_env.viewitems()]
71+
env_strings = ['{0}={1}'.format(k,v) for k,v in remote_env.items()]
7272
remote_invocation = self.remote_invocation(
7373
['/usr/bin/env'] + env_strings + command)
7474
remote_proc = self.popen(remote_invocation, stdin=subprocess.PIPE,
@@ -213,16 +213,16 @@ def main():
213213
remote_dir = posixpath.join(args.remote_dir, args.remote_input_prefix)
214214
input_files = find_transfers(args.command, args.input_prefix,
215215
remote_dir)
216-
assert not any(upload_files.has_key(f) for f in input_files)
216+
assert not any(f in upload_files for f in input_files)
217217
upload_files.update(input_files)
218218
if args.output_prefix:
219219
assert not args.remote_output_prefix.startswith("..")
220220
remote_dir = posixpath.join(args.remote_dir, args.remote_output_prefix)
221221
test_files = find_transfers(args.command, args.output_prefix,
222222
remote_dir)
223-
assert not any(upload_files.has_key(f) for f in test_files)
223+
assert not any(f in upload_files for f in test_files)
224224
upload_files.update(test_files)
225-
assert not any(download_files.has_key(f) for f in test_files)
225+
assert not any(f in download_files for f in test_files)
226226
download_files.update(test_files)
227227
remote_test_specific_dir = remote_dir
228228

0 commit comments

Comments
 (0)