Skip to content

Commit 5bf6aa4

Browse files
authored
Merge pull request #1 from Tracks12:dev
Dev
2 parents e729c2a + a984bd1 commit 5bf6aa4

File tree

9 files changed

+50
-12
lines changed

9 files changed

+50
-12
lines changed

core/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"version": "0.1"
1515
})
1616

17-
REGEX_ARGS = str("\\s(?=(?:[^\"'`]*[\"'`][^\"'`]*[\"'`])*[^\"'`]*$)")
17+
REGEX_ARGS = str("\\s(?=(?:[^\"'`]*[\"'`][^\"'`]*[\"'`])*[^\"'`]*$)")
18+
UNITS = tuple[str](("o", "ko", "Mo", "Go", "To"))
1819

1920
def helper(commands: tuple) -> None:
2021
colors = tuple[str]((Colors.cyan, Colors.yellow, Colors.red))

libs/wslbuilder/archlinux.ico

66.1 KB
Binary file not shown.

libs/wslbuilder/debian.ico

66.1 KB
Binary file not shown.

libs/wslbuilder/fedora.ico

66.1 KB
Binary file not shown.

libs/wslbuilder/ubuntu.ico

66.1 KB
Binary file not shown.

libs/wslbuilder/wslbuilder.tar

2.24 MB
Binary file not shown.

main.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,20 @@ def config(cfg: Config) -> bool:
103103
print(f"{Icons.warn}{e}")
104104

105105
elif(args[0] in commands[1][0]):
106-
match(args[1]):
107-
case "encode":
108-
print(cfg.getEncoding())
106+
try:
107+
match(args[1]):
108+
case "encode":
109+
print(cfg.getEncoding())
109110

110-
case "splash":
111-
print(cfg.getSplash())
111+
case "splash":
112+
print(cfg.getSplash())
113+
114+
case "all":
115+
print(f"encode: {cfg.getEncoding()}")
116+
print(f"splash: {cfg.getSplash()}")
112117

113-
case "all":
114-
print(f"encode: {cfg.getEncoding()}")
115-
print(f"splash: {cfg.getSplash()}")
118+
except IndexError:
119+
print(f"{Icons.warn}No value was entered !")
116120

117121
elif(args[0] in commands[-2][0]):
118122
helper(commands)

tools/shell.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
from os import system as shell
5+
from traceback import format_exc
56

7+
from core.icons import Icons
68
from core.tool import Tool
79

810
class Shell(Tool):
@@ -24,5 +26,25 @@ def __init__(self, args: list[str]):
2426

2527
self._run(args)
2628

29+
def _run(self, args: list[str]) -> bool:
30+
try:
31+
for i, a in enumerate(self._args):
32+
if(args[1] in a[0]):
33+
self._execs[i](args[2: len(args)])
34+
return(True)
35+
36+
self._exec(args[1: len(args)])
37+
38+
except IndexError:
39+
print(' To see more of command type "-h" or "--help" on arguments')
40+
41+
except ValueError as e:
42+
print(f"{Icons.warn}{e}")
43+
44+
except Exception:
45+
print(f"{Icons.warn}{format_exc()}")
46+
47+
return(False)
48+
2749
def _exec(self, args: list[str]) -> None:
2850
shell(" ".join(args))

tools/wslBuilder.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
from os import listdir, mkdir, remove, rmdir, system as shell
5-
from os.path import abspath, dirname
5+
from os.path import abspath, dirname, getsize
66

7+
from core import UNITS
78
from core.icons import Icons
89
from core.tool import Tool
910

@@ -134,9 +135,19 @@ def _init(self) -> None:
134135
def _list(self) -> None:
135136
__distros = listdir(self.__path)
136137

137-
print(f"\n {' '*1}* Name{' '*(18-len('Name'))}Path")
138+
print(f"\n {' '*1}* Name{' '*(18-len('Name'))}Size{' '*(12-len('Size'))}Path")
138139
for i, distro in enumerate(__distros, start=1):
139-
print(f" {' '*(2-len(str(i)))}{i}. {distro.replace('-', ':')}{' '*(18-len(distro))}{abspath(f'{self.__path}/{distro}')}")
140+
size = [getsize(abspath(f"{self.__path}/{distro}/ext4.vhdx")), UNITS[0]]
141+
142+
for j in range(1, len(UNITS)):
143+
size[0] /= 1000
144+
size[1] = UNITS[j]
145+
if(size[0] < 1024):
146+
break
147+
148+
size = f"{round(size[0], 2)} {size[1]}"
149+
150+
print(f" {' '*(2-len(str(i)))}{i}. {distro.replace('-', ':')}{' '*(18-len(distro))}{size}{' '*(12-len(size))}{abspath(f'{self.__path}/{distro}')}")
140151

141152
def _start(self, args: list[str]) -> None:
142153
__distros = listdir(self.__path)

0 commit comments

Comments
 (0)