Skip to content

Commit

Permalink
3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
SirDank committed Dec 17, 2023
1 parent 9c17506 commit 55bd9f8
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 5 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@

---

# 🚨 Windows Software Downloader / Updater 🚨

- A simple tool to download and update windows software using [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/)

## ♦️ Preview ♦️

<br><p align="center"><img width="800" alt="image" src="https://github.com/SirDank/dank.tool/assets/52797753/aee3f2bd-834a-4fbc-b8f1-b8fd43126434"></p><br>

<p>&nbsp;</p>

---

# 🚨 Windows / Office Activator 🚨

- Full credits to [massgravel](https://github.com/massgravel/Microsoft-Activation-Scripts) for their amazing work!
Expand Down Expand Up @@ -384,6 +396,19 @@
└─📄 package-updater.cmd [ script I use to quickly update all packages used by the dank.tool before I build the latest version ]
```

## ⭕ Completely Offline Installation & Usage Guide ⭕

- [Download repository](https://github.com/SirDank/dank.tool/archive/refs/heads/main.zip)
- Turn off wifi (to prevent the dank.tool from connecting to the internet)
- Extract the dank.tool.zip and run the installer, finish installation and run the dank.tool
- After it says "Failed to get code", move the dank.tool.py script from the `__src__` folder to the `__src__` folder at the install location
- List of offline modules can be found [here](https://github.com/SirDank/dank.tool/blob/main/__src__/dank.tool.py#L199)
- Move all scripts (except the ones available offline) from the `__modules__` folder to the `__local_modules__` folder at the install location
- Move all (offline) scripts from the `__modules__` folder to the `__modules__` folder at the install location
- Edit the `settings.json` file at the install location and set `"offline-src": "1"` and `"offline_mode": "1"`
- Hit enter on the dank.tool and enjoy offline dank.tool!
- Note: If you want to switch back to online mode to enable updates and use the latest modules, first delete the `__local_modules__` folder at the install location and then set `"offline-src": "0"` and `"offline_mode": "0"` in the `settings.json` file at the install location.

## ⭕ Build Process ⭕

- dank.tool is built using [nuitka](https://github.com/Nuitka/Nuitka) and [inno-setup](https://jrsoftware.org/isinfo.php) by a custom python executable builder designed by me which is not available to the public. ( It is an advanced tool that automates the entire build process for any executable that I produce )
Expand Down
151 changes: 151 additions & 0 deletions __modules__/dank.winget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import os
import subprocess
from rich.panel import Panel
from rich.columns import Columns
from rich.console import Console
from dankware import title, cls, clr, align, rm_line
from dankware import white, white_normal, red, red_normal, red_dim, green

def winget_installed():
try:
result = subprocess.run(['winget', '--info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode == 0:
return True
else:
return False
except FileNotFoundError:
return False

def print_banner():
banner = "\n\n _ _ _ _ \n _| |___ ___| |_ _ _ _|_|___ ___ ___| |_ \n| . | .'| | '_|_| | | | | | . | -_| _|\n|___|__,|_|_|_,_|_|_____|_|_|_|_ |___|_| \n |___| \n\n\n"
cls(); print(clr(align(banner),4,colours=[white, white_normal, red, red_normal, red_dim]))
print(clr(" [ Commands ]\n\n - search NAME (to find software)\n\n - installed (installed software, winget only)\n\n - updates\n\n - clear (refresh screen)\n\n - exit\n"))

def handle_response(cmd, results, mode):

cmd = cmd.stdout.decode('utf-8').split('Source')[1].splitlines()[2:]
indexes = []

prev = ''
for index, char in enumerate(cmd[0]):
if prev == ' ' and char != ' ':
indexes.append(index)
prev = char
for line in cmd[1:]:
prev = ''
for index, char in enumerate(line):
if prev == ' ' and char != ' ' and index in indexes:
indexes.append(index)
prev = char

max_count = max([indexes.count(_) for _ in sorted(list(set(indexes)))])
indexes = [_ for _ in sorted(list(set(indexes))) if indexes.count(_) == max_count]
indexes.insert(0,0)
results.clear()
index = 1

for line in cmd:
parts = [line[i:j] for i,j in zip(indexes, indexes[1:]+[None])]
if '.' in parts[1].strip():
results[index] = {'name': parts[0].strip(), 'id': parts[1].strip()}#, 'version': parts[2].strip(), 'source': parts[3].strip()}
index += 1

console = Console()
user_renderables = [f"[b][bright_white]{key} [bright_red]- [bright_white]{value['name']}[/b]" for key, value in results.items()]
results['mode'] = mode; print()
console.print(Panel(title=f"[red1]> [bright_white][b]R E S U L T S[/b] [red1]<", title_align="center", renderable=Columns(user_renderables, expand=True), style="bright_red", expand=True))

if mode == 'search':
print(clr("\n - Type number to install.\n"))
elif mode == 'installed':
print(clr("\n - Type number to display info.\n"))
elif mode == 'updates':
print(clr("\n - Type number to update.\n"))

def print_info(id):
cmd = subprocess.run(['winget', 'show', '--id', id], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if cmd.returncode == 0:
print(clr(cmd.stdout.decode('utf-8')))
else:
print(clr(f"\n [ERROR]: {cmd.stderr.decode('utf-8')}\n",2))

def main():

results = {}
print_banner()

while True:

cmd = input(clr(' > ') + green)

if cmd.lower().startswith('search '):
cmd = subprocess.run(['winget', 'search', '--accept-source-agreements', cmd[7:]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if cmd.returncode == 0:
handle_response(cmd, results, 'search')
else:
print(clr(f"\n [ERROR]: {cmd.stderr.decode('utf-8')}\n",2))

elif cmd.lower().startswith('installed'):
cmd = subprocess.run(['winget', 'list', '--accept-source-agreements'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if cmd.returncode == 0:
handle_response(cmd, results, 'installed')
else:
print(clr(f"\n [ERROR]: {cmd.stderr.decode('utf-8')}\n",2))

elif cmd.lower().startswith('updates'):
cmd = subprocess.run(['winget', 'upgrade', '--accept-source-agreements'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if cmd.returncode == 0:
handle_response(cmd, results, 'updates')
else:
print(clr(f"\n [ERROR]: {cmd.stderr.decode('utf-8')}\n",2))

elif cmd.isdigit():

if results:
cmd = int(cmd)
if cmd in results.keys():

if results['mode'] == 'search':
if input(clr("\n > Display info? [y/n]: ") + green).lower().startswith('y'):
print_info(results[cmd]['id'])
else: rm_line(); rm_line()
if input(clr("\n > Install? [y/n]: ") + green).lower().startswith('y'):
print()
os.system(f"winget install --interactive --id {results[cmd]['id']}")
print()
else: rm_line()

elif results['mode'] == 'installed':
print_info(results[cmd]['id'])

elif results['mode'] == 'updates':
print()
os.system(f"winget upgrade --interactive --id {results[cmd]['id']}")
print()

else: rm_line()
else: rm_line()
else: rm_line()

elif cmd.lower().startswith('clear'):
print_banner()

elif cmd.lower().startswith('exit'):
break

else:
rm_line()

if __name__ == "__main__":

title("𝚍𝚊𝚗𝚔.𝚠𝚒𝚗𝚐𝚎𝚝")

if os.name != 'nt':
input(clr("\n - This module only works for Windows! Press ENTER to exit... ",2))
elif not winget_installed():
input(clr("\n - This module requires winget to be installed! Press ENTER to exit... ",2))
else:
main()

if "DANK_TOOL_VERSION" in os.environ:
del main, winget_installed, print_banner, handle_response, print_info
10 changes: 9 additions & 1 deletion __src__/dank.tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ def set_globals_two():

translate('Windows OS Tools'): {

translate('Software Downloader / Updater'): {
'info': menu_request_responses["dank.winget"],
'title': "𝚍𝚊𝚗𝚔.𝚠𝚒𝚗𝚐𝚎𝚝",
'project': "dank.winget",
'rpc': "installing / updating software"
},

translate('Windows / Office Activator'): {
'info': menu_request_responses["Microsoft-Activation-Scripts"],
'title': "𝚍𝚊𝚗𝚔.𝚠𝚒𝚗-𝚊𝚌𝚝𝚒𝚟𝚊𝚝𝚎",
Expand Down Expand Up @@ -502,7 +509,8 @@ def translate(text):
"dank.auto-clicker",
"dank.browser-backup",
"dank.fusion-fall",
"dank.game"
"dank.game",
"dank.winget"
)
)

Expand Down
8 changes: 5 additions & 3 deletions __src__/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

# variables

DANK_TOOL_VERSION = "3.2.1"
DANK_TOOL_VERSION = "3.2.2"
session = requests.Session()
_executor = ThreadPoolExecutor(10)
headers = {"User-Agent": "dank.tool"}
Expand Down Expand Up @@ -134,6 +134,8 @@ def latest_dank_tool_version():
print(clr("\n - Please do not use the dev-branch, it is meant for testing/debugging only!",2))
global BRANCH; BRANCH = "main"
os.environ['DANK_TOOL_DEV_BRANCH'] = "0"
tmp = open('settings.json', 'r', encoding='utf-8').read().replace('"dev-branch": "1"', '"dev-branch": "0"')
open('settings.json', 'w', encoding='utf-8').write(tmp); del tmp
else:
break
os.environ['DANK_TOOL_ONLINE'] = "1"
Expand Down Expand Up @@ -231,7 +233,7 @@ def check_windows_language():
if not os.path.isdir('__modules__'): os.mkdir('__modules__')
if not os.path.isdir('__local_modules__'): os.mkdir('__local_modules__')

if not OFFLINE_SRC and ( ONLINE_MODE or not os.path.isfile('__src__/dank.tool.py') ):
if not OFFLINE_SRC and ONLINE_MODE:
while True:
try: code = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/{BRANCH}/__src__/dank.tool.py", headers=headers).content.decode(); break
except: input(clr("\n > Failed to get code! Make sure you are connected to the internet! Press [ENTER] to try again... ",2))
Expand Down Expand Up @@ -282,7 +284,7 @@ def dank_tool_runs_counter():
try: session.get("https://dank-site.onrender.com/counter?id=dank.tool&hit=true", headers=headers); break
except: fail_counter += 1
time.sleep(60)

if ONLINE_MODE:
_executor.submit(dank_tool_runs_counter)
else:
Expand Down
2 changes: 1 addition & 1 deletion __src__/executor_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.2.2
Binary file modified dank.tool.zip
Binary file not shown.

0 comments on commit 55bd9f8

Please sign in to comment.