pros-cli
pros-cli copied to clipboard
✨Create new project without internet
Summary:
- Added 'download-ok' switch to
new-project
to decide if remote templates can be used in creating projects - Put some lines from
new-project
into new helper function_create_project
for this purpose (and to make click happy) - Due to a generic Exception being raised when there is no internet connection (instead of an actual ConnectionError for some reason), added a nested try and except statement to attempt a new project with local templates if remote templates cannot be reached, raises another exception if that fails
- Fixed
resolved_templates
so that it actually takes into account whether 'download-ok' is true or false before downloading from remote - "Can't GitHub" error could be placed before the output telling user which templates are used, but I'm not sure how to place it as I don't want it to trigger before a potential Exception due to something that is NOT a lack of internet
- Removed
allow_online: bool = True
from top ofresolve_templates
to make above features work - Removed
allow_online=download_ok
fromtemplate = self.resolve_template(identifier=identifier, allow_online=download_ok, **kwargs)
becauseresolve_templates
now takes 'download_ok' into account seperately
Motivation:
Let users make new project from local templates without internet
References (optional):
Closes #91
Test Plan:
-
(With internet) Purge templates, download 2nd most recent versions of okapilib and kernel, then run
pros c n . --no-download
to demonstrate that the most recent remote templates are not applied, and the local templates are used instead -
(Without internet) Create a new project with
pros c n .
. There will be an error that alerts the user that the CLI can't connect to GitHub, and it creates a project with the local templates you have instead. -
(Without internet)
pros c n . --download
. Even if --download is specified, if there is no internet it creates from local templates without problem. -
(With internet)
pros c n .
. Newest versions of templates from remote are automatically downloaded and applied as usual. -
(Without internet)
pros c n .
creates a new project with the most recent local templates.
I'd rather just fix resolve_templates
to always be OK if a remote depot is unavailable.
e.g. try block around: https://github.com/purduesigbots/pros-cli/blob/1d9f6bae72b7e44ca4329d337b3921b7c41ae6df/pros/conductor/conductor.py#L119-L124
I'd rather just fix
resolve_templates
to always be OK if a remote depot is unavailable.e.g. try block around:
https://github.com/purduesigbots/pros-cli/blob/1d9f6bae72b7e44ca4329d337b3921b7c41ae6df/pros/conductor/conductor.py#L119-L124
When I try to have the try in resolve_templates it generates a bunch of error messages, seemingly because it doesn't like calling itself... but makes the project anyways? I have no idea
I'm not seeing the try except block anywhere, have you pushed it yet? Also, what are you doing with the exception after catching it? It seems like it's just getting printed and moving on.
With internet
No internet
There's not really an easy way to get rid of the duplicate warnings but I think that having them is better than not having any indication of no connection at all.