2018-11-01 18:06:07 +03:00
|
|
|
#!/usr/bin/env python3
|
2019-06-20 02:58:25 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2018-11-01 18:06:07 +03:00
|
|
|
#
|
2019-06-20 02:58:25 +03:00
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
2018-11-01 18:06:07 +03:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
from . import cmd_util, subcmd as subcmd_mod
|
|
|
|
from .subcmd import Subcmd
|
|
|
|
from .trace_cmd import trace_cmd
|
|
|
|
|
|
|
|
|
|
|
|
@trace_cmd("enable", "Enable tracing")
|
|
|
|
class EnableTraceCmd(Subcmd):
|
|
|
|
def run(self, args: argparse.Namespace) -> int:
|
|
|
|
instance = cmd_util.get_eden_instance(args)
|
|
|
|
with instance.get_thrift_client() as client:
|
|
|
|
client.enableTracing()
|
2018-11-13 07:23:19 +03:00
|
|
|
return 0
|
2018-11-01 18:06:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
@trace_cmd("disable", "Disable tracing")
|
|
|
|
class DisableTraceCmd(Subcmd):
|
|
|
|
def run(self, args: argparse.Namespace) -> int:
|
|
|
|
instance = cmd_util.get_eden_instance(args)
|
|
|
|
with instance.get_thrift_client() as client:
|
|
|
|
client.disableTracing()
|
2018-11-13 07:23:19 +03:00
|
|
|
return 0
|
2018-11-01 18:06:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
@subcmd_mod.subcmd("trace", "Commands for managing eden tracing")
|
|
|
|
class TraceCmd(Subcmd):
|
2019-08-30 23:28:14 +03:00
|
|
|
# pyre-fixme[13]: Attribute `parser` is never initialized.
|
2018-11-13 07:23:19 +03:00
|
|
|
parser: argparse.ArgumentParser
|
|
|
|
|
2018-11-01 18:06:07 +03:00
|
|
|
def setup_parser(self, parser: argparse.ArgumentParser) -> None:
|
|
|
|
self.parser = parser
|
|
|
|
self.add_subcommands(parser, trace_cmd.commands)
|
|
|
|
|
|
|
|
def run(self, args: argparse.Namespace) -> int:
|
|
|
|
self.parser.print_help()
|
|
|
|
return 0
|