#!/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("ÕýÈ·Éú³ÉÎļþ£¡£¡£¡")