diff --git a/README.md b/README.md index 18b84e4..b0c0727 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@ Don't forget to star this repository if you really liked it :) ### How to Install? - Install [Python v3.7.3](https://www.python.org/downloads/release/python-373/) (make sure you tick, `Add Python to PATH`) -- Then open PowerShell and type these commands, +- Then open PowerShell and type these commands, one by one, ``` +python -m pip install pip --upgrade pip install fishy python -m fishy ``` diff --git a/build.bat b/build.bat index 4de4449..aa69ad5 100644 --- a/build.bat +++ b/build.bat @@ -1,4 +1,5 @@ @echo off +rd build dist /s /q call activate ./venv python ./setup.py sdist python ./setup.py bdist_wheel diff --git a/fishy/__main__.py b/fishy/__main__.py index d8554c4..51c2cfb 100644 --- a/fishy/__main__.py +++ b/fishy/__main__.py @@ -3,7 +3,6 @@ import logging import os import sys import time -from os import execl from tkinter import messagebox import win32con @@ -127,7 +126,7 @@ def initialize(gui, c: Config): create_shortcut_first(gui, c) initialize_uid(c) - new_session = web.get_session(c.get('uid')) + new_session = web.get_session(c) if new_session is None: logging.error("Couldn't create a session, some features might not work") print(f"created session {new_session}") @@ -171,6 +170,8 @@ def ask_terms(): def main(): + print("launching please wait...") + c = Config() if not check_eula(c): diff --git a/fishy/systems/config.py b/fishy/systems/config.py index a47f048..aadf964 100644 --- a/fishy/systems/config.py +++ b/fishy/systems/config.py @@ -20,9 +20,11 @@ class Config: if save: self.save_config() - def save_config(self): - def save(): - with open(filename, 'w') as f: - f.write(json.dumps(self.config_dict)) + def delete(self, key): + del self.config_dict[key] + self.save_config() + + def save_config(self): + with open(filename, 'w') as f: + f.write(json.dumps(self.config_dict)) - Thread(target=save).start() diff --git a/fishy/systems/fishing_event.py b/fishy/systems/fishing_event.py index 485efbf..e7268dc 100644 --- a/fishy/systems/fishing_event.py +++ b/fishy/systems/fishing_event.py @@ -87,11 +87,13 @@ class IdleEvent(FishEvent): :param previousMode: previous mode in the state machine """ - if previousMode.name == "hook": - logging.info("HOLE DEPLETED") + if G.fishCaught > 0: web.send_hole_deplete(self.uid, G.fishCaught, time.time() - G.hole_start_time, G.fish_times) G.fishCaught = 0 - elif previousMode.name == "stick": + + if previousMode.name == "hook": + logging.info("HOLE DEPLETED") + else: logging.info("FISHING INTERRUPTED") def onExitCallback(self, currentMode): diff --git a/fishy/systems/terms_gui.py b/fishy/systems/terms_gui.py index d05a6c5..1dcd62f 100644 --- a/fishy/systems/terms_gui.py +++ b/fishy/systems/terms_gui.py @@ -88,7 +88,7 @@ def _formatHyperLink(text, message): lambda *a, **k: text.config(cursor="arrow")) text.tag_bind(str(index), "", - lambda: webbrowser.open(groups['address'])) + lambda x: webbrowser.open(groups['address'])) start = match.end() else: text.insert("end", message[start:]) diff --git a/fishy/systems/web.py b/fishy/systems/web.py index b10033e..2b9e25b 100644 --- a/fishy/systems/web.py +++ b/fishy/systems/web.py @@ -1,14 +1,16 @@ import logging +import traceback from functools import wraps import requests from whatsmyip.ip import get_ip from whatsmyip.providers import GoogleDnsProvider +from fishy.systems import helper from fishy.systems.globals import G -# domain = "https://fishyeso.herokuapp.com" -domain = "http://127.0.0.1:5000" +domain = "https://fishyeso.herokuapp.com" +# domain = "http://127.0.0.1:5000" user = "/api/user" notify = "/api/notify" @@ -37,8 +39,8 @@ def fallback(default): try: return f(*args, **kwargs) except: + traceback.print_exc() return default - return wrapper return inner @@ -105,11 +107,17 @@ def unsub(uid): @fallback(None) -def get_session(uid, lazy=True): +def get_session(config, lazy=True): if lazy and G._session_id is not None: return G._session_id - body = {"uid": uid} + body = {"uid": config.get("uid")} response = requests.post(domain + session, params=body) + + if response.status_code == 405: + config.delete("uid") + helper.restart() + return None + G._session_id = response.json()["session_id"] return G._session_id