2007年04月09日 星期一 12:27
Dear all,
§Ú¥ÎPython¼g¤F¤@Óµ{¦¡¦Û°Ê§ì¤å¥ó¡Aµ{¦¡¤@ª½¦b¹B¦æ¤¤¡A¨C¹j30¬í·|¥h
°»´ú¤@¦¸¬O§_¦³¤å¥ó¦s¦b¦}Ū¨ú¡C¦ý¬O²{¦bµo²{¨C¹j30¬í°»´ú¹L¤å¥ó¦Z¡Aµ{¦¡¥e¥Î
ªº¤º¦s·|¼W¥[¡A°ò¥»¤W¨C¦¸¼W¥[4K¡A³o¼Ë·íµ{¦¡³sÄò¹B¦æ´XÓ¬P´Á¦Z¡A¥e¥Îªº¤º¦s
·|«D±`¤j¡A½Ð°Ý«ç¤\¯à¦Û°ÊÄÀ©ñ¥e¥Îªº¤º¦s¡H
-------------- 下一部分 --------------
¤@?HTMLªþ¥ó³Q²¾°£...
URL: http://python.cn/pipermail/python-chinese/attachments/20070409/f903ae93/attachment.html
2007年04月09日 星期一 12:36
»áÔö¼ÓµÄ£¿ÊDz»ÊÇÄãfork³öÁË×Ó½ø³Ìѽ£¿ ûÊÂ×öµÄʱºòsleep»áÔö¼ÓÄÚ´æµÄ£¿ºÃÏñ²»»á°É On 4/9/07, Zuggie <zuggie.zhu在gmail.com> wrote: > > Dear all, > ÎÒÓÃPythonÁËÒ»³Ìʽ×ÔÓ×¥Îļþ£¬³ÌʽһֱÔÚß\ÐÐÖУ¬Ã¿¸ô30ÃëþÈ¥ > ÉyÒ»´ÎÊÇ·ñÓÐÎļþ´æÔÚ²¢×xÈ¡¡£µ«ÊǬFÔÚ°l¬Fÿ¸ô30ÃëÉyß^Îļþºó£¬³ÌʽռÓà > µÄÈ´æþÔö¼Ó£¬»ù±¾ÉÏÿ´ÎÔö¼Ó4K£¬ß@Ó®³ÌʽßBÀmß\ÐÐ×ÐÇÆÚºó£¬Õ¼ÓõÄÈ´æ > þ·Ç³£´ó£¬ÕÔõôÄÜ×ÔÓá·ÅÕ¼ÓõÄȴ棿 > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- ×¢ÒâÉíÌ壬ÉíÌåÊǸïÃüµÄ±¾Ç®£¡£¡ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070409/5b3fe642/attachment.htm
2007年04月09日 星期一 12:37
ÄãµÄ³ÌÐòдµÄÓÐÎÊÌâ°É£¬ÊDz»ÊÇÓÐЩ¶ÔÏóûÓÐÊÍ·Å£¬±ÈÈ磬²»Í£µÄÌí¼Óµ½list¶ÔÏóÖÐÁË£¬python×Ô¶¯À¬»ø»ØÊյġ£ ÁíÍ⣬python2¡£2µÄÀ¬»ø»ØÊÕÓÐЩÎÊÌâ¡£ Ä㻹¿ÉÒÔ¿´¿´pythonµÄGCÄ£¿é¡£ 2007/4/9, Zuggie <zuggie.zhu at gmail.com>: > > Dear all, > ÎÒÓÃPythonÁËÒ»³Ìʽ×ÔÓ×¥Îļþ£¬³ÌʽһֱÔÚß\ÐÐÖУ¬Ã¿¸ô30ÃëþÈ¥ > ÉyÒ»´ÎÊÇ·ñÓÐÎļþ´æÔÚ²¢×xÈ¡¡£µ«ÊǬFÔÚ°l¬Fÿ¸ô30ÃëÉyß^Îļþºó£¬³ÌʽռÓà > µÄÈ´æþÔö¼Ó£¬»ù±¾ÉÏÿ´ÎÔö¼Ó4K£¬ß@Ó®³ÌʽßBÀmß\ÐÐ×ÐÇÆÚºó£¬Õ¼ÓõÄÈ´æ > þ·Ç³£´ó£¬ÕÔõôÄÜ×ÔÓá·ÅÕ¼ÓõÄȴ棿 > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- devdoer devdoer at gmail.com http://devdoer.blog.sohu.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070409/f1c731d8/attachment.html
2007年04月09日 星期一 12:44
¾ÍÊÇÒòéPython±¾íþ×ÔÓ»ØÊÕÀ¬»ø£¬ËùÒÔÎÒ²ÅÓXµÃÓÐî}ÏÂÃæÊdzÌʽԴ´a¡£
#!/usr/bin/env python
# -*- encoding:utf-8 -*-
# This program for get HuangPu Final Test Data and Update SFC data
# It will 30 second execute one time.
#
# code by: Zuggie.Zhu
# code date: 2007-03-22
# version: 1.0.1
import os
import sys
import pymssql
import decimal
from DBConnect import *
from time import *
syspath = os.path.dirname(sys.argv[0])
myconns = CDBConfig(syspath + "\\DBConnect.config")
con = pymssql.connect(host = CDBConfig.DBConnects["host"], user =
CDBConfig.DBConnects["user"], \
password = CDBConfig.DBConnects["password"], database =
CDBConfig.DBConnects["database"])
def listDirectory(directory, fileExtList):
fileExtList = [ext.upper() for ext in fileExtList]
fileList = [os.path.join("", f) for f in os.listdir(directory) \
if os.path.splitext(f)[1].upper() in fileExtList]
return fileList
def get_path():
try:
f = open(syspath + "\\FbtTest.fp", "r")
try:
filepath = f.readline().strip()
finally:
f.close()
except:
pass
return filepath
while 1:
f_name = []
f_name = listDirectory(get_path(), [".mac"])
if len(f_name) > 0:
for i in range(len(f_name)):
try:
f_flag = ""
f_time = ""
f_result = ""
f_station = ""
f_operator = ""
f_chassis = ""
r_data = []
c_data = []
f_file = open(get_path() + "\\" + f_name[i], "r")
try:
s_flag = f_file.readline().rstrip()
s_time = f_file.readline().rstrip()
s_result = f_file.readline().rstrip()
s_station = f_file.readline().rstrip()
s_operator = f_file.readline().rstrip()
s_chassis = f_file.readline().rstrip()
f_flag = s_flag
f_time = s_time
f_result = s_result
f_station = s_station
f_operator = s_operator
f_chassis = s_chassis
if s_flag == "P":
query = "exec Dell_HuangPu_FBTTEST_sp '%s', '%s',
'%s', '', '', '%s', '%s', 'FbtTest', '0'" % (s_chassis, s_time, s_result,
s_station, s_operator)
else:
query = "exec Dell_HuangPu_FBTTEST_sp '%s', '%s',
'%s', '', '', '%s', '%s', 'FbtTest', '1'" % (s_chassis, s_time, s_result,
s_station, s_operator)
cur = con.cursor()
cur.__init__
cur.execute(query)
r_data = cur.fetchone()
for col in r_data:
c_data.append(col)
con.commit()
finally:
f_file.close()
Y = strftime('%Y')
M = strftime('%m')
D = strftime('%d')
h = strftime('%H')
m = strftime('%M')
s = strftime('%S')
t_time = Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
if c_data[0] > 0:
try:
f_file_2 = open(syspath + "\\Error\\" + f_name[i],
"a")
try:
f_file_2.write(f_flag + "\n")
f_file_2.write(f_time + "\n")
f_file_2.write(f_result + "\n")
f_file_2.write(f_station + "\n")
f_file_2.write(f_operator + "\n")
f_file_2.write(f_chassis + "\n")
f_file_2.write("\n\n" + t_time + " , " +
str(c_data[0]) + " , " + c_data[1] + "\n")
finally:
f_file_2.close()
except IOError:
pass
else:
try:
f_file_2 = open(syspath + "\\Backup\\" + f_name[i],
"a")
try:
f_file_2.write(f_flag + "\n")
f_file_2.write(f_time + "\n")
f_file_2.write(f_result + "\n")
f_file_2.write(f_station + "\n")
f_file_2.write(f_operator + "\n")
f_file_2.write(f_chassis +
"\n")
f_file_2.write("\n\n" + t_time + " transfer
finished" + "\n")
finally:
f_file_2.close()
except IOError:
pass
os.remove(get_path() + "\\" + f_name[i])
except IOError:
pass
sleep(1 * 30)
2007/4/9, bird devdoer <devdoer在gmail.com>:
>
> ÄãµÄ³ÌÐòдµÄÓÐÎÊÌâ°É£¬ÊDz»ÊÇÓÐЩ¶ÔÏóûÓÐÊÍ·Å£¬±ÈÈ磬²»Í£µÄÌí¼Óµ½list¶ÔÏóÖÐÁË£¬python×Ô¶¯À¬»ø»ØÊյġ£
> ÁíÍ⣬python2¡£2µÄÀ¬»ø»ØÊÕÓÐЩÎÊÌâ¡£
> Ä㻹¿ÉÒÔ¿´¿´pythonµÄGCÄ£¿é¡£
>
> 2007/4/9, Zuggie <zuggie.zhu在gmail.com >:
> >
> > Dear all,
> > ÎÒÓÃPythonÁËÒ»³Ìʽ×ÔÓ×¥Îļþ£¬³ÌʽһֱÔÚß\ÐÐÖУ¬Ã¿¸ô30ÃëþÈ¥
> > ÉyÒ»´ÎÊÇ·ñÓÐÎļþ´æÔÚ²¢×xÈ¡¡£µ«ÊǬFÔÚ°l¬Fÿ¸ô30ÃëÉyß^Îļþºó£¬³ÌʽռÓÃ
> > µÄÈ´æþÔö¼Ó£¬»ù±¾ÉÏÿ´ÎÔö¼Ó4K£¬ß@Ó®³ÌʽßBÀmß\ÐÐ×ÐÇÆÚºó£¬Õ¼ÓõÄÈ´æ
> > þ·Ç³£´ó£¬ÕÔõôÄÜ×ÔÓá·ÅÕ¼ÓõÄȴ棿
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> devdoer
> devdoer在gmail.com
> http://devdoer.blog.sohu.com/
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070409/a808b64d/attachment.html
2007年04月10日 星期二 00:24
通常解决这种问题使用“排除法”。把sleep去掉,然后一边注释你的代码一边跑,
一点一点的排除,什么时候发现内存不变了,大概就找到问题了。
在 2007-04-09一的 12:44 +0800,Zuggie写道:
> 就是因Python本自踊厥绽圾,所以我才X得有}下面是程式源a。
>
> #!/usr/bin/env python
> # -*- encoding:utf-8 -*-
> # This program for get HuangPu Final Test Data and Update SFC data
> # It will 30 second execute one time.
> #
> # code by: Zuggie.Zhu
> # code date: 2007-03-22
> # version: 1.0.1
>
> import os
> import sys
> import pymssql
> import decimal
> from DBConnect import *
> from time import *
>
> syspath = os.path.dirname(sys.argv[0])
>
> myconns = CDBConfig(syspath + "\\DBConnect.config")
> con = pymssql.connect(host = CDBConfig.DBConnects["host"], user =
> CDBConfig.DBConnects["user"], \
> password = CDBConfig.DBConnects ["password"], database =
> CDBConfig.DBConnects["database"])
>
> def listDirectory(directory, fileExtList):
> fileExtList = [ext.upper() for ext in fileExtList]
> fileList = [os.path.join ("", f) for f in os.listdir(directory) \
> if os.path.splitext(f)[1].upper() in fileExtList]
> return fileList
>
> def get_path():
> try:
> f = open(syspath + "\\FbtTest.fp", "r")
> try:
> filepath = f.readline().strip()
> finally:
> f.close()
> except:
> pass
> return filepath
>
> while 1:
> f_name = []
> f_name = listDirectory(get_path(), [".mac"])
>
> if len(f_name) > 0:
> for i in range(len(f_name)):
> try:
> f_flag = ""
> f_time = ""
> f_result = ""
> f_station = ""
> f_operator = ""
> f_chassis = ""
> r_data = []
> c_data = []
> f_file = open(get_path() + "\\" + f_name[i], "r")
> try:
> s_flag = f_file.readline().rstrip()
> s_time = f_file.readline().rstrip()
> s_result = f_file.readline().rstrip()
> s_station = f_file.readline().rstrip()
> s_operator = f_file.readline().rstrip()
> s_chassis = f_file.readline().rstrip()
> f_flag = s_flag
> f_time = s_time
> f_result = s_result
> f_station = s_station
> f_operator = s_operator
> f_chassis = s_chassis
> if s_flag == "P":
> query = "exec Dell_HuangPu_FBTTEST_sp '%s', '%
> s', '%s', '', '', '%s', '%s', 'FbtTest', '0'" % (s_chassis, s_time,
> s_result, s_station, s_operator)
> else:
> query = "exec Dell_HuangPu_FBTTEST_sp '%s', '%
> s', '%s', '', '', '%s', '%s', 'FbtTest', '1'" % (s_chassis, s_time,
> s_result, s_station, s_operator)
> cur = con.cursor()
> cur.__init__
> cur.execute(query)
> r_data = cur.fetchone()
> for col in r_data:
> c_data.append(col)
> con.commit()
> finally:
> f_file.close()
>
> Y = strftime('%Y')
> M = strftime('%m')
> D = strftime('%d')
> h = strftime('%H')
> m = strftime('%M')
> s = strftime('%S')
> t_time = Y + "-" + M + "-" + D + " " + h + ":" + m +
> ":" + s
>
> if c_data[0] > 0:
> try:
> f_file_2 = open(syspath + "\\Error\\" +
> f_name[i], "a")
> try:
> f_file_2.write(f_flag + "\n")
> f_file_2.write(f_time + "\n")
> f_file_2.write(f_result + "\n")
> f_file_2.write(f_station + "\n")
> f_file_2.write(f_operator + "\n")
> f_file_2.write(f_chassis + "\n")
> f_file_2.write("\n\n" + t_time + " , " +
> str(c_data[0]) + " , " + c_data[1] + "\n")
> finally:
> f_file_2.close()
> except IOError:
> pass
> else:
> try:
> f_file_2 = open(syspath + "\\Backup\\" +
> f_name[i], "a")
> try:
> f_file_2.write(f_flag + "\n")
> f_file_2.write(f_time + "\n")
> f_file_2.write(f_result + "\n")
> f_file_2.write(f_station + "\n")
> f_file_2.write(f_operator + "\n")
> f_file_2.write(f_chassis +
> "\n")
> f_file_2.write("\n\n" + t_time + "
> transfer finished" + "\n")
> finally:
> f_file_2.close()
> except IOError:
> pass
>
> os.remove(get_path() + "\\" + f_name[i])
>
> except IOError:
> pass
>
> sleep(1 * 30)
>
>
> 2007/4/9, bird devdoer <devdoer at gmail.com>:
> 你的程序写的有问题吧,是不是有些对象没有释放,比如,不停的添加
> 到list对象中了,python自动垃圾回收的。
> 另外,python2。2的垃圾回收有些问题。
> 你还可以看看python的GC模块。
>
> 2007/4/9, Zuggie <zuggie.zhu at gmail.com >:
> Dear all,
> 我用Python了一程式自幼ノ募,程式一直在\行中,每隔
> 30秒去
> y一次是否有文件存在并x取。但是F在lF每隔30秒y^文件后,
> 程式占用
> 的却增加,基本上每次增加4K,@赢程式Bm\行星期后,占用的
> 却
> 非常大,怎么能自俞放占用的却妫
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>
>
> --
> devdoer
> devdoer at gmail.com
> http://devdoer.blog.sohu.com/
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年04月10日 星期二 00:41
t_time = Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s ½«ÕâÒ»ÐÐд³É''.join([...])µÄÐÎʽ£¬»òÕßÓÃformat£¬¾¡Á¿¼õÉÙÖмä×Ö·û´®µÄÉú³É£¬¿ÉÒÔÓÐЧ¼õÉÙ×Ö·û´®³ØÕ¼ÓÃÄÚ´æ¡£ÁíÍ⣬¿ÉÒÔ²éÔÄÒ»ÏÂgcÄ£¿éÓÐûÓÐÊÕËõ×Ö·û´®³ØµÄ·½·¨¡£¶ÔÓÚÓÐÔËÐÐʱµÄÈí¼þ»·¾³£¬¾³£»áÓöµ½ÕâÖÖ¹ýÓ̲»¼°µÄ·³ÄÕ¡£ ÔÚ07-4-10£¬vcc <vcc在163.com> дµÀ£º > > ͨ³£½â¾öÕâÖÖÎÊÌâʹÓÃ"Åųý·¨"¡£°ÑsleepÈ¥µô£¬È»ºóÒ»±ß×¢ÊÍÄãµÄ´úÂëÒ»±ßÅÜ£¬ > Ò»µãÒ»µãµÄÅųý£¬Ê²Ã´Ê±ºò·¢ÏÖÄÚ´æ²»±äÁË£¬´ó¸Å¾ÍÕÒµ½ÎÊÌâÁË¡£ > > ÔÚ 2007-04-09Ò»µÄ 12:44 +0800£¬ZuggieдµÀ£º > > ¾ÍÊÇÒòPython±¾×ÔÓ»ØÊÕÀ»ø£¬ËùÒÔÎÒ²ÅXµÃÓÐ}ÏÂÃæÊdzÌʽԴa¡£ > > > > #!/usr/bin/env python > > # -*- encoding:utf-8 -*- > > # This program for get HuangPu Final Test Data and Update SFC data > > # It will 30 second execute one time. > > # > > # code by: Zuggie.Zhu > > # code date: 2007-03-22 > > # version: 1.0.1 > > > > import os > > import sys > > import pymssql > > import decimal > > from DBConnect import * > > from time import * > > > > syspath = os.path.dirname(sys.argv[0]) > > > > myconns = CDBConfig(syspath + "\\DBConnect.config") > > con = pymssql.connect(host = CDBConfig.DBConnects["host"], user = > > CDBConfig.DBConnects["user"], \ > > password = CDBConfig.DBConnects ["password"], database = > > CDBConfig.DBConnects["database"]) > > > > def listDirectory(directory, fileExtList): > > fileExtList = [ext.upper() for ext in fileExtList] > > fileList = [os.path.join ("", f) for f in os.listdir(directory) \ > > if os.path.splitext(f)[1].upper() in fileExtList] > > return fileList > > > > def get_path(): > > try: > > f = open(syspath + "\\FbtTest.fp", "r") > > try: > > filepath = f.readline().strip() > > finally: > > f.close() > > except: > > pass > > return filepath > > > > while 1: > > f_name = [] > > f_name = listDirectory(get_path(), [".mac"]) > > > > if len(f_name) > 0: > > for i in range(len(f_name)): > > try: > > f_flag = "" > > f_time = "" > > f_result = "" > > f_station = "" > > f_operator = "" > > f_chassis = "" > > r_data = [] > > c_data = [] > > f_file = open(get_path() + "\\" + f_name[i], "r") > > try: > > s_flag = f_file.readline().rstrip() > > s_time = f_file.readline().rstrip() > > s_result = f_file.readline().rstrip() > > s_station = f_file.readline().rstrip() > > s_operator = f_file.readline().rstrip() > > s_chassis = f_file.readline().rstrip() > > f_flag = s_flag > > f_time = s_time > > f_result = s_result > > f_station = s_station > > f_operator = s_operator > > f_chassis = s_chassis > > if s_flag == "P": > > query = "exec Dell_HuangPu_FBTTEST_sp '%s', '% > > s', '%s', '', '', '%s', '%s', 'FbtTest', '0'" % (s_chassis, s_time, > > s_result, s_station, s_operator) > > else: > > query = "exec Dell_HuangPu_FBTTEST_sp '%s', '% > > s', '%s', '', '', '%s', '%s', 'FbtTest', '1'" % (s_chassis, s_time, > > s_result, s_station, s_operator) > > cur = con.cursor() > > cur.__init__ > > cur.execute(query) > > r_data = cur.fetchone() > > for col in r_data: > > c_data.append(col) > > con.commit() > > finally: > > f_file.close() > > > > Y = strftime('%Y') > > M = strftime('%m') > > D = strftime('%d') > > h = strftime('%H') > > m = strftime('%M') > > s = strftime('%S') > > t_time = Y + "-" + M + "-" + D + " " + h + ":" + m + > > ":" + s > > > > if c_data[0] > 0: > > try: > > f_file_2 = open(syspath + "\\Error\\" + > > f_name[i], "a") > > try: > > f_file_2.write(f_flag + "\n") > > f_file_2.write(f_time + "\n") > > f_file_2.write(f_result + "\n") > > f_file_2.write(f_station + "\n") > > f_file_2.write(f_operator + "\n") > > f_file_2.write(f_chassis + "\n") > > f_file_2.write("\n\n" + t_time + " , " + > > str(c_data[0]) + " , " + c_data[1] + "\n") > > finally: > > f_file_2.close() > > except IOError: > > pass > > else: > > try: > > f_file_2 = open(syspath + "\\Backup\\" + > > f_name[i], "a") > > try: > > f_file_2.write(f_flag + "\n") > > f_file_2.write(f_time + "\n") > > f_file_2.write(f_result + "\n") > > f_file_2.write(f_station + "\n") > > f_file_2.write(f_operator + "\n") > > f_file_2.write(f_chassis + > > "\n") > > f_file_2.write("\n\n" + t_time + " > > transfer finished" + "\n") > > finally: > > f_file_2.close() > > except IOError: > > pass > > > > os.remove(get_path() + "\\" + f_name[i]) > > > > except IOError: > > pass > > > > sleep(1 * 30) > > > > > > 2007/4/9, bird devdoer <devdoer在gmail.com>: > > ÄãµÄ³ÌÐòдµÄÓÐÎÊÌâ°É£¬ÊDz»ÊÇÓÐЩ¶ÔÏóûÓÐÊÍ·Å£¬±ÈÈ磬²»Í£µÄÌí¼Ó > > µ½list¶ÔÏóÖÐÁË£¬python×Ô¶¯À¬»ø»ØÊյġ£ > > ÁíÍ⣬python2¡£2µÄÀ¬»ø»ØÊÕÓÐЩÎÊÌâ¡£ > > Ä㻹¿ÉÒÔ¿´¿´pythonµÄGCÄ£¿é¡£ > > > > 2007/4/9, Zuggie <zuggie.zhu在gmail.com >: > > Dear all, > > ÎÒÓÃPythonÁËÒ»³Ìʽ×ÔÓ×¥Î³ÌʽһֱÔÚ\ÐÐÖУ¬Ã¿¸ô > > 30ÃëÈ¥ > > yÒ»´ÎÊÇ·ñÓÐÎļþ´æÔÚ²¢xÈ¡¡£µ«ÊÇFÔÚlFÿ¸ô30Ãëy^Îļþºó£¬ > > ³ÌʽռÓà > > µÄÈ´Ôö¼Ó£¬»ù±¾ÉÏÿ´ÎÔö¼Ó4K£¬@Ó®³ÌʽBm\ÐÐÐÇÆÚºó£¬Õ¼ÓÃµÄ > > ȴ > > ·Ç³£´ó£¬ÔõôÄÜ×ÔÓá·ÅÕ¼ÓõÄÈ´æ£ > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > -- > > devdoer > > devdoer在gmail.com > > http://devdoer.blog.sohu.com/ > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- µÇɽÕßÈ¥µÇɽ£¬ÒòΪɽÔÚÄÇÀï ÎÒÔÚ˼¿¼£¬ÒòΪÎÊÌâÔÚÄÇÀï ÁõöÎ March.Liu -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070410/2e9c117b/attachment-0001.html
2007年04月10日 星期二 01:48
在 2007-04-10二的 00:41 +0800,刘鑫写道: > t_time = Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s > 将这一行写成''.join([...])的形式,或者用format,尽量减少中间字符串的生 > 成,可以有效减少字符串池占用内存。另外,可以查阅一下gc模块有没有收缩字 > 符串池的方法。对于有运行时的软件环境,经常会遇到这种过犹不及的烦恼。 这些最基本的功能通常不会有什么问题,不然就太恐怖了;-) 我猜pymssql的可能性较大,c有时候是让人很头痛的。 当然,还有个更简单的方法,写个简单的脚本每隔30秒system一下python ****.py,或者加到crontab里,从此世界清静晒.... > > 在07-4-10,vcc <vcc at 163.com> 写道: > 通常解决这种问题使用"排除法"。把sleep去掉,然后一边注释你的代 > 码一边跑, > 一点一点的排除,什么时候发现内存不变了,大概就找到问题了。 > > 在 2007-04-09一的 12:44 +0800,Zuggie写道: > > 就是因Python本自踊厥绽圾,所以我才X得有}下面是程式源a。 > > > > #!/usr/bin/env python > > # -*- encoding:utf-8 -*- > > # This program for get HuangPu Final Test Data and Update > SFC data > > # It will 30 second execute one time. > > # > > # code by: Zuggie.Zhu > > # code date: 2007-03-22 > > # version: 1.0.1 > > > > import os > > import sys > > import pymssql > > import decimal > > from DBConnect import * > > from time import * > > > > syspath = os.path.dirname(sys.argv[0]) > > > > myconns = CDBConfig(syspath + "\\DBConnect.config") > > con = pymssql.connect(host = CDBConfig.DBConnects["host"], > user = > > CDBConfig.DBConnects["user"], \ > > password = CDBConfig.DBConnects ["password"], database = > > CDBConfig.DBConnects["database"]) > > > > def listDirectory(directory, fileExtList): > > fileExtList = [ext.upper() for ext in fileExtList] > > fileList = [os.path.join ("", f) for f in > os.listdir(directory) \ > > if os.path.splitext(f)[1].upper() in > fileExtList] > > return fileList > > > > def get_path(): > > try: > > f = open(syspath + "\\FbtTest.fp", "r") > > try: > > filepath = f.readline().strip() > > finally: > > f.close() > > except: > > pass > > return filepath > > > > while 1: > > f_name = [] > > f_name = listDirectory(get_path(), [".mac"]) > > > > if len(f_name) > 0: > > for i in range(len(f_name)): > > try: > > f_flag = "" > > f_time = "" > > f_result = "" > > f_station = "" > > f_operator = "" > > f_chassis = "" > > r_data = [] > > c_data = [] > > f_file = open(get_path() + "\\" + f_name[i], > "r") > > try: > > s_flag = f_file.readline().rstrip() > > s_time = f_file.readline().rstrip() > > s_result = f_file.readline().rstrip() > > s_station = f_file.readline().rstrip() > > s_operator = f_file.readline().rstrip() > > s_chassis = f_file.readline().rstrip() > > f_flag = s_flag > > f_time = s_time > > f_result = s_result > > f_station = s_station > > f_operator = s_operator > > f_chassis = s_chassis > > if s_flag == "P": > > query = "exec > Dell_HuangPu_FBTTEST_sp '%s', '% > > s', '%s', '', '', '%s', '%s', 'FbtTest', '0'" % (s_chassis, > s_time, > > s_result, s_station, s_operator) > > else: > > query = "exec > Dell_HuangPu_FBTTEST_sp '%s', '% > > s', '%s', '', '', '%s', '%s', 'FbtTest', '1'" % (s_chassis, > s_time, > > s_result, s_station, s_operator) > > cur = con.cursor () > > cur.__init__ > > cur.execute(query) > > r_data = cur.fetchone() > > for col in r_data: > > c_data.append(col) > > con.commit() > > finally: > > f_file.close() > > > > Y = strftime('%Y') > > M = strftime('%m') > > D = strftime('%d') > > h = strftime('%H') > > m = strftime('%M') > > s = strftime('%S') > > t_time = Y + "-" + M + "-" + D + " " + h + > ":" + m + > > ":" + s > > > > if c_data[0] > 0: > > try: > > f_file_2 = open(syspath + "\\Error\ > \" + > > f_name[i], "a") > > try: > > f_file_2.write(f_flag + "\n") > > f_file_2.write(f_time + "\n") > > f_file_2.write(f_result + "\n") > > f_file_2.write(f_station + "\n") > > f_file_2.write(f_operator + > "\n") > > f_file_2.write(f_chassis + > "\n") > > f_file_2.write("\n\n" + t_time + > " , " + > > str(c_data[0]) + " , " + c_data[1] + "\n") > > finally: > > f_file_2.close() > > except IOError: > > pass > > else: > > try: > > f_file_2 = open(syspath + "\\Backup\ > \" + > > f_name[i], "a") > > try: > > f_file_2.write(f_flag + "\n") > > f_file_2.write(f_time + "\n") > > f_file_2.write(f_result + "\n") > > f_file_2.write(f_station + "\n") > > f_file_2.write(f_operator + > "\n") > > f_file_2.write(f_chassis + > > "\n") > > f_file_2.write("\n\n" + t_time + > " > > transfer finished" + "\n") > > finally: > > f_file_2.close() > > except IOError: > > pass > > > > os.remove(get_path() + "\\" + f_name[i]) > > > > except IOError: > > pass > > > > sleep(1 * 30) > > > > > > 2007/4/9, bird devdoer <devdoer at gmail.com>: > > 你的程序写的有问题吧,是不是有些对象没有释放,比如, > 不停的添加 > > 到list对象中了,python自动垃圾回收的。 > > 另外,python2。2的垃圾回收有些问题。 > > 你还可以看看python的GC模块。 > > > > 2007/4/9, Zuggie <zuggie.zhu at gmail.com >: > > Dear all, > > 我用Python了一程式自幼ノ募,程式一直在 > \行中,每隔 > > 30秒去 > > y一次是否有文件存在并x取。但是F在lF每隔30秒 > y^文件后, > > 程式占用 > > 的却增加,基本上每次增加4K,@赢程式Bm\行星期 > 后,占用的 > > 却 > > 非常大,怎么能自俞放占用的却妫 > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request at lists.python.cn > > Detail Info: > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > -- > > devdoer > > devdoer at gmail.com > > http://devdoer.blog.sohu.com/ > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request at lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to > python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe > to python-chinese-request at lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to > python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe > to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > -- > 登山者去登山,因为山在那里 > 我在思考,因为问题在那里 > > 刘鑫 > March.Liu > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年04月10日 星期二 02:00
我也做抓取 我内存最多不超过10MB CPU 不超过2% 程序和你差不多 每天大概要采集 12次 每次大概 2W个页面 分析 更新mysql 如果线程处于挂起状态的时候 内存只有500多KB的占用 在 07-4-10,vcc<vcc在163.com> 写道: > 在 2007-04-10二的 00:41 +0800,刘鑫写道: > > t_time = Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s > > 将这一行写成''.join([...])的形式,或者用format,尽量减少中间字符串的生 > > 成,可以有效减少字符串池占用内存。另外,可以查阅一下gc模块有没有收缩字 > > 符串池的方法。对于有运行时的软件环境,经常会遇到这种过犹不及的烦恼。 > > 这些最基本的功能通常不会有什么问题,不然就太恐怖了;-) > 我猜pymssql的可能性较大,c有时候是让人很头痛的。 > > 当然,还有个更简单的方法,写个简单的脚本每隔30秒system一下python > ****.py,或者加到crontab里,从此世界清静晒.... > > > > > 在07-4-10,vcc <vcc在163.com> 写道: > > 通常解决这种问题使用"排除法"。把sleep去掉,然后一边注释你的代 > > 码一边跑, > > 一点一点的排除,什么时候发现内存不变了,大概就找到问题了。 > > > > 在 2007-04-09一的 12:44 +0800,Zuggie写道: > > > 就是因Python本自踊厥绽圾,所以我才X得有}下面是程式源a。 > > > > > > #!/usr/bin/env python > > > # -*- encoding:utf-8 -*- > > > # This program for get HuangPu Final Test Data and Update > > SFC data > > > # It will 30 second execute one time. > > > # > > > # code by: Zuggie.Zhu > > > # code date: 2007-03-22 > > > # version: 1.0.1 > > > > > > import os > > > import sys > > > import pymssql > > > import decimal > > > from DBConnect import * > > > from time import * > > > > > > syspath = os.path.dirname(sys.argv[0]) > > > > > > myconns = CDBConfig(syspath + "\\DBConnect.config") > > > con = pymssql.connect(host = CDBConfig.DBConnects["host"], > > user = > > > CDBConfig.DBConnects["user"], \ > > > password = CDBConfig.DBConnects ["password"], database = > > > CDBConfig.DBConnects["database"]) > > > > > > def listDirectory(directory, fileExtList): > > > fileExtList = [ext.upper() for ext in fileExtList] > > > fileList = [os.path.join ("", f) for f in > > os.listdir(directory) \ > > > if os.path.splitext(f)[1].upper() in > > fileExtList] > > > return fileList > > > > > > def get_path(): > > > try: > > > f = open(syspath + "\\FbtTest.fp", "r") > > > try: > > > filepath = f.readline().strip() > > > finally: > > > f.close() > > > except: > > > pass > > > return filepath > > > > > > while 1: > > > f_name = [] > > > f_name = listDirectory(get_path(), [".mac"]) > > > > > > if len(f_name) > 0: > > > for i in range(len(f_name)): > > > try: > > > f_flag = "" > > > f_time = "" > > > f_result = "" > > > f_station = "" > > > f_operator = "" > > > f_chassis = "" > > > r_data = [] > > > c_data = [] > > > f_file = open(get_path() + "\\" + f_name[i], > > "r") > > > try: > > > s_flag = f_file.readline().rstrip() > > > s_time = f_file.readline().rstrip() > > > s_result = f_file.readline().rstrip() > > > s_station = f_file.readline().rstrip() > > > s_operator = f_file.readline().rstrip() > > > s_chassis = f_file.readline().rstrip() > > > f_flag = s_flag > > > f_time = s_time > > > f_result = s_result > > > f_station = s_station > > > f_operator = s_operator > > > f_chassis = s_chassis > > > if s_flag == "P": > > > query = "exec > > Dell_HuangPu_FBTTEST_sp '%s', '% > > > s', '%s', '', '', '%s', '%s', 'FbtTest', '0'" % (s_chassis, > > s_time, > > > s_result, s_station, s_operator) > > > else: > > > query = "exec > > Dell_HuangPu_FBTTEST_sp '%s', '% > > > s', '%s', '', '', '%s', '%s', 'FbtTest', '1'" % (s_chassis, > > s_time, > > > s_result, s_station, s_operator) > > > cur = con.cursor () > > > cur.__init__ > > > cur.execute(query) > > > r_data = cur.fetchone() > > > for col in r_data: > > > c_data.append(col) > > > con.commit() > > > finally: > > > f_file.close() > > > > > > Y = strftime('%Y') > > > M = strftime('%m') > > > D = strftime('%d') > > > h = strftime('%H') > > > m = strftime('%M') > > > s = strftime('%S') > > > t_time = Y + "-" + M + "-" + D + " " + h + > > ":" + m + > > > ":" + s > > > > > > if c_data[0] > 0: > > > try: > > > f_file_2 = open(syspath + "\\Error\ > > \" + > > > f_name[i], "a") > > > try: > > > f_file_2.write(f_flag + "\n") > > > f_file_2.write(f_time + "\n") > > > f_file_2.write(f_result + "\n") > > > f_file_2.write(f_station + "\n") > > > f_file_2.write(f_operator + > > "\n") > > > f_file_2.write(f_chassis + > > "\n") > > > f_file_2.write("\n\n" + t_time + > > " , " + > > > str(c_data[0]) + " , " + c_data[1] + "\n") > > > finally: > > > f_file_2.close() > > > except IOError: > > > pass > > > else: > > > try: > > > f_file_2 = open(syspath + "\\Backup\ > > \" + > > > f_name[i], "a") > > > try: > > > f_file_2.write(f_flag + "\n") > > > f_file_2.write(f_time + "\n") > > > f_file_2.write(f_result + "\n") > > > f_file_2.write(f_station + "\n") > > > f_file_2.write(f_operator + > > "\n") > > > f_file_2.write(f_chassis + > > > "\n") > > > f_file_2.write("\n\n" + t_time + > > " > > > transfer finished" + "\n") > > > finally: > > > f_file_2.close() > > > except IOError: > > > pass > > > > > > os.remove(get_path() + "\\" + f_name[i]) > > > > > > except IOError: > > > pass > > > > > > sleep(1 * 30) > > > > > > > > > 2007/4/9, bird devdoer <devdoer在gmail.com>: > > > 你的程序写的有问题吧,是不是有些对象没有释放,比如, > > 不停的添加 > > > 到list对象中了,python自动垃圾回收的。 > > > 另外,python2。2的垃圾回收有些问题。 > > > 你还可以看看python的GC模块。 > > > > > > 2007/4/9, Zuggie <zuggie.zhu在gmail.com >: > > > Dear all, > > > 我用Python了一程式自幼ノ募,程式一直在 > > \行中,每隔 > > > 30秒去 > > > y一次是否有文件存在并x取。但是F在lF每隔30秒 > > y^文件后, > > > 程式占用 > > > 的却增加,基本上每次增加4K,@赢程式Bm\行星期 > > 后,占用的 > > > 却 > > > 非常大,怎么能自俞放占用的却妫 > > > > > > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: > > > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > -- > > > devdoer > > > devdoer在gmail.com > > > http://devdoer.blog.sohu.com/ > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe > > to python-chinese-request在lists.python.cn > > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe > > to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > -- > > 登山者去登山,因为山在那里 > > 我在思考,因为问题在那里 > > > > 刘鑫 > > March.Liu > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年04月10日 星期二 02:07
×öÒ»¸ösubprocessÈçºÎ£¿³ýÁËÓÐsystemÓï¾äµÄºÃ´¦£¬»¹¿ÉÒÔ»ñµÃ²¢·¢ÄÜÁ¦¡£ ×îÖØÒªµÄÊÇ£¬¿´ÆðÀ´±È½Ï»ªÀöXD ÔÚ07-4-10£¬vcc <vcc在163.com> дµÀ£º > > ÔÚ 2007-04-10¶þµÄ 00:41 +0800£¬ÁõöÎдµÀ£º > > t_time = Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s > > ½«ÕâÒ»ÐÐд³É''.join([...])µÄÐÎʽ£¬»òÕßÓÃformat£¬¾¡Á¿¼õÉÙÖмä×Ö·û´®µÄÉú > > ³É£¬¿ÉÒÔÓÐЧ¼õÉÙ×Ö·û´®³ØÕ¼ÓÃÄÚ´æ¡£ÁíÍ⣬¿ÉÒÔ²éÔÄÒ»ÏÂgcÄ£¿éÓÐûÓÐÊÕËõ×Ö > > ·û´®³ØµÄ·½·¨¡£¶ÔÓÚÓÐÔËÐÐʱµÄÈí¼þ»·¾³£¬¾³£»áÓöµ½ÕâÖÖ¹ýÓ̲»¼°µÄ·³ÄÕ¡£ > > ÕâЩ×î»ù±¾µÄ¹¦ÄÜͨ³£²»»áÓÐʲôÎÊÌ⣬²»È»¾ÍÌ«¿Ö²ÀÁË;-) > ÎÒ²ÂpymssqlµÄ¿ÉÄÜÐԽϴó£¬cÓÐʱºòÊÇÈÃÈ˺ÜÍ·Í´µÄ¡£ > > µ±È»£¬»¹Óиö¸ü¼òµ¥µÄ·½·¨£¬Ð´¸ö¼òµ¥µÄ½Å±¾Ã¿¸ô30ÃësystemÒ»ÏÂpython > ****.py£¬»òÕß¼Óµ½crontabÀ´Ó´ËÊÀ½çÇ徲ɹ.... > > > > > ÔÚ07-4-10£¬vcc <vcc在163.com> дµÀ£º > > ͨ³£½â¾öÕâÖÖÎÊÌâʹÓÃ"Åųý·¨"¡£°ÑsleepÈ¥µô£¬È»ºóÒ»±ß×¢ÊÍÄãµÄ´ú > > ÂëÒ»±ßÅÜ£¬ > > Ò»µãÒ»µãµÄÅųý£¬Ê²Ã´Ê±ºò·¢ÏÖÄÚ´æ²»±äÁË£¬´ó¸Å¾ÍÕÒµ½ÎÊÌâÁË¡£ > > > > ÔÚ 2007-04-09Ò»µÄ 12:44 +0800£¬ZuggieдµÀ£º > > > ¾ÍÊÇÒòPython±¾×ÔÓ»ØÊÕÀ»ø£¬ËùÒÔÎÒ²ÅXµÃÓÐ}ÏÂÃæÊdzÌʽԴa¡£ > > > > > > #!/usr/bin/env python > > > # -*- encoding:utf-8 -*- > > > # This program for get HuangPu Final Test Data and Update > > SFC data > > > # It will 30 second execute one time. > > > # > > > # code by: Zuggie.Zhu > > > # code date: 2007-03-22 > > > # version: 1.0.1 > > > > > > import os > > > import sys > > > import pymssql > > > import decimal > > > from DBConnect import * > > > from time import * > > > > > > syspath = os.path.dirname(sys.argv[0]) > > > > > > myconns = CDBConfig(syspath + "\\DBConnect.config") > > > con = pymssql.connect(host = CDBConfig.DBConnects["host"], > > user = > > > CDBConfig.DBConnects["user"], \ > > > password = CDBConfig.DBConnects ["password"], database = > > > CDBConfig.DBConnects["database"]) > > > > > > def listDirectory(directory, fileExtList): > > > fileExtList = [ext.upper() for ext in fileExtList] > > > fileList = [os.path.join ("", f) for f in > > os.listdir(directory) \ > > > if os.path.splitext(f)[1].upper() in > > fileExtList] > > > return fileList > > > > > > def get_path(): > > > try: > > > f = open(syspath + "\\FbtTest.fp", "r") > > > try: > > > filepath = f.readline().strip() > > > finally: > > > f.close() > > > except: > > > pass > > > return filepath > > > > > > while 1: > > > f_name = [] > > > f_name = listDirectory(get_path(), [".mac"]) > > > > > > if len(f_name) > 0: > > > for i in range(len(f_name)): > > > try: > > > f_flag = "" > > > f_time = "" > > > f_result = "" > > > f_station = "" > > > f_operator = "" > > > f_chassis = "" > > > r_data = [] > > > c_data = [] > > > f_file = open(get_path() + "\\" + f_name[i], > > "r") > > > try: > > > s_flag = f_file.readline().rstrip() > > > s_time = f_file.readline().rstrip() > > > s_result = f_file.readline().rstrip() > > > s_station = f_file.readline().rstrip() > > > s_operator = f_file.readline().rstrip() > > > s_chassis = f_file.readline().rstrip() > > > f_flag = s_flag > > > f_time = s_time > > > f_result = s_result > > > f_station = s_station > > > f_operator = s_operator > > > f_chassis = s_chassis > > > if s_flag == "P": > > > query = "exec > > Dell_HuangPu_FBTTEST_sp '%s', '% > > > s', '%s', '', '', '%s', '%s', 'FbtTest', '0'" % (s_chassis, > > s_time, > > > s_result, s_station, s_operator) > > > else: > > > query = "exec > > Dell_HuangPu_FBTTEST_sp '%s', '% > > > s', '%s', '', '', '%s', '%s', 'FbtTest', '1'" % (s_chassis, > > s_time, > > > s_result, s_station, s_operator) > > > cur = con.cursor () > > > cur.__init__ > > > cur.execute(query) > > > r_data = cur.fetchone() > > > for col in r_data: > > > c_data.append(col) > > > con.commit() > > > finally: > > > f_file.close() > > > > > > Y = strftime('%Y') > > > M = strftime('%m') > > > D = strftime('%d') > > > h = strftime('%H') > > > m = strftime('%M') > > > s = strftime('%S') > > > t_time = Y + "-" + M + "-" + D + " " + h + > > ":" + m + > > > ":" + s > > > > > > if c_data[0] > 0: > > > try: > > > f_file_2 = open(syspath + "\\Error\ > > \" + > > > f_name[i], "a") > > > try: > > > f_file_2.write(f_flag + "\n") > > > f_file_2.write(f_time + "\n") > > > f_file_2.write(f_result + "\n") > > > f_file_2.write(f_station + "\n") > > > f_file_2.write(f_operator + > > "\n") > > > f_file_2.write(f_chassis + > > "\n") > > > f_file_2.write("\n\n" + t_time + > > " , " + > > > str(c_data[0]) + " , " + c_data[1] + "\n") > > > finally: > > > f_file_2.close() > > > except IOError: > > > pass > > > else: > > > try: > > > f_file_2 = open(syspath + "\\Backup\ > > \" + > > > f_name[i], "a") > > > try: > > > f_file_2.write(f_flag + "\n") > > > f_file_2.write(f_time + "\n") > > > f_file_2.write(f_result + "\n") > > > f_file_2.write(f_station + "\n") > > > f_file_2.write(f_operator + > > "\n") > > > f_file_2.write(f_chassis + > > > "\n") > > > f_file_2.write("\n\n" + t_time + > > " > > > transfer finished" + "\n") > > > finally: > > > f_file_2.close() > > > except IOError: > > > pass > > > > > > os.remove(get_path() + "\\" + f_name[i]) > > > > > > except IOError: > > > pass > > > > > > sleep(1 * 30) > > > > > > > > > 2007/4/9, bird devdoer <devdoer在gmail.com>: > > > ÄãµÄ³ÌÐòдµÄÓÐÎÊÌâ°É£¬ÊDz»ÊÇÓÐЩ¶ÔÏóûÓÐÊÍ·Å£¬±ÈÈ磬 > > ²»Í£µÄÌí¼Ó > > > µ½list¶ÔÏóÖÐÁË£¬python×Ô¶¯À¬»ø»ØÊյġ£ > > > ÁíÍ⣬python2¡£2µÄÀ¬»ø»ØÊÕÓÐЩÎÊÌâ¡£ > > > Ä㻹¿ÉÒÔ¿´¿´pythonµÄGCÄ£¿é¡£ > > > > > > 2007/4/9, Zuggie <zuggie.zhu在gmail.com >: > > > Dear all, > > > ÎÒÓÃPythonÁËÒ»³Ìʽ×ÔÓ×¥Î³ÌʽһֱÔÚ > > \ÐÐÖУ¬Ã¿¸ô > > > 30ÃëÈ¥ > > > yÒ»´ÎÊÇ·ñÓÐÎļþ´æÔÚ²¢xÈ¡¡£µ«ÊÇFÔÚlFÿ¸ô30Ãë > > y^Îļþºó£¬ > > > ³ÌʽռÓà > > > µÄÈ´Ôö¼Ó£¬»ù±¾ÉÏÿ´ÎÔö¼Ó4K£¬@Ó®³ÌʽBm\ÐÐÐÇÆÚ > > ºó£¬Õ¼ÓÃµÄ > > > ȴ > > > ·Ç³£´ó£¬ÔõôÄÜ×ÔÓá·ÅÕ¼ÓõÄÈ´æ£ > > > > > > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: > > > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > -- > > > devdoer > > > devdoer在gmail.com > > > http://devdoer.blog.sohu.com/ > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe > > to python-chinese-request在lists.python.cn > > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe > > to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > -- > > µÇɽÕßÈ¥µÇɽ£¬ÒòΪɽÔÚÄÇÀï > > ÎÒÔÚ˼¿¼£¬ÒòΪÎÊÌâÔÚÄÇÀï > > > > ÁõöÎ > > March.Liu > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- µÇɽÕßÈ¥µÇɽ£¬ÒòΪɽÔÚÄÇÀï ÎÒÔÚ˼¿¼£¬ÒòΪÎÊÌâÔÚÄÇÀï ÁõöÎ March.Liu -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070410/28e112fe/attachment.htm
Zeuux © 2025
京ICP备05028076号