Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Tinderbox scraper #714

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,5 @@ filename = scraper.download()
To run the entire test suite to check if your changes create any errors, run `tox`.

If you only run very specific tests, please specify it via `tox -- -k <keyword>`.
For example, if you are only interested in tests that look at tinderbox builds, run `tox -- -k tinderbox`.
For example, if you are only interested in tests that look at release builds, run `tox -- -k release`.
The `-k <keyword>` works for folders, filenames and even names of test methods.
2 changes: 0 additions & 2 deletions mozdownload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
DirectScraper,
ReleaseScraper,
ReleaseCandidateScraper,
TinderboxScraper,
TryScraper,
)

Expand All @@ -26,6 +25,5 @@
DirectScraper,
ReleaseScraper,
ReleaseCandidateScraper,
TinderboxScraper,
TryScraper,
]
6 changes: 3 additions & 3 deletions mozdownload/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def parse_arguments(argv):
dest='build_number',
type=int,
metavar='BUILD_NUMBER',
help='Number of the build (for candidate, daily, and tinderbox builds)')
help='Number of the build (for candidate, and daily builds)')
parser.add_argument('--debug-build',
dest='debug_build',
action='store_true',
help='Download a debug build (for tinderbox, and try builds)')
help='Download a debug build (for try builds)')
parser.add_argument('--destination', '-d',
dest='destination',
default=os.getcwd(),
Expand Down Expand Up @@ -91,7 +91,7 @@ def parse_arguments(argv):
'attempts, default: %(default)s')
parser.add_argument('--revision',
dest='revision',
help='Revision of the build (for daily, tinderbox, and try builds)')
help='Revision of the build (for daily, and try builds)')
parser.add_argument('--stub',
dest='is_stub_installer',
action='store_true',
Expand Down
10 changes: 1 addition & 9 deletions mozdownload/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
'daily': scraper.DailyScraper,
'direct': scraper.DirectScraper,
'release': scraper.ReleaseScraper,
'tinderbox': scraper.TinderboxScraper,
'try': scraper.TryScraper,
}

Expand All @@ -32,7 +31,7 @@ def __init__(self, scraper_type, **kwargs):
:param application: The name of the application to download.
:param base_url: The base url to be used
:param branch: Name of the branch.
:param build_number: Number of the build (for candidate, daily, and tinderbox builds).
:param build_number: Number of the build (for candidate, and daily builds).
:param date: Date of the build.
:param debug_build: Download a debug build.
:param destination: Directory or file name to download the file to.
Expand Down Expand Up @@ -106,13 +105,6 @@ def __init__(self, scraper_type, **kwargs):
'date': kwargs.get('date'),
'revision': kwargs.get('revision'),
},
'tinderbox': {
'branch': kwargs.get('branch', 'mozilla-central'),
'build_number': kwargs.get('build_number'),
'date': kwargs.get('date'),
'debug_build': kwargs.get('debug_build', False),
'revision': kwargs.get('revision'),
},
'try': {
'debug_build': kwargs.get('debug_build', False),
'revision': kwargs.get('revision'),
Expand Down
218 changes: 0 additions & 218 deletions mozdownload/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from mozdownload import errors
from mozdownload import treeherder
from mozdownload.parser import DirectoryParser
from mozdownload.timezones import PacificTimezone
from mozdownload.utils import urljoin

APPLICATIONS = ('devedition', 'firefox', 'fenix', 'thunderbird')
Expand Down Expand Up @@ -835,223 +834,6 @@ def build_filename(self, binary):
'EXT': self.get_file_extension(binary)}


class TinderboxScraper(Scraper):
"""Class to download a tinderbox build of a Gecko based application."""

def __init__(self, branch=None, build_number=None, date=None,
debug_build=False, revision=None, *args, **kwargs):
"""Create instance of a tinderbox scraper."""
self.branch = branch
self.build_number = build_number
self.debug_build = debug_build
self.date = date
self.revision = revision

self.timestamp = None
# Currently any time in RelEng is based on the Pacific time zone.
self.timezone = PacificTimezone()

Scraper.__init__(self, *args, **kwargs)

def get_build_info(self):
"""Define additional build information."""
# Retrieve branch once knowing self.application from Scraper.__init__

if self.branch is None:
self.branch = APPLICATIONS_TO_BRANCH.get(self.application, DEFAULT_BRANCH)
# Retrieve build by revision
if self.revision:
th = treeherder.Treeherder(self.application, self.branch, self.platform)
builds = th.query_builds_by_revision(
self.revision, job_type_name='Build', debug_build=self.debug_build)

if not builds:
raise errors.NotFoundError('No builds have been found for revision', self.revision)

# Extract timestamp from each build folder
self.builds = [build.rsplit('/', 2)[1] for build in builds]
self.show_matching_builds(self.builds)

# There is only a single build
self.build_index = 0
self.logger.info('Selected build: %s' % self.builds[self.build_index])

return

# Internally we access builds via index
if self.build_number is not None:
self.build_index = int(self.build_number) - 1
else:
self.build_index = None

if self.date is not None:
try:
# date is provided in the format 2013-07-23
self.date = datetime.strptime(self.date, '%Y-%m-%d')
except Exception:
try:
# date is provided as a unix timestamp
datetime.fromtimestamp(float(self.date))
self.timestamp = self.date
except Exception:
raise ValueError('%s is not a valid date' % self.date)

# For localized builds we do not have to retrieve the list of builds
# because only the last build is available
if not self.locale_build:
self.builds, self.build_index = self.get_build_info_for_index(
self.build_index)
# Always force a timestamp prefix in the filename
self.timestamp = self.builds[self.build_index]

@property
def binary_regex(self):
"""Return the regex for the binary."""
regex_base_name = (r'^(%(STUB_NEW)s|%(BINARY_NAME)s-.*\.%(LOCALE)s\.%(PLATFORM)s)')
regex_suffix = {'linux': r'.*\.%(EXT)s$',
'linux64': r'.*\.%(EXT)s$',
'mac': r'.*\.%(EXT)s$',
'mac64': r'.*\.%(EXT)s$',
'win32': r'(\.installer%(STUB)s)?\.%(EXT)s$',
'win64': r'(\.installer%(STUB)s)?\.%(EXT)s$'}

regex = regex_base_name + regex_suffix[self.platform]

return regex % {'BINARY_NAME': APPLICATIONS_TO_BINARY_NAME.get(self.application,
self.application),
'LOCALE': self.locale,
'PLATFORM': PLATFORM_FRAGMENTS[self.platform],
'STUB': '-stub' if self.is_stub_installer else '',
'STUB_NEW': 'setup' if self.is_stub_installer else '',
'EXT': self.extension_regex}

def build_filename(self, binary):
"""Return the proposed filename with extension for the binary."""

return '%(TIMESTAMP)s%(BRANCH)s%(DEBUG)s-%(NAME)s' % {
'TIMESTAMP': self.timestamp + '-' if self.timestamp else '',
'BRANCH': self.branch,
'DEBUG': '-debug' if self.debug_build else '',
'NAME': binary}

@property
def build_list_regex(self):
"""Return the regex for the folder which contains the list of builds."""
regex = 'tinderbox-builds/%(BRANCH)s-%(PLATFORM)s%(L10N)s%(DEBUG)s/'

return regex % {
'BRANCH': self.branch,
'PLATFORM': '' if self.locale_build else self.platform_regex,
'L10N': 'l10n' if self.locale_build else '',
'DEBUG': '-debug' if self.debug_build else ''}

def date_matches(self, timestamp):
"""Determine whether the timestamp date is equal to the argument date."""
if self.date is None:
return False

timestamp = datetime.fromtimestamp(float(timestamp), self.timezone)
if self.date.date() == timestamp.date():
return True

return False

def detect_platform(self):
"""Detect the current platform."""
platform = Scraper.detect_platform(self)

# On OS X we have to special case the platform detection code and
# fallback to 64 bit builds for the en-US locale
if mozinfo.os == 'mac' and self.locale == 'en-US' and \
mozinfo.bits == 64:
platform = "%s%d" % (mozinfo.os, mozinfo.bits)

return platform

def is_build_dir(self, folder_name):
"""Return whether or not the given dir contains a build."""
# Cannot move up to base scraper due to parser.entries call in
# get_build_info_for_index (see below)
url = '%s/' % urljoin(self.base_url, self.build_list_regex, folder_name)

if self.application in APPLICATIONS_MULTI_LOCALE \
and self.locale != 'multi':
url = '%s/' % urljoin(url, self.locale)

parser = self._create_directory_parser(url)

pattern = re.compile(self.binary_regex, re.IGNORECASE)
for entry in parser.entries:
try:
pattern.match(entry).group()
return True
except Exception:
# No match, continue with next entry
continue
return False

def get_build_info_for_index(self, build_index=None):
"""Get additional information for the build at the given index."""
url = urljoin(self.base_url, self.build_list_regex)

if self.timestamp:
# If a timestamp is given, retrieve the folder with the timestamp
# as name
entries = [self.timestamp]
else:
self.logger.info('Retrieving list of builds from %s' % url)
parser = self._create_directory_parser(url)
parser.entries = parser.filter(r'^\d+$')

if self.date:
# If date is given, retrieve the subset of builds on that date
parser.entries = list(filter(self.date_matches, parser.entries))

if not parser.entries:
message = 'No builds have been found'
raise errors.NotFoundError(message, url)

entries = parser.entries

self.show_matching_builds(entries)

# If no index has been given, set it to the last build of the day.
if build_index is None:
# Find the most recent non-empty entry.
build_index = len(entries)
for build in reversed(entries):
build_index -= 1
if not build_index or self.is_build_dir(build):
break

if build_index >= len(entries):
raise errors.NotFoundError('Specified build number has not been found ', url)

self.logger.info('Selected build: %s' % entries[build_index])

return (entries, build_index)

@property
def path_regex(self):
"""Return the regex for the path to the build folder."""
if self.locale_build:
return self.build_list_regex

return '%s/' % urljoin(self.build_list_regex, self.builds[self.build_index])

@property
def platform_regex(self):
"""Return the platform fragment of the URL."""
platform_fragments = {'linux': 'linux',
'linux64': 'linux64',
'mac': 'macosx64',
'mac64': 'macosx64',
'win32': 'win32',
'win64': 'win64'}

return platform_fragments[self.platform]


class TryScraper(Scraper):
"""Class to download a try build of a Gecko based application."""

Expand Down
41 changes: 0 additions & 41 deletions mozdownload/timezones.py

This file was deleted.

5 changes: 0 additions & 5 deletions tests/cli/test_correct_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
'fname': '2013-10-01-03-02-04-mozilla-central-firefox-27.0a1.en-US.win32.installer.exe',
},

'tinderbox': {
'args': ['-t', 'tinderbox', '-p', 'win32'],
'fname': '1374583608-mozilla-central-firefox-25.0a1.en-US.win32.installer.exe',
},

'try': {
'args': ['-t', 'try', '-p', 'win32', '--revision', '8fcac92cfcad'],
'builds': ['/firefox/try-builds/test-user@mozilla.com-8fcac92cfcad/try-win32/'],
Expand Down

This file was deleted.

Loading