Skip to content

Commit

Permalink
changed all relative paths to absloute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Jul 28, 2023
1 parent 099d5d7 commit 3ff7b9d
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 52 deletions.
16 changes: 7 additions & 9 deletions app/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
from utls import Worker

script_dir = os.path.dirname(os.path.abspath(__file__))
dll_path = os.path.join(script_dir, r"data\System.Management.Automation.dll")
clr.AddReference(dll_path)
clr.AddReference(script_dir + r"\data\System.Management.Automation.dll")


class internal_func(Ui_MainProgram):
Expand All @@ -26,10 +25,10 @@ def error_msg(self, text, msg_details, title="Error", critical=False):
msg.setText(f'{str(text)} ')
if critical:
msg.setIcon(QMessageBox.Icon.Critical)
msg.setWindowIcon(QIcon('./data/images/error_r.png'))
msg.setWindowIcon(QIcon(f'{script_dir}/data/images/error_r.png'))
else:
msg.setIcon(QMessageBox.Icon.Warning)
msg.setWindowIcon(QIcon('./data/images/error_y.png'))
msg.setWindowIcon(QIcon(f'{script_dir}/data/images/error_y.png'))
msg.setDetailedText(str(msg_details) +
'\n\ncheck Full Logs [Help --> Open Logs]')
if text == "Failed To Clear Cache Files!":
Expand All @@ -49,7 +48,7 @@ def error_msg(self, text, msg_details, title="Error", critical=False):
def show_error_popup(self, txt="An Error Has Occured Try Again!"):
msg = QMessageBox()
msg.setWindowTitle('Error')
msg.setWindowIcon(QIcon('./data/images/error_r.png'))
msg.setWindowIcon(QIcon(f'{script_dir}/data/images/error_r.png'))
msg.setText(f'{txt} ')
msg.setIcon(QMessageBox.Icon.Critical)
if txt in ("No Logs Found!", "No Downloads Found!"):
Expand All @@ -69,7 +68,7 @@ def show_error_popup(self, txt="An Error Has Occured Try Again!"):
def show_success_popup(self, text=None):
msg = QMessageBox()
msg.setWindowTitle('Success')
msg.setWindowIcon(QIcon('./data/images/success.png'))
msg.setWindowIcon(QIcon(f'{script_dir}/data/images/success.png'))
if text:
msg.setText(f'{text} ')
else:
Expand Down Expand Up @@ -163,7 +162,7 @@ def stop_func(self):
def closeEvent(self, event):
close = QMessageBox()
close.setWindowTitle("Confirm")
close.setWindowIcon(QIcon('./data/images/error_y.png'))
close.setWindowIcon(QIcon(f'{script_dir}/data/images/error_y.png'))
close.setText("Are you sure you want to exit? ")
close.setIcon(QMessageBox.Icon.Warning)
close.setStandardButtons(
Expand Down Expand Up @@ -226,8 +225,7 @@ def download_install(self, arg):
def download_install_thread(data, progress_current, progress_main):
main_dict, final_data, file_name, uwp = data
part = int(50 / len(final_data))
abs_path = os.getcwd()
dwnpath = f'{abs_path}/downloads/'
dwnpath = f'{script_dir}//downloads/'
if not os.path.exists(dwnpath):
os.makedirs(dwnpath)
path_lst = {}
Expand Down
9 changes: 6 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from modules.app_selector import AppSelector
from utls import UrlBox, Worker, open_browser

script_dir = os.path.dirname(os.path.abspath(__file__))


class MainWindowGui(core):

Expand Down Expand Up @@ -86,7 +88,7 @@ def remove_(path, mode='file'):
text="Cache Files Cleared Successfully!"))

def open_downloads(self):
path = os.path.realpath("./downloads")
path = os.path.realpath(f'{script_dir}/downloads')
if os.path.exists(path):
os.startfile(path)
else:
Expand Down Expand Up @@ -143,7 +145,8 @@ def close(event):
self.window.activateWindow() # set focus to the currently open window
else: # open a new window
self.window = QMainWindow()
self.window.setWindowIcon(QIcon('./data/images/search.png'))
self.window.setWindowIcon(
QIcon(f'{script_dir}/data/images/search.png'))
search_app = AppSelector()
search_app.setupUi(self.window)
# overding the new window close event for proper cleanup
Expand All @@ -157,7 +160,7 @@ def main():
MainProgram = QMainWindow()
ui = MainWindowGui()
ui.setupUi(MainProgram)
MainProgram.setWindowIcon(QIcon('./data/images/main.ico'))
MainProgram.setWindowIcon(QIcon(f'{script_dir}/data/images/main.ico'))
MainProgram.closeEvent = ui.closeEvent # overiding close event
MainProgram.show()
sys.exit(app.exec())
Expand Down
16 changes: 9 additions & 7 deletions app/modules/app_selector.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# importing required libraries
import os

from PyQt6.QtCore import QObject, QUrl, pyqtSignal
from PyQt6.QtGui import QAction, QIcon
from PyQt6.QtWebEngineCore import QWebEnginePage
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWidgets import (QLabel, QLineEdit, QMenu, QPushButton, QStatusBar,
QToolBar)

parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

class CustomWebEngineView(QWebEngineView):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -145,7 +147,7 @@ def current_url():

# setting status tip
back_btn.setStatusTip("Back to previous page")
back_btn.setIcon(QIcon('./data/images/Back.png'))
back_btn.setIcon(QIcon(f'{parent_dir}/data/images/Back.png'))

# adding action to the back button
# making browser go back
Expand All @@ -157,7 +159,7 @@ def current_url():
# similarly for forward action
next_btn = QAction("", qt_window)
next_btn.setStatusTip("Forward to next page")
next_btn.setIcon(QIcon('./data/images/forward.png'))
next_btn.setIcon(QIcon(f'{parent_dir}/data/images/forward.png'))

# adding action to the next button
# making browser go forward
Expand All @@ -171,7 +173,7 @@ def current_url():
# similarly for reload action
reload_btn = QAction("", qt_window)
reload_btn.setStatusTip("Reload page")
reload_btn.setIcon(QIcon('./data/images/reload.png'))
reload_btn.setIcon(QIcon(f'{parent_dir}/data/images/reload.png'))

# adding action to the reload button
# making browser to reload
Expand All @@ -181,7 +183,7 @@ def current_url():
# similarly for home button
home_btn = QAction("", qt_window)
home_btn.setStatusTip("Home page")
home_btn.setIcon(QIcon('./data/images/home.png'))
home_btn.setIcon(QIcon(f'{parent_dir}/data/images/home.png'))

# adding action to the home button
# making browser go to home
Expand All @@ -207,7 +209,7 @@ def current_url():
qt_window.select_btn = QPushButton(qt_window)
qt_window.select_btn.setText("Select")
qt_window.select_btn.setStatusTip("Select The File To Download")
qt_window.select_btn.setIcon(QIcon('./data/images/ok.png'))
qt_window.select_btn.setIcon(QIcon(f'{parent_dir}/data/images/ok.png'))
qt_window.select_btn.clicked.connect(current_url)
navtb.addWidget(qt_window.select_btn)
qt_window.urlbar.returnPressed.connect(navigate_to_url)
Expand All @@ -221,7 +223,7 @@ def current_url():
# app = QApplication(sys.argv)

# window = QMainWindow()
# window.setWindowIcon(QIcon('./data/images/search.png'))
# window.setWindowIcon(QIcon(f'{parent_dir}/data/images/search.png'))
# newwindow = url_window()
# newwindow.setupUi(window)
# window.show()
Expand Down
42 changes: 19 additions & 23 deletions app/modules/gui.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Form implementation generated from reading ui file 'modules/altinstaller.ui'
#
# Created by: PyQt6 UI code generator 6.5.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.

import os

from PyQt6 import QtCore, QtGui, QtWidgets

# parent directory for absloute path
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

class Ui_MainProgram(object):
def setupUi(self, MainProgram):
Expand Down Expand Up @@ -47,7 +43,7 @@ def setupUi(self, MainProgram):
self.imagetitle.setMinimumSize(QtCore.QSize(51, 51))
self.imagetitle.setMaximumSize(QtCore.QSize(51, 51))
self.imagetitle.setText("")
self.imagetitle.setPixmap(QtGui.QPixmap("modules\\../data/images/installer_icon.png"))
self.imagetitle.setPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/installer_icon.png"))
self.imagetitle.setScaledContents(True)
self.imagetitle.setObjectName("imagetitle")
self.horizontalLayout_3.addWidget(self.imagetitle)
Expand Down Expand Up @@ -221,7 +217,7 @@ def setupUi(self, MainProgram):
self.menuDependencies.setEnabled(True)
self.menuDependencies.setTearOffEnabled(False)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("modules\\../data/images/dependencies.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/dependencies.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.menuDependencies.setIcon(icon)
self.menuDependencies.setToolTipsVisible(False)
self.menuDependencies.setObjectName("menuDependencies")
Expand All @@ -237,7 +233,7 @@ def setupUi(self, MainProgram):
self.actionDownload_From_Url.setObjectName("actionDownload_From_Url")
self.actionclear_cache = QtGui.QAction(parent=MainProgram)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap("modules\\../data/images/clear.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon1.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/clear.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionclear_cache.setIcon(icon1)
self.actionclear_cache.setObjectName("actionclear_cache")
self.actionInstall_Driver_Chrome = QtGui.QAction(parent=MainProgram)
Expand All @@ -246,37 +242,37 @@ def setupUi(self, MainProgram):
self.actionInstall_Chrome_Driver.setObjectName("actionInstall_Chrome_Driver")
self.actionCheck_For_Updates = QtGui.QAction(parent=MainProgram)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap("modules\\../data/images/update.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon2.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/update.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionCheck_For_Updates.setIcon(icon2)
self.actionCheck_For_Updates.setObjectName("actionCheck_For_Updates")
self.actionAbout = QtGui.QAction(parent=MainProgram)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap("modules\\../data/images/about.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon3.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/about.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionAbout.setIcon(icon3)
self.actionAbout.setStatusTip("")
self.actionAbout.setObjectName("actionAbout")
self.actionHelp = QtGui.QAction(parent=MainProgram)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap("modules\\../data/images/help.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon4.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/help.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionHelp.setIcon(icon4)
self.actionHelp.setObjectName("actionHelp")
self.actionOpen_Logs = QtGui.QAction(parent=MainProgram)
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap("modules\\../data/images/log.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon5.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/log.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionOpen_Logs.setIcon(icon5)
self.actionOpen_Logs.setObjectName("actionOpen_Logs")
self.actionDownload_From_Url_2 = QtGui.QAction(parent=MainProgram)
self.actionDownload_From_Url_2.setObjectName("actionDownload_From_Url_2")
self.actioninstall_From_File = QtGui.QAction(parent=MainProgram)
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap("modules\\../data/images/file.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon6.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/file.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actioninstall_From_File.setIcon(icon6)
self.actioninstall_From_File.setObjectName("actioninstall_From_File")
self.actionSet_Wait_Time = QtGui.QAction(parent=MainProgram)
self.actionSet_Wait_Time.setObjectName("actionSet_Wait_Time")
self.actionDownloads = QtGui.QAction(parent=MainProgram)
icon7 = QtGui.QIcon()
icon7.addPixmap(QtGui.QPixmap("modules\\../data/images/downloads.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon7.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/downloads.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionDownloads.setIcon(icon7)
self.actionDownloads.setObjectName("actionDownloads")
self.actionAll_Dependencies = QtGui.QAction(parent=MainProgram)
Expand All @@ -289,22 +285,22 @@ def setupUi(self, MainProgram):
self.actionIgnore_Latest_Version = QtGui.QAction(parent=MainProgram)
self.actionIgnore_Latest_Version.setCheckable(True)
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap("modules\\../data/images/unchecked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon9.addPixmap(QtGui.QPixmap("modules\\../data/images/checked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.On)
icon9.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/unchecked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon9.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/checked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.On)
self.actionIgnore_Latest_Version.setIcon(icon9)
self.actionIgnore_Latest_Version.setObjectName("actionIgnore_Latest_Version")
self.actionIgnore_All_filters = QtGui.QAction(parent=MainProgram)
self.actionIgnore_All_filters.setCheckable(True)
icon10 = QtGui.QIcon()
icon10.addPixmap(QtGui.QPixmap("modules\\../data/images/unchecked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon10.addPixmap(QtGui.QPixmap("modules\\../data/images/checked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.On)
icon10.addPixmap(QtGui.QPixmap("modules\\../data/images/unchecked.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off)
icon10.addPixmap(QtGui.QPixmap("modules\\../data/images/checked.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.On)
icon10.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/unchecked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon10.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/checked.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.On)
icon10.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/unchecked.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off)
icon10.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/checked.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.On)
self.actionIgnore_All_filters.setIcon(icon10)
self.actionIgnore_All_filters.setObjectName("actionIgnore_All_filters")
self.actionInstall_using_url = QtGui.QAction(parent=MainProgram)
icon11 = QtGui.QIcon()
icon11.addPixmap(QtGui.QPixmap("modules\\../data/images/link.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
icon11.addPixmap(QtGui.QPixmap(f"{parent_dir}/data/images/link.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionInstall_using_url.setIcon(icon11)
self.actionInstall_using_url.setObjectName("actionInstall_using_url")
self.menuDependencies.addAction(self.actionIgnore_Latest_Version)
Expand Down
28 changes: 18 additions & 10 deletions app/modules/url_gen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import html
import json
import os
import platform
import re
import time
Expand All @@ -10,6 +11,8 @@
import requests

warnings.filterwarnings("ignore")
# parent directory for absloute path
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# using this to check if the user has decieded to stop the process

Expand Down Expand Up @@ -54,11 +57,12 @@ def url_generator(url, ignore_ver, all_dependencies, Event, progress_current, pr
session = requests.Session()
r = session.get(details_api, timeout=20)
response = json.loads(r.text, object_hook=lambda obj:
{k: json.loads(v) if k == 'FulfillmentData' else v for k, v in obj.items()})
{k: json.loads(v) if k == 'FulfillmentData' else v for k, v in obj.items()})

if not response.get("Payload", None):
raise Exception('No Data Found: --> [You Selected Wrong Page, Try Again!]')

raise Exception(
'No Data Found: --> [You Selected Wrong Page, Try Again!]')

response_data = response["Payload"]["Skus"][0]
data_list = response_data.get("FulfillmentData", None)
total_prog += 20
Expand Down Expand Up @@ -214,7 +218,8 @@ def greater_ver(arg1, arg2):
release_type = "Retail"

# getting the encrypted cookie for the fe3 delivery api
with open("./data/xml/GetCookie.xml", "r") as f:
GetCookie_path = os.path.join(parent_dir, r"data\xml\GetCookie.xml")
with open(GetCookie_path, "r") as f:
cookie_content = f.read()
check(Event)
out = session.post(
Expand All @@ -232,7 +237,9 @@ def greater_ver(arg1, arg2):

# getting the update id,revision number and package name from the fe3 delivery api by providing the encrpyted cookie, cat_id, realse type
# Map {"retail": "Retail", "release preview": "RP","insider slow": "WIS", "insider fast": "WIF"}
with open("./data/xml/WUIDRequest.xml", "r") as f:
WUIDRequest_path = os.path.join(
parent_dir, r"data\xml\WUIDRequest.xml")
with open(WUIDRequest_path, "r") as f:
cat_id_content = f.read().format(cookie, cat_id, release_type)
check(Event)
out = session.post(
Expand Down Expand Up @@ -280,7 +287,8 @@ def greater_ver(arg1, arg2):
final_dict[value] = identities[value]

# getting the download url for the files using the api
with open("./data/xml/FE3FileUrl.xml", "r") as f:
FE3FileUrl_path = os.path.join(parent_dir, r"data\xml\FE3FileUrl.xml")
with open(FE3FileUrl_path, "r") as f:
file_content = f.read()

file_dict = {} # the final result
Expand Down Expand Up @@ -336,10 +344,10 @@ def non_uwp_gen():

r = session.get(api, timeout=20)
datas = json.loads(r.text)

if not datas.get("Data", None):
raise Exception("server returned a empty list")

total_prog += 20
progress_current.emit(total_prog)

Expand All @@ -355,7 +363,7 @@ def non_uwp_gen():
file_dict = {}
# casting to list for indexing
download_data = list(download_data)

# parsing
arch = download_data[0][0]
locale = download_data[0][1]
Expand Down

0 comments on commit 3ff7b9d

Please sign in to comment.