Skip to content

Commit

Permalink
fixed temp directory bug with build
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaaoBlues authored Jul 20, 2021
1 parent 1705777 commit e8c39e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 5 additions & 2 deletions copypasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pyautogui import write as send_keystrokes
from flask_cors import CORS, cross_origin
from re import findall
import sys

#init flask app and secret key
app = Flask(__name__)
Expand All @@ -25,8 +26,10 @@

app.secret_key = "CF3gNqD#%#MpSs=7J!VmM2KxWCWhGwjSP%pc*4G?XuUU4s6CC=2KcUba4WPA#EhhZ52gyU57_nF6cDM*_B9X7FpPH%^-c+c8naZSx2$atBwS?V"

APP_PATH = path.abspath(__file__).replace("main.py","").replace("main.exe","").replace("copypasta.exe","").replace("copypasta.py","")

if getattr(sys, 'frozen', False):
APP_PATH = path.dirname(sys.executable)
elif __file__:
APP_PATH = path.dirname(__file__)



Expand Down
17 changes: 12 additions & 5 deletions launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
from shutil import rmtree
from zipfile import ZipFile
from os import path, chdir, remove
import sys

APP_PATH = path.abspath(__file__).replace("main.py","").replace("main.exe","").replace("copypasta.exe","").replace("copypasta.py","").replace("launcher.exe","").replace("launcher.py","")
if getattr(sys, 'frozen', False):
APP_PATH = path.dirname(sys.executable)
elif __file__:
APP_PATH = path.dirname(__file__)


def update_main_executable(version: str) -> None:

if not literal_eval(get("https://api.github.com/repos/CopyPastaOfficial/CopyPasta/tags").text)[0]['name'] == version:


print("NOT UP TO DATE")
#remove copypasta folder berfore downloading new version
try:
rmtree("copypasta")
Expand Down Expand Up @@ -43,8 +47,10 @@ def get_current_version_and_check_update() -> None:

with open("copypasta/version","r") as f:
version = f.read()
print(version)
f.close()
update_main_executable(version)

update_main_executable(version)
except:
update_main_executable("0")

Expand All @@ -53,12 +59,13 @@ def get_current_version_and_check_update() -> None:

#make sure we work in the right directory
chdir(APP_PATH)
print(APP_PATH)

#install copypasta like if it is not installed by the same process as updating
if not is_installed():
#is still the lastest version ?
get_current_version_and_check_update()


print("starting copypasta...")
#now that we have the lastest, we can start the app :D
Popen("copypasta/copypasta.exe")

0 comments on commit e8c39e3

Please sign in to comment.