Skip to content
Merged
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
27 changes: 10 additions & 17 deletions src/manage/install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)
from .fsutils import ensure_tree, rmtree, unlink
from .indexutils import Index
from .logging import LOGGER, ProgressPrinter
from .logging import CONSOLE_MAX_WIDTH, LOGGER, ProgressPrinter
from .pathutils import Path, PurePath
from .tagutils import install_matches_any, tag_or_range
from .urlutils import (
Expand All @@ -21,11 +21,6 @@
)


# TODO: Consider reading the current console width
# Though there's a solid argument we should just pick one and stick with it
CONSOLE_WIDTH = 79


# In-process cache to save repeat downloads
DOWNLOAD_CACHE = {}

Expand Down Expand Up @@ -404,7 +399,7 @@
if install["url"].casefold().endswith(".nupkg".casefold()):
package = package.with_suffix(".nupkg")

with ProgressPrinter("Downloading", maxwidth=CONSOLE_WIDTH) as on_progress:
with ProgressPrinter("Downloading", maxwidth=CONSOLE_MAX_WIDTH) as on_progress:

Check warning on line 402 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L402

Added line #L402 was not covered by tests
package = download_package(cmd, install, package, DOWNLOAD_CACHE, on_progress=on_progress)
validate_package(install, package)
if must_copy and package.parent != download_dir:
Expand Down Expand Up @@ -456,7 +451,7 @@
)
raise

with ProgressPrinter("Extracting", maxwidth=CONSOLE_WIDTH) as on_progress:
with ProgressPrinter("Extracting", maxwidth=CONSOLE_MAX_WIDTH) as on_progress:

Check warning on line 454 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L454

Added line #L454 was not covered by tests
extract_package(package, dest, on_progress=on_progress, repair=cmd.repair)

if target:
Expand Down Expand Up @@ -493,13 +488,13 @@
if s["kind"] not in cmd.disable_shortcut_kinds]
install["shortcuts"] = shortcuts

install["url"] = sanitise_url(install["url"])

Check warning on line 491 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L491

Added line #L491 was not covered by tests
if source != cmd.fallback_source:
install["source"] = sanitise_url(source)

Check warning on line 493 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L493

Added line #L493 was not covered by tests

LOGGER.debug("Write __install__.json to %s", dest)
with open(dest / "__install__.json", "w", encoding="utf-8") as f:
json.dump({
**install,
"url": sanitise_url(install["url"]),
"source": sanitise_url(source),
}, f, default=str)
json.dump(install, f, default=str)

Check warning on line 497 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L497

Added line #L497 was not covered by tests

LOGGER.verbose("Install complete")

Expand All @@ -510,13 +505,11 @@
LOGGER.error("An error occurred. Please check any output above, "
"or the log file, and try again.")
LOGGER.info("Log file for this session: !Y!%s!W!", logfile)
# TODO: Update issues URL to actual repository
LOGGER.info("If you cannot resolve it yourself, please report the error with "
"your log file at https://github.com/python/pymanager")
else:
LOGGER.error("An error occurred. Please check any output above, "
"and try again with -vv for more information.")
# TODO: Update issues URL to actual repository
LOGGER.info("If you cannot resolve it yourself, please report the error with "
"verbose output file at https://github.com/python/pymanager")
LOGGER.debug("TRACEBACK:", exc_info=True)
Expand Down Expand Up @@ -546,7 +539,7 @@
if not cmd.automatic_install:
LOGGER.debug("automatic_install is not set - exiting")
raise AutomaticInstallDisabledError()
LOGGER.info("!B!" + "*" * CONSOLE_WIDTH + "!W!")
LOGGER.info("!B!" + "*" * CONSOLE_MAX_WIDTH + "!W!")

Check warning on line 542 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L542

Added line #L542 was not covered by tests

download_index = {"versions": []}

Expand Down Expand Up @@ -737,6 +730,6 @@
finally:
if cmd.automatic:
LOGGER.info("To see all available commands, run '!G!py help!W!'")
LOGGER.info("!B!" + "*" * CONSOLE_WIDTH + "!W!")
LOGGER.info("!B!" + "*" * CONSOLE_MAX_WIDTH + "!W!")

Check warning on line 733 in src/manage/install_command.py

View check run for this annotation

Codecov / codecov/patch

src/manage/install_command.py#L733

Added line #L733 was not covered by tests

LOGGER.debug("END install_command.execute")
2 changes: 1 addition & 1 deletion src/manage/pep514utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _is_tag_managed(company_key, tag_name, *, creating=False):
raise
else:
LOGGER.warn("Attempted to clean up invalid registry key %s but "
"failed after too many attempts.", tag_name);
"failed after too many attempts.", tag_name)
return False
return True

Expand Down