wildcat007
2017-01-20 18:02:47 +08:00
渣渣代码分享下
[code]#!/usr/bin/env python
# coding=utf-8
# author=Tonybreak
import os
import platform
import time
WIN_RSYNC = 'E:/xxxx/cwRsync_5.5.0_x86_Free/bin/rsync.exe'
LINUX_RSYNC = '/usr/bin/rsync'
HOST = '10.3.5.70'
MOD_NAME = 'logs'
def i_system():
return platform.system()
def choose_rsync():
if i_system() == "Windows":
rsync = WIN_RSYNC
elif i_system() == "Linux":
rsync = LINUX_RSYNC
else:
rsync = "Maybe something is wrong."
return rsync
def rsync_cmd():
target = []
rsync = choose_rsync()
cmds = '%s %s::%s' %(rsync,HOST,MOD_NAME)
dd = os.popen(cmds)
for d in dd:
target.append(d.strip().split(' '))
for i in target:
d4 = int(i[-4].replace(',', ''))
t = str(i[-3] + ' ' + i[-2])
t1 = time.strptime(t, '%Y/%m/%d %H:%M:%S')
t3 = int(time.mktime(t1))
print i[-1], t3, d4
def main():
rsync_cmd()
if __name__ == '__main__':
main()
[/code]