Skip to content

Commit

Permalink
move installer system to os
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed May 21, 2024
1 parent 5c1dc96 commit 07981c6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 63 deletions.
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3

from src.misc.log import log
import os
from src.misc.createDirectories import createDirectories,createFiles
Expand Down
107 changes: 44 additions & 63 deletions src/getModels/select_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,45 @@ def install_modules(self):
if os.path.exists(f"{thisdir}/bin/") == False:
os.mkdir(f"{thisdir}/bin/")
for i in os.listdir(f"{thisdir}/files/"):
print(i)
if i == "ffmpeg":
os.system(f'chmod +x "{thisdir}/files/ffmpeg"')
os.system(f'mv "{thisdir}/files/ffmpeg" "{thisdir}/bin/"')
os.chmod(
os.path.join(thisdir,"files","ffmpeg"),
0o755
)

os.rename(
os.path.join(thisdir,"files","ffmpeg"),
os.path.join(thisdir,"bin","ffmpeg")
)
if i == "yt-dlp_linux":
os.system(f'chmod +x "{thisdir}/files/yt-dlp_linux"')
os.system(f'mv "{thisdir}/files/yt-dlp_linux" "{thisdir}/bin/"')
os.chmod(
os.path.join(thisdir,"files",i),
0o755
)

os.rename(
os.path.join(thisdir,"files",i),
os.path.join(thisdir,"bin",i)
)
if i == "glxinfo":
os.system(f'chmod +x "{thisdir}/files/glxinfo"')
os.system(f'mv "{thisdir}/files/glxinfo" "{thisdir}/bin/"')
os.chmod(
os.path.join(thisdir,"files",i),
0o755
)

os.rename(
os.path.join(thisdir,"files",i),
os.path.join(thisdir,"bin",i)
)
if i == "rife-ncnn-vulkan":
try:
os.mkdir(f"{settings.ModelDir}/rife/")
except:
pass
os.system(f'chmod +x "{thisdir}/files/rife-ncnn-vulkan"')
os.chmod(
os.path.join(thisdir,"files",i),
0o755
)
os.system(
f'mv "{thisdir}/files/rife-ncnn-vulkan" "{thisdir}/models/rife/"'
)
Expand All @@ -134,13 +157,17 @@ def install_modules(self):
original_ai_name = name
original_ai_name_ncnn_vulkan = name

os.system(
f'mv "{thisdir}/files/{name}" "{settings.ModelDir}/{original_ai_name}"'
)
os.system(
f'chmod +x "{settings.ModelDir}/{original_ai_name}/{original_ai_name_ncnn_vulkan}"'
)

try:
os.rename(
os.path.join(thisdir,"files",name),
os.path.join(settings.ModelDir,original_ai_name)
)
os.chmod(
os.path.join(settings.ModelDir,original_ai_name,original_ai_name_ncnn_vulkan),
0o755
)
except:
pass
if ".tar.gz" in i:
with tarfile.open(f"{thisdir}/files/{i}", "r") as f:
f.extractall(f"{settings.ModelDir}/rife/")
Expand Down Expand Up @@ -343,55 +370,9 @@ def on_count_changed(self, list):
self.ui.gbLabel.setText(f"{downloaded_data_gb}/{total_data_gb}GB")

def start_main(self):
for i in os.listdir(f"{thisdir}/files/"):
if os.path.exists(f"{thisdir}/bin/") == False:
os.mkdir(f"{thisdir}/bin/")
if i == "ffmpeg":
os.system(f'chmod +x "{thisdir}/files/ffmpeg"')
os.system(f'mv "{thisdir}/files/ffmpeg" "{thisdir}/bin/"')
if i == "yt-dlp_linux":
os.system(f'chmod +x "{thisdir}/files/yt-dlp_linux"')
os.system(f'mv "{thisdir}/files/yt-dlp_linux" "{thisdir}/bin/"')
if i == "glxinfo":
os.system(f'chmod +x "{thisdir}/files/glxinfo"')
os.system(f'mv "{thisdir}/files/glxinfo" "{thisdir}/bin/"')

log(i)
if ".zip" in i:
with ZipFile(f"{thisdir}/files/{i}", "r") as zip_ref:
name = i.replace(".zip", "")
if "-ncnn-vulkan" in name:
try:
original_ai_name_ncnn_vulkan = re.findall(
r"[\w]*-ncnn-vulkan", name
)[0]
original_ai_name = original_ai_name_ncnn_vulkan.replace(
"-ncnn-vulkan", ""
)
log(original_ai_name)
except:
pass
else:
original_ai_name = name
original_ai_name_ncnn_vulkan = name

zip_ref.extractall(f"{thisdir}/files/")

os.system(
f'mv "{thisdir}/files/{name}" "{settings.ModelDir}/{original_ai_name}"'
)
os.system(
f'chmod +x "{settings.ModelDir}/{original_ai_name}/{original_ai_name_ncnn_vulkan}"'
)
os.system(
f'chmod +x "{settings.ModelDir}/{original_ai_name}/upscayl-bin"'
)
if ".tar.gz" in i:
with tarfile.open(f"{thisdir}/files/{i}", "r") as f:
f.extractall(f"{settings.ModelDir}/rife/")
handleCUDAModels(i)

deleteDownloaded()
if check_for_individual_models != None:
if check_for_individual_models() != None:
if check_if_online():
QApplication.closeAllWindows()

Expand Down

0 comments on commit 07981c6

Please sign in to comment.