Skip to content

Commit

Permalink
Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankpatibandla committed Mar 19, 2024
1 parent e4383ee commit b5ee8a4
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 179 deletions.
12 changes: 6 additions & 6 deletions pros/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def make(project: c.Project, build_args):
analytics.send("make")
exit_code = project.compile(build_args)
if exit_code != 0:
if sys.platform == 'win32':
if sys.platform == "win32":
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

logger(__name__).error(f'Failed to make project: Exit Code {exit_code}', extra={'sentry': False})
raise click.ClickException('Failed to build')
logger(__name__).error(f"Failed to make project: Exit Code {exit_code}", extra={"sentry": False})
raise click.ClickException("Failed to build")
return exit_code


Expand Down Expand Up @@ -82,10 +82,10 @@ def build_compile_commands(
build_args, cdb_file=compile_commands, suppress_output=suppress_output, sandbox=sandbox
)
if exit_code != 0:
if sys.platform == 'win32':
if sys.platform == "win32":
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

logger(__name__).error(f'Failed to make project: Exit Code {exit_code}', extra={'sentry': False})
raise click.ClickException('Failed to build')
logger(__name__).error(f"Failed to make project: Exit Code {exit_code}", extra={"sentry": False})
raise click.ClickException("Failed to build")
return exit_code
37 changes: 26 additions & 11 deletions pros/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,18 @@ def callback(ctx: click.Context, param: click.Parameter, value: bool):
add_tag("no-sentry", value)
if value:
pros.common.sentry.disable_prompt()
decorator = click.option('--no-sentry', expose_value=False, is_flag=True, default=True, is_eager=True,
help="Disable sentry reporting prompt.", callback=callback, cls=PROSOption, hidden=True)(f)

decorator = click.option(
"--no-sentry",
expose_value=False,
is_flag=True,
default=True,
is_eager=True,
help="Disable sentry reporting prompt.",
callback=callback,
cls=PROSOption,
hidden=True,
)(f)
decorator.__name__ = f.__name__
return decorator

Expand Down Expand Up @@ -251,9 +261,11 @@ def callback(ctx: click.Context, param: click.Parameter, value: str):
if allow_none:
return None
elif required:
raise click.UsageError(f'{os.path.abspath(value or ".")} is not inside a PROS project. '
f'Execute this command from within a PROS project or specify it '
f'with --project project/path')
raise click.UsageError(
f'{os.path.abspath(value or ".")} is not inside a PROS project. '
f"Execute this command from within a PROS project or specify it "
f"with --project project/path"
)
else:
return None

Expand Down Expand Up @@ -324,12 +336,15 @@ def resolve_v5_port(port: Optional[str], type: str, quiet: bool = False) -> Tupl
return None, False
if len(ports) > 1:
if not quiet:
brain_id = click.prompt('Multiple {} Brains were found. Please choose one to upload the program: [{}]'
.format('v5', ' | '.join([p.product.split(' ')[-1] for p in ports])),
default=ports[0].product.split(' ')[-1],
show_default=False,
type=click.Choice([p.description.split(' ')[-1] for p in ports]))
port = [p.device for p in ports if p.description.split(' ')[-1] == brain_id][0]
brain_id = click.prompt(
"Multiple {} Brains were found. Please choose one to upload the program: [{}]".format(
"v5", " | ".join([p.product.split(" ")[-1] for p in ports])
),
default=ports[0].product.split(" ")[-1],
show_default=False,
type=click.Choice([p.description.split(" ")[-1] for p in ports]),
)
port = [p.device for p in ports if p.description.split(" ")[-1] == brain_id][0]

assert port in [p.device for p in ports]
else:
Expand Down
Loading

0 comments on commit b5ee8a4

Please sign in to comment.