Skip to content

Commit

Permalink
Working on Getting Flatpak Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraust committed Sep 3, 2024
1 parent 6af38b6 commit 96ec4c8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
__pycache__
build
builddir
.flatpak-builder
dist
repo
.venv
8 changes: 2 additions & 6 deletions OSCRUI/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .translation import init_translation

from .leagueconnector import OSCRClient
from .iofunctions import get_asset_path, load_icon_series, load_icon, open_link, reset_temp_folder
from .iofunctions import get_asset_path, load_icon_series, load_icon, open_link
from .textedit import format_path
from .widgets import AnalysisPlot, BannerLabel, FlipButton, WidgetStorage
from .widgetbuilder import ABOTTOM, ACENTER, AHCENTER, ALEFT, ARIGHT, ATOP, AVCENTER
Expand Down Expand Up @@ -87,7 +87,6 @@ def __init__(self, theme, args, path, config, versions) -> None:
self.update_translation()
self.league_api = None

reset_temp_folder(self.config['templog_folder_path'])
self.app, self.window = self.create_main_window()
self.copy_shortcut = QShortcut(
QKeySequence.StandardKey.Copy, self.window, self.copy_analysis_table_callback)
Expand Down Expand Up @@ -173,8 +172,6 @@ def init_config(self):
"""
self.current_combat_id = -1
self.current_combat_path = ''
self.config['templog_folder_path'] = os.path.abspath(
self.app_dir + self.config['templog_folder_path'])
self.config['ui_scale'] = self.settings.value('ui_scale', type=float)
self.config['live_scale'] = self.settings.value('live_scale', type=float)
self.config['icon_size'] = round(
Expand All @@ -193,7 +190,6 @@ def parser_settings(self) -> dict:
setting = self.settings.value(setting_key, type=settings_type, defaultValue='')
if setting:
settings[setting_key] = setting
settings['templog_folder_path'] = self.config['templog_folder_path']
return settings

@property
Expand Down Expand Up @@ -1269,4 +1265,4 @@ def setup_settings_frame(self):
scroll_layout.addLayout(sec_2)

scroll_frame.setLayout(scroll_layout)
scroll_area.setWidget(scroll_frame)
scroll_area.setWidget(scroll_frame)
4 changes: 3 additions & 1 deletion OSCRUI/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from PySide6.QtWidgets import QFileDialog, QLineEdit
from PySide6.QtCore import QTemporaryDir

from OSCR import (
LIVE_TABLE_HEADER, OSCR, repair_logfile as oscr_repair_logfile, split_log_by_combat,
Expand Down Expand Up @@ -315,4 +316,5 @@ def repair_logfile(self):
"""
"""
log_path = os.path.abspath(self.entry.text())
oscr_repair_logfile(log_path, self.config['templog_folder_path'])
dir = QTemporaryDir()
oscr_repair_logfile(log_path, dir.path())
12 changes: 0 additions & 12 deletions OSCRUI/iofunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,6 @@ def store_json(data: dict | list, path: str):
sys.stdout.write(f'[Error] Data could not be saved: {e}')


def reset_temp_folder(path: str):
'''
Deletes and re-creates folder housing temporary log files.
'''
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(path)
else:
raise FileExistsError(f'Expected path to folder, got "{path}"')
os.mkdir(path)


def sanitize_file_name(txt, chr_set='extended') -> str:
"""Converts txt to a valid filename.
Expand Down
8 changes: 7 additions & 1 deletion OSCRUI/leagueconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from OSCR_django_client.api import (CombatlogApi, LadderApi, LadderEntriesApi,
VariantApi)
from PySide6.QtWidgets import QMessageBox
from PySide6.QtCore import QTemporaryDir

from .datafunctions import CustomThread, analyze_log_callback
from .datamodels import LeagueTableModel, SortingProxy
Expand Down Expand Up @@ -207,8 +208,13 @@ def download_and_view_combat(self, translation):
log_id = table_model._combatlog_id_list[row]
result = self.league_api.download(log_id)
result = gzip.decompress(result)

dir = QTemporaryDir()
if not dir.isValid():
raise Exception("Invalid temporary directory")

with tempfile.NamedTemporaryFile(
mode="w", encoding="utf-8", dir=self.config["templog_folder_path"], delete=False
mode="w", encoding="utf-8", dir=dir.path(), delete=False
) as file:
file.write(result.decode())
analyze_log_callback(
Expand Down
18 changes: 18 additions & 0 deletions com.stobuilds.oscr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
id: com.stobuilds.oscr
runtime: org.freedesktop.Platform
runtime-version: "23.08"
sdk: org.freedesktop.Sdk
command: oscr
modules:
- name: python3
buildsystem: simple
build-commands:
- python3 -m pip install --prefix=/app src/deps/oscr-ui
sources:
- type: git
url: https://github.com/STOCD/OSCR-UI.git
commit: bdde9e46f953004c131d7faae50b57dd91e5d28a
dest: "src/deps/oscr-ui"
build-options:
build-args:
- --share=network

0 comments on commit 96ec4c8

Please sign in to comment.