[python-chinese] =?GB2312?B?UmU6IFtweXRob24tY2hpbmVzZV0gUmU=?= =?GB2312?B?IDogW3B5dGhvbi1jaGluZXNlXSCDyLTmz/u6xA==?=
刘鑫
march.liu在gmail.com
星期二 四月 10 02:07:16 HKT 2007
×öÒ»¸ö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
关于邮件列表 python-chinese 的更多信息