|
26 | 26 |
|
27 | 27 | classPsUtilProcessProxy:
|
28 | 28 | def__init__(self,ssh,pid):
|
| 29 | +assertisinstance(ssh,RemoteOperations) |
| 30 | +asserttype(pid)==int# noqa: E721 |
29 | 31 | self.ssh=ssh
|
30 | 32 | self.pid=pid
|
31 | 33 |
|
32 | 34 | defkill(self):
|
33 |
| -command="kill {}".format(self.pid) |
34 |
| -self.ssh.exec_command(command) |
| 35 | +assertisinstance(self.ssh,RemoteOperations) |
| 36 | +asserttype(self.pid)==int# noqa: E721 |
| 37 | +command= ["kill",str(self.pid)] |
| 38 | +self.ssh.exec_command(command,encoding=get_default_encoding()) |
35 | 39 |
|
36 | 40 | defcmdline(self):
|
37 |
| -command="ps -p {} -o cmd --no-headers".format(self.pid) |
38 |
| -stdin,stdout,stderr=self.ssh.exec_command(command,verbose=True,encoding=get_default_encoding()) |
39 |
| -cmdline=stdout.strip() |
| 41 | +assertisinstance(self.ssh,RemoteOperations) |
| 42 | +asserttype(self.pid)==int# noqa: E721 |
| 43 | +command= ["ps","-p",str(self.pid),"-o","cmd","--no-headers"] |
| 44 | +output=self.ssh.exec_command(command,encoding=get_default_encoding()) |
| 45 | +asserttype(output)==str# noqa: E721 |
| 46 | +cmdline=output.strip() |
| 47 | +# TODO: This code work wrong if command line contains quoted values. Yes? |
40 | 48 | returncmdline.split()
|
41 | 49 |
|
42 | 50 |
|
|