mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 02:27:13 +02:00
Handle "AbortedByUser" exception
This commit is contained in:
@ -7,8 +7,7 @@ from shutil import copyfile
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from platformio import app
|
from platformio import app, exception
|
||||||
from platformio.exception import ProjectInitialized, UnknownBoard
|
|
||||||
from platformio.util import get_boards, get_source_dir
|
from platformio.util import get_boards, get_source_dir
|
||||||
|
|
||||||
|
|
||||||
@ -24,11 +23,12 @@ def cli(project_dir, board, disable_auto_uploading):
|
|||||||
src_dir = join(project_dir, "src")
|
src_dir = join(project_dir, "src")
|
||||||
lib_dir = join(project_dir, "lib")
|
lib_dir = join(project_dir, "lib")
|
||||||
if all([isfile(project_file), isdir(src_dir), isdir(lib_dir)]):
|
if all([isfile(project_file), isdir(src_dir), isdir(lib_dir)]):
|
||||||
raise ProjectInitialized()
|
raise exception.ProjectInitialized()
|
||||||
|
|
||||||
builtin_boards = set(get_boards().keys())
|
builtin_boards = set(get_boards().keys())
|
||||||
if board and not set(board).issubset(builtin_boards):
|
if board and not set(board).issubset(builtin_boards):
|
||||||
raise UnknownBoard(", ".join(set(board).difference(builtin_boards)))
|
raise exception.UnknownBoard(
|
||||||
|
", ".join(set(board).difference(builtin_boards)))
|
||||||
|
|
||||||
# ask about auto-uploading
|
# ask about auto-uploading
|
||||||
if board and app.get_setting("enable_prompts"):
|
if board and app.get_setting("enable_prompts"):
|
||||||
@ -80,7 +80,7 @@ def cli(project_dir, board, disable_auto_uploading):
|
|||||||
fg="green"
|
fg="green"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
click.secho("Aborted by user", fg="red")
|
raise exception.AbortedByUser()
|
||||||
|
|
||||||
|
|
||||||
def fill_project_envs(project_file, board_types, disable_auto_uploading):
|
def fill_project_envs(project_file, board_types, disable_auto_uploading):
|
||||||
|
@ -13,6 +13,11 @@ class PlatformioException(Exception):
|
|||||||
return Exception.__str__(self)
|
return Exception.__str__(self)
|
||||||
|
|
||||||
|
|
||||||
|
class AbortedByUser(PlatformioException):
|
||||||
|
|
||||||
|
MESSAGE = "Aborted by user"
|
||||||
|
|
||||||
|
|
||||||
class UnknownPlatform(PlatformioException):
|
class UnknownPlatform(PlatformioException):
|
||||||
|
|
||||||
MESSAGE = "Unknown platform '%s'"
|
MESSAGE = "Unknown platform '%s'"
|
||||||
|
Reference in New Issue
Block a user