Skip to content

Commit

Permalink
Push up sys.exit to bin/aws
Browse files Browse the repository at this point in the history
The clidriver class now only returns RCs, and
bin/aws actually calls sys.exit.
  • Loading branch information
jamesls committed Apr 10, 2013
1 parent 99fc84f commit c7e1347
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def create_service_parser(self, remaining):
args, remaining = parser.parse_known_args(remaining)
if args.operation == 'help':
get_service_help(self.service)
sys.exit(0)
return 0
self.operation = self.service.get_operation(args.operation)
return self.create_operation_parser(remaining)

Expand Down Expand Up @@ -182,12 +182,12 @@ def create_operation_parser(self, remaining):
required=param.required)
if 'help' in remaining:
get_operation_help(self.operation)
sys.exit(0)
return 0
args, remaining = parser.parse_known_args(remaining)
if remaining:
print('Something is wrong. We have leftover options')
print(remaining)
sys.exit(-1)
return -1
return args

def unpack_cli_arg(self, param, s):
Expand Down Expand Up @@ -264,7 +264,7 @@ def display_error_and_exit(self, ex):
print(ex)
elif self.args.output != 'json':
print(ex)
sys.exit(1)
return 1

def get_error_code_and_message(self, response):
code = 'Unknown'
Expand Down Expand Up @@ -293,15 +293,15 @@ def call(self, args):
code, message = self.get_error_code_and_message(response_data)
print(msg.format(error_code=code,
error_message=message))
sys.exit(http_response.status_code - 399)
return http_response.status_code - 399
if http_response.status_code >= 400:
msg = self.session.get_data('messages/ClientError')
code, message = self.get_error_code_and_message(response_data)
print(msg.format(error_code=code,
error_message=message))
sys.exit(http_response.status_code - 399)
return http_response.status_code - 399
except Exception as ex:
self.display_error_and_exit(ex)
return self.display_error_and_exit(ex)

def _display_response(self, operation, response_data):
try:
Expand Down Expand Up @@ -342,7 +342,7 @@ def main(self):
if self.args.service_name == 'help':
provider = self.session.get_variable('provider')
get_provider_help(provider=provider)
sys.exit(0)
return 0
else:
if self.args.debug:
from six.moves import http_client
Expand All @@ -354,4 +354,4 @@ def main(self):
self.formatter = get_formatter(output, self.args)
self.service = self.session.get_service(self.args.service_name)
args = self.create_service_parser(remaining)
self.call(args)
return self.call(args)
6 changes: 3 additions & 3 deletions bin/aws
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

import sys
import awscli.clidriver


def main():
driver = awscli.clidriver.CLIDriver()
driver.main()
return driver.main()


if __name__ == '__main__':
main()
sys.exit(main())

0 comments on commit c7e1347

Please sign in to comment.