MCPcopy Index your code
hub / github.com/aws/aws-cli / Windows

Class Windows

awscli/customizations/codedeploy/systems.py:41–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41class Windows(System):
42 CONFIG_DIR = r'C:\ProgramData\Amazon\CodeDeploy'
43 CONFIG_FILE = 'conf.onpremises.yml'
44 CONFIG_PATH = rf'{CONFIG_DIR}\{CONFIG_FILE}'
45 INSTALLER = 'codedeploy-agent.msi'
46
47 def validate_administrator(self):
48 if not ctypes.windll.shell32.IsUserAnAdmin():
49 raise RuntimeError(
50 'You must run this command as an Administrator.'
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 )

Callers 2

setUpMethod · 0.90
validate_instanceFunction · 0.90

Calls

no outgoing calls

Tested by 1

setUpMethod · 0.72