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
  • 相关阅读:
    8086 CPU 寄存器
    python中 * 的用法
    字典的相应操作
    tesseract学习记录
    C学习之路2012.8.28
    函数库管理
    2013.3.19C++浏览记录。。。
    自动生成makefile文件学习
    整理做过的东西(电子警察)
    基于zed的tesseract移植过程记录
  • 原文地址:https://www.cnblogs.com/strikebone/p/3574654.html
Copyright © 2011-2022 走看看