Skip to content

Commit

Permalink
add fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
salilmishra23 committed Jan 29, 2023
1 parent d1126e8 commit 98dfc54
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*.egg-info
*.pyc
.coverage
build
dist
.pytest_cache/
.vscode/
build
dist
39 changes: 24 additions & 15 deletions mozdownload/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,25 @@

# Used if the application is named differently than the subfolder on the server
APPLICATIONS_TO_FTP_DIRECTORY = {'fennec': 'mobile'}
# Used if the application is named differently then the binary on the server
# Used if the application is named differently than the binary on the server
APPLICATIONS_TO_BINARY_NAME = {'devedition': 'firefox'}

APPLICATION_BUILD_FILENAME = {
app: (
'%(TIMESTAMP)s-%(BRANCH)s-%(NAME)s' if app != 'fenix'
else '%(TIMESTAMP)s-%(NAME)s'
)
for app in APPLICATIONS
}

APPLICATION_REGEX = {
app: (
r'%(DATE)s-(\d+-)+%(BRANCH)s%(L10N)s%(PLATFORM)s$' if app != 'fenix'
else r'%(DATE)s-(\d+-){3}fenix-(\d+\.\d.\d)%(PLATFORM)s$'
)
for app in APPLICATIONS
}

# Base URL for the path to all builds
BASE_URL = 'https://archive.mozilla.org/pub/'

Expand All @@ -59,7 +75,10 @@
'android-api-11': r'android-arm',
'android-api-15': r'android-arm',
'android-api-16': r'android-arm',
'android-arm64-v8a': r'android-arm64-v8a',
'android-armeabi-v7a': r'android-armeabi-v7a',
'android-x86': r'android-i386',
'android-x86_64': r'android-x86_64',
'linux': r'linux-i686',
'linux64': r'linux-x86_64',
'mac': r'mac',
Expand Down Expand Up @@ -213,8 +232,6 @@ def path_regex(self):
@property
def platform_regex(self):
"""Return the platform fragment of the URL."""
if self.application == "fenix":
return self.platform
return PLATFORM_FRAGMENTS[self.platform]

@property
Expand Down Expand Up @@ -473,19 +490,14 @@ def get_build_info_for_date(self, date, build_index=None):

self.logger.info('Retrieving list of builds from %s' % url)
parser = self._create_directory_parser(url)
regex = r'%(DATE)s-(\d+-)+%(BRANCH)s%(L10N)s%(PLATFORM)s$' % {
regex = APPLICATION_REGEX[self.application] % {
'DATE': date.strftime('%Y-%m-%d'),
'BRANCH': self.branch,
# ensure to select the correct subfolder for localized builds
'L10N': '(-l10n)?' if self.locale_build else '',
'PLATFORM': '' if self.application not in (
'fennec') else '-' + self.platform
'fenix', 'fennec') else '-' + self.platform
}
if self.application == 'fenix':
regex = r'%(DATE)s-(\d+-){3}fenix-(\d+\.\d.\d)-%(PLATFORM)s$' % {
'DATE': date.strftime('%Y-%m-%d'),
'PLATFORM': self.platform
}
parser.entries = parser.filter(regex)
parser.entries = parser.filter(self.is_build_dir)

Expand Down Expand Up @@ -525,7 +537,7 @@ def binary_regex(self):
'android-api-15': r'\.%(EXT)s$',
'android-api-16': r'\.%(EXT)s$',
'android-arm64-v8a': r'\.%(EXT)s$',
'armeabi-v7a': r'\.%(EXT)s$',
'android-armeabi-v7a': r'\.%(EXT)s$',
'android-x86': r'\.%(EXT)s$',
'android-x86_64': r'\.%(EXT)s$',
'linux': r'\.%(EXT)s$',
Expand Down Expand Up @@ -554,10 +566,7 @@ def build_filename(self, binary):
# If it's not available use the build's date
timestamp = self.date.strftime('%Y-%m-%d')

if self.application == 'fenix':
return binary

return '%(TIMESTAMP)s-%(BRANCH)s-%(NAME)s' % {
return APPLICATION_BUILD_FILENAME[self.application] % {
'TIMESTAMP': timestamp,
'BRANCH': self.branch,
'NAME': binary}
Expand Down
12 changes: 6 additions & 6 deletions tests/daily_scraper/test_daily_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@

fenix_tests = [
({'application': 'fenix', 'platform': 'android-arm64-v8a', 'date': '2022-11-14'},
'fenix-108.0b1.multi.android-arm64-v8a.apk',
'2022-11-14-17-01-36-fenix-108.0b1.multi.android-arm64-v8a.apk',
'fenix/nightly/2022/11/2022-11-14-17-01-36-fenix-108.0b1-android-arm64-v8a/fenix-108.0b1.multi.android-arm64-v8a.apk'),
({'application': 'fenix', 'platform': 'android-x86', 'date': '2022-11-14'},
'fenix-108.0b1.multi.android-x86.apk',
'2022-11-14-17-01-36-fenix-108.0b1.multi.android-x86.apk',
'fenix/nightly/2022/11/2022-11-14-17-01-36-fenix-108.0b1-android-x86/fenix-108.0b1.multi.android-x86.apk'),
({'application': 'fenix', 'platform': 'android-arm64-v8a', 'date': '2022-11-14'},
'fenix-108.0b1.multi.android-arm64-v8a.apk',
'fenix/nightly/2022/11/2022-11-14-17-01-36-fenix-108.0b1-android-arm64-v8a/fenix-108.0b1.multi.android-arm64-v8a.apk'),
({'application': 'fenix', 'platform': 'android-armeabi-v7a', 'date': '2022-11-14'},
'2022-11-14-17-01-36-fenix-108.0b1.multi.android-armeabi-v7a.apk',
'fenix/nightly/2022/11/2022-11-14-17-01-36-fenix-108.0b1-android-armeabi-v7a/fenix-108.0b1.multi.android-armeabi-v7a.apk'),
({'application': 'fenix', 'platform': 'android-x86_64', 'date': '2022-11-14'},
'fenix-108.0b1.multi.android-x86_64.apk',
'2022-11-14-17-01-36-fenix-108.0b1.multi.android-x86_64.apk',
'fenix/nightly/2022/11/2022-11-14-17-01-36-fenix-108.0b1-android-x86_64/fenix-108.0b1.multi.android-x86_64.apk'),
]

Expand Down

0 comments on commit 98dfc54

Please sign in to comment.