/
copyjson.py
36 lines (29 loc) · 1.31 KB
/
copyjson.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
import glob, os
from shutil import copy
def copyjson():
for subdir in os.listdir("/media/"):
print(subdir)
subdirpath = "/media/"+subdir+"/"
print(subdirpath)
if os.path.exists(subdirpath):
print("exists")
#access = os.access(subdirpath, os.R_OK)
#print(access)
#if access:
#print("before")
#print(os.listdir(subdirpath))
for file in os.listdir(subdirpath):
#print("after")
print(file)
if file.endswith(".json.txt"):
print("hi")
copy(subdirpath+"/"+file, "/home/pi/locations")
print("bye")
return True
else:
print("file not found")
else:
print("path not acessible")
else:
print("path not found")
return False