Merge lp:~jml/launchpad/generate-ppa-logging into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | j.c.sackett on 2012-05-31 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15370 |
| Proposed branch: | lp:~jml/launchpad/generate-ppa-logging |
| Merge into: | lp:launchpad |
| Diff against target: |
921 lines (+236/-202) 13 files modified
database/schema/upgrade.py (+3/-7) lib/lp/app/browser/tales.py (+3/-9) lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py (+90/-52) lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py (+79/-129) lib/lp/bugs/doc/sourceforge-remote-products.txt (+1/-0) lib/lp/registry/doc/teammembership.txt (+1/-0) lib/lp/services/looptuner.py (+0/-4) lib/lp/services/osutils.py (+6/-0) lib/lp/services/scripts/base.py (+11/-0) lib/lp/services/tests/test_osutils.py (+13/-0) lib/lp/services/tests/test_utils.py (+16/-1) lib/lp/services/utils.py (+12/-0) lib/lp/translations/doc/poexport-request.txt (+1/-0) |
| To merge this branch: | bzr merge lp:~jml/launchpad/generate-ppa-logging |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| j.c.sackett (community) | Approve on 2012-05-31 | ||
| Jelmer Vernooij (community) | code | 2012-05-30 | Approve on 2012-05-30 |
|
Review via email:
|
|||
Commit Message
Instrument generate_
Description of the Change
Turns out that generate_
Along the way, I've done some cleanups to code. In an effort to reduce the line count damage, I may have gone a bit overboard in cramming changes into this diff. Sorry.
Here's a summary:
* Add a debug log to all cronscripts to say how long they spent running
* Add a method to get the last activity of a cronscript
* Add total_seconds helper to get the number of seconds in a timedelta
* Use this helper in lots of places
* Add write_file helper to write out a file. Just use this helper in these tests.
* Rename deactivateTokens to deactivateInval
* Rename getNewTokensSin
* Change the 'getNew*' methods in generate_
* Change both 'getNew*' methods to use the same damn since time
* Calculate the correct since time once, and test that directly, deleting other indirect tests
* Use matchers and helpers in the tests where possible
* General test cleanup
* Lots of instrumentation
Adds 31 lines of code.
| Jonathan Lange (jml) wrote : | # |
| j.c.sackett (jcsackett) wrote : | # |
Jonathan--
This looks good. I have two quibbles about comments in the code below, but that's all.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -384,3 +388,14 @@
> """Values are obfuscated recursively."""
> obfuscated = obfuscate_
> self.assertEqua
> +
> +
> +class TestTotalSecond
> +
> + # Remove this when Python 2.6 support is dropped. Replace calls with
> + # timedelta.
> +
> + def test_total_
> + # Numbers are arbitrary.
> + duration = timedelta(days=3, seconds=45, microseconds=16)
> + self.assertEqual(3 * 24 * 3600 + 45.000016, total_seconds(
Could you make the comment in this test an XXX comment? It marginally
increases the chances other people will notice this and kill it appropriately.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -26,6 +26,7 @@
> 'save_bz2_pickle',
> 'synchronize',
> 'text_delta',
> + 'total_seconds',
> 'traceback_info',
> 'utc_now',
> 'value_string',
> @@ -383,3 +384,15 @@
> for key, value in o.iteritems())
> else:
> return o
> +
> +
> +def total_seconds(
> + """The number of total seconds in a timedelta.
> +
> + In Python 2.7, spell this as duration.
> + Python 2.6 or earlier.
> + """
> + return (
> + (duration.
> + (duration.seconds + duration.days * 24 * 3600) * 1e6)
> + / 1e6)
This should probably have a similar XXX comment.
I believe I mentioned the LoC tool in IRC; as you mentioned, this is part of a broader arc of work--if that's going to end up reducing LoC, fantastic. If not, you still have that credit I mentioned, so either way this should be fine as regards our LoC limits.
Thanks!

FWIW, the tests and set up methods for test_generate_ ppa_htaccess ought to be broken up into little pieces.