Skip to content

Commit d891034

Browse files
committed
Bump yapf version 0.7.1 -> 0.14.0
New flake8 versions are no longer compatible with the old yapf version used. 1. Fixed 2 flake8 errors. 2. Fixed few docstring/RST errors. 3. Adjusted scripts/check_style.sh to the new yapf exit codes 4. Rest of the changes were generated by running the new yapf(0.14.0) on rest of the code. Signed-off-by: Nadav Goldin <[email protected]>
1 parent fa588e4 commit d891034

38 files changed

+426
-361
lines changed

README.rst

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ The Lago Project
33
Lago is an add-hoc virtual framework which helps you build virtualized
44
environments on your server or laptop for various use cases.
55

6-
It currently utilizes 'libvirt' for creating VMs, but we are working on adding
7-
more providers such as 'containers'.
6+
For the official docs see: http://lago.readthedocs.io
87

9-
TODO: Add the 'Lago story' and introduction.
10-
11-
For more info on the Lago project, please visit the full documentation
12-
page at http://lago.readthedocs.io
8+
.. todo:: Add the 'Lago story' and introduction.

docs/Debugging_and_Troubleshooting.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ the full command line.
8181
**NOTE**: You can use any other template repo if you specify your own json file
8282
there
8383

84-
**TODO**: document the repo store json file format
84+
.. todo:: document the repo store json file format
8585

8686

8787
Initializing the prefix

docs/Jenkins_Example.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ From within the cloned repository, run the following commands:
4444
lago start
4545

4646
- Installing the vms:
47+
4748
- Jenkins will be installed on the server.
4849
- OpenJDK will be installed on the slaves.
4950

@@ -81,8 +82,6 @@ When you done with the enviroment:
8182
Note:
8283
To turn on the vms, use::
8384

84-
::
85-
8685
lago start
8786

8887
And if you will not have a need for the environment in the future:
@@ -97,4 +96,4 @@ And if you will not have a need for the environment in the future:
9796
If this simple example just got you even more interested, join the major leauge and try out the
9897
oVirt example! oVirt_Example_
9998

100-
.. _oVirt_Example: oVirt_Example.html
99+
.. _oVirt_Example: oVirt_Example.html

docs/Lago_Examples.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Getting started with some Lago Examples!
2-
=======================================
2+
=========================================
33

44
Get Lago up & running in no time using one of the available examples
55

@@ -9,7 +9,7 @@ Available Examples
99
------------------
1010

1111
* Simple Jenkins server + slaves: Jenkins_Example_
12-
* Advanced oVirt example (using nested virtualization): oVirt_Example_
12+
* Advanced oVirt example (using nested virtualization): oVirt_Example_
1313

1414
.. _Jenkins_Example: Jenkins_Example.html
1515
.. _oVirt_Example: oVirt_Example.html

docs/conf.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
os.path.dirname(__file__), '../lago_template_repo'
4141
]
4242
)
43-
subprocess.call(['make', '--directory=..', 'changelog', ])
43+
subprocess.call([
44+
'make',
45+
'--directory=..',
46+
'changelog',
47+
])
4448
shutil.move('../ChangeLog', '_static/ChangeLog.txt')
4549

4650
# Mock all the modules that are included by lago, so autoimport works as
@@ -226,12 +230,13 @@
226230

227231
# Custom sidebar templates, maps document names to template names.
228232
html_sidebars = {
229-
'**': [
230-
'about.html',
231-
'navigation.html',
232-
'relations.html',
233-
'searchbox.html',
234-
],
233+
'**':
234+
[
235+
'about.html',
236+
'navigation.html',
237+
'relations.html',
238+
'searchbox.html',
239+
],
235240
}
236241

237242
# Additional templates that should be rendered to pages, maps page names to
@@ -301,9 +306,7 @@
301306
# (source start file, target name, title,
302307
# author, documentclass [howto, manual, or own class]).
303308
latex_documents = [
304-
(
305-
master_doc, 'Lago.tex', u'Lago Documentation', u'David Caro', 'manual'
306-
)
309+
(master_doc, 'Lago.tex', u'Lago Documentation', u'David Caro', 'manual')
307310
]
308311

309312
# The name of an image file (relative to this directory) to place at the top of

docs/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ environments on your server or laptop for various use cases.
99
It currently utilizes 'libvirt' for creating VMs, but we are working on adding
1010
more providers such as 'containers'.
1111

12-
TODO: Add the 'Lago story' and introduction.
12+
.. todo:: Add the 'Lago story' and introduction.
1313

1414
Getting started
1515
---------------

lago/cmd.py

+64-63
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
import lago.plugins.cli
3434
import lago.templates
3535
from lago.config import config
36-
from lago import (log_utils, workdir as lago_workdir, )
36+
from lago import (
37+
log_utils,
38+
workdir as lago_workdir,
39+
)
3740
from lago.utils import (in_prefix, with_logging)
3841

3942
LOGGER = logging.getLogger('cli')
@@ -130,9 +133,8 @@ def do_init(
130133
if virt_config is None:
131134
virt_config = os.path.abspath('LagoInitFile')
132135

133-
os.environ['LAGO_INITFILE_PATH'] = os.path.dirname(
134-
os.path.abspath(virt_config)
135-
)
136+
os.environ['LAGO_INITFILE_PATH'
137+
] = os.path.dirname(os.path.abspath(virt_config))
136138

137139
if prefix_name == 'current':
138140
prefix_name = 'default'
@@ -339,10 +341,8 @@ def do_shell(prefix, host, args=None, **kwargs):
339341
except KeyError:
340342
LOGGER.error('Unable to find VM %s', host)
341343
LOGGER.info(
342-
'Available VMs:\n\t' + '\n\t'.join(
343-
prefix.virt_env.get_vms().keys(
344-
)
345-
)
344+
'Available VMs:\n\t' +
345+
'\n\t'.join(prefix.virt_env.get_vms().keys())
346346
)
347347
raise
348348

@@ -380,10 +380,8 @@ def do_console(prefix, host, **kwargs):
380380
except KeyError:
381381
LOGGER.error('Unable to find VM %s', host)
382382
LOGGER.info(
383-
'Available VMs:\n\t' + '\n\t'.join(
384-
prefix.virt_env.get_vms().keys(
385-
)
386-
)
383+
'Available VMs:\n\t' +
384+
'\n\t'.join(prefix.virt_env.get_vms().keys())
387385
)
388386
raise
389387

@@ -402,44 +400,51 @@ def do_status(prefix, out_format, **kwargs):
402400
uuid = f.read()
403401

404402
info_dict = {
405-
'Prefix': {
406-
'Base directory': prefix.paths.prefix,
407-
'UUID': uuid,
408-
'Networks': dict(
409-
(
410-
net.name(),
411-
{
412-
'gateway': net.gw(),
413-
'status': net.alive() and 'up' or 'down',
414-
'management': net.is_management(),
415-
}
416-
) for net in prefix.virt_env.get_nets().values()
417-
),
418-
'VMs': dict(
419-
(
420-
vm.name(),
421-
{
422-
'distro': vm.distro(),
423-
'root password': vm.root_password(),
424-
'status': vm.state(),
425-
'snapshots': ', '.join(vm._spec['snapshots'].keys()),
426-
'VNC port': vm.vnc_port() if vm.alive() else None,
427-
'metadata': vm.metadata,
428-
'NICs': dict(
429-
(
430-
'eth%d' % i,
431-
{
432-
'network': nic['net'],
433-
'ip': nic.get('ip', 'N/A'),
434-
}
435-
436-
) for i, nic in enumerate(vm.nics())
437-
),
438-
}
439-
440-
) for vm in prefix.virt_env.get_vms().values()
441-
),
442-
},
403+
'Prefix':
404+
{
405+
'Base directory':
406+
prefix.paths.prefix,
407+
'UUID':
408+
uuid,
409+
'Networks':
410+
dict(
411+
(
412+
net.name(), {
413+
'gateway': net.gw(),
414+
'status': net.alive() and 'up' or 'down',
415+
'management': net.is_management(),
416+
}
417+
) for net in prefix.virt_env.get_nets().values()
418+
),
419+
'VMs':
420+
dict(
421+
(
422+
vm.name(), {
423+
'distro':
424+
vm.distro(),
425+
'root password':
426+
vm.root_password(),
427+
'status':
428+
vm.state(),
429+
'snapshots':
430+
', '.join(vm._spec['snapshots'].keys()),
431+
'VNC port':
432+
vm.vnc_port() if vm.alive() else None,
433+
'metadata':
434+
vm.metadata,
435+
'NICs':
436+
dict(
437+
(
438+
'eth%d' % i, {
439+
'network': nic['net'],
440+
'ip': nic.get('ip', 'N/A'),
441+
}
442+
) for i, nic in enumerate(vm.nics())
443+
),
444+
}
445+
) for vm in prefix.virt_env.get_vms().values()
446+
),
447+
},
443448
}
444449

445450
print out_format.format(info_dict)
@@ -499,10 +504,8 @@ def do_copy_from_vm(prefix, host, remote_path, local_path, **kwargs):
499504
except KeyError:
500505
LOGGER.error('Unable to find VM %s', host)
501506
LOGGER.info(
502-
'Available VMs:\n\t' + '\n\t'.join(
503-
prefix.virt_env.get_vms().keys(
504-
)
505-
)
507+
'Available VMs:\n\t' +
508+
'\n\t'.join(prefix.virt_env.get_vms().keys())
506509
)
507510
raise
508511

@@ -541,10 +544,8 @@ def do_copy_to_vm(prefix, host, remote_path, local_path, **kwargs):
541544
except KeyError:
542545
LOGGER.error('Unable to find VM %s', host)
543546
LOGGER.info(
544-
'Available VMs:\n\t' + '\n\t'.join(
545-
prefix.virt_env.get_vms().keys(
546-
)
547-
)
547+
'Available VMs:\n\t' +
548+
'\n\t'.join(prefix.virt_env.get_vms().keys())
548549
)
549550
raise
550551

@@ -609,10 +610,7 @@ def create_parser(cli_plugins, out_plugins):
609610
help='Log level to use'
610611
)
611612
parser.add_argument(
612-
'--logdepth',
613-
default=3,
614-
type=int,
615-
help='How many task levels to show'
613+
'--logdepth', default=3, type=int, help='How many task levels to show'
616614
)
617615

618616
try:
@@ -774,7 +772,10 @@ def main():
774772
out_plugins = lago.plugins.load_plugins(
775773
lago.plugins.PLUGIN_ENTRY_POINTS['out']
776774
)
777-
parser = create_parser(cli_plugins=cli_plugins, out_plugins=out_plugins, )
775+
parser = create_parser(
776+
cli_plugins=cli_plugins,
777+
out_plugins=out_plugins,
778+
)
778779
args = parser.parse_args()
779780
config.update_args(args)
780781

lago/config.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def _get_configs_path():
4242

4343
paths = []
4444
xdg_paths = [
45-
path for path in base_dirs.load_config_paths(
46-
'lago', 'lago.conf'
47-
)
45+
path for path in base_dirs.load_config_paths('lago', 'lago.conf')
4846
]
4947
paths.extend([path for path in CONFS_PATH if os.path.exists(path)])
5048
paths.extend(reversed(xdg_paths))
@@ -54,10 +52,10 @@ def _get_configs_path():
5452
def get_env_dict(root_section):
5553
"""Read all Lago variables from the environment.
5654
The lookup format is:
57-
LAGO_VARNAME - will land into 'lago' section
58-
LAGO__SECTION1__VARNAME - will land into 'section1' section, notice
59-
the double '__'.
60-
LAGO__LONG_SECTION_NAME__VARNAME - will land into 'long_section_name'
55+
LAGO_VARNAME - will land into 'lago' section
56+
LAGO__SECTION1__VARNAME - will land into 'section1' section, notice
57+
the double '__'.
58+
LAGO__LONG_SECTION_NAME__VARNAME - will land into 'long_section_name'
6159
6260
6361
Returns:
@@ -122,9 +120,9 @@ def __init__(self, root_section='lago'):
122120
def load(self):
123121
"""Load all configuration from INI format files and ENV, always
124122
preferring the last read. Order of loading is:
125-
1) Custom paths as defined in constants.CONFS_PATH
126-
2) XDG standard paths
127-
3) Environment variables
123+
1) Custom paths as defined in constants.CONFS_PATH
124+
2) XDG standard paths
125+
3) Environment variables
128126
129127
Returns:
130128
dict: dict of section configuration dicts
@@ -169,10 +167,8 @@ def update_parser(self, parser):
169167
configp.read_dict(self._config)
170168
configp.read_string(ini_str)
171169
self._config.update(
172-
{
173-
s: dict(configp.items(s))
174-
for s in configp.sections()
175-
}
170+
{s: dict(configp.items(s))
171+
for s in configp.sections()}
176172
)
177173

178174
def get(self, *args):

lago/log_utils.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
import sys
2828
import datetime
2929
import threading
30-
from collections import (OrderedDict, deque, )
30+
from collections import (
31+
OrderedDict,
32+
deque,
33+
)
3134
from functools import wraps
3235

3336
#: Message to be shown when a task is started
@@ -439,7 +442,10 @@ def handle_error(self):
439442
return
440443

441444
# All the parents inherit the failure
442-
self.mark_parent_tasks_as_failed(self.cur_task, flush_logs=True, )
445+
self.mark_parent_tasks_as_failed(
446+
self.cur_task,
447+
flush_logs=True,
448+
)
443449

444450
# Show the start headers for all the parent tasks if they were not
445451
# shown by the depth level limit
@@ -501,9 +507,9 @@ def pretty_emit(self, record, is_header=False, task_level=None):
501507

502508
if is_header:
503509
extra_prefix = (
504-
self.get_task_indicator(task_level - 1) + ' ' + (
505-
'' if self.am_i_main_thread else '[%s] ' % self.cur_thread
506-
) + task + ': '
510+
self.get_task_indicator(task_level - 1) + ' ' +
511+
('' if self.am_i_main_thread else '[%s] ' % self.cur_thread) +
512+
task + ': '
507513
)
508514
record.levelno = logging.INFO
509515
else:

0 commit comments

Comments
 (0)