(self, params)
| 51 | ) |
| 52 | |
| 53 | def install(self, params): |
| 54 | if 'installer' in params: |
| 55 | self.INSTALLER = params.installer |
| 56 | |
| 57 | process = subprocess.Popen( |
| 58 | [ |
| 59 | 'powershell.exe', |
| 60 | '-Command', |
| 61 | 'Stop-Service', |
| 62 | '-Name', |
| 63 | 'codedeployagent', |
| 64 | ], |
| 65 | stdout=subprocess.PIPE, |
| 66 | stderr=subprocess.PIPE, |
| 67 | ) |
| 68 | (output, error) = process.communicate() |
| 69 | not_found = ( |
| 70 | "Cannot find any service with service name 'codedeployagent'" |
| 71 | ) |
| 72 | if process.returncode != 0 and not_found not in error: |
| 73 | raise RuntimeError( |
| 74 | f'Failed to stop the AWS CodeDeploy Agent:\n{error}' |
| 75 | ) |
| 76 | |
| 77 | response = self.s3.get_object(Bucket=params.bucket, Key=params.key) |
| 78 | with open(self.INSTALLER, 'wb') as f: |
| 79 | f.write(response['Body'].read()) |
| 80 | |
| 81 | subprocess.check_call( |
| 82 | [ |
| 83 | rf'.\{self.INSTALLER}', |
| 84 | '/quiet', |
| 85 | '/l', |
| 86 | r'.\codedeploy-agent-install-log.txt', |
| 87 | ], |
| 88 | shell=True, |
| 89 | ) |
| 90 | subprocess.check_call( |
| 91 | [ |
| 92 | 'powershell.exe', |
| 93 | '-Command', |
| 94 | 'Restart-Service', |
| 95 | '-Name', |
| 96 | 'codedeployagent', |
| 97 | ] |
| 98 | ) |
| 99 | |
| 100 | process = subprocess.Popen( |
| 101 | [ |
| 102 | 'powershell.exe', |
| 103 | '-Command', |
| 104 | 'Get-Service', |
| 105 | '-Name', |
| 106 | 'codedeployagent', |
| 107 | ], |
| 108 | stdout=subprocess.PIPE, |
| 109 | stderr=subprocess.PIPE, |
| 110 | ) |
nothing calls this directly
no test coverage detected