-
Notifications
You must be signed in to change notification settings - Fork 11
/
hdzero_programmer.py
52 lines (38 loc) · 1.36 KB
/
hdzero_programmer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import threading
import os
import sys
import shutil
from main_window import ui_thread_proc
from download import download_thread_proc
from ch341 import ch341_thread_proc
def get_resource_folder():
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.dirname(os.path.abspath(__file__))
resource_folder = os.path.join(base_path, "data_folder")
print(resource_folder)
return resource_folder
def check_and_release_resource():
resource_folder = get_resource_folder()
if os.path.exists("resource"):
pass
else:
for filename in os.listdir(resource_folder):
source_file = os.path.join(resource_folder, filename)
destination_file = os.path.join("resource", filename)
if os.path.isfile(source_file):
shutil.copy(source_file, destination_file)
elif os.path.isdir(source_file):
shutil.copytree(source_file, destination_file)
def main():
check_and_release_resource()
download_thread = threading.Thread(
target=download_thread_proc, name="download")
download_thread.start()
ui_thread = threading.Thread(target=ui_thread_proc, name="ui")
ui_thread.start()
ch341_thread = threading.Thread(target=ch341_thread_proc, name="ch341")
ch341_thread.start()
if __name__ == '__main__':
main()