pros-cli icon indicating copy to clipboard operation
pros-cli copied to clipboard

✨Create new project without internet

Open omegaStag opened this issue 3 years ago • 4 comments

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 of resolve_templates to make above features work
  • Removed allow_online=download_ok from template = self.resolve_template(identifier=identifier, allow_online=download_ok, **kwargs) because resolve_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:

  1. (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 image

  2. (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. image

  3. (Without internet) pros c n . --download. Even if --download is specified, if there is no internet it creates from local templates without problem. image

  4. (With internet) pros c n .. Newest versions of templates from remote are automatically downloaded and applied as usual. image

  5. (Without internet) pros c n . creates a new project with the most recent local templates. image

omegaStag avatar Oct 29 '21 02:10 omegaStag

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

edjubuh avatar Nov 01 '21 03:11 edjubuh

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

image

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

omegaStag avatar Nov 27 '21 17:11 omegaStag

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.

WillXuCodes avatar Nov 29 '21 17:11 WillXuCodes

With internet image

No internet image 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.

omegaStag avatar Dec 27 '21 15:12 omegaStag