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

Fixes 'make.exe.exe' typo. Adds disable sentry prompt option for VSCode. #190

Merged
merged 3 commits into from
Jan 17, 2022
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
6 changes: 3 additions & 3 deletions pros/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def version(ctx: click.Context, param, value):
@default_options
@click.option('--version', help='Displays version and exits', is_flag=True, expose_value=False, is_eager=True,
callback=version)
def cli():
pros.common.sentry.register()

@click.option('--no-sentry', help='Disables sentry reporting prompt (Made for VSCode Extension)',is_flag=True,default=False)
def cli(**kwargs):
pros.common.sentry.register(kwargs['no_sentry'])

if __name__ == '__main__':
main()
12 changes: 7 additions & 5 deletions pros/common/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pros.config.cli_config import CliConfig # noqa: F401, flake8 issue, flake8 issue with "if TYPE_CHECKING"

cli_config: 'CliConfig' = None

global force_prompt_off
SUPPRESSED_EXCEPTIONS = [PermissionError, click.Abort]


Expand All @@ -22,7 +22,9 @@ def prompt_to_send(event: Dict[str, Any], hint: Optional[Dict[str, Any]]) -> Opt
with ui.Notification():
if cli_config is None or (cli_config.offer_sentry is not None and not cli_config.offer_sentry):
return

if force_prompt_off:
ui.logger(__name__).debug('Sentry prompt was forced off through click option')
return
if 'extra' in event and not event['extra'].get('sentry', True):
ui.logger(__name__).debug('Not sending candidate event because event was tagged with extra.sentry = False')
return
Expand Down Expand Up @@ -107,9 +109,9 @@ def add_tag(key: str, value: str):
scope.set_tag(key, value)


def register(cfg: Optional['CliConfig'] = None):
global cli_config, client

def register(force_off, cfg: Optional['CliConfig'] = None):
global cli_config, client, force_prompt_off
force_prompt_off = force_off
if cfg is None:
from pros.config.cli_config import cli_config as get_cli_config
cli_config = get_cli_config()
Expand Down
4 changes: 2 additions & 2 deletions pros/conductor/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def make(self, build_args: List[str]):
except Exception as e:
if not os.environ.get('PROS_TOOLCHAIN'):
ui.logger(__name__).warn("PROS toolchain not found! Please ensure the toolchain is installed correctly and your environment variables are set properly.\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}.exe' WITH EXCEPTION: {str(e)}\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}' WITH EXCEPTION: {str(e)}\n",extra={'sentry':False})
stdout_pipe.close()
stderr_pipe.close()
sys.exit()
Expand Down Expand Up @@ -290,7 +290,7 @@ def libscanbuild_capture(args: argparse.Namespace) -> Tuple[int, Iterable[Compil
except Exception as e:
if not os.environ.get('PROS_TOOLCHAIN'):
ui.logger(__name__).warn("PROS toolchain not found! Please ensure the toolchain is installed correctly and your environment variables are set properly.\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}.exe' WITH EXCEPTION: {str(e)}\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}' WITH EXCEPTION: {str(e)}\n",extra={'sentry':False})
if not suppress_output:
pipe.close()
sys.exit()
Expand Down