зеркало из https://github.com/mozilla/ff-tool.git
Коммит
1f92b5e6f0
|
@ -1,3 +1,6 @@
|
|||
_temp
|
||||
venv
|
||||
*.pyc
|
||||
*.egg-info/
|
||||
*.egg
|
||||
.tox/
|
||||
|
|
2
Makefile
2
Makefile
|
@ -25,7 +25,7 @@ test:
|
|||
tox
|
||||
|
||||
clean:
|
||||
rm -rf venv *egg* dist ./docs/_build .tox
|
||||
rm -rf venv *egg* dist ./docs/_build .tox _temp
|
||||
find . -name '*.pyc' -delete
|
||||
find . -name '__pycache__' -type d -exec rm -fr {} \;
|
||||
|
||||
|
|
37
README.md
37
README.md
|
@ -1,4 +1,37 @@
|
|||
# ff-tool
|
||||
Python CLI tool for downloading desktop Firefox version, managing profiles and test prefs
|
||||
ff-tool is a Python CLI tool for downloading desktop Firefox versions,
|
||||
as well as managing profiles and test prefs. It is largely a glorified
|
||||
convenience wrapper we've written around these amazing tools/libraries:
|
||||
|
||||
* [mozdownload](https://github.com/mozilla/mozdownload)
|
||||
* [mozprofile](https://github.com/mozilla/mozprofile)
|
||||
|
||||
|
||||
:bangbang: _NOTE: This tool is work in progress... DO NOT USE_ :bangbang:
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
## Pre-requisites
|
||||
* ff-tool requires you have python and virtualenv installed.
|
||||
|
||||
## Build
|
||||
```
|
||||
$ make build
|
||||
$ source ./venv/bin/activate
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
```
|
||||
$ deactivate
|
||||
$ make clean
|
||||
```
|
||||
|
||||
# Run
|
||||
## Example(s)
|
||||
```
|
||||
$ ff -h
|
||||
$ ff download -h
|
||||
$ ff download -c nightly
|
||||
```
|
||||
|
||||
# Work in progress... DO NOT USE
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
[gr]
|
||||
version=latest
|
||||
type=release
|
||||
branch=
|
||||
|
||||
[beta]
|
||||
version=latest-beta
|
||||
type=candidate
|
||||
branch=
|
||||
|
||||
[aurora]
|
||||
version=
|
||||
type=daily
|
||||
branch=mozilla-aurora
|
||||
|
||||
[nightly]
|
||||
version=
|
||||
type=daily
|
||||
branch=mozilla-central
|
|
@ -0,0 +1,34 @@
|
|||
# https://archive.mozilla.org/pub/firefox/releases/latest/README.txt
|
||||
|
||||
[DEFAULT]
|
||||
# install paths
|
||||
PATH_PROGRAM_FILES = /cygdrive/c/Program Files
|
||||
PATH_FIREFOX_BIN = firefox.exe
|
||||
# env vars
|
||||
PATH_FIREFOX_BIN_ENV = %(PATH_FIREFOX_APP)s/%(PATH_FIREFOX_BIN)s
|
||||
PATH_FIREFOX_PROFILES_ENV = %(APPDATA)s\Mozilla\Firefox\Profiles
|
||||
PATH_SIKULIX_BIN_ENV = /cygdrive/c/sikulix
|
||||
|
||||
[nightly]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxNightly.exe
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = %(PATH_PROGRAM_FILES)s/Nightly
|
||||
|
||||
[aurora]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxDevEdition.exe
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = %(PATH_PROGRAM_FILES)s/Firefox Developer Edition
|
||||
|
||||
[beta]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxBeta.exe
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = %(PATH_PROGRAM_FILES)s/Mozilla Firefox Beta
|
||||
|
||||
[gr]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxRelease.exe
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = %(PATH_PROGRAM_FILES)s/Mozilla Firefox
|
|
@ -0,0 +1,33 @@
|
|||
# https://archive.mozilla.org/pub/firefox/releases/latest/README.txt
|
||||
|
||||
[DEFAULT]
|
||||
# install paths
|
||||
PATH_FIREFOX_BIN = Contents/MacOS/firefox
|
||||
# env vars
|
||||
PATH_FIREFOX_BIN_ENV = %(PATH_FIREFOX_APP)s/%(PATH_FIREFOX_BIN)s
|
||||
PATH_FIREFOX_PROFILES_ENV = $HOME/Library/Application Support/Firefox/
|
||||
PATH_SIKULIX_BIN_ENV = /Applications/Sikuli/runsikulix
|
||||
|
||||
[nightly]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxNightly.dmg
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = /Applications/Firefox Nightly.app
|
||||
|
||||
[aurora]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxDevEdition.dmg
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = /Applications/Firefox Developer Edition.app
|
||||
|
||||
[beta]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxBeta.dmg
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = /Applications/FirefoxBeta.app
|
||||
|
||||
[gr]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = FirefoxRelease.dmg
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = /Applications/Firefox.app
|
|
@ -0,0 +1,33 @@
|
|||
# https://archive.mozilla.org/pub/firefox/releases/latest/README.txt
|
||||
|
||||
[DEFAULT]
|
||||
# install paths
|
||||
PATH_FIREFOX_BIN = firefox
|
||||
# env vars
|
||||
PATH_FIREFOX_BIN_ENV = %(PATH_FIREFOX_APP)s/%(PATH_FIREFOX_BIN)s
|
||||
PATH_FIREFOX_PROFILES_ENV = $HOME/.mozilla
|
||||
PATH_SIKULIX_BIN_ENV = $HOME/Sikuli/runsikulix
|
||||
|
||||
[nightly]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = firefox-nightly.tar.bz2
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = $HOME/bin/firefox-nightly
|
||||
|
||||
[aurora]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = firefox-dev-edition.tar.bz2
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = $HOME/bin/firefox-developer-edition
|
||||
|
||||
[beta]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = firefox-beta.tar.bz2
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = $HOME/bin/firefox-beta
|
||||
|
||||
[gr]
|
||||
# download configs
|
||||
DOWNLOAD_FILENAME = firefox-release.tar.bz2
|
||||
# install configs
|
||||
PATH_FIREFOX_APP = $HOME/bin/firefox-release
|
|
@ -0,0 +1,90 @@
|
|||
"""module providing ff-tool command menus"""
|
||||
|
||||
from firefox_download import download
|
||||
|
||||
|
||||
class CMDDownload():
|
||||
|
||||
def __init__(self, subparsers, CHANNELS, DEFAULT_CHANNEL):
|
||||
download = subparsers.add_parser(
|
||||
'download',
|
||||
help='<download> command help')
|
||||
download.add_argument(
|
||||
'-c',
|
||||
'--channel',
|
||||
choices=CHANNELS,
|
||||
default=DEFAULT_CHANNEL,
|
||||
type=str,
|
||||
help='Download a specific Firefox channel via mozdownload.'
|
||||
)
|
||||
download.set_defaults(func=self.cmd)
|
||||
|
||||
def cmd(self, args):
|
||||
print('Downloading Firefox... [channel: {0}]'.format(args.channel))
|
||||
|
||||
download(args.channel)
|
||||
|
||||
|
||||
class CMDProfile():
|
||||
|
||||
def __init__(self, subparsers):
|
||||
profile = subparsers.add_parser(
|
||||
'profile', help='<profile> command help')
|
||||
profile.add_argument(
|
||||
'-c',
|
||||
'--create',
|
||||
type=str,
|
||||
help='Create a new Firefox profile with the specified name.'
|
||||
)
|
||||
profile.add_argument(
|
||||
'-d',
|
||||
'--delete',
|
||||
type=str,
|
||||
help='Delete the specified Firefox profile.'
|
||||
)
|
||||
profile.set_defaults(func=self.cmd)
|
||||
|
||||
def cmd(self, args):
|
||||
if args.create:
|
||||
print('Creating Firefox profile... [name: {0}]'.format(args.create)) # NOQA
|
||||
|
||||
if args.delete:
|
||||
print('Deleting Firefox profile... [name: {0}]'.format(args.delete)) # NOQA
|
||||
|
||||
|
||||
class CMDInstall():
|
||||
|
||||
def __init__(self, subparsers, CHANNELS, DEFAULT_CHANNEL):
|
||||
install = subparsers.add_parser(
|
||||
'install', help='<install> command help')
|
||||
install.add_argument(
|
||||
'-c',
|
||||
'--channel',
|
||||
choices=CHANNELS,
|
||||
default=DEFAULT_CHANNEL,
|
||||
type=str,
|
||||
help='Install a specific Firefox channel.'
|
||||
)
|
||||
install.set_defaults(func=self.cmd)
|
||||
|
||||
def cmd(self, args):
|
||||
print('Installing Firefox... [channel: {0}]'.format(args.channel))
|
||||
|
||||
|
||||
class CMDUninstall():
|
||||
|
||||
def __init__(self, subparsers, CHANNELS, DEFAULT_CHANNEL):
|
||||
uninstall = subparsers.add_parser(
|
||||
'uninstall', help='<uninstall> command help')
|
||||
uninstall.add_argument(
|
||||
'-c',
|
||||
'--channel',
|
||||
choices=CHANNELS,
|
||||
default=DEFAULT_CHANNEL,
|
||||
type=str,
|
||||
help='Uninstall a specific Firefox channel.'
|
||||
)
|
||||
uninstall.set_defaults(func=self.cmd)
|
||||
|
||||
def cmd(self, args):
|
||||
print('Uninstalling Firefox... [channel: {0}]'.format(args.channel))
|
|
@ -1,24 +0,0 @@
|
|||
"""
|
||||
ff-tool <download> specific arguments...
|
||||
"""
|
||||
|
||||
from firefox_download import download
|
||||
|
||||
|
||||
class cmd_download():
|
||||
def cmd(self, args):
|
||||
print('Downloading Firefox... [channel: {0}]'.format(args.channel))
|
||||
|
||||
download(args.channel)
|
||||
|
||||
def __init__(self, subparsers, CHANNELS, DEFAULT_CHANNEL):
|
||||
download = subparsers.add_parser('download', help='<download> command help')
|
||||
download.add_argument(
|
||||
'-c',
|
||||
'--channel',
|
||||
choices=CHANNELS,
|
||||
default=DEFAULT_CHANNEL,
|
||||
type=str,
|
||||
help='Download a specific Firefox channel via mozdownload.'
|
||||
)
|
||||
download.set_defaults(func=self.cmd)
|
|
@ -1,20 +0,0 @@
|
|||
"""
|
||||
ff-tool <install> specific arguments...
|
||||
"""
|
||||
|
||||
|
||||
class cmd_install():
|
||||
def cmd(self, args):
|
||||
print('Installing Firefox... [channel: {0}]'.format(args.channel))
|
||||
|
||||
def __init__(self, subparsers, CHANNELS, DEFAULT_CHANNEL):
|
||||
install = subparsers.add_parser('install', help='<install> command help')
|
||||
install.add_argument(
|
||||
'-c',
|
||||
'--channel',
|
||||
choices=CHANNELS,
|
||||
default=DEFAULT_CHANNEL,
|
||||
type=str,
|
||||
help='Install a specific Firefox channel.'
|
||||
)
|
||||
install.set_defaults(func=self.cmd)
|
|
@ -1,28 +0,0 @@
|
|||
"""
|
||||
ff-tool <profile> specific arguments...
|
||||
"""
|
||||
|
||||
|
||||
class cmd_profile():
|
||||
def cmd(self, args):
|
||||
if args.create:
|
||||
print('Creating Firefox profile... [name: {0}]'.format(args.create))
|
||||
|
||||
if args.delete:
|
||||
print('Deleting Firefox profile... [name: {0}]'.format(args.delete))
|
||||
|
||||
def __init__(self, subparsers):
|
||||
profile = subparsers.add_parser('profile', help='<profile> command help')
|
||||
profile.add_argument(
|
||||
'-c',
|
||||
'--create',
|
||||
type=str,
|
||||
help='Create a new Firefox profile with the specified name.'
|
||||
)
|
||||
profile.add_argument(
|
||||
'-d',
|
||||
'--delete',
|
||||
type=str,
|
||||
help='Delete the specified Firefox profile.'
|
||||
)
|
||||
profile.set_defaults(func=self.cmd)
|
|
@ -1,20 +0,0 @@
|
|||
"""
|
||||
ff-tool <uninstall> specific arguments...
|
||||
"""
|
||||
|
||||
|
||||
class cmd_uninstall():
|
||||
def cmd(self, args):
|
||||
print('Uninstalling Firefox... [channel: {0}]'.format(args.channel))
|
||||
|
||||
def __init__(self, subparsers, CHANNELS, DEFAULT_CHANNEL):
|
||||
uninstall = subparsers.add_parser('uninstall', help='<uninstall> command help')
|
||||
uninstall.add_argument(
|
||||
'-c',
|
||||
'--channel',
|
||||
choices=CHANNELS,
|
||||
default=DEFAULT_CHANNEL,
|
||||
type=str,
|
||||
help='Uninstall a specific Firefox channel.'
|
||||
)
|
||||
uninstall.set_defaults(func=self.cmd)
|
|
@ -41,15 +41,16 @@ class FirefoxInstall(object):
|
|||
|
||||
if IniHandler.is_linux():
|
||||
# TODO: Move to /opt/* and chmod file?
|
||||
# `tar -jxf firefox-beta.tar.gz -C ./beta --strip-components=1`?
|
||||
local('tar -jxf {0} && mv firefox {1}'.format(installer, install_dir))
|
||||
# `tar -jxf firefox-beta.tar.gz -C ./beta --strip-components=1`? # NOQA
|
||||
local('tar -jxf {0} && mv firefox {1}'.format(installer, install_dir)) # NOQA
|
||||
|
||||
elif IniHandler.is_windows():
|
||||
local('{0} -ms'.format(installer))
|
||||
|
||||
if channel == 'beta':
|
||||
# Since Beta and General Release channels install to the same directory,
|
||||
# install Beta first then rename the directory.
|
||||
# Since Beta and General Release channels install
|
||||
# to the same directory, install Beta first then
|
||||
# rename the directory.
|
||||
gr_install_dir = self.config.get('gr', 'PATH_FIREFOX_APP')
|
||||
local('mv "{0}" "{1}"'.format(gr_install_dir, install_dir))
|
||||
|
||||
|
@ -60,7 +61,10 @@ class FirefoxInstall(object):
|
|||
else:
|
||||
print(('[{0}] was cached, skipping install.'.format(channel)))
|
||||
|
||||
local('"{0}" --version # {1}'.format(self.config.get(channel, 'PATH_FIREFOX_BIN_ENV'), channel))
|
||||
cmd = self.config.get(channel, 'PATH_FIREFOX_BIN_ENV')
|
||||
# local('"{0}" --version # {1}'.format(self.config.get(channel,
|
||||
# 'PATH_FIREFOX_BIN_ENV'), channel))
|
||||
local('"{0}" --version # {1}'.format(cmd, channel))
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -30,7 +30,7 @@ config = configparser.ConfigParser()
|
|||
def _parse_args():
|
||||
"""Parses out args for CLI"""
|
||||
parser = configargparse.ArgumentParser(
|
||||
description='CLI tool for creating Firefox profiles via mozprofile CLI')
|
||||
description='CLI tool for creating Firefox profiles')
|
||||
parser.add_argument('-a', '--application',
|
||||
required=True,
|
||||
help='Application to test. Example: "loop-server"')
|
||||
|
|
|
@ -23,7 +23,7 @@ class FirefoxProfileHandler(object):
|
|||
|
||||
def switch_prefs(self, profile_name, user_prefs, channel='nightly'):
|
||||
channel_firefox_bin = self.config.get(channel, 'PATH_FIREFOX_BIN_ENV')
|
||||
print(('{0} -CreateProfile {1}'.format(channel_firefox_bin, profile_name)))
|
||||
print(('{0} -CreateProfile {1}'.format(channel_firefox_bin, profile_name))) # NOQA
|
||||
print('copy prefs.js to <new profile name> dir')
|
||||
|
||||
def delete_all_profiles(self):
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
"""firefox test tool helper script"""
|
||||
|
||||
import configargparse
|
||||
|
||||
|
||||
def _parse_args():
|
||||
"""Parses out args for CLI"""
|
||||
parser = configargparse.ArgumentParser(
|
||||
description='cross-platform CLI tool for installing firefox and managing profiles')
|
||||
parser.add_argument('-i', '--install',
|
||||
help='install firefox version (release, beta, aurora, nightly',
|
||||
default='nightly',
|
||||
type=str)
|
||||
parser.add_argument('-u', '--uninstall',
|
||||
help='install firefox version (release, beta, aurora, nightly, ALL',
|
||||
type=str)
|
||||
parser.add_argument('-p', '--create-profile',
|
||||
help='create new profile (indicate name)',
|
||||
type=str)
|
||||
parser.add_argument('-d', '--delete-profile',
|
||||
help='delete profile (indicate name)',
|
||||
type=str)
|
||||
parser.add_argument('-s', '--set-profile-path',
|
||||
help='-s <path to profile>',
|
||||
default='<put OS-specific default path here??>',
|
||||
type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
return args, parser
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entrypoint for CLI"""
|
||||
|
||||
args, parser = _parse_args()
|
||||
|
||||
print('INSTALL: {0}'.format(args.install))
|
||||
print('UNINSTALL: {0}'.format(args.uninstall))
|
||||
print('CREATE PROFILE: {0}'.format(args.create_profile))
|
||||
print('DELETE PROFILE: {0}'.format(args.delete_profile))
|
||||
print('SET PROFILE PATH: {0}'.format(args.set_profile_path))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -44,7 +44,7 @@ class FirefoxUninstall(object):
|
|||
|
||||
# If we're on Windows/Cygwin, use the uninstaller.
|
||||
if self.config.is_windows():
|
||||
local("\"{0}/uninstall/helper.exe\" -ms".format(path_firefox_app))
|
||||
local("\"{0}/uninstall/helper.exe\" -ms".format(path_firefox_app)) # NOQA
|
||||
|
||||
# Otherwise just rimraf the Firefox folder.
|
||||
else:
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
import argparse
|
||||
|
||||
from cmd_download import cmd_download
|
||||
from cmd_install import cmd_install
|
||||
from cmd_profile import cmd_profile
|
||||
from cmd_uninstall import cmd_uninstall
|
||||
from cmd import CMDDownload, CMDInstall, CMDUninstall, CMDProfile
|
||||
|
||||
CHANNELS = ['gr', 'release', 'stable',
|
||||
'beta',
|
||||
|
@ -30,21 +27,26 @@ def get_channel(channel):
|
|||
return channel
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(prog='ff')
|
||||
subparsers = parser.add_subparsers(help='commands', dest='command')
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog='ff')
|
||||
subparsers = parser.add_subparsers(help='commands', dest='command')
|
||||
|
||||
"""
|
||||
Global arguments...
|
||||
"""
|
||||
# parser.add_argument('--foo', action='store_true', help='foo help')
|
||||
"""
|
||||
Global arguments...
|
||||
"""
|
||||
# parser.add_argument('--foo', action='store_true', help='foo help')
|
||||
|
||||
download = cmd_download(subparsers, CHANNELS, DEFAULT_CHANNEL)
|
||||
install = cmd_install(subparsers, CHANNELS, DEFAULT_CHANNEL)
|
||||
profile = cmd_profile(subparsers)
|
||||
uninstall = cmd_uninstall(subparsers, CHANNELS, DEFAULT_CHANNEL)
|
||||
CMDDownload(subparsers, CHANNELS, DEFAULT_CHANNEL)
|
||||
CMDInstall(subparsers, CHANNELS, DEFAULT_CHANNEL)
|
||||
CMDProfile(subparsers)
|
||||
CMDUninstall(subparsers, CHANNELS, DEFAULT_CHANNEL)
|
||||
|
||||
options = parser.parse_args()
|
||||
if "channel" in options:
|
||||
options = parser.parse_args()
|
||||
if "channel" in options:
|
||||
options.channel = get_channel(options.channel)
|
||||
|
||||
options.func(options)
|
||||
options.func(options)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Fabric3
|
||||
configargparse
|
||||
configparser
|
||||
mozdownload
|
||||
mozdownload==1.20.2
|
||||
tox==2.3.1
|
||||
flake8==2.5.4
|
||||
|
|
2
setup.py
2
setup.py
|
@ -34,7 +34,7 @@ setup(name='ff-tool',
|
|||
zip_safe=False,
|
||||
entry_points='''
|
||||
[console_scripts]
|
||||
fftool = fftool.main:menu
|
||||
ff = fftool.main:main
|
||||
''',
|
||||
**extra_options
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче