From b2de74e0cd84cf9ac317c3cb828e43f136545f62 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 5 Dec 2023 14:03:55 -0700 Subject: [PATCH] Now works running from source and pyinstaller on Windows --- README.md | 13 +++++ businesslogic.py | 44 +++++++-------- gamefinder.py | 144 +++++++++++++++++++++++++++++++---------------- path.py | 57 +++++++++++++++++++ pip.txt | Bin 0 -> 1042 bytes setupwizard.py | 16 ++++-- 6 files changed, 196 insertions(+), 78 deletions(-) create mode 100644 path.py create mode 100644 pip.txt diff --git a/README.md b/README.md index 5059e62..5228a7c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,19 @@ In order to access the Ebay API, you will need a set of four different productio Visit https://developer.ebay.com/api-docs/static/gs_create-the-ebay-api-keysets.html to continue creating Ebay Developer Program production keys for API access use with your Gamefinder installation. +## Usage +Both a native Windows 11 executable is available at https://github.com/bekindpleaserewind/gamefinder/releases as is the complete source code under the GPLv3 license. + +### Binary (Windows 11) +If you are on windows, just execute the Windows 11 executable and you should be good to go. + +### Source +If you're running through source, you need to go through the following steps: + +1. Install the pip modules by running ```pip install -r pip.txt```. I recommend doing this is a venv dedicated to Gamefinder. +2. Ensure that the alerts/icons directories are in the same location as the source code (it is auto resolved in path.py). +3. Execute ```python gamefinder.py```. + ## Support If you're feeling supportive today, you can buy me a cup of coffee at https://www.buymeacoffee.com/bekindpleaserewind diff --git a/businesslogic.py b/businesslogic.py index e3c0749..db3b205 100644 --- a/businesslogic.py +++ b/businesslogic.py @@ -8,6 +8,7 @@ from pygame import mixer from PySide6.QtCore import QObject, Slot, QRunnable +from path import Pathinfo from appinfo import Info from signals import GameFinderSignals, WorkerSignals, SettingsSignals @@ -18,22 +19,21 @@ class GameFinder(FindingConnection, QObject): def __init__(self): self.signals = GameFinderSignals() + self.pathinfo = Pathinfo() + self.settings = Settings() self.settings.signals.reload.connect(self.settings.load) self.settings.load() - self.config = os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml') - self.platforms = os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml') - # Initialize pygame audio mixer mixer.init() - super(GameFinder, self).__init__(config_file = self.config) + super(GameFinder, self).__init__(config_file = self.pathinfo.ebay) def find(self): self.running = True - with open(self.platforms, "r") as fd: + with open(self.pathinfo.platforms, "r") as fd: platform_config = yaml.load(fd, Loader=yaml.SafeLoader) try: @@ -119,8 +119,7 @@ def find(self): itemCount = len(items) # Audio Notification if self.settings.enableAudioNotification and itemCount > 0: - song = os.path.join(sys._MEIPASS, 'alerts', "games.mp3") - mixer.music.load(song) + mixer.music.load(self.pathinfo.music.games) if not mixer.get_busy(): mixer.music.play() @@ -143,6 +142,7 @@ def __init__(self): super(Worker, self).__init__() self.running = False self.signals = WorkerSignals() + self.pathinfo = Pathinfo() self.settings = Settings() self.settings.signals.reload.connect(self.settings.load) self.settings.load() @@ -156,11 +156,7 @@ def handleGameFinderData(self, d): @Slot() def run(self): self.running = True - if Info.FROZEN: - self.config = os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml') - self.platforms = os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml') - - if os.path.exists(self.config) and os.path.exists(self.platforms): + if os.path.exists(self.pathinfo.ebay) and os.path.exists(self.pathinfo.platforms): gf = GameFinder() gf.signals.notify.connect(self.handleGameFinderNotify) gf.signals.data.connect(self.handleGameFinderData) @@ -175,7 +171,7 @@ def run(self): # Calculate interval in 60 second blocks # and auto determine how often we should # sleep before another run. - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), "r") as fd: + with open(self.pathinfo.platforms, "r") as fd: platforms = yaml.load(fd, Loader=yaml.SafeLoader) platformCount = len(platforms.keys()) @@ -202,7 +198,8 @@ def isRunning(self): class Conditions: def __init__(self): - with open(os.path.join(sys._MEIPASS, 'itemfilters.yaml'), "r") as fd: + self.pathinfo = Pathinfo() + with open(self.pathinfo.itemfilters, "r") as fd: data = yaml.load(fd, Loader=yaml.SafeLoader) self.conditions = data['Condition'] @@ -211,24 +208,24 @@ def __init__(self): self.itemfilters = False self.aspectfilters = False self.saved = False - + self.pathinfo = Pathinfo() self.load() def load(self): try: - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), "r") as fd: + with open(self.pathinfo.platforms, "r") as fd: self.saved = yaml.load(fd, Loader=yaml.SafeLoader) except: self.saved = {} try: - with open(os.path.join(sys._MEIPASS, 'itemfilters.yaml'), "r") as fd: + with open(self.pathinfo.itemfilters, "r") as fd: self.itemfilters = yaml.load(fd, Loader=yaml.SafeLoader) except: self.itemfilters = {} try: - with open(os.path.join(sys._MEIPASS, 'aspectfilters.yaml'), "r") as fd: + with open(self.pathinfo.aspectfilters, "r") as fd: self.aspectfilters = yaml.load(fd, Loader=yaml.SafeLoader) except: self.aspectfilters = {} @@ -301,8 +298,9 @@ class Settings: signals = SettingsSignals() def __init__(self): + self.pathinfo = Pathinfo() # create settings.yaml with defaults if it does not exist - if not os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'settings.yaml')): + if not os.path.exists(self.pathinfo.settings): save = { 'apiCallsPerDay': self.apiCallsPerDay, 'automaticInterval': self.automaticInterval, @@ -311,11 +309,11 @@ def __init__(self): 'enableAudioNotification': self.enableAudioNotification, 'enableDesktopNotification': self.enableDesktopNotification, } - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'settings.yaml'), "w") as fd: + with open(self.pathinfo.settings, "w") as fd: yaml.dump(save, fd) def load(self): - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'settings.yaml'), "r") as fd: + with open(self.pathinfo.settings, "r") as fd: settings = yaml.load(fd, Loader=yaml.SafeLoader) self.apiCallsPerDay = settings['apiCallsPerDay'] self.automaticInterval = settings['automaticInterval'] @@ -325,7 +323,7 @@ def load(self): self.enableDesktopNotification = settings['enableDesktopNotification'] def save(self): - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'settings.yaml'), "r") as fd: + with open(self.pathinfo.settings, "r") as fd: settings = yaml.load(fd, Loader=yaml.SafeLoader) save = { @@ -337,7 +335,7 @@ def save(self): 'enableDesktopNotification': self.enableDesktopNotification, } - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'settings.yaml'), "w") as fd: + with open(self.pathinfo.settings, "w") as fd: yaml.dump(save, fd) self.signals.reload.emit(True) \ No newline at end of file diff --git a/gamefinder.py b/gamefinder.py index da52dd4..147879a 100644 --- a/gamefinder.py +++ b/gamefinder.py @@ -8,13 +8,51 @@ import iso3166 -from PySide6.QtGui import QIcon, QAction, QColor, QDesktopServices -from PySide6.QtCore import QThreadPool, QSize, Qt -from PySide6.QtWidgets import QApplication, QSystemTrayIcon, QMenu, QMainWindow, QWidget, QHBoxLayout, QLabel, QHeaderView, QTableWidget, QTableWidgetItem, QAbstractItemView, QSizePolicy, QDialog, QComboBox, QTreeWidgetItem, QButtonGroup - +# PySide6 +from PySide6.QtGui import ( + QIcon, + QAction, + QColor, + QDesktopServices +) + +from PySide6.QtCore import ( + Qt, + QSize, + QThreadPool, +) + +from PySide6.QtWidgets import ( + QAbstractItemView, + QApplication, + QButtonGroup, + QComboBox, + QDialog, + QHBoxLayout, + QHeaderView, + QLabel, + QMainWindow, + QMenu, + QSizePolicy, + QSystemTrayIcon, + QTableWidget, + QTableWidgetItem, + QTreeWidgetItem, + QWidget, +) + +# Local code from appinfo import Info +from path import Pathinfo from signals import AppSignals -from businesslogic import GameFinder, Worker, Conditions, SavedPlatforms, Settings + +from businesslogic import ( + GameFinder, + Worker, + Conditions, + SavedPlatforms, + Settings +) from mainwindow import Ui_MainWindow from setupwizard import SetupWizard @@ -37,7 +75,7 @@ def handler(signum, frame): pass class App: - def __init__(self, qtApp, foreground = False): + def __init__(self, qtApp): self.app = qtApp self.signals = AppSignals() self.worker = None @@ -115,10 +153,12 @@ def __init__(self, state): super(IconStatusBar, self).__init__() self.setupUi(self) + self.pathinfo = Pathinfo() + if state == ONLINE: - self.icon = QIcon(os.path.join(sys._MEIPASS, 'online.png')) + self.icon = QIcon(self.pathinfo.icon.online) elif state == OFFLINE: - self.icon = QIcon(os.path.join(sys._MEIPASS, 'online.png')) + self.icon = QIcon(self.pathinfo.icon.offline) else: return @@ -158,7 +198,6 @@ def __init__(self, url, color, items, parent = None): self.link.setContentsMargins(0, 0, 0, 0) self.link.setStyleSheet("background-color: {}".format(color)) self.link.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) - #self.link.setTextInteractionFlags(Qt.TextBrowserInteraction) self.link.setOpenExternalLinks(False) self.link.setText("{}".format(url, url)) self.link.setAutoFillBackground(True) @@ -331,6 +370,9 @@ class Platform: platforms = {} models = {} + def __init__(self): + self.pathinfo = Pathinfo() + def addPlatform(self, search, category, locations, conditions, platform = None, model = None): id = str(uuid.uuid4()) self.search[id] = search @@ -341,8 +383,8 @@ def addPlatform(self, search, category, locations, conditions, platform = None, self.conditions[id] = conditions config = {} - if os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml')): - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), "r") as fd: + if os.path.exists(self.pathinfo.platforms): + with open(self.pathinfo.platforms, "r") as fd: config = yaml.load(fd, Loader=yaml.SafeLoader) config[id] = { @@ -363,7 +405,7 @@ def addPlatform(self, search, category, locations, conditions, platform = None, if len(self.conditions[id]) > 0: config[id]['itemFilters']['Conditions'] = self.conditions[id] - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), "w") as fd: + with open(self.pathinfo.platforms, "w") as fd: yaml.dump(config, fd) return(id) @@ -372,7 +414,9 @@ class AboutDialog(QDialog, Ui_About): def __init__(self, parent = None): super(AboutDialog, self).__init__(parent) self.setupUi(self) - icon = QIcon(os.path.join(sys._MEIPASS, 'gamefinder_logo_whitebackground.png')) + self.pathinfo = Pathinfo() + + icon = QIcon(self.pathinfo.logo.normal) pixmap = icon.pixmap(QSize(128, 128)) self.logo.setPixmap(pixmap) @@ -384,6 +428,8 @@ def __init__(self, parent = None): self.categoryToAspectFilters = {} self.setupUi(self) + self.pathinfo = Pathinfo() + self.results = [] self.saves = False self.clickTracker = False @@ -578,10 +624,10 @@ def removeClicked(self): targetType = target.data(0, Qt.UserRole) if targetType == TYPE_ID: configId = target.text(0) - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), "r") as fd: + with open(self.pathinfo.platforms, "r") as fd: config = yaml.load(fd, Loader=yaml.SafeLoader) - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), "w") as fd: + with open(self.pathinfo.platforms, "w") as fd: del config[configId] yaml.dump(config, fd) @@ -729,16 +775,16 @@ def loadLocations(self, reset = False): def loadCategory(self, loadUi = True): self.categoryToAspectFilters = {} - if os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml')): + if os.path.exists(self.pathinfo.platforms): # Load configuration id - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'platforms.yaml'), 'r') as fd: + with open(self.pathinfo.platforms, 'r') as fd: configData = yaml.safe_load(fd) for configId in configData: self.categoryToAspectFilters[configId] = { 'aspectFilters': configData[configId]['aspectFilters'], } # Load aspectFilter category names and ids - with open(os.path.join(sys._MEIPASS, 'aspectfilters.yaml'), 'r') as fd: + with open(self.pathinfo.aspectfilters, 'r') as fd: aspectFilterData = yaml.safe_load(fd) # Get each configuration id @@ -762,7 +808,7 @@ def loadCategory(self, loadUi = True): self.category.addItem(category, userData = categories[category]) # Load any missing categories: - with open(os.path.join(sys._MEIPASS, 'aspectfilters.yaml'), 'r') as fd: + with open(self.pathinfo.aspectfilters, 'r') as fd: aspectFilterData = yaml.safe_load(fd) for categoryId in aspectFilterData.keys(): name = aspectFilterData[categoryId]['name'] @@ -984,6 +1030,7 @@ def __init__(self): super(MainWindow, self).__init__() self.setupUi(self) + self.pathinfo = Pathinfo() self.running = False self.settings = Settings() @@ -991,7 +1038,7 @@ def __init__(self): self.settings.load() # Set our window icon - self.setWindowIcon(QIcon(os.path.join(sys._MEIPASS, 'gamefinder_logo_whitebackground_small.png'))) + self.setWindowIcon(QIcon(self.pathinfo.logo.small)) # Create a new gamefinder application and configure signals self.gamefinder = App(app) @@ -1009,23 +1056,23 @@ def __init__(self): self.actionAbout.triggered.connect(self.about) # System tray - self.trayIcon = QIcon(os.path.join(sys._MEIPASS, 'gamefinder_logo_whitebackground.png')) + self.trayIcon = QIcon(self.pathinfo.logo.normal) self.tray = SystemTrayIcon(self.trayIcon, self.gamefinder, self) # Setup toolbar self.toolBar.setIconSize(QSize(24, 24)) # Toolbar start button - self.button_start = QAction(QIcon(os.path.join(sys._MEIPASS, 'start.png')), "Start", self) + self.button_start = QAction(QIcon(self.pathinfo.icon.start), "Start", self) self.button_start.setStatusTip("Start Searching") self.button_start.triggered.connect(self.start) - if os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml')): + if os.path.exists(self.pathinfo.ebay): self.button_start.setDisabled(False) else: self.button_start.setDisabled(True) self.toolBar.addAction(self.button_start) # Toolbar stop button - self.button_stop = QAction(QIcon(os.path.join(sys._MEIPASS, 'stop.png')), "Stop", self) + self.button_stop = QAction(QIcon(self.pathinfo.icon.stop), "Stop", self) self.button_stop.setStatusTip("Stop Searching") self.button_stop.triggered.connect(self.stop) self.button_stop.setDisabled(True) @@ -1034,14 +1081,14 @@ def __init__(self): self.toolBar.addSeparator() # Toolbar tally button - self.button_clear = QAction(QIcon(os.path.join(sys._MEIPASS, 'tally.png')), "Clear", self) + self.button_clear = QAction(QIcon(self.pathinfo.icon.tally), "Clear", self) self.button_clear.setStatusTip("Mark Results Read") self.button_clear.triggered.connect(self.markResultsRead) self.button_clear.setDisabled(False) self.toolBar.addAction(self.button_clear) # Toolbar delete button - self.button_trash = QAction(QIcon(os.path.join(sys._MEIPASS, 'trash.png')), "Delete", self) + self.button_trash = QAction(QIcon(self.pathinfo.icon.trash), "Delete", self) self.button_trash.setStatusTip("Delete Read Results") self.button_trash.triggered.connect(self.trashReadResults) self.button_trash.setDisabled(False) @@ -1050,13 +1097,13 @@ def __init__(self): self.toolBar.addSeparator() # Toolbar platforms button - self.button_platforms = QAction(QIcon(os.path.join(sys._MEIPASS, 'platforms.png')), "Platforms", self) + self.button_platforms = QAction(QIcon(self.pathinfo.icon.platform), "Platforms", self) self.button_platforms.setStatusTip("Searching and Platforms") self.button_platforms.triggered.connect(self.displayPlatformsDialog) self.button_platforms.setDisabled(False) self.toolBar.addAction(self.button_platforms) # Toolbar Credentials - self.button_credentials = QAction(QIcon(os.path.join(sys._MEIPASS, 'credentials.png')), "Credentials", self) + self.button_credentials = QAction(QIcon(self.pathinfo.icon.credentials), "Credentials", self) self.button_credentials.setStatusTip("Credentials") self.button_credentials.triggered.connect(self.displayAuthenticationSetup) self.button_credentials.setDisabled(False) @@ -1067,7 +1114,7 @@ def __init__(self): self.toolBar.addWidget(toolbarSpacer) # Toolbar Settings (align right) - self.button_settings = QAction(QIcon(os.path.join(sys._MEIPASS, 'settings.png')), "Settings", self) + self.button_settings = QAction(QIcon(self.pathinfo.icon.settings), "Settings", self) self.button_settings.setStatusTip("Settings") self.button_settings.triggered.connect(self.displaySettingsDialog) self.button_settings.setDisabled(False) @@ -1169,7 +1216,7 @@ def shutdown(self, *args, **kwargs): def loadTableState(self): # Load existing saved state on a best try effort try: - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'state.yaml'), "r") as fd: + with open(self.pathinfo.state, "r") as fd: data = yaml.load(fd, Loader=yaml.SafeLoader) for row in data['state']: self.tableWidget.addData([row['values']], row['activated']) @@ -1209,7 +1256,7 @@ def saveTableState(self): ], }) - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'state.yaml'), "w") as fd: + with open(self.pathinfo.state, "w") as fd: yaml.dump(data, fd) def isRunning(self): @@ -1232,26 +1279,25 @@ def stop(self, *args, **kwargs): app = QApplication([]) app.setQuitOnLastWindowClosed(False) - if Info.FROZEN: - appData = os.path.join(os.environ['APPDATA'], Info.APPNAME) - ebayYaml = os.path.join(appData, 'ebay.yaml') + pathinfo = Pathinfo() + if not os.path.exists(pathinfo.app): + os.mkdir(pathinfo.app) - if not os.path.exists(appData): - os.mkdir(appData) + window = MainWindow() - window = MainWindow() + if not os.path.exists(pathinfo.ebay): + window.show() + window.activateWindow() + wizard = SetupWizard(window) + wizard.show() + else: + window.show() + window.activateWindow() - if not os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml')): - window.show() - window.activateWindow() - wizard = SetupWizard(window) - wizard.show() - else: - window.show() - window.activateWindow() + # Start QT Application + rCode = app.exec() - # Start QT Application - app.exec() + # Wait for threads to exit + window.reap() - # Wait for threads to exit - window.reap() \ No newline at end of file + sys.exit(rCode) \ No newline at end of file diff --git a/path.py b/path.py new file mode 100644 index 0000000..11e4e9c --- /dev/null +++ b/path.py @@ -0,0 +1,57 @@ +import os +import sys + +from appinfo import Info + +class Logo: + small = False + normal = False + +class Music: + games = False + +class Icon: + online = False + offline = False + start = False + stop = False + tally = False + trash = False + platform = False + credentials = False + settings = False + +class Pathinfo: + # file paths + app = os.path.join(os.environ['APPDATA'], Info.APPNAME) + state = os.path.join(app, 'state.yaml') + settings = os.path.join(app, 'settings.yaml') + platforms = os.path.join(app, 'platforms.yaml') + aspectfilters = os.path.join(app, 'aspectfilters.yaml') + itemfilters = os.path.join(app, 'itemfilters.yaml') + ebay = os.path.join(app, 'ebay.yaml') + + logo = Logo + icon = Icon + music = Music + + def __init__(self): + if Info.FROZEN: + self.icondir = sys._MEIPASS + self.musicdir = os.path.join(sys._MEIPASS, 'alerts') + else: + self.musicdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'alerts') + self.icondir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'icons') + + self.logo.small = os.path.join(self.icondir, 'gamefinder_logo_whitebackground_small.png') + self.logo.normal = os.path.join(self.icondir, 'gamefinder_logo_whitebackground.png') + self.icon.online = os.path.join(self.icondir, 'online.png') + self.icon.offline = os.path.join(self.icondir, 'offline.png') + self.icon.start = os.path.join(self.icondir, 'start.png') + self.icon.stop = os.path.join(self.icondir, 'stop.png') + self.icon.tally = os.path.join(self.icondir, 'tally.png') + self.icon.trash = os.path.join(self.icondir, 'trash.png') + self.icon.platform = os.path.join(self.icondir, 'platforms.png') + self.icon.credentials = os.path.join(self.icondir, 'credentials.png') + self.icon.settings = os.path.join(self.icondir, 'settings.png') + self.music.games = os.path.join(self.musicdir, 'games.mp3') \ No newline at end of file diff --git a/pip.txt b/pip.txt new file mode 100644 index 0000000000000000000000000000000000000000..a021f333c2543a1fb4cce46610c5c4a36b23b2cb GIT binary patch literal 1042 zcmZ{jOHaa35QS%L;!mmJjV@eh;!YD1S1t?X(NJhDC8$4M{mz}M(q&x}Z|Sk=u&LJ9>0^N5AFr z&J9ep9Y8de*xpKh?f9<%`4xDC7gEn4s4vk@?GsdH+s=Vp^g?}w?hfxurVv_+?pu`# zg)+ETO_PlSDu-^u$Cj_a$sc$=QNWn6-qd0iU;C2BaHr-EU@w-YfMC9Zyp_dM?!yCeJwH zJ#?=A?|!07n=+c&Y>Go=G*Dmmq;87}41wEON3qC&%)k}<{9 literal 0 HcmV?d00001 diff --git a/setupwizard.py b/setupwizard.py index f306f30..55ac815 100644 --- a/setupwizard.py +++ b/setupwizard.py @@ -4,6 +4,7 @@ from PySide6.QtWidgets import QWizard, QWizardPage from appinfo import Info +from path import Pathinfo from wizardpage1 import Ui_WizardPage1 from wizardpage2 import Ui_WizardPage2 @@ -17,6 +18,7 @@ class SetupWizardPage1(QWizardPage, Ui_WizardPage1): def __init__(self): super(SetupWizardPage1, self).__init__() self.setupUi(self) + self.pathinfo = Pathinfo() class SetupWizardPage2(QWizardPage, Ui_WizardPage2): def __init__(self): @@ -28,8 +30,8 @@ def __init__(self): self.registerField('production_token*', self.lineEditToken) def initializePage(self): - if os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml')): - with open(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml'), "r") as fd: + if os.path.exists(self.pathinfo.ebay): + with open(self.pathinfo.ebay, "r") as fd: config = yaml.load(fd, Loader=yaml.SafeLoader) self.lineEditAppid.setText(config['api.ebay.com']['appid']) self.lineEditCertid.setText(config['api.ebay.com']['certid']) @@ -48,6 +50,8 @@ def __init__(self, parent=None, stopConnection = False): self.stopConnection = stopConnection super(SetupWizard, self).__init__(parent) + self.pathinfo = Pathinfo() + self.dataPage2 = SetupWizardPage2Data() page1 = SetupWizardPage1() @@ -64,7 +68,7 @@ def accept(self): if self.generateEbayYaml(): if self.window is not None: - if os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml')): + if os.path.exists(self.pathinfo.ebay): self.window.button_start.setDisabled(False) else: self.window.button_start.setDisabled(True) @@ -74,7 +78,7 @@ def accept(self): return True - if os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml')): + if os.path.exists(self.pathinfo.ebay): self.window.button_start.setDisabled(False) else: self.window.button_start.setDisabled(True) @@ -107,10 +111,10 @@ def generateEbayYaml(self): } # stop connection - if self.stopConnection and os.path.exists(os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml')): + if self.stopConnection and os.path.exists(self.pathinfo.ebay): self.window.stop() - ebayYamlPath = os.path.join(os.environ['APPDATA'], Info.APPNAME, 'ebay.yaml') + ebayYamlPath = self.pathinfo.ebay try: with open(ebayYamlPath, 'w') as fd: yaml.dump(ebayYaml, fd)