Skip to content

Commit

Permalink
Now works running from source and pyinstaller on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bekindpleaserewind committed Dec 5, 2023
1 parent c90ad66 commit b2de74e
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 78 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
44 changes: 21 additions & 23 deletions businesslogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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())

Expand All @@ -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']

Expand All @@ -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 = {}
Expand Down Expand Up @@ -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,
Expand All @@ -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']
Expand All @@ -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 = {
Expand All @@ -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)
Loading

0 comments on commit b2de74e

Please sign in to comment.