Merge lp:~mandel/ubuntuone-dev-tools/point_to_pylint into lp:ubuntuone-dev-tools
| Status: | Merged | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Approved by: | dobey on 2010-12-22 | ||||||||
| Approved revision: | 24 | ||||||||
| Merged at revision: | 19 | ||||||||
| Proposed branch: | lp:~mandel/ubuntuone-dev-tools/point_to_pylint | ||||||||
| Merge into: | lp:ubuntuone-dev-tools | ||||||||
| Diff against target: |
102 lines (+76/-4) 1 file modified
bin/u1lint (+76/-4) |
||||||||
| To merge this branch: | bzr merge lp:~mandel/ubuntuone-dev-tools/point_to_pylint | ||||||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| dobey (community) | 2010-12-21 | Approve on 2010-12-22 | |
| Natalia Bidart | Approve on 2010-12-22 | ||
| Roberto Alsina (community) | Approve on 2010-12-22 | ||
|
Review via email:
|
|||
Commit Message
Added a function that will return the full path to pylint in a windows system to fix lp:692923
Description of the Change
Added a function that will return the full path to pylint in a windows system to fix lp:692923
| Manuel de la Peña (mandel) wrote : | # |
> What happens if there is no Python in the registry at all? What happens if
> WindowsError is raised again by the calls within the except clause?
I means that the python installation was not correctly done and therefore that the system cannot be trusted. I agree in some sense to defense programming, but not when the installation of the runtime used is wrong. I do agree that a third try should be added just to raise a more meaningful exception but not for any other reason.
> I think
> you need a couple more try/except clauses. Also, you should combin the 3 final
> calls into one line as "return os.path.join(path, 'Scripts', 'pylint.bat')" I
> think, inside an else: statement, and the other OpenKey/QueryValue calls
> inside a try/except block, where the script fails with a more meaningful error
> when a WindowsError is raised if any of those calls fails with that exception.
> You also need to check that pylint.bat exists and is executable, and exit with
> a meaningful error like "You must have pylint 0.21 or newer installed to use
> u1lint."
>
> Also, you probably need to handle the case when USE_PYFLAKES is specified in
> the environment, instead of relying on pylint.
>
Yes, but that is another branches job and a different bug. This branches just fixes the fact that pylint cannot be found by the subprocess call. Lets keep merge proposals small so that the reviews make more sense. I have filled a diff bug for the pyflakes issue (lp:693080)
> You don't need to assign the result of find_pylint_path() to a variable to
> insert it in the list. Just replacing the current string with the function
> call is enough. The same with platform = sys.platform in the function. You
> don't need to assign another variable to it for use in the if statement.
>
I just prefer this style, I'll assign those variables directly.
> Perhaps renaming the function to find_python_
> for that in the path on Windows would be better. Would make it easy to
> abstract for pyflakes or pylint (or other future scripts).
Pyflakes installation using easy_install does not work on windows directly unless the user sets up his system to do so (http://
> I'd also reverse
> the if logic in the function, so that you do "if sys.platform is 'win32': blah
> blah; else: return script_name" instead. It makes it clearer that the special
> cases are first, and the default is to return the passed in script name.
I prefer to have the default result at the beginning like when dealing with a recursive call. First the default, later the exceptional case. It can be easily reverted so I do not mind.
- 19. By Manuel de la Peña on 2010-12-22
-
Improve the code to work when pyflakes is enabled rather than pylint.Reverted is statements. Added exception when python path is not found.
| Natalia Bidart (nataliabidart) wrote : | # |
When running the tests I'm getting:
Traceback (most recent call last):
File "bin/u1lint", line 216, in <module>
main()
File "bin/u1lint", line 185, in main
pylint_
AttributeError: 'str' object has no attribute 'append'
- 20. By Manuel de la Peña on 2010-12-22
-
Ensure that an array is returned on linux too.
- 21. By Manuel de la Peña on 2010-12-22
-
Ensure that array is returned on linux too.
| Natalia Bidart (nataliabidart) wrote : | # |
Lint notices:
== Python Lint Notices ==
bin/u1lint:
207: [W0511] XXX Testing that W0511 does not cause a failure
42: [F0401, find_python_
47: [E0602, find_python_
53: [E0602, find_python_
58: [E1101, find_python_
- 22. By Manuel de la Peña on 2010-12-22
-
Added comments to disable pylint noise on linux.
- 23. By Manuel de la Peña on 2010-12-22
-
Use new pylint disable and enable.
| dobey (dobey) wrote : | # |
51 + except:
This should probably only catch WindowsError. Other exceptions should not get masked with the InvalidSetupExc
96 + # append the extra args to the start info
97 + pylint_
98 + pylint_
This would be better as pylint_
- 24. By Manuel de la Peña on 2010-12-22
-
Use extend to append a collection to the pylint command. Add WindowsError as the exception to avoid other exceptions to be masked by the InvalidSetupExc
eption.

What happens if there is no Python in the registry at all? What happens if WindowsError is raised again by the calls within the except clause? I think you need a couple more try/except clauses. Also, you should combin the 3 final calls into one line as "return os.path.join(path, 'Scripts', 'pylint.bat')" I think, inside an else: statement, and the other OpenKey/QueryValue calls inside a try/except block, where the script fails with a more meaningful error when a WindowsError is raised if any of those calls fails with that exception. You also need to check that pylint.bat exists and is executable, and exit with a meaningful error like "You must have pylint 0.21 or newer installed to use u1lint."
Also, you probably need to handle the case when USE_PYFLAKES is specified in the environment, instead of relying on pylint.
You don't need to assign the result of find_pylint_path() to a variable to insert it in the list. Just replacing the current string with the function call is enough. The same with platform = sys.platform in the function. You don't need to assign another variable to it for use in the if statement.
Perhaps renaming the function to find_python_ script( script_ name), and checking for that in the path on Windows would be better. Would make it easy to abstract for pyflakes or pylint (or other future scripts). I'd also reverse the if logic in the function, so that you do "if sys.platform is 'win32': blah blah; else: return script_name" instead. It makes it clearer that the special cases are first, and the default is to return the passed in script name.