Skip to content

Commit 765a9cc

Browse files
committed
Fixed PEP8 errors missed on previous merge.
1 parent e054ffb commit 765a9cc

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

client/deis.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,7 @@ def providers_create(self, args):
16351635
16361636
Usage: deis providers:create <id> <type> <creds>
16371637
"""
1638+
# TODO: This function has a McCabe of 13. Refactor for simplicity.
16381639
type = args.get('<type>') # @ReservedAssignment
16391640
if type == 'ec2':
16401641
# read creds from envvars
@@ -1731,13 +1732,15 @@ def providers_discover(self, args):
17311732
else:
17321733
print('No Rackspace credentials discovered.')
17331734
if 'DIGITALOCEAN_API_KEY' in os.environ and 'DIGITALOCEAN_CLIENT_ID' in os.environ:
1734-
print("Found Digitalocean credentials: {}".format(os.environ['DIGITALOCEAN_CLIENT_ID']))
1735+
print("Found Digitalocean credentials: {}".format(
1736+
os.environ['DIGITALOCEAN_CLIENT_ID']))
17351737
inp = raw_input('Import these credentials? (y/n) : ')
17361738
if inp.lower().strip('\n') != 'y':
17371739
print('Aborting.')
17381740
else:
1739-
creds = {'client_id': os.environ['DIGITALOCEAN_CLIENT_ID'],
1740-
'api_key': os.environ['DIGITALOCEAN_API_KEY'],
1741+
creds = {
1742+
'client_id': os.environ['DIGITALOCEAN_CLIENT_ID'],
1743+
'api_key': os.environ['DIGITALOCEAN_API_KEY'],
17411744
}
17421745
body = {'creds': json.dumps(creds)}
17431746
sys.stdout.write('Uploading Digitalocean credentials... ')

provider/digitalocean.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'new-york-2': 'New York 2'
1919
}
2020

21+
2122
def seed_flavors():
2223
"""Seed the database with default Flavors for digital ocean"""
2324
flavors = []
@@ -39,7 +40,7 @@ def build_layer(layer):
3940
# create a new SSH key
4041
name = "deis-{formation}-{id}".format(**layer)
4142
# import a new keypair to the Digital Ocean Control Panel
42-
params = { 'name': name, 'ssh_pub_key': layer['ssh_public_key'] }
43+
params = {'name': name, 'ssh_pub_key': layer['ssh_public_key']}
4344
conn.request('/ssh_keys/new/', method='GET', params=params)
4445
# Digital Ocean images only have the root user created by default
4546
l = Layer.objects.get(id=layer['id'])
@@ -90,10 +91,12 @@ def _get_droplet_kwargs(node, conn):
9091
'size_id': _get_id(conn.sizes(), params.get('size', '4GB')),
9192
'image_id': _get_id(conn.images(show_all=False), params.get('image', 'deis-base')),
9293
'region_id': _get_id(conn.regions(), params.get('region', 'San Francisco 1')),
93-
'ssh_key_ids': [str(_get_id(conn.all_ssh_keys(), "deis-{formation}-{layer}".format(**node)))],
94+
'ssh_key_ids': [str(_get_id(conn.all_ssh_keys(),
95+
"deis-{formation}-{layer}".format(**node)))],
9496
'virtio': True
9597
}
9698

99+
97100
def _get_droplet_metadata(droplet):
98101
return {
99102
'id': droplet.id,
@@ -107,17 +110,20 @@ def _get_droplet_metadata(droplet):
107110
'ip_address': droplet.ip_address
108111
}
109112

113+
110114
def _create_digitalocean_connection(creds):
111115
if not creds:
112116
raise EnvironmentError('No credentials provided')
113117
return client.Client(creds['client_id'], creds['api_key'])
114118

119+
115120
def _get_id(lst, name):
116121
for i in lst:
117122
if i.name == name:
118123
return i.id
119124
return None
120125

126+
121127
def _get_name(lst, name):
122128
for i in lst:
123129
if i.name == name:

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
22
max-line-length = 99
33
exclude = */api/migrations/*,*/build/*,*/venv/*,*/virtualenv/*
4-
max-complexity = 12
4+
max-complexity = 14

0 commit comments

Comments
 (0)