Last active
August 28, 2016 07:29
-
-
Save mintisan/e4ac4593c7f47f63bfc9bf23a8b85f9c to your computer and use it in GitHub Desktop.
copy bin from Downloads directory to board(like Nucleo) automatically for mbed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from shutil import copyfile | |
# `sudo pip install walkdir` if you don't install walkdir | |
import walkdir as wd | |
import time | |
src_dir = os.environ['HOME']+'/Downloads/' | |
dst_dir = '/Volumes/NUCLEO/' | |
pattern = "*_NUCLEO_F401RE.bin" | |
while True: | |
time.sleep(1) | |
bin_file = wd.file_paths(wd.filtered_walk(src_dir, depth=0,included_files=[pattern])) | |
fn_l = list(bin_file) | |
if len(fn_l) == 0: | |
print("no bin file is exits!") | |
continue | |
fn = str(fn_l[0]).split('/')[-1] | |
print(fn, "is coped to " + dst_dir) | |
copyfile(src_dir+fn,dst_dir+fn) | |
os.remove(src_dir+fn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment