-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy2rpi.py
42 lines (30 loc) · 964 Bytes
/
copy2rpi.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
import os
import subprocess
from dotenv import load_dotenv
# load the envs from .env
load_dotenv()
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
PI_IP = os.getenv("PI_IP")
PC_DATA_FOLDER = (
os.path.join(SCRIPT_PATH) + "/"
) # the / implies to copy the src folder into the dst folder, not as as subfolder
PI_DATA_FOLDER = f"pi@{PI_IP}:~/Projects/tagespaul_2.0/"
################################
# Copy data to py
################################
print("*********** copy data to PI ***********")
sub_string = "rsync -av -e ssh {0} {1} --exclude=/.git/ ".format(
PC_DATA_FOLDER,
PI_DATA_FOLDER,
)
print(sub_string)
sub_report = subprocess.call(sub_string, shell=True)
print(sub_report)
# print('*********** copy data from PI ***********')
# sub_string = 'rsync -av -e ssh {0} {1}'.format(
# PI_DATA_FOLDER,
# PC_DATA_FOLDER,
# )
# print(sub_string)
# sub_report = subprocess.call(sub_string, shell = True)
# print(sub_report)