mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
No issue: convert to argparse in setup-startup-profiling.py.
This commit is contained in:
parent
8cd4db6762
commit
0201120c61
@ -9,13 +9,11 @@ https://profiler.firefox.com/docs/#/./guide-remote-profiling?id=startup-profilin
|
|||||||
for more information.
|
for more information.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
|
|
||||||
SCRIPT_NAME = os.path.basename(__file__)
|
|
||||||
|
|
||||||
PATH_PREFIX = '/data/local/tmp'
|
PATH_PREFIX = '/data/local/tmp'
|
||||||
|
|
||||||
GV_CONFIG = b'''env:
|
GV_CONFIG = b'''env:
|
||||||
@ -26,10 +24,17 @@ GV_CONFIG = b'''env:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def print_usage_and_exit():
|
def parse_args():
|
||||||
print('USAGE: ./{} [activate|deactivate] [nightly|beta|release|debug]'.format(SCRIPT_NAME), file=sys.stderr)
|
p = argparse.ArgumentParser(
|
||||||
print('example: ./{} activate nightly'.format(SCRIPT_NAME), file=sys.stderr)
|
description=("Easily enable start up profiling using the Firefox Profiler. Finish capturing the profile in "
|
||||||
sys.exit(1)
|
"about:debugging on desktop. See "
|
||||||
|
"https://profiler.firefox.com/docs/#/./guide-remote-profiling?id=startup-profiling for "
|
||||||
|
"details."))
|
||||||
|
p.add_argument('command', choices=['activate', 'deactivate'], help=("whether to activate or deactive start up "
|
||||||
|
"profiling for the given release channel"))
|
||||||
|
p.add_argument('release_channel', choices=['nightly', 'beta', 'release', 'debug'], help=("the release channel to "
|
||||||
|
"change the startup profiling state of the command on"))
|
||||||
|
return p.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def push(id, filename):
|
def push(id, filename):
|
||||||
@ -69,21 +74,15 @@ def convert_channel_to_id(channel):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
args = parse_args()
|
||||||
cmd = sys.argv[1]
|
|
||||||
channel = sys.argv[2]
|
|
||||||
id = convert_channel_to_id(channel)
|
|
||||||
except (IndexError, KeyError) as e:
|
|
||||||
print_usage_and_exit()
|
|
||||||
|
|
||||||
|
id = convert_channel_to_id(args.release_channel)
|
||||||
filename = id + '-geckoview-config.yaml'
|
filename = id + '-geckoview-config.yaml'
|
||||||
|
|
||||||
if cmd == 'activate':
|
if args.command == 'activate':
|
||||||
push(id, filename)
|
push(id, filename)
|
||||||
elif cmd == 'deactivate':
|
elif args.command == 'deactivate':
|
||||||
remove(filename)
|
remove(filename)
|
||||||
else:
|
|
||||||
print_usage_and_exit()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user