-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathmain.py
executable file
·64 lines (49 loc) · 2.07 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# utils/profdata_merge/main.py
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
# This module is used to prevent profile data filling up available disk space
# by listening for profile data and merging them into a universal profdata
# file while tests are executing.
# This file invokes the runner after parsing arguments.
from __future__ import print_function
import argparse
import logging
import sys
import tempfile
import runner
SERVER_ADDRESS = ('localhost', 12400)
TESTS_FINISHED_SENTINEL = "PROFDATA_MERGE_WORKER_TESTS_FINISHED_SENTINEL"
if __name__ == "__main__":
if sys.platform != "darwin":
sys.exit("Error: The profile data merge worker requires OS X.")
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--log-file",
help="The file to write logs in debug mode.")
subparsers = parser.add_subparsers()
start = subparsers.add_parser("start")
start.add_argument("-d", "--debug",
help="Run in foreground and report status.",
action="store_true")
start.add_argument("-o", "--output-dir",
help=("The directory to write the PID file" +
"and final profdata file."),
default=tempfile.gettempdir())
start.add_argument("--no-remove",
action="store_true",
help="Don't remove profraw files after merging them.")
start.set_defaults(func=runner.start_server)
stop = subparsers.add_parser("stop")
stop.set_defaults(func=runner.stop_server)
args = parser.parse_args()
log_args = {'level': logging.DEBUG}
if args.log_file:
log_args['filename'] = args.log_file
logging.basicConfig(**log_args)
args.func(args)