Merge lp://staging/~codehelp/lava-dispatcher/pep8 into lp://staging/lava-dispatcher

Proposed by Neil Williams
Status: Merged
Approved by: Neil Williams
Approved revision: 677
Merged at revision: 638
Proposed branch: lp://staging/~codehelp/lava-dispatcher/pep8
Merge into: lp://staging/lava-dispatcher
Diff against target: 2308 lines (+351/-313)
43 files modified
doc/conf.py (+10/-9)
doc/examples/plugins/demo-action-plugin/demo_action_plugin/foo.py (+2/-1)
doc/examples/plugins/demo-action-plugin/setup.py (+3/-3)
doc/external_measurement.rst (+1/-1)
lava/dispatcher/commands.py (+3/-2)
lava_dispatcher/actions/__init__.py (+3/-2)
lava_dispatcher/actions/android_install_cts_medias.py (+2/-2)
lava_dispatcher/actions/boot_control.py (+8/-4)
lava_dispatcher/actions/deploy.py (+9/-9)
lava_dispatcher/actions/launch_control.py (+10/-7)
lava_dispatcher/actions/lava_android_test.py (+31/-32)
lava_dispatcher/actions/lava_test_shell.py (+27/-23)
lava_dispatcher/client/base.py (+13/-10)
lava_dispatcher/client/lmc_utils.py (+26/-27)
lava_dispatcher/client/targetdevice.py (+1/-1)
lava_dispatcher/config.py (+7/-1)
lava_dispatcher/context.py (+2/-1)
lava_dispatcher/device/capri.py (+7/-4)
lava_dispatcher/device/fastboot.py (+3/-3)
lava_dispatcher/device/fastmodel.py (+13/-13)
lava_dispatcher/device/ipmi_pxe.py (+17/-22)
lava_dispatcher/device/k3v2.py (+7/-4)
lava_dispatcher/device/master.py (+20/-21)
lava_dispatcher/device/nexus10.py (+5/-2)
lava_dispatcher/device/qemu.py (+3/-3)
lava_dispatcher/device/sdmux.py (+1/-1)
lava_dispatcher/device/target.py (+4/-4)
lava_dispatcher/device/uefi.py (+1/-1)
lava_dispatcher/device/vexpress.py (+5/-4)
lava_dispatcher/downloader.py (+8/-9)
lava_dispatcher/job.py (+23/-23)
lava_dispatcher/lava_test_shell.py (+26/-27)
lava_dispatcher/signals/__init__.py (+0/-2)
lava_dispatcher/signals/duration.py (+2/-2)
lava_dispatcher/signals/shellhooks.py (+8/-2)
lava_dispatcher/tarballcache.py (+6/-6)
lava_dispatcher/test_data.py (+3/-2)
lava_dispatcher/tests/__init__.py (+1/-0)
lava_dispatcher/tests/helper.py (+6/-1)
lava_dispatcher/tests/test_config.py (+5/-5)
lava_dispatcher/tests/test_device_version.py (+8/-6)
lava_dispatcher/utils.py (+6/-6)
setup.py (+5/-5)
To merge this branch: bzr merge lp://staging/~codehelp/lava-dispatcher/pep8
Reviewer Review Type Date Requested Status
Antonio Terceiro Approve
Review via email: mp+175231@code.staging.launchpad.net

This proposal supersedes a proposal from 2013-07-16.

Description of the change

The complete PEP8 set of changes in preparation for the MultiNode merge.

http://cards.linaro.org/browse/LAVA-485

There are a variety of changes here - a lot of whitespace changes and:

0: Fixing mutable default arguments (var=[])
1: Fixing variables which shadow keywords (dir -> from_dir)
2: Fixing docstrings markup (change ''' to """)
3: Fix some equality operators which should be 'is' instead of '=='
4: Some functions fail to resolve due to missing declarations in the base class.

Updated for changes during first review by Antonio.

To post a comment you must log in.
Revision history for this message
Antonio Terceiro (terceiro) wrote : Posted in a previous version of this proposal
Download full text (20.0 KiB)

Thanks for putting this together!

Most of the changes look fine. I have some comments below that need to
be addressed we merge this.

 review needs-fixing

> === modified file 'lava_dispatcher/actions/lava_android_test.py'
> --- lava_dispatcher/actions/lava_android_test.py 2013-04-23 10:33:49 +0000
> +++ lava_dispatcher/actions/lava_android_test.py 2013-07-16 16:30:42 +0000
> @@ -42,13 +42,12 @@
> 'test_name': {'type': 'string'},
> 'option': {'type': 'string', 'optional': True},
> 'timeout': {'type': 'integer', 'optional': True},
> - },
> + },
> 'additionalProperties': False,
> - }
> + }
>
> def test_name(self, test_name, option=None, timeout=-1):
> - return super(cmd_lava_android_test_run, self).test_name() + \
> - ' (%s)' % test_name
> + return super(cmd_lava_android_test_run, self).test_name() + ' (%s)' % test_name
>
> def run(self, test_name, option=None, timeout=-1):
> #Make sure in test image now
> @@ -56,9 +55,9 @@
> with self.client.android_tester_session() as session:
> bundle_name = generate_bundle_file_name(test_name)
> cmds = ["lava-android-test", 'run', test_name,
> - '-s', session.dev_name,
> - '-o', '%s/%s.bundle' % (self.context.host_result_dir,
> - bundle_name)]
> + '-s', session.dev_name,
> + '-o', '%s/%s.bundle' % (self.context.host_result_dir,
> + bundle_name)]
> if option is not None:
> cmds.extend(['-O', option])
> if timeout != -1:
> @@ -72,8 +71,8 @@
> t.join()
> if rc == 124:
> raise TimeoutError(
> - "The test case(%s) on device(%s) times out" % (
> - test_name, session.dev_name))
> + "The test case(%s) on device(%s) times out" % (
> + test_name, session.dev_name))

Please use the opportunity to fix a typo here: s/times/timed/

> elif rc != 0:
> raise OperationFailed(
> "Failed to run test case(%s) on device(%s) with return "
> @@ -86,15 +85,15 @@
> 'type': 'object',
> 'properties': {
> 'commands': {'type': 'array', 'items': {'type': 'string'},
> - 'optional': True},
> + 'optional': True},
> 'command_file': {'type': 'string', 'optional': True},
> 'parser': {'type': 'string', 'optional': True},
> 'timeout': {'type': 'integer', 'optional': True},
> - },
> + },
> 'additionalProperties': False,
> - }
> + }
>
> - def test_name(self, commands=[], command_file=None, parser=None,
> + def test_name(self, commands=None, command_file=None, parser=None,
> timeout=-1):
> if commands:
> return '%s (commands=[%s])' % (
> @@ -102,10 +101,11 @@
> ','....

review: Needs Fixing
Revision history for this message
Neil Williams (codehelp) wrote : Posted in a previous version of this proposal
Download full text (4.9 KiB)

> Thanks for putting this together!
>
> Most of the changes look fine. I have some comments below that need to
> be addressed we merge this.
> review needs-fixing
>
> > === modified file 'lava_dispatcher/actions/lava_android_test.py'
> > raise TimeoutError(
> > - "The test case(%s) on device(%s) times out" % (
> > - test_name,
> session.dev_name))
> > + "The test case(%s) on device(%s) times out" % (
> > + test_name, session.dev_name))
>
> Please use the opportunity to fix a typo here: s/times/timed/

Done.

> > - def run(self, commands=[], command_file=None, parser=None, timeout=-1):
> > + def run(self, commands=None, command_file=None, parser=None,
> timeout=-1):
> > + if not commands:
> > + commands = []
>
> This should is not actually needed, since commands is only used below inside a
> `if commands:`. Maybe it makes clear that commands is expected to be a list,
> though.

If something other than a list is passed, the function will fail with or without the
added check. I think I'll remove the if and add a docstring instead.

> > === modified file 'lava_dispatcher/actions/lava_test_shell.py'
> > - 'testdef': {'type': 'string',
> > - 'optional': True}
> > - },
> > + {'git-repo': {'type': 'string',
> > + 'optional': True},
> > + 'bzr-repo': {'type': 'string',
> > + 'optional': True},
> > + 'revision': {'type': 'string',
> > + 'optional': True},
> > + 'testdef': {'type': 'string',
> > + 'optional': True}
> > + },
>
>
> The indentation of this part does not look right at all.

Fixed. It needed a double indent in each case:

                                        {'git-repo': {'type': 'string',
                                                'optional': True},

> > === modified file 'lava_dispatcher/device/target.py'
> > ubuntu_deployment_data = {
> > 'TESTER_PS1': "linaro-test [rc=$(echo \$?)]# ",
> > 'TESTER_PS1_PATTERN': "linaro-test \[rc=(\d+)\]# ",
> > @@ -86,7 +85,7 @@
> > """
> > raise NotImplementedError('power_on')
> >
> > - def deploy_linaro(self, hwpack, rfs):
> > + def deploy_linaro(self, hwpack, rfs, bootloader):
> > raise NotImplementedError('deploy_image')
> >
> > def deploy_android(self, boot, system, userdata):
> > @@ -130,14 +129,14 @@
> > """ Powers on the target, returning a CommandRunner object and will
> > power off the target when the context is exited
> > """
> > - proc = runner = None
> > + self.proc = runner = None
> > try:
> > - proc = self.power_on()
>...

Read more...

Revision history for this message
Antonio Terceiro (terceiro) wrote :

Looks good to me

 review approve

review: Approve
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Posted in a previous version of this proposal

Antonio Terceiro <email address hidden> writes:

>> @@ -565,7 +571,7 @@
>> session.wait_home_screen()
>> except:
>> # ignore home screen exception if it is a health check job.
>> - if not (self.context.job_data.has_key("health_check") and self.context.job_data["health_check"] == True):
>> + if not ('health_check' in self.context.job_data and self.context.job_data["health_check"] is True):
>
> isn't `x is True` equivalent to `x`? Or do we need to explicitly only accept
> True as a truth value there?

Please please pelase never write a literal on either side of an 'is' test!

Cheers,
mwh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches