|
#!/usr/bin/python
# -*- coding:utf8 -*-
### 2017-04-10
import os
import commands
import time
DownIp = '106.75.87.81'
CurrTime = time.strftime('%Y%m%d', time.localtime(time.time()))
Year = time.strftime('%Y', time.localtime(time.time()))
Month = time.strftime('%m', time.localtime(time.time()))
Day = time.strftime('%d', time.localtime(time.time()))
BaseDir = '/data/down_logs/'
Yesterday = 0
###
CurrTime = int(CurrTime)
Day = int(Day)
Year = int(Year)
Month = int(Month)
if Day != 1:
Yesterday = CurrTime - 1
if Day == 1 and (Month in [5,7,10,12]):
Month = Month - 1
if 1 <= Month <= 9:
Month = "%02d" % Month
Day = 30
Yesterday = str(Year) + str(Month) + str(Day)
if Day == 1 and (Month in [2,4,6,8,9,11]):
Month = Month - 1
if 1 <= Month <= 9:
Month = "%02d" % Month
Day = 31
Yesterday = str(Year) + str(Month) + str(Day)
if Day == 1 and Month == 1:
Month = 12
Day = 31
Year = Year - 1
Yesterday = str(Year) + str(Month) + str(Day)
if Day == 1 and Month == 3:
Month = Month - 1
if 1 <= Month <= 9:
Month = "%02d" % Month
flag = Year % 4
if flag == 0:
Day = 29
else:
Day = 28
Yesterday = str(Year) + str(Month) + str(Day)
#####
## Down logs
FullDir = BaseDir + str(Yesterday)
if not os.path.exists(FullDir):
os.mkdir(FullDir)
os.chdir(FullDir)
LogList = ["%02d"%i for i in range(0,24)]
for x in LogList:
Url = "http://" + DownIp + "/logs/" + str(Yesterday) + "/down.tvmore.com.cn/big_" + str(Yesterday) + str(x) + "_access.log.seg000.gz"
cmd = 'wget %s' % Url
(status,output) = commands.getstatusoutput(cmd)
if status:
print "success"
#The counts of downdload
(Stat,Output) = commands.getstatusoutput('zcat * | grep MoreTV_TVApp_2_0_Android/20170214/MoreTVApp3.0_guanwang_V3.1.3.apk| wc -l')
result = open('/data/www/tongji/index.html','a+')
if Stat == 0:
result.write("<h3>" + str(Yesterday) + ':'+ " " + Output + "</h3>")
result.close()
|
|