diff --git a/embedded_server/embedded_server.py b/embedded_server/embedded_server.py index 18e582f8..3cab2667 100644 --- a/embedded_server/embedded_server.py +++ b/embedded_server/embedded_server.py @@ -182,7 +182,7 @@ def check_channel_exec_request(self, channel, cmd, def check_channel_env_request(self, channel, name, value): if not hasattr(channel, 'environment'): channel.environment = {} - channel.environment.update({name: value}) + channel.environment.update({name.decode('utf8'): value.decode('utf8')}) return True def _read_response(self, channel, process): diff --git a/pssh/pssh_client.py b/pssh/pssh_client.py index 362ab131..d580cf2f 100644 --- a/pssh/pssh_client.py +++ b/pssh/pssh_client.py @@ -663,7 +663,7 @@ def _exec_command(self, host, command, sudo=False, user=None, shell=None, use_shell=True, use_pty=True, environment=None): """Make SSHClient, run command on host""" - if not host in self.host_clients or not self.host_clients[host]: + if host not in self.host_clients or self.host_clients[host] is None: _user, _port, _password, _pkey = self._get_host_config_values(host) _user = user if user else _user self.host_clients[host] = SSHClient(host, user=_user, diff --git a/setup.py b/setup.py index b1569716..20ad31d7 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Software Development :: Libraries :: Python Modules', 'Operating System :: POSIX :: Linux', 'Operating System :: POSIX :: BSD', diff --git a/tests/test_pssh_client.py b/tests/test_pssh_client.py index 978f3888..2f9c4d86 100644 --- a/tests/test_pssh_client.py +++ b/tests/test_pssh_client.py @@ -217,7 +217,7 @@ def test_pssh_client_ssh_exception(self): self.assertRaises(SSHException, client.run_command, self.fake_cmd) del client server.kill() - + def test_pssh_client_timeout(self): server_timeout=0.2 client_timeout=server_timeout-0.1 @@ -269,7 +269,7 @@ def test_pssh_client_long_running_command_exit_codes(self): self.assertTrue(output[self.host]['exit_code'] == 0, msg="Got non-zero exit code %s" % ( output[self.host]['exit_code'],)) - + def test_pssh_client_retries(self): """Test connection error retries""" listen_port = self.make_random_port() @@ -287,7 +287,7 @@ def test_pssh_client_retries(self): "expected %s" % (num_tries, expected_num_tries,)) else: raise Exception('No ConnectionErrorException') - + def test_sftp_exceptions(self): # Port with no server listening on it on separate ip host = '127.0.0.3' @@ -297,7 +297,7 @@ def test_sftp_exceptions(self): client.pool.join() for cmd in cmds: self.assertRaises(ConnectionErrorException, cmd.get) - + def test_pssh_copy_file(self): """Test parallel copy file""" test_file_data = 'test' @@ -319,7 +319,7 @@ def test_pssh_copy_file(self): os.unlink(filepath) shutil.rmtree(remote_test_dir) del client - + def test_pssh_client_directory(self): """Tests copying multiple directories with SSH client. Copy all the files from local directory to server, then make sure they are all present.""" @@ -405,7 +405,7 @@ def test_pssh_client_copy_file_failure(self): os.chmod(remote_test_path, mask) for path in [local_test_path, remote_test_path]: shutil.rmtree(path) - + def test_pssh_copy_remote_file(self): """Test parallel copy file to local host""" test_file_data = 'test' @@ -737,7 +737,7 @@ def test_ssh_exception(self): else: raise Exception("Expected SSHException") server.kill() - + def test_multiple_single_quotes_in_cmd(self): """Test that we can run a command with multiple single quotes""" output = self.client.run_command("echo 'me' 'and me'") @@ -751,7 +751,7 @@ def test_multiple_single_quotes_in_cmd(self): self.assertEqual(expected, stdout[0], msg="Got unexpected output. Expected %s, got %s" % ( expected, stdout[0],)) - + def test_backtics_in_cmd(self): """Test running command with backtics in it""" output = self.client.run_command("out=`ls` && echo $out") @@ -759,7 +759,7 @@ def test_backtics_in_cmd(self): self.assertTrue(output[self.host]['exit_code'] == 0, msg="Error executing cmd with backtics - error code %s" % ( output[self.host]['exit_code'],)) - + def test_multiple_shell_commands(self): """Test running multiple shell commands in one go""" output = self.client.run_command("echo me; echo and; echo me") @@ -771,7 +771,7 @@ def test_multiple_shell_commands(self): self.assertEqual(expected, stdout, msg="Got unexpected output. Expected %s, got %s" % ( expected, stdout,)) - + def test_escaped_quotes(self): """Test escaped quotes in shell variable are handled correctly""" output = self.client.run_command('t="--flags=\\"this\\""; echo $t')