-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsync.py
More file actions
31 lines (17 loc) · 783 Bytes
/
rsync.py
File metadata and controls
31 lines (17 loc) · 783 Bytes
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
import subprocess
import filecmp
class R_sync:
def __init__(self, from_folderpath, to_folderpath):
self.from_folderpath = str(from_folderpath)
self.to_folderpath = str(to_folderpath)
def sync(self):
# Running the shell command:
subprocess.run(f"(rsync {self.from_folderpath+'/*'} {self.to_folderpath})", shell=True)
def compare(self):
# Comparing to make sure both directories are identical
if self.from_folderpath !="" and self.to_folderpath !="":
comparison = filecmp.dircmp(self.from_folderpath, self.to_folderpath)
for item in comparison.left_list:
if item not in comparison.right_list:
return False
return True