-
Notifications
You must be signed in to change notification settings - Fork 0
/
tm_list.py
48 lines (37 loc) · 1.4 KB
/
tm_list.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
43
44
45
46
47
48
'''
Created on Mar 1, 2015
@author: namezys
Show state of disabled backup of Time Machine
'''
import os
from argparse import ArgumentParser
from tm_police.ctrl import find_tm_disabled_parent
DESCR = """Check disable of Time Machine backup of given files and search
closest parent with disable flag"""
def main():
parser = ArgumentParser(description=DESCR)
parser.add_argument("-p", "--parent", action="store_true",
help="Show parent with given property")
parser.add_argument("-a", "--all", action="store_true",
help="Print all paths. Otherwise print only\
path with disabled backup")
parser.add_argument("paths", nargs="*", help="path for check")
args = parser.parse_args()
paths = args.paths
if not paths:
paths = os.listdir(".")
elif len(paths) == 1:
paths = [os.path.join(paths[0], i) for i in os.listdir(paths[0])]
for path in paths:
abs_path = os.path.abspath(path)
parent = find_tm_disabled_parent(abs_path)
if parent is None and not args.all:
continue
print path,
if args.parent and parent is not None:
rel_path = os.path.relpath(parent, abs_path)
parent = os.path.normpath(os.path.join(path, rel_path))
print '*' if parent == path else parent,
print
if __name__ == '__main__':
main()