Skip to content

Commit

Permalink
Merge branch 'develop' into auto-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankpatibandla committed Mar 19, 2024
2 parents 5b80149 + 30dfe91 commit e4383ee
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 327 deletions.
18 changes: 14 additions & 4 deletions pros/cli/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import ctypes
import sys
from typing import *

import click
Expand Down Expand Up @@ -25,8 +27,12 @@ def make(project: c.Project, build_args):
analytics.send("make")
exit_code = project.compile(build_args)
if exit_code != 0:
logger(__name__).error(f"Failed to make project: Exit Code {exit_code}", extra={"sentry": False})
raise click.ClickException("Failed to build")
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')
return exit_code


Expand Down Expand Up @@ -76,6 +82,10 @@ def build_compile_commands(
build_args, cdb_file=compile_commands, suppress_output=suppress_output, sandbox=sandbox
)
if exit_code != 0:
logger(__name__).error(f"Failed to make project: Exit Code {exit_code}", extra={"sentry": False})
raise click.ClickException("Failed to build")
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')
return exit_code
40 changes: 15 additions & 25 deletions pros/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,8 @@ 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=False,
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 @@ -260,12 +250,13 @@ def callback(ctx: click.Context, param: click.Parameter, value: str):
if project_path is None:
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')
else:
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"
)
return None

return c.Project(project_path)

def wrapper(f: Union[click.Command, Callable]):
Expand Down Expand Up @@ -333,14 +324,13 @@ def resolve_v5_port(port: Optional[str], type: str, quiet: bool = False) -> Tupl
return None, False
if len(ports) > 1:
if not quiet:
port = click.prompt(
"Multiple {} ports were found. Please choose one: [{}]".format(
"v5", "|".join([p.device for p in ports])
),
default=ports[0].device,
show_default=False,
type=click.Choice([p.device for p in ports]),
)
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:
return None, False
Expand Down
Loading

0 comments on commit e4383ee

Please sign in to comment.