-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_all.py
29 lines (21 loc) · 942 Bytes
/
upload_all.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
import os
import pathlib
from utils import upload_file_to_karmen, print_msg
from settings import GCODE_DIR
def upload_all_func():
gcode_files = os.listdir(GCODE_DIR)
for file in gcode_files:
file_path = pathlib.Path(os.path.join(GCODE_DIR, file))
if file_path.suffix != '.UPLOADED': # skip .UPLOADED files
print_msg(f'Processing file: {file_path}')
if file_path.suffix != '.gcode':
print_msg(f' - Skip uknown file type.')
elif file_path.suffix == '.gcode':
if f'{file}.UPLOADED' in gcode_files:
print_msg(f' - Skip - file is already uploaded.')
else:
print_msg(f' - Going to upload file to Karmen...')
upload_file_to_karmen(file_path.name, file_path)
open(f'{file_path}.UPLOADED', 'a').close()
if __name__ == '__main__':
upload_all_func()