Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Commit 6c6ffde

Browse files
authored
Added filecheck.py
Includes the check_files function to download the required files.
1 parent 2fc00e4 commit 6c6ffde

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

utils/filecheck.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import requests
3+
4+
from windows.loading import LoadingWindow
5+
6+
def check_files():
7+
loadingwindow = LoadingWindow()
8+
9+
files = [
10+
"https://raw.githubusercontent.com/bentettmar/barnotes/main/data/icon.png",
11+
"https://raw.githubusercontent.com/bentettmar/barnotes/main/data/note.txt"
12+
]
13+
14+
loadingwindow.update_text("Checking files...")
15+
if not os.path.exists(os.path.expanduser("~/Library/Application Support/BarNotes")):
16+
os.makedirs(os.path.expanduser("~/Library/Application Support/BarNotes"))
17+
loadingwindow.update_text("Creating directory...")
18+
19+
loadingwindow.update_text("Downloading files...")
20+
for file in files:
21+
if not os.path.exists(os.path.expanduser(f"~/Library/Application Support/BarNotes/{file.split('/')[-1]}")):
22+
loadingwindow.update_text(f"Downloading {file.split('/')[-1]}...")
23+
r = requests.get(file)
24+
with open(os.path.expanduser(f"~/Library/Application Support/BarNotes/{file.split('/')[-1]}"), "wb") as f:
25+
f.write(r.content)
26+
loadingwindow.update_text(f"Downloaded {file.split('/')[-1]}...")
27+
28+
loadingwindow.update_text("Done!")
29+
loadingwindow.destroy()

0 commit comments

Comments
 (0)