Skip to content

Commit

Permalink
- Auto Hold update for tag version install
Browse files Browse the repository at this point in the history
- Show HOLD_UPDATE for hold state in `ls`
- Better request session
  • Loading branch information
Rishang committed Nov 5, 2023
1 parent b599d95 commit b0c6ae0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
13 changes: 10 additions & 3 deletions InstallRelease/cli_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
isNone,
threads,
PackageVersion,
requests_session,
)

from InstallRelease.core import get_release, extract_release, install_bin, GithubInfo
Expand Down Expand Up @@ -145,12 +146,16 @@ def get(
if yn.lower() != "y":
return
else:
pprint("[magenta]Downloading...[/magenta]")
pprint("\n[magenta]Downloading...[/magenta]")

extract_release(item=_gr, at=at.name)

releases[0].assets = [_gr]

# hold update if tag_name is not empty
if tag_name != "":
releases[0].hold_update = True

mkdir(dest)
install_bin(src=at.name, dest=dest, local=local, name=toolname)

Expand Down Expand Up @@ -257,7 +262,9 @@ def list_install(
_table.append(
{
"Name": i.name,
"Version": state[key].tag_name,
"Version": state[key].tag_name + f"[yellow] *HOLD_UPDATE*[/yellow]"
if state[key].hold_update == True
else state[key].tag_name,
"Url": state[key].url,
}
)
Expand Down Expand Up @@ -315,7 +322,7 @@ def pull_state(url: str = "", override: bool = False):
if isNone(url):
return

r: dict = requests.get(url=url).json()
r: dict = requests_session.get(url=url).json()

data: dict = {k: GithubRelease(**r[k]) for k in r}
state: TypeState = cache.state
Expand Down
6 changes: 4 additions & 2 deletions InstallRelease/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
# locals
from InstallRelease.constants import _colors

requests_session = requests.Session()

console = Console()


Expand Down Expand Up @@ -97,7 +99,7 @@ def latest_version(self):
if self._latest_version != None:
return self._latest_version

response = requests.get(self.url)
response = requests_session.get(self.url)
logger.debug(
f"pipi response for package '{self.package_name}': " + str(response)
)
Expand Down Expand Up @@ -211,7 +213,7 @@ def mkdir(path: str):
def download(url: str, at: str):
"""Download a file"""

file = requests.get(url, stream=True)
file = requests_session.get(url, stream=True)
if not os.path.exists(at):
os.makedirs(at)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ in-project = true

[tool.poetry]
name = "install-release"
version = "0.3.8"
version = "0.3.9"
readme = "README.md"
description = "A cli tool to install tools based on your device info directly from github releases and keep them updated."
authors = ["Rishang <[email protected]>"]
Expand Down

0 comments on commit b0c6ae0

Please sign in to comment.