mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 15:34:01 -07:00
test/: PEP8 compliancy (#24803)
* test/: PEP8 compliancy - Make PEP8 compliant * Python3 chokes on casting int to bytes (#24952) But if we tell the formatter that the var is a number, it works
This commit is contained in:
parent
31c59ad5f9
commit
4efec414e7
110 changed files with 1702 additions and 1547 deletions
|
@ -55,19 +55,19 @@ def prompt_and_delete(item, prompt, assumeyes):
|
|||
if not assumeyes:
|
||||
assumeyes = raw_input(prompt).lower() == 'y'
|
||||
assert hasattr(item, 'delete') or hasattr(item, 'terminate'), \
|
||||
"Class <%s> has no delete or terminate attribute" % item.__class__
|
||||
"Class <%s> has no delete or terminate attribute" % item.__class__
|
||||
if assumeyes:
|
||||
if hasattr(item, 'delete'):
|
||||
item.delete()
|
||||
print ("Deleted %s" % item)
|
||||
print("Deleted %s" % item)
|
||||
if hasattr(item, 'terminate'):
|
||||
item.terminate()
|
||||
print ("Terminated %s" % item)
|
||||
print("Terminated %s" % item)
|
||||
|
||||
|
||||
def delete_rax(args):
|
||||
"""Function for deleting CloudServers"""
|
||||
print ("--- Cleaning CloudServers matching '%s'" % args.match_re)
|
||||
print("--- Cleaning CloudServers matching '%s'" % args.match_re)
|
||||
search_opts = dict(name='^%s' % args.match_re)
|
||||
for region in pyrax.identity.services.compute.regions:
|
||||
cs = pyrax.connect_to_cloudservers(region=region)
|
||||
|
@ -80,7 +80,7 @@ def delete_rax(args):
|
|||
|
||||
def delete_rax_clb(args):
|
||||
"""Function for deleting Cloud Load Balancers"""
|
||||
print ("--- Cleaning Cloud Load Balancers matching '%s'" % args.match_re)
|
||||
print("--- Cleaning Cloud Load Balancers matching '%s'" % args.match_re)
|
||||
for region in pyrax.identity.services.load_balancer.regions:
|
||||
clb = pyrax.connect_to_cloud_loadbalancers(region=region)
|
||||
for lb in rax_list_iterator(clb):
|
||||
|
@ -92,7 +92,7 @@ def delete_rax_clb(args):
|
|||
|
||||
def delete_rax_keypair(args):
|
||||
"""Function for deleting Rackspace Key pairs"""
|
||||
print ("--- Cleaning Key Pairs matching '%s'" % args.match_re)
|
||||
print("--- Cleaning Key Pairs matching '%s'" % args.match_re)
|
||||
for region in pyrax.identity.services.compute.regions:
|
||||
cs = pyrax.connect_to_cloudservers(region=region)
|
||||
for keypair in cs.keypairs.list():
|
||||
|
@ -104,7 +104,7 @@ def delete_rax_keypair(args):
|
|||
|
||||
def delete_rax_network(args):
|
||||
"""Function for deleting Cloud Networks"""
|
||||
print ("--- Cleaning Cloud Networks matching '%s'" % args.match_re)
|
||||
print("--- Cleaning Cloud Networks matching '%s'" % args.match_re)
|
||||
for region in pyrax.identity.services.network.regions:
|
||||
cnw = pyrax.connect_to_cloud_networks(region=region)
|
||||
for network in cnw.list():
|
||||
|
@ -116,7 +116,7 @@ def delete_rax_network(args):
|
|||
|
||||
def delete_rax_cbs(args):
|
||||
"""Function for deleting Cloud Networks"""
|
||||
print ("--- Cleaning Cloud Block Storage matching '%s'" % args.match_re)
|
||||
print("--- Cleaning Cloud Block Storage matching '%s'" % args.match_re)
|
||||
for region in pyrax.identity.services.network.regions:
|
||||
cbs = pyrax.connect_to_cloud_blockstorage(region=region)
|
||||
for volume in cbs.list():
|
||||
|
@ -128,7 +128,7 @@ def delete_rax_cbs(args):
|
|||
|
||||
def delete_rax_cdb(args):
|
||||
"""Function for deleting Cloud Databases"""
|
||||
print ("--- Cleaning Cloud Databases matching '%s'" % args.match_re)
|
||||
print("--- Cleaning Cloud Databases matching '%s'" % args.match_re)
|
||||
for region in pyrax.identity.services.database.regions:
|
||||
cdb = pyrax.connect_to_cloud_databases(region=region)
|
||||
for db in rax_list_iterator(cdb):
|
||||
|
@ -146,7 +146,7 @@ def _force_delete_rax_scaling_group(manager):
|
|||
|
||||
def delete_rax_scaling_group(args):
|
||||
"""Function for deleting Autoscale Groups"""
|
||||
print ("--- Cleaning Autoscale Groups matching '%s'" % args.match_re)
|
||||
print("--- Cleaning Autoscale Groups matching '%s'" % args.match_re)
|
||||
for region in pyrax.identity.services.autoscale.regions:
|
||||
asg = pyrax.connect_to_autoscale(region=region)
|
||||
for group in rax_list_iterator(asg):
|
||||
|
@ -170,11 +170,11 @@ def main():
|
|||
try:
|
||||
func(args)
|
||||
except Exception as e:
|
||||
print ("---- %s failed (%s)" % (func.__name__, e.message))
|
||||
print("---- %s failed (%s)" % (func.__name__, e.message))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
print ('\nExiting...')
|
||||
print('\nExiting...')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue