mozilla/mozdownload — pull request #47 by mykmelez (2012-12-11 23:49:31+00:00)
Title: filter potential build dirs by whether or not they contain a build

B2G nightly dirs started proliferating recently, with many such dirs for a given date, most of which don't contain a build. See for example:

https://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/2012/12/

Which has this bevy of dirs for 2012-12-10:

2012-12-10-12-20-53-mozilla-beta/	10-Dec-2012 12:27
2012-12-10-12-23-21-mozilla-beta/	10-Dec-2012 12:26
2012-12-10-12-23-28-mozilla-beta/	10-Dec-2012 12:37
2012-12-10-12-23-36-mozilla-beta/	10-Dec-2012 12:26
2012-12-10-12-23-47-mozilla-beta/	10-Dec-2012 12:27
2012-12-10-12-24-20-mozilla-beta/	10-Dec-2012 12:34
2012-12-10-12-38-57-mozilla-beta/	10-Dec-2012 14:42
2012-12-10-12-42-07-mozilla-beta/	10-Dec-2012 14:52
2012-12-10-12-43-24-mozilla-beta/	10-Dec-2012 13:25
2012-12-10-12-43-46-mozilla-beta/	10-Dec-2012 14:49
2012-12-10-12-43-59-mozilla-beta/	10-Dec-2012 15:03
2012-12-10-12-46-54-mozilla-beta/	10-Dec-2012 13:52
2012-12-10-12-47-10-mozilla-beta/	10-Dec-2012 13:54
2012-12-10-12-47-18-mozilla-beta/	10-Dec-2012 14:02
2012-12-10-12-47-19-mozilla-beta/	10-Dec-2012 14:02
2012-12-10-13-37-54-mozilla-central/	10-Dec-2012 14:17
2012-12-10-13-37-55-mozilla-central/	10-Dec-2012 14:18
2012-12-10-14-57-04-mozilla-beta/	10-Dec-2012 15:36
2012-12-10-14-58-42-mozilla-beta/	10-Dec-2012 15:53
2012-12-10-14-58-58-mozilla-beta/	10-Dec-2012 15:49
2012-12-10-14-59-43-mozilla-beta/	10-Dec-2012 15:51
2012-12-10-15-03-46-mozilla-beta/	10-Dec-2012 16:07
2012-12-10-15-04-04-mozilla-beta/	10-Dec-2012 17:06
2012-12-10-15-04-06-mozilla-beta/	10-Dec-2012 17:05
2012-12-10-20-12-30-mozilla-beta/	10-Dec-2012 20:28

Finding a build thus requires a more sophisticated algorithm than the one that *mozdownload* currently uses. It isn't enough to find all dirs for the given day/channel and then pick the last one. *mozdownload* must also filter the dirs by whether or not they contain an actual build.

Here's a branch that does that. Along the way, it fixes a recent regression that triggers an exception when checking if `tmp_file` is a file under certain circumstances in which `tmp_file` is undefined. And it enhances the directory parser to allow filtering by both regex and function.