mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-06 06:51:36 +01:00
Merge pull request #1 from FAUSheppy/dev/updater
Some checks failed
ci / docker (push) Has been cancelled
Some checks failed
ci / docker (push) Has been cancelled
feat: extraction tracking
This commit is contained in:
@@ -11,6 +11,8 @@ import imagetools
|
|||||||
import webbrowser
|
import webbrowser
|
||||||
import statekeeper
|
import statekeeper
|
||||||
import infowidget
|
import infowidget
|
||||||
|
import requests
|
||||||
|
import tkinter
|
||||||
|
|
||||||
customtkinter.set_appearance_mode("dark")
|
customtkinter.set_appearance_mode("dark")
|
||||||
customtkinter.set_default_color_theme("blue")
|
customtkinter.set_default_color_theme("blue")
|
||||||
@@ -389,5 +391,9 @@ if __name__ == "__main__":
|
|||||||
app.update()
|
app.update()
|
||||||
|
|
||||||
# fill and run app #
|
# fill and run app #
|
||||||
load_main() # TODO add button to reopen config # TODO add button to purge cache/purge cache window # TODO show game size on remote
|
try:
|
||||||
|
load_main() # TODO add button to reopen config # TODO add button to purge cache/purge cache window # TODO show game size on remote
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
app.withdraw()
|
||||||
|
tkinter.messagebox.showerror("There was a connection problem", str(e))
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
|||||||
1
db.py
1
db.py
@@ -15,6 +15,7 @@ class Download(Base):
|
|||||||
local_path = Column(String)
|
local_path = Column(String)
|
||||||
url = Column(String)
|
url = Column(String)
|
||||||
size = Column(Integer)
|
size = Column(Integer)
|
||||||
|
count = Column(Integer) # extraction only
|
||||||
type = Column(String)
|
type = Column(String)
|
||||||
finished = Column(Boolean)
|
finished = Column(Boolean)
|
||||||
|
|
||||||
|
|||||||
18
software.py
18
software.py
@@ -96,25 +96,27 @@ class Software:
|
|||||||
|
|
||||||
os.makedirs(software_path, exist_ok=True)
|
os.makedirs(software_path, exist_ok=True)
|
||||||
|
|
||||||
|
# beginn progress tracking #
|
||||||
with zipfile.ZipFile(cache_src, 'r') as zip_ref:
|
with zipfile.ZipFile(cache_src, 'r') as zip_ref:
|
||||||
|
|
||||||
|
statekeeper.log_begin_download(local_path=cache_src, path=cache_src, url=None, type="extraction", start_size=len(zip_ref.infolist()))
|
||||||
total_count = zip_ref.infolist()
|
total_count = zip_ref.infolist()
|
||||||
count = 0
|
count = 0
|
||||||
for member in tqdm.tqdm(total_count, desc='Extracting '):
|
for member in tqdm.tqdm(total_count, desc='Extracting '):
|
||||||
try:
|
try:
|
||||||
zip_ref.extract(member, software_path)
|
zip_ref.extract(member, software_path)
|
||||||
count += 1
|
count += 1
|
||||||
#self.progress_bar_wrapper.get_pb().set(count/len(total_count))
|
|
||||||
#self.progress_bar_wrapper.get_pb().update_idletasks()
|
# update progress #
|
||||||
#self.progress_bar_wrapper.set_text(
|
statekeeper.set_extraction_status(cache_src, count)
|
||||||
# text="Extracting: {:.2f}%".format(count/len(total_count)*100))
|
|
||||||
|
|
||||||
except zipfile.error as e:
|
except zipfile.error as e:
|
||||||
print(e)
|
print(e)
|
||||||
pass # TODO ???
|
pass # TODO ???
|
||||||
#zip_ref.extractall(software_path)
|
|
||||||
|
# finish extraction tracking #
|
||||||
#self.progress_bar_wrapper.set_text(text="Loading..")
|
statekeeper.log_end_download(cache_src, type="extraction")
|
||||||
#self.progress_bar_wrapper.update()
|
|
||||||
|
|
||||||
def install_async(self):
|
def install_async(self):
|
||||||
|
|
||||||
|
|||||||
@@ -41,27 +41,45 @@ def _download(url, path, auth):
|
|||||||
|
|
||||||
raise AssertionError("Non-200 Response for:", url, path, response.status_code, response.text)
|
raise AssertionError("Non-200 Response for:", url, path, response.status_code, response.text)
|
||||||
|
|
||||||
def log_begin_download(path, local_path, url):
|
def log_begin_download(path, local_path, url, type="download", start_size=-1):
|
||||||
|
|
||||||
|
if type == "extraction":
|
||||||
|
print("Extraction path:", path)
|
||||||
|
else:
|
||||||
|
print("Download path", path)
|
||||||
|
|
||||||
session = db.session()
|
session = db.session()
|
||||||
print("Download path", path)
|
path_exists = session.query(Download).filter(and_(Download.path==path, Download.finished==False, Download.type==type)).first()
|
||||||
path_exists = session.query(Download).filter(and_(Download.path==path, Download.finished==False)).first()
|
|
||||||
if path_exists and False: # TODO FIX THIS
|
if path_exists and False: # TODO FIX THIS
|
||||||
print("DAFUG", path_exists)
|
print("DAFUG", path_exists)
|
||||||
print("WTF", path_exists.path)
|
print("WTF", path_exists.path)
|
||||||
raise AssertionError("ERROR: {} is already downloading.".format(path))
|
raise AssertionError("ERROR: {} is already downloading.".format(path))
|
||||||
else:
|
else:
|
||||||
print("Adding to download log:", path)
|
print("Adding to download log:", path)
|
||||||
session.merge(Download(path=path, size=-1, type="download", local_path=local_path, url=url, finished=False))
|
session.merge(Download(path=path, size=start_size, type=type, local_path=local_path, url=url, finished=False, count=1))
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
db.close_session()
|
db.close_session()
|
||||||
|
|
||||||
def log_end_download(path):
|
def set_extraction_status(path, count):
|
||||||
|
|
||||||
|
session = db.session()
|
||||||
|
obj = session.query(Download).filter(and_(Download.path==path, Download.type=="extraction")).first()
|
||||||
|
if not obj:
|
||||||
|
print("ERROR: {} is not currently extraction, cannot set status.".format(path))
|
||||||
|
else:
|
||||||
|
obj.count = count
|
||||||
|
session.merge(obj)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
db.close_session()
|
||||||
|
|
||||||
|
def log_end_download(path, type="download"):
|
||||||
|
|
||||||
print("Downlod end logged", path)
|
print("Downlod end logged", path)
|
||||||
session = db.session()
|
session = db.session()
|
||||||
obj = session.query(Download).filter(Download.path==path).first()
|
obj = session.query(Download).filter(and_(Download.path==path, Download.type==type)).first()
|
||||||
if not obj:
|
if not obj:
|
||||||
raise AssertionError("ERROR: {} is not downloading/cannot remove.".format(path))
|
raise AssertionError("ERROR: {} is not downloading/cannot remove.".format(path))
|
||||||
else:
|
else:
|
||||||
@@ -100,8 +118,16 @@ def get_percent_filled(path, auth):
|
|||||||
|
|
||||||
session = db.session()
|
session = db.session()
|
||||||
obj = session.query(Download).filter(Download.path==path, Download.finished==False).first()
|
obj = session.query(Download).filter(Download.path==path, Download.finished==False).first()
|
||||||
|
|
||||||
|
if not obj:
|
||||||
|
return 100
|
||||||
|
|
||||||
|
if obj.type == "extraction":
|
||||||
|
return obj.count / obj.size * 100
|
||||||
|
|
||||||
if not obj:
|
if not obj:
|
||||||
return 100 # means its finished
|
return 100 # means its finished
|
||||||
|
|
||||||
size = _bytes_to_mb(os.stat(obj.local_path).st_size)
|
size = _bytes_to_mb(os.stat(obj.local_path).st_size)
|
||||||
total_size = get_download_size(obj.path, auth)
|
total_size = get_download_size(obj.path, auth)
|
||||||
session.close()
|
session.close()
|
||||||
|
|||||||
2
todo.txt
2
todo.txt
@@ -1,7 +1,5 @@
|
|||||||
# important
|
# important
|
||||||
## downloaded file hash sum check
|
## downloaded file hash sum check
|
||||||
## apply custom tkinter look to pg window & move pg window to better relativ start location so it's no longer blocking the back button by default
|
|
||||||
## zip extraction progress
|
|
||||||
## fix initial startup pictures not loading
|
## fix initial startup pictures not loading
|
||||||
## implement flush download cache button
|
## implement flush download cache button
|
||||||
## fix Call of duty installation chain
|
## fix Call of duty installation chain
|
||||||
|
|||||||
Reference in New Issue
Block a user