zoukankan      html  css  js  c++  java
  • 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:]+"
    ")
    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
  • 相关阅读:
    设计模式C++描述----06.适配器(Adapter)模式
    设计模式C++描述----05.职责链(Chain of Responsibility)模式
    设计模式C++描述----04.观察者(Observer)模式
    设计模式C++描述----03.工厂(Factory)模式
    设计模式的几种原则
    设计模式C++描述----02.模板(Template)模式
    常用 UML 类图
    前端插件之Bootstrap Switch 选择框开关控制
    Django处理流程
    Django之logging日志
  • 原文地址:https://www.cnblogs.com/strikebone/p/3574654.html
Copyright © 2011-2022 走看看