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

🔖 Release 3.5.0 #316

Closed
wants to merge 16 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
- name: Update Build Number
id: step1
run: |
git describe --tags
git clean -f
python3 version.py
echo "::set-output name=test::$(cat version)"

Expand Down
2 changes: 1 addition & 1 deletion pip_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.2
3.4.3
3 changes: 2 additions & 1 deletion pros/cli/click_classes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from collections import defaultdict
from typing import *

from rich_click import RichCommand
import click.decorators
from click import ClickException
from pros.conductor.project import Project as p
from pros.common.utils import get_version


class PROSFormatted(click.BaseCommand):
class PROSFormatted(RichCommand):
"""
Common format functions used in the PROS derived classes. Derived classes mix and match which functions are needed
"""
Expand Down
5 changes: 4 additions & 1 deletion pros/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def resolve_v5_port(port: Optional[str], type: str, quiet: bool = False) -> Tupl
is_joystick = False
if not port:
ports = find_v5_ports(type)
logger(__name__).debug('Ports: {}'.format(';'.join([str(p.__dict__) for p in ports])))
if len(ports) == 0:
if not quiet:
logger(__name__).error('No {0} ports were found! If you think you have a {0} plugged in, '
Expand All @@ -252,8 +253,10 @@ 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'),
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]))
assert port in [p.device for p in ports]
else:
Expand Down
78 changes: 62 additions & 16 deletions pros/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pros.conductor.templates import ExternalTemplate
from pros.ga.analytics import analytics


@pros_root
def conductor_cli():
pass
Expand Down Expand Up @@ -90,8 +91,8 @@ def fetch(query: c.BaseTemplate):
help="Force apply the template, disregarding if the template is already installed.")
@click.option('--remove-empty-dirs/--no-remove-empty-dirs', 'remove_empty_directories', is_flag=True, default=True,
help='Remove empty directories when removing files')
@click.option('--beta', is_flag=True, default=False, show_default=True,
help='Allow applying beta templates')
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
help='Create a project using the PROS 4 kernel')
@project_option()
@template_query(required=True)
@default_options
Expand All @@ -116,8 +117,6 @@ def apply(project: c.Project, query: c.BaseTemplate, **kwargs):
help="Force apply the template, disregarding if the template is already installed.")
@click.option('--remove-empty-dirs/--no-remove-empty-dirs', 'remove_empty_directories', is_flag=True, default=True,
help='Remove empty directories when removing files')
@click.option('--beta', is_flag=True, default=False, show_default=True,
help='Allow applying beta templates')
@project_option()
@template_query(required=True)
@default_options
Expand All @@ -143,8 +142,8 @@ def install(ctx: click.Context, **kwargs):
help="Force apply the template, disregarding if the template is already installed.")
@click.option('--remove-empty-dirs/--no-remove-empty-dirs', 'remove_empty_directories', is_flag=True, default=True,
help='Remove empty directories when removing files')
@click.option('--beta', is_flag=True, default=False, show_default=True,
help='Allow upgrading to beta templates')
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
help='Create a project using the PROS 4 kernel')
@project_option()
@template_query(required=False)
@default_options
Expand Down Expand Up @@ -205,8 +204,8 @@ def uninstall_template(project: c.Project, query: c.BaseTemplate, remove_user: b
help='Compile the project after creation')
@click.option('--build-cache', is_flag=True, default=None, show_default=False,
help='Build compile commands cache after creation. Overrides --compile-after if both are specified.')
@click.option('--beta', is_flag=True, default=False, show_default=True,
help='Create a project with a beta template')
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
help='Create a project using the PROS 4 kernel')
@click.pass_context
@default_options
def new_project(ctx: click.Context, path: str, target: str, version: str,
Expand All @@ -218,6 +217,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
analytics.send("new-project")
version_source = version.lower() == 'latest'
if version.lower() == 'latest' or not version:
version = '>0'
if not force_system and c.Project.find_project(path) is not None:
Expand All @@ -228,7 +228,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
_conductor = c.Conductor()
if target is None:
target = _conductor.default_target
project = _conductor.new_project(path, target=target, version=version,
project = _conductor.new_project(path, target=target, version=version, version_source=version_source,
force_user=force_user, force_system=force_system,
no_default_libs=no_default_libs, **kwargs)
ui.echo('New PROS Project was created:', output_machine=False)
Expand All @@ -237,7 +237,10 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
if compile_after or build_cache:
with ui.Notification():
ui.echo('Building project...')
ctx.exit(project.compile([], scan_build=build_cache))
exit_code = project.compile([], scan_build=build_cache)
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')

except Exception as e:
pros.common.logger(__name__).exception(e)
Expand All @@ -255,13 +258,13 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
help='Force update all remote depots, ignoring automatic update checks')
@click.option('--limit', type=int, default=15,
help='The maximum number of displayed results for each library')
@click.option('--beta', is_flag=True, default=False, show_default=True,
help='View beta templates in the listing')
@click.option('--early-access/--disable-early-access', '--early/--disable-early', '-ea/-dea', 'early_access', '--beta/--disable-beta', default=None,
help='View a list of early access templates')
@template_query(required=False)
@click.pass_context
@default_options
def query_templates(ctx, query: c.BaseTemplate, allow_offline: bool, allow_online: bool, force_refresh: bool,
limit: int, beta: bool):
limit: int, early_access: bool):
"""
Query local and remote templates based on a spec

Expand All @@ -271,10 +274,10 @@ def query_templates(ctx, query: c.BaseTemplate, allow_offline: bool, allow_onlin
if limit < 0:
limit = 15
templates = c.Conductor().resolve_templates(query, allow_offline=allow_offline, allow_online=allow_online,
force_refresh=force_refresh, beta=beta)
if beta:
force_refresh=force_refresh, early_access=early_access)
if early_access:
templates += c.Conductor().resolve_templates(query, allow_offline=allow_offline, allow_online=allow_online,
force_refresh=force_refresh, beta=False)
force_refresh=force_refresh, early_access=False)

render_templates = {}
for template in templates:
Expand Down Expand Up @@ -323,3 +326,46 @@ def info_project(project: c.Project, ls_upgrades):
template["upgrades"] = sorted({t.version for t in templates}, key=lambda v: semver.Version(v), reverse=True)

ui.finalize('project-report', report)

@conductor.command('add-depot')
@click.argument('name')
@click.argument('url')
@default_options
def add_depot(name: str, url: str):
"""
Add a depot

Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
_conductor = c.Conductor()
_conductor.add_depot(name, url)

ui.echo(f"Added depot {name} from {url}")

@conductor.command('remove-depot')
@click.argument('name')
@default_options
def remove_depot(name: str):
"""
Remove a depot

Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
_conductor = c.Conductor()
_conductor.remove_depot(name)

ui.echo(f"Removed depot {name}")

@conductor.command('query-depots')
@click.option('--url', is_flag=True)
@default_options
def query_depots(url: bool):
"""
Gets all the stored depots

Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
_conductor = c.Conductor()
ui.echo(f"Available Depots{' (Add --url for the url)' if not url else ''}:\n")
ui.echo('\n'.join(_conductor.query_depots(url))+"\n")

7 changes: 6 additions & 1 deletion pros/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pros.common.sentry

import click
import ctypes
import sys

import pros.common.ui as ui
Expand All @@ -27,6 +28,10 @@
import pros.cli.interactive
import pros.cli.user_script

if sys.platform == 'win32':
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

root_sources = [
'build',
'conductor',
Expand Down Expand Up @@ -63,7 +68,7 @@ def main():
.format(version = get_version()), ctx_obj)
click_handler.setFormatter(formatter)
logging.basicConfig(level=logging.WARNING, handlers=[click_handler])
cli.main(prog_name='pros', obj=ctx_obj)
cli.main(prog_name='pros', obj=ctx_obj, windows_expand_args=False)
except KeyboardInterrupt:
click.echo('Aborted!')
except Exception as e:
Expand Down
5 changes: 5 additions & 0 deletions pros/cli/misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def upgrade(force_check, no_install):
"""
Check for updates to the PROS CLI
"""
with ui.Notification():
ui.echo('The "pros upgrade" command is currently non-functioning. Did you mean to run "pros c upgrade"?', color='yellow')

return # Dead code below

analytics.send("upgrade")
from pros.upgrade import UpgradeManager
manager = UpgradeManager()
Expand Down
2 changes: 2 additions & 0 deletions pros/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def upload(path: Optional[str], project: Optional[c.Project], port: str, **kwarg

# apply upload_options as a template
options = dict(**project.upload_options)
if 'port' in options and port is None:
port = options.get('port', None)
if 'slot' in options and kwargs.get('slot', None) is None:
kwargs.pop('slot')
elif kwargs.get('slot', None) is None:
Expand Down
Loading
Loading