首页 技术 正文
技术 2022年11月23日
0 收藏 880 点赞 3,864 浏览 1565 个字

import pymongo,urllib
import sys
import time
import datetime
reload(sys)
sys.setdefaultencoding(‘utf8’)
from pymongo.connection import Connection
from datetime import timedelta
import os

connection=pymongo.Connection(‘127.0.0.1’,27017)
db = connection.upload
db.authenticate(“username”,”passowd”)
format=”%Y-%m-%d %H:%M:%S”
fileName=”dstUrl”
datefmt=”%m%d”

now = datetime.datetime.now().replace(day=1,hour=0,minute=0,second=0)
aDay = timedelta(days =-1)
endDate=now+aDay
startDate=endDate.replace(day=1)
endDateStr=endDate.strftime(format)
startDateStr=startDate.strftime(format)
startTime=int(time.mktime(time.strptime(startDateStr, ‘%Y-%m-%d %H:%M:%S’))*1000)
endTime=int(time.mktime(time.strptime(endDateStr, ‘%Y-%m-%d %H:%M:%S’))*1000)
#f=open(fileName, “w”)
fileName=fileName+”(“+startDate.strftime(datefmt)+”-“+endDate.strftime(datefmt)+”).txt”

def findList(startTime,endTime):
print “startTime”+startDateStr+” endTime”+endDateStr
query={“completeTime”:{“$gte”:startTime,”$lt”:endTime},”status”:30,”videoCDNStatus”:10,”checksumStatus”:10,”mmsStatus”:1}
encodeCursor=db.video_encode.find(query)
historyCursor=db.video_encode_history.find(query)
taskIterator(encodeCursor)
taskIterator(historyCursor)

def taskIterator(cusor):
for encode in cusor:
mid=encode[“mid”]
encodeId=encode[“encodeId”]
vtype=encode[“vtype”]
dstUrl=encode[“dstUrl”]
checksumPath=encode[“checksumPtah”]
f.write(str(mid)+”,”+str(encodeId)+”,”+vtype+”,”+dstUrl+”,”+checksumPath+”\n”)

print “start run to export dst url to file %s”,fileName
if(os.path.isfile(fileName)):
print “file %s is exsis ,not create file”,fileName
else:
f=open(fileName, “w”)
findList(startTime,endTime)
f.close;

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,946
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,472
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,285
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,101
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,733
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,768