Skip to content

Commit f69b0da

Browse files
tombhmboersma
authored andcommitted
Fixed Flake8 errors
1 parent 34c70c8 commit f69b0da

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

client/deis.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,25 +1757,30 @@ def providers_discover(self, args):
17571757
# Check for locally booted Deis Controller VM
17581758
try:
17591759
running_vms = subprocess.check_output(
1760-
['vboxmanage', 'list', 'runningvms'],
1761-
stderr=subprocess.PIPE)
1760+
['vboxmanage', 'list', 'runningvms'],
1761+
stderr=subprocess.PIPE
1762+
)
17621763
except subprocess.CalledProcessError:
17631764
running_vms = ""
1764-
# Vagrant internally names a running VM using the folder name in which the Vagrantfile resides, eg;
1765-
# my-deis-code-folder_default_1383326629
1765+
# Vagrant internally names a running VM using the folder name in which the Vagrantfile
1766+
# resides, eg; my-deis-code-folder_default_1383326629
17661767
deis_codebase_folder = self._session.git_root().split('/')[-1]
17671768
if deis_codebase_folder in running_vms:
17681769
print("Detected locally running Deis Controller VM")
1769-
# In order for the Controller to be able to boot Vagrant VMs it needs to run commands on the host machine.
1770-
# It does this via an SSH server. In order to access that server we need to send the current user's name
1771-
# and IP address.
1770+
# In order for the Controller to be able to boot Vagrant VMs it needs to run commands
1771+
# on the host machine. It does this via an SSH server. In order to access that server
1772+
# we need to send the current user's name and IP address.
17721773
try:
17731774
user = subprocess.check_output(
17741775
"whoami",
17751776
stderr=subprocess.PIPE
17761777
).strip()
17771778
ip = subprocess.check_output(
1778-
"/sbin/ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n1",
1779+
"/sbin/ifconfig | \
1780+
grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | \
1781+
grep -Eo '([0-9]*\.){3}[0-9]*' | \
1782+
grep -v '127.0.0.1' | \
1783+
head -n1",
17791784
stderr=subprocess.PIPE,
17801785
shell=True
17811786
).strip()
@@ -1798,7 +1803,6 @@ def providers_discover(self, args):
17981803
else:
17991804
print("No Vagrant VMs detected")
18001805

1801-
18021806
def providers_info(self, args):
18031807
"""
18041808
Print information about a specific provider

provider/vagrant.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,31 +72,31 @@ def build_node(node):
7272
node['params'].setdefault('memory', '512')
7373
template = open('/opt/deis/controller/contrib/vagrant/nodes_vagrantfile_template.rb')
7474
raw = string.Template(template.read())
75-
result = raw.substitute({ 'id':uid, 'memory':node['params']['memory'] })
75+
result = raw.substitute({'id': uid, 'memory': node['params']['memory']})
7676

7777
# Make a folder for the VM with its own Vagrantfile. Vagrant will then create a .vagrant folder
7878
# there too when it first gets booted.
7979
node_dir = HOST_NODES_DIR + '/' + uid
8080
mkdir = 'mkdir ' + node_dir
8181
cp_tpl = 'echo "' + result.replace('"', '\\"') + '" > ' + node_dir + '/Vagrantfile'
82-
_host_ssh(commands = [mkdir, cp_tpl], creds = node['creds'])
82+
_host_ssh(commands=[mkdir, cp_tpl], creds=node['creds'])
8383

8484
# Boot the VM
85-
_run_vagrant_command(uid, args = ['up'], creds = node['creds'])
85+
_run_vagrant_command(uid, args=['up'], creds=node['creds'])
8686

8787
# Copy the layer's public SSH key to the VM so that the Controller can access it.
8888
_run_vagrant_command(
8989
uid,
90-
args = [
90+
args=[
9191
'ssh',
9292
'-c',
9393
'"echo \\"' + node['ssh_public_key'] + '\\" >> /home/vagrant/.ssh/authorized_keys"'
9494
],
95-
creds = node['creds'],
95+
creds=node['creds'],
9696
)
9797

9898
provider_id = uid
99-
fqdn = provider_id + '.local' # hostname is broadcast via avahi-daemon
99+
fqdn = provider_id + '.local' # hostname is broadcast via avahi-daemon
100100
metadata = {
101101
'id': uid,
102102
'fqdn': fqdn,
@@ -114,11 +114,11 @@ def destroy_node(node):
114114

115115
# This is useful if node creation failed. So that there's a record in the DB, but it has no
116116
# ID associated with it.
117-
if node['provider_id'] == None:
117+
if node['provider_id'] is None:
118118
return
119119

120120
# Shut the VM down and destroy it
121-
_run_vagrant_command(node['provider_id'], args = ['destroy', '--force'], creds = node['creds'])
121+
_run_vagrant_command(node['provider_id'], args=['destroy', '--force'], creds=node['creds'])
122122
node_dir = HOST_NODES_DIR + '/' + node['provider_id']
123123

124124
# Sanity check before `rm -rf`
@@ -128,21 +128,21 @@ def destroy_node(node):
128128
# Completely remove the folder that contained the VM
129129
rm_vagrantfile = 'rm ' + node_dir + '/Vagrantfile'
130130
rm_node_dir = 'rm -rf ' + node_dir
131-
_host_ssh(commands = [rm_vagrantfile, rm_node_dir], creds = node['creds'])
131+
_host_ssh(commands=[rm_vagrantfile, rm_node_dir], creds=node['creds'])
132132

133133

134-
def _run_vagrant_command(node_id, args = [], creds = {}):
134+
def _run_vagrant_command(node_id, args=[], creds={}):
135135
"""
136136
args: A tuple of arguments to a vagrant command line.
137137
e.g. ['up', 'my_vm_name', '--no-provision']
138138
"""
139139

140140
cd = 'cd ' + HOST_NODES_DIR + '/' + node_id
141141
command = ['vagrant'] + [arg for arg in args if arg is not None]
142-
return _host_ssh(commands = [cd, ' '.join(command)], creds = creds)
142+
return _host_ssh(commands=[cd, ' '.join(command)], creds=creds)
143143

144144

145-
def _host_ssh(creds = {}, commands = []):
145+
def _host_ssh(creds={}, commands=[]):
146146
"""
147147
Connect to the host machine. Namely the user's local machine.
148148
"""

0 commit comments

Comments
 (0)