1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package CreateAllCaptchaPath
#
# @todo: Éú³ÉͼÐÎÑéÖ¤ÂëµÄ·¾¶±í
# @author Alee
# @date 2011-06-07 15:30
# @version 1.1
#
# ÏêϸÃèÊö:
# @change: "2011-06-23 14:00" Alee Ìí¼ÓËæ»úÉú³ÉͼÐÎÖØÔØ¹¦ÄÜ
#------------------------------------------------------------------------------ 
"""Version = 2011-06-23 14:00"""
 
 
import os
import sys
import datetime
 
 
def CreateCaptchaFile():
    #ĬÈϵ±Ç°Â·¾¶
    Def_Captcha_Path = ''
    
    ext, fileName = GetImageExt()
    
    if ext == '':
        LogFile("ûÓÐ×Ô¶¨ºó׺»ò±íÃû(no ext or filename in argv)")
        return
    
    LogFile("¿ªÊ¼Éú³ÉÎļþ%s ÄÚÈÝΪ%s"%(fileName, ext))
    
    fileIns = open(fileName, 'w')
    
    for path in os.walk(Def_Captcha_Path):
        
        filePath = path[0]
        for image in path[2]:
            tmpList = os.path.splitext(filePath.split('\\')[-1] + '_' + image)
            
            if tmpList[-1] != ext:
                continue
            
            fileIns.write(os.path.splitext(filePath.split('\\')[-1] + '_' + image)[0] + '\t' + filePath + os.sep + image + '\n')
    
    fileIns.close()
 
def GetImageExt():
    if len(sys.argv) != 3:
        return ['', '']
    
    return sys.argv[1:]
 
def LogFile(msg):
    fileIns = open('log.txt', 'a+')
    timestr = str(datetime.datetime.today()).split('.')[0]
    fileIns.write(timestr + '\t' + msg + '\n')
    fileIns.close()
    print msg
    
    
try:
    CreateCaptchaFile()
except Exception, e:
    LogFile("·¢Éú´íÎó: %s"%e)
    
LogFile("ÕýÈ·Éú³ÉÎļþ£¡£¡£¡")