ccttp图片处理过程
1.python输出404的图片
1 #!/usr/bin/python 2 # coding: utf-8 3 4 import psycopg2 5 import sys 6 from datetime import * 7 import time 8 import urllib 9 import urllib2 10 import httplib 11 import json 12 from jinja2 import Template 13 from jinja2 import Environment, PackageLoader 14 import codecs 15 import smtplib 16 from email.MIMEText import MIMEText 17 18 19 def getImageFromPath(imgPath): 20 try: 21 conn = httplib.HTTPConnection("img111.com") 22 conn.request("GET", "/ttttn/"+imgPath) 23 r1 = conn.getresponse() 24 if r1.status == 404: 25 output = open('/tmp/data1', 'a') 26 output.write(imgPath[5:]+"\r\n") 27 output.close() 28 print "not find " + imgPath 29 conn.close() 30 except: 31 print "get url Exp" 32 return 33 34 def queryDb(): 35 conn = psycopg2.connect(database="", user="", password="", host="", port="5432") 36 cur = conn.cursor() 37 38 offset = 0; 39 while(1): 40 time.sleep(2) 41 exeSql="SELECT id,image from aaa where type='cccc' and image like 'tttt%' order by id limit 100 offset " + str(offset) 42 cur.execute(exeSql) 43 rows = cur.fetchall() 44 offset += 100 45 if(len(rows) <= 0): 46 break 47 for row in rows: 48 #print str(row[0]) + ":" + row[1] 49 imgPath = row[1] 50 imgPathItems = imgPath.split('/') 51 if(len(imgPathItems) >=4 ): 52 lasts = imgPathItems[3].split('.') 53 strItem = imgPathItems[0] + "/" +imgPathItems[1] + "/" + imgPathItems[2] + "/4_" + lasts[0] + "_index.jpg" 54 getImageFromPath(strItem)
2.touch相关的文件
DIR1=/home for line in `cat /tmp/data1` do echo "touch ${DIR1}/${line}" touch ${DIR1}/${line} sleep 3 done
posted on 2014-03-01 07:28 strikebone 阅读(382) 评论(0) 编辑 收藏 举报