<s> from __future__ import print_function <EOL> import os <EOL> import six <EOL> import pyrax <EOL> pyrax . set_setting ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> creds_file = os . path . expanduser ( "<STR_LIT>" ) <EOL> pyrax . set_credential_file ( creds_file ) <EOL> au = pyrax . autoscale <EOL> def safe_int ( val , allow_zero = True ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> ret = int ( val ) <EOL> except ValueError : <EOL> print ( "<STR_LIT>" % val ) <EOL> return False <EOL> if not allow_zero and ret == <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> return False <EOL> return ret <EOL> sgs = au . list ( ) <EOL> if not sgs : <EOL> print ( "<STR_LIT>" ) <EOL> exit ( ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> for pos , sg in enumerate ( sgs ) : <EOL> print ( "<STR_LIT>" % ( pos , sg . name ) ) <EOL> intanswer = - <NUM_LIT:1> <EOL> while intanswer < <NUM_LIT:0> : <EOL> answer = six . moves . input ( "<STR_LIT>" ) <EOL> if not answer : <EOL> print ( "<STR_LIT>" ) <EOL> exit ( ) <EOL> intanswer = safe_int ( answer ) <EOL> if intanswer is False : <EOL> intanswer = - <NUM_LIT:1> <EOL> continue <EOL> if not <NUM_LIT:0> <= intanswer < len ( sgs ) : <EOL> print ( "<STR_LIT>" % answer ) <EOL> intanswer = - <NUM_LIT:1> <EOL> policies = sg . list_policies ( ) <EOL> if not policies : <EOL> print ( "<STR_LIT>" ) <EOL> exit ( ) <EOL> for pos , policy in enumerate ( policies ) : <EOL> print ( "<STR_LIT>" % ( pos , policy . name ) ) <EOL> answer = six . moves . input ( "<STR_LIT>" ) <EOL> if not answer : <EOL> print ( "<STR_LIT>" ) <EOL> exit ( ) <EOL> intanswer = safe_int ( answer ) <EOL> if not <NUM_LIT:0> <= intanswer < len ( policies ) : <EOL> print ( "<STR_LIT>" % answer ) <EOL> exit ( ) <EOL> policy = policies [ intanswer ] <EOL> policy . delete ( ) <EOL> print ( "<STR_LIT>" % policy . name ) </s>
