commit 9d38ea4e43a43f8e1eb6e1c7e301bd30f79898ea parent 83d9135eff8734e060c01a96390f6baefe9151df Author: therealFIGBERT <figbertwelner@gmail.com> Date: Tue, 30 Jul 2019 12:57:18 -0700 Changing target filepath in test file Diffstat:
M | Test/test.py | | | 14 | +++++++++++++- |
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/Test/test.py b/Test/test.py @@ -2,10 +2,22 @@ import os import requests import tkinter as tk +def find_path(file): + """Return the correct filename if you are running it as a script""" + return os.path.dirname( + os.path.abspath( + inspect.getfile( + inspect.currentframe() + ) + ) + ) + "/{}".format(file) + def update_script(): git_data = requests.get("https://raw.githubusercontent.com/therealFIGBERT/figENC/master/Test/test.py").text - with open(os.getcwd() + "test.py", "w") as write: + print("File read") + with open(find_path("test.py")) as write: write.write(git_data) + print("File written") #This line is only on GitHub root = tk.Tk()