-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsync.py
41 lines (34 loc) · 1.07 KB
/
dsync.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
"""
"""
from dsync.arguments import Arguments
from dsync.logger import Logger
from dsync.timer import Timer
from dsync.uploader import Uploader
from dsync.auth import Auth
class Dsync:
def __init__(self, args):
self.timer = Timer().start()
self.args = args
self.logger = Logger.create(
name=__name__,
level=args.log_level)
self.uploader = Uploader(
target_dir=args.directory,
chunk_size=args.chunk_size,
custom_ignore=args.ignore,
dryrun=args.dryrun)
self.auth = Auth(access_token=args.access_token)
def execute(self):
self.logger.info('Started with %s %s' % (
self.args.directory,
'[dryrun]' if self.args.dryrun else '',
))
self.uploader.ensure_client(
token=self.auth.ensure_token()
).walk()
return self
def exit(self):
self.logger.info('Exiting %s' % self.timer.stop())
return self
if __name__ == '__main__':
Dsync(args=Arguments.create().parse()).execute().exit()