1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-06 14:36:47 +00:00

ensure log dir

这个提交包含在:
bigeagle
2014-10-18 22:08:52 +08:00
父节点 e4a0790c66
当前提交 2ddb524f77

查看文件

@@ -19,6 +19,11 @@ class MirrorProvider(object):
self.hooks = hooks self.hooks = hooks
self.p = None self.p = None
def ensure_log_dir(self):
log_dir = os.path.dirname(self.log_file)
if not os.path.exists(log_dir):
sh.mkdir("-p", log_dir)
def run(self): def run(self):
raise NotImplementedError("run method should be implemented") raise NotImplementedError("run method should be implemented")
@@ -65,7 +70,7 @@ class RsyncProvider(MirrorProvider):
return _options return _options
def run(self): def run(self):
self.ensure_log_dir()
_args = self.options _args = self.options
_args.append(self.upstream_url) _args.append(self.upstream_url)
_args.append(self.local_dir) _args.append(self.local_dir)
@@ -86,7 +91,7 @@ class ShellProvider(MirrorProvider):
self.command = command.split() self.command = command.split()
def run(self): def run(self):
self.ensure_log_dir()
now = datetime.now().strftime("%Y-%m-%d_%H") now = datetime.now().strftime("%Y-%m-%d_%H")
log_file = self.log_file.format(date=now) log_file = self.log_file.format(date=now)