0.3.0 final

- build now deletes old version before building the new one
- prints lauching before initializing
- removed multithreading from config saving
- better logic for fising interupted
- fix terms link bug
- now prints exception during web calls
- removes the uid if not found during get_session
This commit is contained in:
DESKTOP-JVKHS7I\Adam 2020-05-07 11:33:30 +05:30
parent 79c7f748e1
commit 066c25f08a
7 changed files with 32 additions and 17 deletions

View File

@ -11,8 +11,9 @@ Don't forget to star this repository if you really liked it :)
### How to Install? ### How to Install?
- Install [Python v3.7.3](https://www.python.org/downloads/release/python-373/) (make sure you tick, `Add Python to PATH`) - 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 pip install fishy
python -m fishy python -m fishy
``` ```

View File

@ -1,4 +1,5 @@
@echo off @echo off
rd build dist /s /q
call activate ./venv call activate ./venv
python ./setup.py sdist python ./setup.py sdist
python ./setup.py bdist_wheel python ./setup.py bdist_wheel

View File

@ -3,7 +3,6 @@ import logging
import os import os
import sys import sys
import time import time
from os import execl
from tkinter import messagebox from tkinter import messagebox
import win32con import win32con
@ -127,7 +126,7 @@ def initialize(gui, c: Config):
create_shortcut_first(gui, c) create_shortcut_first(gui, c)
initialize_uid(c) initialize_uid(c)
new_session = web.get_session(c.get('uid')) new_session = web.get_session(c)
if new_session is None: if new_session is None:
logging.error("Couldn't create a session, some features might not work") logging.error("Couldn't create a session, some features might not work")
print(f"created session {new_session}") print(f"created session {new_session}")
@ -171,6 +170,8 @@ def ask_terms():
def main(): def main():
print("launching please wait...")
c = Config() c = Config()
if not check_eula(c): if not check_eula(c):

View File

@ -20,9 +20,11 @@ class Config:
if save: if save:
self.save_config() self.save_config()
def delete(self, key):
del self.config_dict[key]
self.save_config()
def save_config(self): def save_config(self):
def save():
with open(filename, 'w') as f: with open(filename, 'w') as f:
f.write(json.dumps(self.config_dict)) f.write(json.dumps(self.config_dict))
Thread(target=save).start()

View File

@ -87,11 +87,13 @@ class IdleEvent(FishEvent):
:param previousMode: previous mode in the state machine :param previousMode: previous mode in the state machine
""" """
if previousMode.name == "hook": if G.fishCaught > 0:
logging.info("HOLE DEPLETED")
web.send_hole_deplete(self.uid, G.fishCaught, time.time() - G.hole_start_time, G.fish_times) web.send_hole_deplete(self.uid, G.fishCaught, time.time() - G.hole_start_time, G.fish_times)
G.fishCaught = 0 G.fishCaught = 0
elif previousMode.name == "stick":
if previousMode.name == "hook":
logging.info("HOLE DEPLETED")
else:
logging.info("FISHING INTERRUPTED") logging.info("FISHING INTERRUPTED")
def onExitCallback(self, currentMode): def onExitCallback(self, currentMode):

View File

@ -88,7 +88,7 @@ def _formatHyperLink(text, message):
lambda *a, **k: text.config(cursor="arrow")) lambda *a, **k: text.config(cursor="arrow"))
text.tag_bind(str(index), text.tag_bind(str(index),
"<Button-1>", "<Button-1>",
lambda: webbrowser.open(groups['address'])) lambda x: webbrowser.open(groups['address']))
start = match.end() start = match.end()
else: else:
text.insert("end", message[start:]) text.insert("end", message[start:])

View File

@ -1,14 +1,16 @@
import logging import logging
import traceback
from functools import wraps from functools import wraps
import requests import requests
from whatsmyip.ip import get_ip from whatsmyip.ip import get_ip
from whatsmyip.providers import GoogleDnsProvider from whatsmyip.providers import GoogleDnsProvider
from fishy.systems import helper
from fishy.systems.globals import G from fishy.systems.globals import G
# domain = "https://fishyeso.herokuapp.com" domain = "https://fishyeso.herokuapp.com"
domain = "http://127.0.0.1:5000" # domain = "http://127.0.0.1:5000"
user = "/api/user" user = "/api/user"
notify = "/api/notify" notify = "/api/notify"
@ -37,8 +39,8 @@ def fallback(default):
try: try:
return f(*args, **kwargs) return f(*args, **kwargs)
except: except:
traceback.print_exc()
return default return default
return wrapper return wrapper
return inner return inner
@ -105,11 +107,17 @@ def unsub(uid):
@fallback(None) @fallback(None)
def get_session(uid, lazy=True): def get_session(config, lazy=True):
if lazy and G._session_id is not None: if lazy and G._session_id is not None:
return G._session_id return G._session_id
body = {"uid": uid} body = {"uid": config.get("uid")}
response = requests.post(domain + session, params=body) 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"] G._session_id = response.json()["session_id"]
return G._session_id return G._session_id