Skip to content

Commit

Permalink
Merge pull request mozilla-services#3078 from peterbe/bug-1221624-fen…
Browse files Browse the repository at this point in the history
…necandroid-450a-440a2-430b1-and-420-missing-on-socorro-prod

fixes bug 1221624 - FennecAndroid repository digit trimming
  • Loading branch information
rhelmer committed Nov 5, 2015
2 parents f4581df + f72dd5f commit 1fd6d9c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
11 changes: 9 additions & 2 deletions socorro/cron/jobs/ftpscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ def get_json_nightly(self, nightly_url, dirname):
repository = []

for field in dirname.split('-'):
if not field.isdigit():
# Skip until something is not a digit and once we've
# appended at least one, keep adding.
if not field.isdigit() or repository:
repository.append(field)
repository = '-'.join(repository).strip('/')

Expand Down Expand Up @@ -270,6 +272,7 @@ def get_release(self, candidate_url):
yield (platform, version, kvpairs, bad_lines)

def get_nightly(self, nightly_url, dirname):

info_files = self.get_links(nightly_url, ends_with='.txt')
for url in info_files:
basename = os.path.basename(url)
Expand All @@ -282,9 +285,13 @@ def get_nightly(self, nightly_url, dirname):

version = pv.split('-')[-1]
repository = []

for field in dirname.split('-'):
if not field.isdigit():
# Skip until something is not a digit and once we've
# appended at least one, keep adding.
if not field.isdigit() or repository:
repository.append(field)
print ('nightly', dirname, repository)
repository = '-'.join(repository).strip('/')
kvpairs, bad_lines = self.parse_info_file(url, nightly=True)

Expand Down
25 changes: 15 additions & 10 deletions socorro/unittest/cron/jobs/test_ftpscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,11 @@ def mocked_urlopener(url, today=None):
"""
if url.endswith(today.strftime('/mobile/nightly/%Y/%m/')):
return html_wrap % today.strftime("""
<a href="%Y-%m-%d-trunk/">%Y-%m-%d-trunk</a>
<a href="%Y-%m-%d-trunk-11/">%Y-%m-%d-trunk-11</a>
""")
if url.endswith(
today.strftime(
'/mobile/nightly/%Y/%m/%Y-%m-%d-trunk/'
'/mobile/nightly/%Y/%m/%Y-%m-%d-trunk-11/'
)
):
return html_wrap % """
Expand All @@ -738,7 +738,7 @@ def mocked_urlopener(url, today=None):
"""
if url.endswith(
today.strftime(
'/mobile/nightly/%Y/%m/%Y-%m-%d-trunk/'
'/mobile/nightly/%Y/%m/%Y-%m-%d-trunk-11/'
'mozilla-nightly-15.0a1.en-US.linux-x86_64.txt'
)
):
Expand All @@ -748,7 +748,7 @@ def mocked_urlopener(url, today=None):
)
if url.endswith(
today.strftime(
'/mobile/nightly/%Y/%m/%Y-%m-%d-trunk/'
'/mobile/nightly/%Y/%m/%Y-%m-%d-trunk-11/'
'mozilla-nightly-15.0a2.en-US.linux-x86_64.txt'
)
):
Expand Down Expand Up @@ -782,7 +782,7 @@ def mocked_urlopener(url, today=None):

cursor = self.conn.cursor()

columns = 'product_name', 'build_id', 'build_type'
columns = 'product_name', 'build_id', 'build_type', 'repository'
cursor.execute("""
select %s
from releases_raw
Expand All @@ -796,23 +796,28 @@ def mocked_urlopener(url, today=None):
eq_(builds, [{
'build_id': 20120516113045,
'product_name': 'mobile',
'build_type': 'release'
'build_type': 'release',
'repository': 'mozilla-release',
}, {
'build_id': 20120516113045,
'product_name': 'mobile',
'build_type': 'release'
'build_type': 'release',
'repository': 'mozilla-beta',
}, {
'build_id': 20120516114455,
'product_name': 'mobile',
'build_type': 'beta'
'build_type': 'beta',
'repository': 'mozilla-beta',
}, {
'build_id': 20120505030510,
'product_name': 'mobile',
'build_type': 'nightly'
'build_type': 'nightly',
'repository': 'trunk-11',
}, {
'build_id': 20120505443322,
'product_name': 'mobile',
'build_type': 'aurora'
'build_type': 'aurora',
'repository': 'trunk-11',
}])

assert len(build_ids) == 4
Expand Down

0 comments on commit 1fd6d9c

Please sign in to comment.