锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲av无码一区二区三区四区,亚洲精品久久久久无码AV片软件,国产AV无码专区亚洲AVJULIA http://www.tkk7.com/stone2083/category/42431.htmlzh-cnFri, 30 Mar 2018 15:06:00 GMTFri, 30 Mar 2018 15:06:00 GMT60灝嗗浘鐗囪漿鎴怘TML鏍煎紡--鍘熺悊&浠g爜http://www.tkk7.com/stone2083/archive/2013/12/20/407809.htmlstone2083stone2083Fri, 20 Dec 2013 06:28:00 GMThttp://www.tkk7.com/stone2083/archive/2013/12/20/407809.htmlhttp://www.tkk7.com/stone2083/comments/407809.htmlhttp://www.tkk7.com/stone2083/archive/2013/12/20/407809.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/407809.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/407809.html
@see http://www.tkk7.com/stone2083/archive/2013/12/20/407807.html

鍘熺悊

浣跨敤table,tr/td浣滀負涓涓儚绱犵偣錛岀敾鐐廣?br />


浠g爜

 2 import sys, optparse, Image
 3 
 4 TABLE='<table id="image" border="0" cellpadding="0" cellspacing="0">%s</table>'
 5 TR='<tr>%s</tr>'
 6 TD='<td width="1px;" height="1px;" bgcolor="%s"/>'
 7 
 8 def rgb2hex(rgb):
 9     return '#{:02x}{:02x}{:02x}'.format(rgb[0],rgb[1],rgb[2])
10 
11 def get_image(name, thumbnail=1):
12     if(thumbnail >= 1 or thumbnail <= 0): 
13         return Image.open(name)
14     else:
15         img = Image.open(name)
16         return img.resize((int(img.size[0] * thumbnail),int(img.size[1] * thumbnail)))
17 
18 def convert(img):
19     trs = []
20     for height in xrange(img.size[1]):
21         tds = []
22         for width in xrange(img.size[0]):
23             tds.append(TD % rgb2hex(img.getpixel((width, height))))
24         trs.append(TR % (''.join(tds)))
25     return TABLE % (''.join(trs),)
26 
27 parser = optparse.OptionParser('Usage: %prog [options] image')
28 parser.add_option('-c''--compress', dest='thumbnail', default='1', metavar='float', help='specify the compress value (0, 1)')
29 parser.add_option('-o''--out', dest='out', default='out.html', help='specify the output file')
30 opts, args = parser.parse_args()
31 
32 if(len(args) != 1): 
33     parser.print_help()
34     sys.exit(-1)
35 
36 html = open(opts.out,'w')
37 html.write(convert(get_image(args[0], float(opts.thumbnail))))
38 html.close()

涓嬭澆鍦板潃 

https://code.google.com/p/stonelab/downloads/detail?name=img2html.py#makechanges

stone2083 2013-12-20 14:28 鍙戣〃璇勮
]]>
灝嗗浘鐗囪漿鎴怘TML鏍煎紡錛嶏紞鐢℉TML鐢誨浘http://www.tkk7.com/stone2083/archive/2013/12/20/407807.htmlstone2083stone2083Fri, 20 Dec 2013 06:18:00 GMThttp://www.tkk7.com/stone2083/archive/2013/12/20/407807.htmlhttp://www.tkk7.com/stone2083/comments/407807.htmlhttp://www.tkk7.com/stone2083/archive/2013/12/20/407807.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/407807.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/407807.html闃呰鍏ㄦ枃

stone2083 2013-12-20 14:18 鍙戣〃璇勮
]]>
pystack--python stack trace--璁﹑ython鎵撳嵃綰跨▼鏍堜俊鎭?/title><link>http://www.tkk7.com/stone2083/archive/2013/08/19/403028.html</link><dc:creator>stone2083</dc:creator><author>stone2083</author><pubDate>Mon, 19 Aug 2013 05:15:00 GMT</pubDate><guid>http://www.tkk7.com/stone2083/archive/2013/08/19/403028.html</guid><wfw:comment>http://www.tkk7.com/stone2083/comments/403028.html</wfw:comment><comments>http://www.tkk7.com/stone2083/archive/2013/08/19/403028.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/stone2083/comments/commentRss/403028.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stone2083/services/trackbacks/403028.html</trackback:ping><description><![CDATA[pystack: python stack trace. 綾諱技java涓殑jstack鍔熻兘.<br /> 浣跨敤鏂瑰紡:<br /> 1. https://pypi.python.org/pypi/pdbx/0.3.0 涓嬭澆, 鎴栬呯洿鎺ラ氳繃easyinstall瀹夎<br /> 2. python scripts涓? import pdbx; pdbx.enable_pystack(); 寮鍚痯ystack鍔熻兘<br /> 3. kill -30 pid , 灝卞彲浠ユ墦鍗皊tack淇℃伅浜? <br /> 濡?<br /> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->"CP Server Thread-10" tid=4564467712<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-9" tid=4560261120<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-1" tid=4526608384<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-7" tid=4551847936<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-4" tid=4539228160<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-2" tid=4530814976<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "MainThread" tid=140735286018432<br />     at app.run()(raspctl.py:173)<br />     at <span style="color: #0000FF; ">return</span> wsgi.runwsgi(self.wsgifunc(*middleware))(application.py:313)<br />     at <span style="color: #0000FF; ">return</span> httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))(wsgi.py:54)<br />     at server.start()(httpserver.py:157)<br />     at self.tick()(__init__.py:1765)<br />     at s, addr = self.socket.accept()(__init__.py:1800)<br />     at sock, addr = self._sock.accept()(socket.py:202)<br />     at pystack()(pdbx.py:181)<br />     at <span style="color: #0000FF; ">for</span> filename, lineno, _, line in traceback.extract_stack(stack):(pdbx.py:169)<br /> <br /> "CP Server Thread-5" tid=4543434752<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-8" tid=4556054528<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-3" tid=4535021568<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)<br /> <br /> "CP Server Thread-6" tid=4547641344<br />     at self.__bootstrap_inner()(threading.py:525)<br />     at self.run()(threading.py:552)<br />     at conn = self.server.requests.get()(__init__.py:1367)<br />     at self.not_empty.wait()(Queue.py:168)<br />     at waiter.acquire()(threading.py:244)</div> <br /> <br /> 鏍稿績浠g爜:<br /> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008000; ">#</span><span style="color: #008000; "> pystack</span><span style="color: #008000; "><br /> </span><span style="color: #0000FF; ">def</span> pystack():<br />     <span style="color: #0000FF; ">for</span> tid, stack <span style="color: #0000FF; ">in</span> sys._current_frames().items():<br />         info = []<br />         t = _get_thread(tid)<br />         info.append(<span style="color: #800000; ">'</span><span style="color: #800000; ">"%s" tid=%d</span><span style="color: #800000; ">'</span> % (t.name, tid))<br />         <span style="color: #0000FF; ">for</span> filename, lineno, _, line <span style="color: #0000FF; ">in</span> traceback.extract_stack(stack):<br />             info.append(<span style="color: #800000; ">'</span><span style="color: #800000; ">    at %s(%s:%d)</span><span style="color: #800000; ">'</span> % (line, filename[filename.rfind(<span style="color: #800000; ">'</span><span style="color: #800000; ">/</span><span style="color: #800000; ">'</span>) + 1:], lineno))<br />         <span style="color: #0000FF; ">print</span> <span style="color: #800000; ">'</span><span style="color: #800000; ">\r\n</span><span style="color: #800000; ">'</span>.join(info)<br />         <span style="color: #0000FF; ">print</span> <span style="color: #800000; ">''</span><br /> <br /> <span style="color: #0000FF; ">def</span> _get_thread(tid):<br />     <span style="color: #0000FF; ">for</span> t <span style="color: #0000FF; ">in</span> threading.enumerate():<br />         <span style="color: #0000FF; ">if</span> t.ident == tid:<br />             <span style="color: #0000FF; ">return</span> t<br />     <span style="color: #0000FF; ">return</span> None<br /> <br /> <span style="color: #0000FF; ">def</span> _pystack(sig, frame):<br />     pystack()<br /> <br /> <span style="color: #0000FF; ">def</span> enable_pystack():<br />     signal.signal(signal.SIGUSR1, _pystack)</div><br />鏈夐渶瑕佺殑鏈嬪弸,璧剁揣鎷胯蛋鍚?<img src ="http://www.tkk7.com/stone2083/aggbug/403028.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stone2083/" target="_blank">stone2083</a> 2013-08-19 13:15 <a href="http://www.tkk7.com/stone2083/archive/2013/08/19/403028.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>rpdb鏇村悕涓簆dbx騫跺彂甯冨埌pypihttp://www.tkk7.com/stone2083/archive/2013/03/23/396903.htmlstone2083stone2083Sat, 23 Mar 2013 08:11:00 GMThttp://www.tkk7.com/stone2083/archive/2013/03/23/396903.htmlhttp://www.tkk7.com/stone2083/comments/396903.htmlhttp://www.tkk7.com/stone2083/archive/2013/03/23/396903.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/396903.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/396903.htmlrpdb鏇村悕涓簆dbx錛屽彂甯冨埌pypi


stone2083 2013-03-23 16:11 鍙戣〃璇勮
]]>
RPDB V0.2.0 Release (鍊煎緱鎺ㄥ箍)http://www.tkk7.com/stone2083/archive/2013/03/22/396862.htmlstone2083stone2083Fri, 22 Mar 2013 09:23:00 GMThttp://www.tkk7.com/stone2083/archive/2013/03/22/396862.htmlhttp://www.tkk7.com/stone2083/comments/396862.htmlhttp://www.tkk7.com/stone2083/archive/2013/03/22/396862.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/396862.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/396862.html杞歡宸叉洿鏂幫紝鏈鏂拌鏌ョ湅錛?/span>https://code.google.com/p/stonelab/wiki/pdbx
鍘熸枃錛歨ttps://code.google.com/p/stonelab/wiki/RemotePDB

杞歡浠嬬粛

rpdb:榪滅▼PDB璋冭瘯宸ュ叿錛屾槸瀵筽db鐨勬墿灞曘?nbsp;

鍦╬db鍩虹涓婏紝鍋氫簡鍔熻兘鍔犲己錛屼富瑕佺壒鎬у涓嬶細

1. 鍏煎pdb涓鍒囪娉曞拰浣跨敤涔犳儻 

2. 澧炲姞浜嗚繙紼嬭皟璇曞姛鑳斤紝 鍏佽浣犲鎴風閫氳繃telnet榪炴帴鍒版寚瀹氳皟璇曠鍙o紝榪涜榪滅▼璋冭瘯 

3. 澧炲姞浜唕q/rquit鍛戒護錛屾敮鎸佸畨鍏ㄩ鍑烘ā寮忥紝閬垮厤榛樿鐨剄uik浼氬鑷磒ython紼嬪簭寮傚父閫鍑虹殑鎯呭喌 

4. 鍏佽澶氭璋冭瘯 

5. 澧炲姞suspend妯″紡錛屽湪鍚姩鏃跺己鍒舵垨鑰呴潪寮哄埗榪涘叆鏂偣 



stone2083 2013-03-22 17:23 鍙戣〃璇勮
]]>
RPDB-璁㏄DB錛圥ython璋冭瘯宸ュ叿錛夋敮鎸佽繙紼嬭皟璇曞姛鑳?/title><link>http://www.tkk7.com/stone2083/archive/2013/03/21/396812.html</link><dc:creator>stone2083</dc:creator><author>stone2083</author><pubDate>Thu, 21 Mar 2013 08:19:00 GMT</pubDate><guid>http://www.tkk7.com/stone2083/archive/2013/03/21/396812.html</guid><wfw:comment>http://www.tkk7.com/stone2083/comments/396812.html</wfw:comment><comments>http://www.tkk7.com/stone2083/archive/2013/03/21/396812.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/stone2083/comments/commentRss/396812.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stone2083/services/trackbacks/396812.html</trackback:ping><description><![CDATA[<div class="ajidzpy" id="wikicontent"><div class="wnbmbuh" id="wikimaincol" style="vertical-align: top; padding: 5px 25px 10px 10px; background-color: #ffffff; min-width: 64em; border: 1px solid #cccccc;"><h1><span style="color: red;">杞歡宸叉洿鏂幫紝鏈鏂拌鏌ョ湅錛?/span><span style="font-size: 14px; color: red;">https://code.google.com/p/stonelab/wiki/pdbx</span><br /><br />杞歡浠嬬粛</h1><blockquote style="margin: 20px; max-width: 60em;">rpdb鎵╁睍浜唒db錛岃pdb鏀寔榪滅▼璋冭瘯鍔熻兘銆?br /><br />浣跨敤浜唕pdb鐨刾ython鑴氭湰鍦ㄨ繙紼嬪惎鍔紝鏈湴閫氳繃telnet鏂瑰紡榪炴帴涓妑pdb鎻愪緵鐨勮皟璇曠鍙o紝鎺ヤ笅鏉ョ殑鎿嶄綔鍜屾湰鍦板畬鍏ㄤ竴鑷淬?/blockquote><h1><a name="浣跨敤璇存槑"></a>浣跨敤璇存槑</h1><ul style="padding-left: 25px; max-width: 62em;"><li style="margin-bottom: 0.3em;">涓嬭澆</li><blockquote style="margin: 20px; max-width: 60em;">wget <a rel="nofollow" style="color: #0000cc;">https://stonelab.googlecode.com/files/rpdb-0.1.0.tar.gz</a> <br /><br />鏈変袱涓枃浠訛細rpdb.py錛氭墿灞昿db鐨勭被搴擄紱 example.py 婕旂ず紼嬪簭</blockquote><li style="margin-bottom: 0.3em;">瀹夎</li><blockquote style="margin: 20px; max-width: 60em;">灝唕pdb.py鎷瘋礉鍒癙YTHONPATH鍗沖彲錛屾垨鑰呯洿鎺ユ嫹璐漴pdb.py涓婂唴瀹瑰埌浣犵殑python鑴氭湰鍗沖彲錛堢▼搴忛潪甯稿皬宸э紝30+浠g爜琛岋級</blockquote><li style="margin-bottom: 0.3em;">婕旂ず</li><pre style="font-size: 12px; padding: 0.5em; overflow: auto; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; max-width: 70em; background-color: #eeeeee;">pdb <span style="color: #666600;">=</span> <span style="color: #660066;">Rpdb</span><span style="color: #666600;">()</span>         <span style="color: #880000;"># 綾諱技浜巔db=Pdb()</span><br />pdb <span style="color: #666600;">=</span> <span style="color: #660066;">Rpdb</span><span style="color: #666600;">(</span><span style="color: #006666;">8787</span><span style="color: #666600;">)</span> <span style="color: #880000;"># 鎸囧畾榪滅▼璋冭瘯绔彛鍙?/span><br />pdb<span style="color: #666600;">.</span>set_trace<span style="color: #666600;">()</span> <span style="color: #880000;">#璁劇疆鏂偣</span></pre><blockquote style="margin: 20px; max-width: 60em;">濡俥xample.py涓▼搴忥細<pre style="font-size: 12px; padding: 0.5em; overflow: auto; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; max-width: 70em; background-color: #eeeeee;"><span style="color: #880000;">#!/usr/bin/python</span><span style="color: #000000;"><br /><br /></span><span style="color: #000088;">from</span><span style="color: #000000;"> rpdb </span><span style="color: #000088;">import</span> <span style="color: #660066;">Rpdb</span><span style="color: #000000;"><br /></span><span style="color: #000088;">from</span><span style="color: #000000;"> random </span><span style="color: #000088;">import</span><span style="color: #000000;"> randint<br /></span><span style="color: #000088;">from</span><span style="color: #000000;"> time </span><span style="color: #000088;">import</span><span style="color: #000000;"> sleep<br /><br /></span><span style="color: #000088;">def</span><span style="color: #000000;"> add</span><span style="color: #666600;">(</span><span style="color: #000000;">i</span><span style="color: #666600;">,</span><span style="color: #000000;"> j</span><span style="color: #666600;">):</span><span style="color: #000000;"><br />    r </span><span style="color: #666600;">=</span><span style="color: #000000;"> i </span><span style="color: #666600;">+</span><span style="color: #000000;"> j<br />    </span><span style="color: #000088;">return</span><span style="color: #000000;"> r<br /><br /></span><span style="color: #000088;">def</span><span style="color: #000000;"> main</span><span style="color: #666600;">():</span><span style="color: #000000;"><br />    pdb </span><span style="color: #666600;">=</span> <span style="color: #660066;">Rpdb</span><span style="color: #666600;">()</span><span style="color: #000000;"><br />    </span><span style="color: #880000;"># pdb = Rpdb(9999) # debug port:9999</span><span style="color: #000000;"><br />    pdb</span><span style="color: #666600;">.</span><span style="color: #000000;">set_trace</span><span style="color: #666600;">()</span><span style="color: #000000;"><br />    </span><span style="color: #000088;">while</span> <span style="color: #000088;">True</span><span style="color: #666600;">:</span><span style="color: #000000;"><br />        i </span><span style="color: #666600;">=</span><span style="color: #000000;"> randint</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">,</span><span style="color: #006666;">10</span><span style="color: #666600;">)</span><span style="color: #000000;"><br />        j </span><span style="color: #666600;">=</span><span style="color: #000000;"> randint</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">,</span><span style="color: #006666;">10</span><span style="color: #666600;">)</span><span style="color: #000000;"><br />        r </span><span style="color: #666600;">=</span><span style="color: #000000;"> add</span><span style="color: #666600;">(</span><span style="color: #000000;">i</span><span style="color: #666600;">,</span><span style="color: #000000;"> j</span><span style="color: #666600;">)</span><span style="color: #000000;"><br />        </span><span style="color: #000088;">print</span><span style="color: #000000;"> r<br />        sleep</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">)</span><span style="color: #000000;"><br /><br /></span><span style="color: #000088;">if</span><span style="color: #000000;"> __name__ </span><span style="color: #666600;">==</span> <span style="color: #008800;">'__main__'</span><span style="color: #666600;">:</span><span style="color: #000000;"><br />    main</span><span style="color: #666600;">()</span></pre>鏈湴緇堢杈撳叆錛?telnet xxx.xxx.xxx.xxx 8787<pre style="font-size: 12px; padding: 0.5em; overflow: auto; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; max-width: 70em; background-color: #eeeeee;"><span style="color: #000000;">telnet </span><span style="color: #006666;">127.0</span><span style="color: #666600;">.</span><span style="color: #006666;">0.1</span> <span style="color: #006666;">8787</span><span style="color: #000000;"><br /></span><span style="color: #660066;">Trying</span> <span style="color: #006666;">127.0</span><span style="color: #666600;">.</span><span style="color: #006666;">0.1</span><span style="color: #666600;">...</span><span style="color: #000000;"><br /></span><span style="color: #660066;">Connected</span><span style="color: #000000;"> to localhost</span><span style="color: #666600;">.</span><span style="color: #000000;"><br /></span><span style="color: #660066;">Escape</span><span style="color: #000000;"> character </span><span style="color: #000088;">is</span> <span style="color: #008800;">'^]'</span><span style="color: #666600;">.</span><span style="color: #000000;"><br /></span><span style="color: #666600;">></span> <span style="color: #008800;">/Users/</span><span style="color: #000000;">stone</span><span style="color: #666600;">/</span><span style="color: #660066;">Tmp</span><span style="color: #666600;">/</span><span style="color: #000000;">baidu</span><span style="color: #666600;">/</span><span style="color: #000000;">rpdb</span><span style="color: #666600;">/</span><span style="color: #000000;">example</span><span style="color: #666600;">.</span><span style="color: #000000;">py</span><span style="color: #666600;">(</span><span style="color: #006666;">15</span><span style="color: #666600;">)</span><span style="color: #000000;">main</span><span style="color: #666600;">()</span><span style="color: #000000;"><br /></span><span style="color: #666600;">-></span> <span style="color: #000088;">while</span> <span style="color: #000088;">True</span><span style="color: #666600;">:</span><span style="color: #000000;"><br /></span><span style="color: #666600;">(</span><span style="color: #660066;">Pdb</span><span style="color: #666600;">)</span><span style="color: #000000;"> l <br /> </span><span style="color: #006666;">10</span><span style="color: #000000;">     <br /> </span><span style="color: #006666;">11</span><span style="color: #000000;">     </span><span style="color: #000088;">def</span><span style="color: #000000;"> main</span><span style="color: #666600;">():</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">12</span><span style="color: #000000;">         pdb </span><span style="color: #666600;">=</span> <span style="color: #660066;">Rpdb</span><span style="color: #666600;">()</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">13</span><span style="color: #000000;">         </span><span style="color: #880000;"># pdb = Rpdb(9999) # debug port:9999</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">14</span><span style="color: #000000;">         pdb</span><span style="color: #666600;">.</span><span style="color: #000000;">set_trace</span><span style="color: #666600;">()</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">15</span> <span style="color: #666600;">-></span><span style="color: #000000;">     </span><span style="color: #000088;">while</span> <span style="color: #000088;">True</span><span style="color: #666600;">:</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">16</span><span style="color: #000000;">             i </span><span style="color: #666600;">=</span><span style="color: #000000;"> randint</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">,</span><span style="color: #006666;">10</span><span style="color: #666600;">)</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">17</span><span style="color: #000000;">             j </span><span style="color: #666600;">=</span><span style="color: #000000;"> randint</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">,</span><span style="color: #006666;">10</span><span style="color: #666600;">)</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">18</span><span style="color: #000000;">             r </span><span style="color: #666600;">=</span><span style="color: #000000;"> add</span><span style="color: #666600;">(</span><span style="color: #000000;">i</span><span style="color: #666600;">,</span><span style="color: #000000;"> j</span><span style="color: #666600;">)</span><span style="color: #000000;"><br /> </span><span style="color: #006666;">19</span><span style="color: #000000;">             </span><span style="color: #000088;">print</span><span style="color: #000000;"> r<br /> </span><span style="color: #006666;">20</span><span style="color: #000000;">             sleep</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">)</span><span style="color: #000000;"><br /></span><span style="color: #666600;">(</span><span style="color: #660066;">Pdb</span><span style="color: #666600;">)</span><span style="color: #000000;"> n<br /></span><span style="color: #666600;">></span> <span style="color: #008800;">/Users/</span><span style="color: #000000;">stone</span><span style="color: #666600;">/</span><span style="color: #660066;">Tmp</span><span style="color: #666600;">/</span><span style="color: #000000;">baidu</span><span style="color: #666600;">/</span><span style="color: #000000;">rpdb</span><span style="color: #666600;">/</span><span style="color: #000000;">example</span><span style="color: #666600;">.</span><span style="color: #000000;">py</span><span style="color: #666600;">(</span><span style="color: #006666;">16</span><span style="color: #666600;">)</span><span style="color: #000000;">main</span><span style="color: #666600;">()</span><span style="color: #000000;"><br /></span><span style="color: #666600;">-></span><span style="color: #000000;"> i </span><span style="color: #666600;">=</span><span style="color: #000000;"> randint</span><span style="color: #666600;">(</span><span style="color: #006666;">1</span><span style="color: #666600;">,</span><span style="color: #006666;">10</span><span style="color: #666600;">)</span><span style="color: #000000;"><br /></span><span style="color: #666600;">(</span><span style="color: #660066;">Pdb</span><span style="color: #666600;">)</span><span style="color: #000000;"> b </span><span style="color: #006666;">19</span><span style="color: #000000;"><br /></span><span style="color: #660066;">Breakpoint</span> <span style="color: #006666;">1</span><span style="color: #000000;"> at </span><span style="color: #666600;">/</span><span style="color: #660066;">Users</span><span style="color: #666600;">/</span><span style="color: #000000;">stone</span><span style="color: #666600;">/</span><span style="color: #660066;">Tmp</span><span style="color: #666600;">/</span><span style="color: #000000;">baidu</span><span style="color: #666600;">/</span><span style="color: #000000;">rpdb</span><span style="color: #666600;">/</span><span style="color: #000000;">example</span><span style="color: #666600;">.</span><span style="color: #000000;">py</span><span style="color: #666600;">:</span><span style="color: #006666;">19</span><span style="color: #000000;"><br /></span><span style="color: #666600;">(</span><span style="color: #660066;">Pdb</span><span style="color: #666600;">)</span><span style="color: #000000;"> c<br /></span><span style="color: #666600;">></span> <span style="color: #008800;">/Users/</span><span style="color: #000000;">stone</span><span style="color: #666600;">/</span><span style="color: #660066;">Tmp</span><span style="color: #666600;">/</span><span style="color: #000000;">baidu</span><span style="color: #666600;">/</span><span style="color: #000000;">rpdb</span><span style="color: #666600;">/</span><span style="color: #000000;">example</span><span style="color: #666600;">.</span><span style="color: #000000;">py</span><span style="color: #666600;">(</span><span style="color: #006666;">19</span><span style="color: #666600;">)</span><span style="color: #000000;">main</span><span style="color: #666600;">()</span><span style="color: #000000;"><br /></span><span style="color: #666600;">-></span> <span style="color: #000088;">print</span><span style="color: #000000;"> r<br /></span><span style="color: #666600;">(</span><span style="color: #660066;">Pdb</span><span style="color: #666600;">)</span><span style="color: #000000;"> p r<br /></span><span style="color: #006666;">11</span><span style="color: #000000;"><br /></span><span style="color: #666600;">(</span><span style="color: #660066;">Pdb</span><span style="color: #666600;">)</span><span style="color: #000000;"> q<br /></span><span style="color: #660066;">Connection</span><span style="color: #000000;"> closed </span><span style="color: #000088;">by</span><span style="color: #000000;"> foreign host</span><span style="color: #666600;">.</span></pre>鎿嶄綔鍜宲db瀹屽叏涓鑷淬?/blockquote></ul><h1><a name="PDB甯哥敤鍛戒護"></a>PDB甯哥敤鍛戒護</h1><p style="line-height: 1.25em; max-width: 64em;"></p><table style="border-spacing: 0px; border-style: solid; border-color: #cccccc;"><tbody><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鍛戒護</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">浠嬬粛</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">h(elp) command<a style="color: #0000cc;">?</a></td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">杈撳叆h鎴栬卙elp 鍒楀嚭pdb鏀寔鐨勬墍鏈夊懡浠わ紝 h command<a style="color: #0000cc;">?</a> 浠嬬粛鎸囧畾鍛戒護</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">w(here)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鍒楀嚭褰撳墠璋冭瘯鎵鍦ㄨ錛屼竴鑸細浣跨敤 l(ist)</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">l(ist) [first[, last]]</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鍒楀嚭婧愪唬鐮佷俊鎭?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">s(tep)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">榪涘叆鍑芥暟浣?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">n(ext)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鎵ц涓嬩竴琛屼唬鐮?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">c(ont(inue))</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">緇х畫錛岀洿鍒伴亣鍒頒笅涓涓柇鐐?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">r(eturn)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鎵ц鍒板嚱鏁頒綋緇撴潫閭h</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">b(reak)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">璁劇疆鏂偣錛屽彲浠ユ槸浠g爜琛屽彿錛屾柟娉曞悕錛?榪樺彲浠ュ姞榪涘叆鏉′歡</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">tbreak</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">璁劇疆涓存椂鏂偣錛岃繘鍏ヤ竴嬈″悗錛岃嚜鍔ㄦ秷澶?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">cl(ear)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鍙栨秷鏂偣</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">disable</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">璁╂柇鐐瑰け鏁?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">enable</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">璁╂柇鐐圭敓鏁?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">ignore</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">蹇界暐鏂偣n嬈?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">condition</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">緇欐柇鐐規坊鍔犳潯浠訛紝絎﹀悎鏉′歡鐨勬墠榪涘叆鏂偣</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">j(ump) lineno</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">璺蟲帀鎸囧畾琛?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">a(rgs)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鎵撳嵃鍑芥暟浣撳弬鏁頒俊鎭?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">p expression</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鎵撳嵃鍙橀噺</td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">pp expression</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鍚屼笂錛屾墦鍗板緱婕備寒涓浜?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">! statement</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">鎵ц浠g爜錛岄潪甯告湁鐢紝鍙敤鏉ヤ慨鏀瑰彉閲忓?/td></tr><tr><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">q(uit)</td><td style="font-size: 13px; border-style: solid; border-color: #cccccc; padding: 5px;">閫鍑鴻皟璇曪紙pdb鐨剄uit寰堥粍寰堟毚鍔涳級</td></tr></tbody></table><p style="line-height: 1.25em; max-width: 64em;"></p></div></div><img src ="http://www.tkk7.com/stone2083/aggbug/396812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stone2083/" target="_blank">stone2083</a> 2013-03-21 16:19 <a href="http://www.tkk7.com/stone2083/archive/2013/03/21/396812.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍒嗕韓鍑犱釜灝忓伐鍏?-鎺ㄨ崘緇橪inux鐨勭敤鎴?/title><link>http://www.tkk7.com/stone2083/archive/2013/03/19/396660.html</link><dc:creator>stone2083</dc:creator><author>stone2083</author><pubDate>Tue, 19 Mar 2013 07:12:00 GMT</pubDate><guid>http://www.tkk7.com/stone2083/archive/2013/03/19/396660.html</guid><wfw:comment>http://www.tkk7.com/stone2083/comments/396660.html</wfw:comment><comments>http://www.tkk7.com/stone2083/archive/2013/03/19/396660.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/stone2083/comments/commentRss/396660.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stone2083/services/trackbacks/396660.html</trackback:ping><description><![CDATA[<div>鑷繁鍐欑殑鍑犱釜灝忓伐鍏鳳紝鍒嗕韓緇欓渶瑕佺殑浜猴細<br /><br />https://code.google.com/p/stonelab/wiki/BaiduMp3<br />鐧懼害MP3鎵歸噺涓嬭澆宸ュ叿<br /><br /><div>https://code.google.com/p/stonelab/wiki/FileConvertor<br />鏂囦歡緙栫爜杞崲宸ュ叿<br /><br /><div>https://code.google.com/p/stonelab/wiki/MyZip<br />鎵╁睍zip鍛戒護錛屾敮鎸佹枃浠跺悕緙栫爜<br /><br /><div>https://code.google.com/p/stonelab/wiki/Translate<br />鍛戒護琛屼笅鐨勭炕璇戣蔣浠?br /><br /><div>https://code.google.com/p/stonelab/wiki/HostsX<br />鎵╁睍Hosts錛屽埆鍚岲nsProxy錛孌NS浠g悊鏈嶅姟</div></div></div></div></div><img src ="http://www.tkk7.com/stone2083/aggbug/396660.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stone2083/" target="_blank">stone2083</a> 2013-03-19 15:12 <a href="http://www.tkk7.com/stone2083/archive/2013/03/19/396660.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>BaiduMp3--鍩轟簬鍛戒護琛岀殑鐧懼害MP3鎵歸噺涓嬭澆宸ュ叿http://www.tkk7.com/stone2083/archive/2013/03/19/396645.htmlstone2083stone2083Tue, 19 Mar 2013 03:28:00 GMThttp://www.tkk7.com/stone2083/archive/2013/03/19/396645.htmlhttp://www.tkk7.com/stone2083/comments/396645.htmlhttp://www.tkk7.com/stone2083/archive/2013/03/19/396645.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/396645.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/396645.html

杞歡浠嬬粛

BaiduMp3錛屽熀浜庡懡浠よ涓嬬殑鐧懼害MP3姝屾洸鎵歸噺涓嬭澆宸ュ叿銆?br />
涓昏鏀寔鍔熻兘錛?/p>

  • 鎼滅儲 鏍規嵁鍏抽敭璇嶆悳绱㈠尮閰嶇殑姝屾洸
  • 涓嬭澆 鏍規嵁鎼滅儲鍑烘潵鐨勬瓕鏇睮D錛屼笅杞藉埌鏈湴鎸囧畾鐩綍
  • 鎵歸噺涓嬭澆 鏍規嵁鍏抽敭璇嶏紝鎵歸噺涓嬭澆鍖歸厤鐨勬瓕鏇詫紝鍒版湰鍦版寚瀹氱洰褰?/li>

杞歡浣跨敤

  • 鍛戒護鍙傛暟浠嬬粛
  • Usage: baidump3.py [options]

    Options:
      -h, --help            show this help message and exit
      -m MODE, --mode=MODE  specifies the command mode
                            [list|download|multidownload]
      -o OUTPUT, --output=OUTPUT
                            specifies the output dir for download
      -p PAGE, --page=PAGE  specifies the list page
      -k KEY, --key=KEY     specifies the mp3 keyworld
      -f FROMPAGE, --from=FROMPAGE
                            specifies the from page for multidownload
      -t TOPAGE, --to=TOPAGE
                            specifies the end page for multidownload
  • 鎼滅儲
  • 閫氳繃-m list鎸囧畾涓烘悳绱㈡ā寮?-k鍙傛暟鎸囧畾鎼滅儲鍏抽敭璇嶏紝-p鍏抽敭璇嶆寚瀹氬垎欏甸〉闈㈠彿錛岄粯璁や竴欏墊樉紺?0鏉℃暟鎹?br />
    姣斿錛?/baidump3.py -m list -k 70鍚?-p 2 

    鏁堟灉錛?pre style="font-size: 12px; padding: 0.5em; overflow: auto; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; max-width: 70em; background-color: #eeeeee;">./baidump3.py -m list -k 70鍚?/span> -p 2
    Total: 1000 Page:2
    1007797 鍒樿嫢鑻?/span>                   涓虹埍鐥寸媯
    2067170 濮滆偛鎭?/span>                   鍒鎴戜竴涓漢閱?/span>
    209442    褰匠鎱?/span>                   鐩歌鎭ㄦ櫄
    2121730 鏉ㄩ挵鑾?姣涘畞                蹇冮洦
    216206    璁哥編闈?/span>                   钄撳歡
    226444    闄堟窇妗?/span>                   闂?/span>
    253833    寮犲鍙?/span>                   縐嬫剰嫻?/span>
    274172    寮犲鍙?/span>                   涓夊ぉ涓ゅ
    580824    瀛熷涵鑻?/span>                   浼や簡浣犵殑蹇冪殑鎴戜激蹇?/span>
    582858    鑾枃钄?/span>                   鐢靛彴鎯呮瓕
    650924    濮滆偛鎭?/span>                   鍏跺疄鎴戠湡鐨勫緢鍦ㄤ箮
    7274415 婊℃枃鍐?/span>                   鎴戦渶瑕佷綘
    7277793 鏋楀織鐐?/span>                   鍗曡韓鎯呮瓕
    7280177 鏋楀織鐐?/span>                   紱諱漢
    7302437 鏉庡鍏?/span>                   寮犱笁鐨勬瓕
    844889    闄堟窇妗?/span>                   嫻佸厜椋炶垶
    1039139 鐜嬭彶                    瀹規槗鍙椾激鐨勫コ浜?/span>
    1243712 緗楀ぇ浣?/span>                   鎭嬫洸1980
    2076242 鏉庡畻鐩?/span>                   鎴戞槸涓鍙皬灝忛笩
    2121739 鏉ㄩ挵鑾?/span>                   杞昏交鐨勫憡璇変綘
  • 涓嬭澆
  • 閫氳繃-m download鎸囧畾涓轟笅杞芥ā寮?-k鍙傛暟鎸囧畾涓嬭澆姝屾洸ID鍙?-o鍙傛暟鎸囧畾涓嬭澆璺緞錛岄粯璁や負褰撳墠鐩綍銆?br />
    姣斿錛?/baidump3.py -m download -k 1007797 -o ~/Tmp/ 

    鏁堟灉錛?pre style="font-size: 12px; padding: 0.5em; overflow: auto; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; max-width: 70em; background-color: #eeeeee;">Downloading >>> 涓虹埍鐥寸媯.mp3
  • 鎵歸噺涓嬭澆
  • 閫氳繃-m multidownload鎸囧畾涓烘壒閲忎笅杞芥ā寮?-k鍙傛暟鎸囧畾姝屾洸鍏抽敭璇嶏紝 -o鍙傛暟鎸囧畾涓嬭澆璺緞錛堥粯璁や綅涓哄綋鍓嶇洰褰曪級錛?-f鍙傛暟鎸囧畾涓嬭澆寮濮嬮〉闈紙榛樿涓虹涓欏碉級錛?-t鍙傛暟鎸囧畾涓嬭澆緇撴潫欏甸潰錛堥粯璁や負鎼滅儲鍒扮殑鏈鍚庝竴欏碉級

    姣斿錛?/baidump3.py -m multidownload -k 70鍚?-o ~/Tmp/baidu -f 2 -t 3 

    鏁堟灉錛?pre style="font-size: 12px; padding: 0.5em; overflow: auto; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; max-width: 70em; background-color: #eeeeee;"> MultiDownloading Page 2
    Downloading >>> 涓虹埍鐥寸媯.mp3
    Downloading >>> 鍒鎴戜竴涓漢閱?mp3
    Downloading >>> 鐩歌鎭ㄦ櫄.mp3
    Downloading >>> 韞囧啴媧?mp3
    Downloading >>> 钄撳歡.mp3
    Downloading >>> 闂?mp3
    Downloading >>> 縐嬫剰嫻?mp3
    Downloading >>> 涓夊ぉ涓ゅ.mp3
    Downloading >>> 浼や簡浣犵殑蹇冪殑鎴戜激蹇?mp3
    Downloading >>> 鐢靛彴鎯呮瓕.mp3
    Downloading >>> 鍏跺疄鎴戠湡鐨勫緢鍦ㄤ箮.mp3
    Downloading >>> 閹存垿娓剁憰浣風稑.mp3
    Downloading >>> 鍗曡韓鎯呮瓕.mp3
    Downloading >>> 紱諱漢.mp3
    Downloading >>> 寮犱笁鐨勬瓕.mp3
    Downloading >>> 嫻佸厜椋炶垶.mp3
    Downloading >>> 瀹規槗鍙椾激鐨勫コ浜?mp3
    Downloading Fail.
    Downloading >>> 鎴戞槸涓鍙皬灝忛笩.mp3
    Downloading >>> 杞昏交鐨勫憡璇変綘.mp3
    MultiDownloading Page 3
    Downloading >>> 瀛熷﹩姹?mp3
    Downloading >>> 鎯呬功.mp3
    Downloading >>> 姍勬鏍?mp3
    Downloading >>> 閫夋嫨.mp3
    Downloading >>> 緇撴潫涓嶆槸鎴戣鐨勭粨鏋?mp3
    Downloading >>> 閸涙娊浜?mp3
    Downloading >>> 鏉ョ敓緙?mp3
    Downloading >>> 鐩告濋闆ㄤ腑.mp3
    Downloading >>> 浣犳垜鐨勭埍鍙兘鎿﹁偐鑰岃繃.mp3
    Downloading >>> 蹇樻儏姘?mp3
    Downloading >>> 鐖卞娼按.mp3
    Downloading >>> 鐗瑰埆鐨勭埍緇欑壒鍒殑浣?mp3
    Downloading >>> 鍗冨崈闃欐瓕.mp3
    Downloading >>> 娑涘0渚濇棫.mp3
    Downloading >>> Hotel California.mp3
    Downloading >>> Roll Away The Stone.mp3
    Downloading >>> Peace Train.mp3
    Downloading >>> Have You Never Been Mellow.mp3
    Downloading >>> Hot Stuff.mp3
    Downloading >>> Rock The Boat.mp3澶囨敞錛?鏈夊皬姒傜巼浼氬嚭鐜頒貢鐮侊紝浠ュ強灝忓皬姒傜巼鍑虹幇涓嬭澆澶辮觸銆?/blockquote>


stone2083 2013-03-19 11:28 鍙戣〃璇勮
]]>
RaspCTL V0.1.0 Releasedhttp://www.tkk7.com/stone2083/archive/2013/01/16/394311.htmlstone2083stone2083Wed, 16 Jan 2013 08:23:00 GMThttp://www.tkk7.com/stone2083/archive/2013/01/16/394311.htmlhttp://www.tkk7.com/stone2083/comments/394311.htmlhttp://www.tkk7.com/stone2083/archive/2013/01/16/394311.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/394311.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/394311.html杞嚜錛歨ttps://code.google.com/p/stonelab/wiki/RaspCTL
COPY榪囨潵鏍煎紡姣旇緝涔憋紝灝嗗氨鍦扮湅鍚с傚師鏂囩洿鎺ョ湅googlecode wiki鍚?錛氾級

浠涔堟槸RaspCTL
RaspCTL鏄疪aspberry Pi鍜孋ontrol瀛楁瘝鐨勭粍鍚堬紝琛ㄧず鏍戣帗媧炬帶鍒剁銆?RaspCTL鏄竴嬈鵑氳繃鎵嬫満緇堢錛堟硾涔変笂鍖呮嫭鎵嬫満錛屽鉤鏉匡紝鐢佃剳絳夎澶囷級鎺у埗鏍戣帗媧?/a>鐨勮蔣浠躲?br /> 鐩墠錛岄氳繃Raspberry&RaspCTL緇勫悎錛屾墦閫犳垚瀹跺涵澶氬獟浣撴挱鏀炬満欏剁洅錛屽湪姝ゅ満鏅腑錛孯aspCTL闈炲父綾諱技XBMC騫沖彴銆?/span>鏈潵錛屼細涓嶆柇鎵╁睍RaspCTL鍔熻兘錛屾垚涓烘帶鍒跺搴墿鑱旂綉鐨勮澶囦腑蹇冿紝姣斿鎺у埗鎽勫儚澶達紝絀鴻皟寮鍏崇瓑銆傛涔冨悗璇濓紝鎸変笅涓嶈〃銆?/span>


涓轟粈涔堥夋嫨Raspberry Pi&RaspCTL
涓轟粈涔堥夋嫨Raspberry Pi

鎴戜滑鍏堟潵鐪嬬湅Raspberry Pi鐨勭浉鍏沖弬鏁幫細

CPU 700 MHz錛?ARM1176JZF-S
GPU錛堟樉鍗★級 Broadcom VideoCore? IV錛孫penGL ES 2.0錛?1080p30 h.264/MPEG-4 AVC high-profile decoder
MEM錛堝唴瀛橈級 512M
鍒嗚鯨鐜?/td> 1080P
杈撳嚭鎺ュ彛 1*SD鍙?2*USB鍙?1*闊抽鍙?1*HDMI鍙?1*緗戝崱
灝哄 85.6 x 53.98 x 17mm 錛堜竴寮犱俊鐢ㄥ崱澶у皬錛?/td>
浠鋒牸 $35


濂藉惂錛屼竴璧鋒潵鎬葷粨涓婻aspberry Pi鐨勪紭鍔垮惂

  • 灝忓閥錛氬彧鏈変竴寮犱俊鐢ㄥ崱澶у皬
  • GPU寮烘倣錛?紜В1080P錛?0甯?S錛岄氫織鍦板皢錛屽樊涓嶅鏄痠phone4S鎵嬫満鐨?鍊嶆ц兘
  • 杈撳嚭鎺ュ彛涓板瘜錛?鍖呮嫭2*USB錛?*HDMI
  • 鎬т環姣旈珮錛?35

    浠庤繖浜涚壒鎬х湅錛孯aspberry闈炲父鍚堥傚厖褰撻珮娓呰棰戞挱鏀炬満欏剁洅錛屾潵鏇夸唬鐩墠鐨勫崕鏁版満欏剁洅錛堝崕鏁板畼鏂瑰瀯鏂紝璐圭敤楂橈紝璐ㄩ噺宸級銆?瀹跺涵涓紝鍙璐疆浜哛aspberry Pi鍜屽甯︼紝楂樻竻鐢靛獎鐢佃錛屽厤璐圭湅銆?錛氾級

涓轟粈涔堥夋嫨RaspCTL
鍙湁涓涓師鍥狅細Raspberry Pi CPU寰堝急錛?00MHZ銆?鍚屾牱錛屾垜浠潵鐪嬩竴緇勬暟鎹細

  • Raspbian Terminal涓?CPU LOAD鍦?.2宸﹀彸
  • Raspbian XWindows涓嬶紝 CPU鍗犵敤鐜囧樊涓嶅鍦?0%浠ヤ笂
  • XBian涓嬶紝CPU鍗犵敤鐜囧湪95%浠ヤ笂
    濡傛灉錛孯aspberry Pi CPU鑳藉己鎮嶉偅涔堜竴鐐圭偣錛岄偅涔圶Bian涓瀹氭槸棣栭夛紝鎴戜篃涓嶄細閲嶆柊鍒涢燫aspCTL榪欎釜杞瓙浜嗐傚彧鏄洰鍓嶏紝XBMC鍦≧aspberry Pi錛圶Bian錛変笂鐨勬ц兘澶碂緋曚簡銆?浠庢暟鎹湅錛屽彧鏈夊湪Raspbian Terminal涓嬬殑鎬ц兘錛屾墠鑳界鍚堢敤鎴風殑鏈熸湜錛屾墍浠ヤ綔鑰呯紪鍐欎簡RaspCTL榪欎釜鎺у埗绔傞氳繃鎵嬫満緇堢鐨勭晫闈紝鏉ユ搷浣淩aspbian Terminal錛屽疄鐜板濯掍綋鎾斁鐨勫姛鑳姐?/span>

RaspCTL(V0.1.0)鍔熻兘鐗規?/h1>
  1. 鏀寔瑙嗗睆錛岄煶棰戞挱鏀?/li>
    • 鏀寔鎾斁錛屾殏鍋滐紝鍋滄錛屽揩榪涳紝蹇錛屾挱鏀懼垪琛紝涓婁竴棣栵紝涓嬩竴棣栫瓑
  2. 鏀寔鏈湴鏂囦歡鏌ョ湅
    • 鏌ョ湅澶氬獟浣撴枃浠?/li>
  3. 閰嶇疆緋葷粺淇℃伅
    • 閰嶇疆澶氬獟浣撴枃浠舵牴璺緞絳?/li>
  4. 瑙嗛緗戠珯鐪熷疄URL鍒嗘瀽
    • 鏀寔鍖呮嫭浼橀叿錛屽湡璞嗭紝榪呴浄錛岀櫨搴︾瓑82涓綉绔欒棰慤RL鍒嗘瀽
  5. 鍒跺畾Plugins瑙勮寖
    • 鍙潪甯告柟渚垮紑鍙慠aspCTL Pugin

浣跨敤鑰呮枃妗?/h1>

濡備綍瀹夎RaspCTL

  1. 涓嬭澆RaspCTL
    1. 涓嬭澆錛岃В鍘嬪埌鎸囧畾鐩綍
    2. 鎴栬呯洿鎺ヤ嬌鐢╯vn鍦板潃錛?svn co https://stonelab.googlecode.com/svn/tags/raspctl-0.1.0 RaspCTL
  2. 瀹夎RaspCTL
    1. chmox +x bin/install.sh; bin/install.sh
    2. 浼氳嚜鍔ㄥ畨瑁匯aspCTL渚濊禆鐨勭涓夋柟搴擄紝涓昏鏄痯ython-webpy python-jinja2 python-pexpect渚濊禆

濡備綍浣跨敤RaspCTL

  1. 鍚姩RaspCTL鏈嶅姟
    • bin/start.sh
    • 鍚姩鍚庯紝鍦ㄤ綘鎵嬫満嫻忚鍣ㄤ笂杈撳叆錛?/li>
    • http://xxx.xxx.xxx.xxx:8000/config 閰嶇疆浣犳爲鑾撴淳涓婃湰鍦板濯掍綋鏂囦歡鏍圭洰褰?/li>
    • http://xxx.xxx.xxx.xxx:8000/player 榪涘叆鎾斁鍣?/li>
    • 鐐瑰嚮娣誨姞錛岄夋嫨鏈湴澶氬獟浣撴枃浠?/li>
    • 鐐瑰嚮鎾斁錛屾殏鍋滅瓑鍔熻兘
  2. 鍏抽棴RaspCTL鏈嶅姟
    • bin/shutdown.sh

甯歌闂

  • Q錛氬浣曡嚜鍚姩RaspCTL鏈嶅姟
    • 灝?bin/start.sh 閰嶇疆鍒版爲鑾撴淳鐨?etc/rc.local exit涔嬪墠銆?鍚岀悊錛屼綘鍦╮c.local涓彲浠ュ惎鍔ㄥ叾浠栦換浣曟湇鍔★紱
  • Q錛氬浣曚嬌鐢?0绔彛
    • debian緋葷粺紱佺敤浜嗗皬浜?024鐨勭鍙o紝鎵浠aspCTL鍙湁浣跨敤8000绔彛銆傚彲浠ラ氳繃iptable灝?0绔彛璇鋒眰杞彂鍒?000绔彛錛?iptables -t nat -A PREROUTING -p tcp --dport 81 -j REDIRECT --to-ports 8080

寮鍙戣呮枃妗?/h1>

綾誨簱API

Omxplayer

play 鎾斁錛屽彲浠ユ寚瀹氭挱鏀懼垪琛ㄤ腑浠諱竴涓涓祫婧?/td>
pause 鏆傚仠鎾斁
resume 鎭㈠鎾斁
stop 鍋滄鎾斁
lseek 蹇錛?蹇30縐掞紝 鍙傛暟涓篢rue鐨勮瘽錛屽揩閫10鍒嗛挓
rseek 蹇繘錛?蹇繘30縐掞紝鍙傛暟涓篢rue鐨勮瘽錛屽揩榪?0鍒嗛挓
prev 鎾斁涓婁竴棣?/td>
next 鎾斁涓嬩竴棣?/td>
set_playlist 璁劇疆鎾斁鍒楄〃
add_playitem 娣誨姞澶氬獟浣撹祫婧愬埌鎾斁鍒楄〃涓? 鍙傛暟涓?('url', 'name') 璧勬簮鍦板潃錛?璧勬簮鏄劇ず鍚?/td>
del_playitem 娓呯┖鎾斁鍒楄〃
sort_playitem 鎾斁鍒楄〃鎺掑簭
set_dev 璁劇疆杈撳嚭璁懼錛?hdmi鎺ュ彛 鎴栬?鏈湴闊抽鎺ュ彛
set_loop 璁劇疆鎾斁妯″紡錛氶『搴忥紝寰幆
get_info 鑾峰彇鎾斁鍣ㄤ俊鎭紝濡傛挱鏀劇姸鎬佺瓑

LocalFile?

get_mediapath 鑾峰緱澶氬獟浣撴枃浠舵牴鐩綍璺緞
list 鑾峰彇涓涓洰褰曚笅鐨勬墍鏈夎祫婧?/td>
list_all 閫掑綊鑾峰彇涓涓洰褰曚笅鐨勬墍鏈夎祫婧?/td>

Config

load 鑾峰彇raspctl.cnf涓殑閰嶇疆淇℃伅
save 鏇存柊raspctl.cnf涓殑閰嶇疆淇℃伅

MediaUrl?

get_urls 鑾峰彇緗戠珯url瀵瑰簲鐨勭湡瀹炶灞弖rl鍦板潃淇℃伅錛?fmt=high 鑾峰彇楂樻竻瑙嗗睆鍦板潃

Ajax瑙勮寖

浣跨敤Ajax鐨勭洰鐨勶細涓轟簡RaspCTL鎻愪緵鐨勬湇鍔″彲浠ュ悓鏃惰WAP錛?Android APP, IOS APP浣跨敤錛孯aspCTL鏈嶅姟鍧囦互Ajax褰㈠紡鎻愪緵銆傚笇鏈汸lugins寮鍙戣呬篃閬電収榪欎釜瑙勭害錛屼絾涓嶅己鍒躲?br /> 綾誨簱涓紝鍙琚爣蹇桜classmethod鐨勬柟娉曪紝浼氱洿鎺ユ毚闇叉垚Ajax鏈嶅姟錛屽錛?/span>

class Foo:
   
@classmethod
   
def hello(cls, arg1, arg2):
       
return {msg: 'Hello Ajax[%s %s]' % (arg1, arg2)}


Ajax鏈嶅姟鍦板潃涓猴細http://xxx.xxx.xxx.xxx:8000/api?data={"name":"Foo.hello", "args":["stone2083", "connie2083"]} 鏈嶅姟淇℃伅涓猴細

{
  status
: "Success",
  message
: "Success",
  api
: {
    args
: [ ],
    name
: "Foo.hello"
 
},
  result
: {
    msg
: "Hello Ajax[stone2083 connie2083]"
 
}
}

Plugins瑙勮寖

youku --> 鎻掍歡鍚嶅瓧
    __init__
.py --> 鎻掍歡紼嬪簭
    index
.html --> 鎻掍歡妯℃澘 銆愬彲閫夋嫨銆?/span>

init.py 鍐呭涓猴細

from rasplib import Plugin
urls
= (
   
'/', 'Index',
)

# 蹇呴』鍒涘緩plugin瀹炰緥錛屽弬鏁板垎鍒負鎻掍歡鍚嶏紝浣滆呭悕錛岀増鏈彿錛?鏀寔鍔熻兘鐨剈rls
#鍏朵腑錛宲lugin涓寘鍚玆aspCTL綾誨簱鐨勬墍鏈夋柟娉曪紝鍙洿鎺ヨ皟鐢?/span>
plugin
= Plugin('youku','stone2083', '0.1', urls)

#web.py鍐欐硶錛屾彃浠惰鑼冨茍涓嶅紩鍏ユ柊鐨勫涔犳垚鏈?/span>
class Index:
   
def GET(self):
       
return 'youku-NotSupported.'  #鍙互鐩存帴杈撳嚭
       
#return plugin.render.index()  #鍙互娓叉煋鏌愪釜妯℃澘淇℃伅

鍐欏湪鏈鍚?/h1>
  • RaspCTL浣滆呰仈緋諱俊鎭細stone2083#yahoo.cn 紼嬪簭鐨勪換浣曢棶棰樺彲鐩存帴鑱旂郴榪欎釜閭
  • 鎷涘嫙UED璁捐鍓嶇鐣岄潰 0.1.0鍓嶇闈炲父緋熺硶錛屾ュ緟閲嶆瀯
  • 鎷涘嫙Plugin寮鍙戣咃紝涓板瘜RaspCTL
  • 鏈熷緟灝忕櫧榧犻傜敤RaspCTL


stone2083 2013-01-16 16:23 鍙戣〃璇勮
]]>SAE Python 鏀寔web.py (闈炲畼鏂規敮鎸?http://www.tkk7.com/stone2083/archive/2011/11/24/364738.htmlstone2083stone2083Thu, 24 Nov 2011 07:48:00 GMThttp://www.tkk7.com/stone2083/archive/2011/11/24/364738.htmlhttp://www.tkk7.com/stone2083/comments/364738.htmlhttp://www.tkk7.com/stone2083/archive/2011/11/24/364738.html#Feedback3http://www.tkk7.com/stone2083/comments/commentRss/364738.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/364738.html 棣栨鍊掕吘SAE錛屼笉鐔熸倝錛岀瀻鎼烇紝絎竴浠跺共鐨勪簨鎯咃紝灝辨槸灝濊瘯濡備綍璁㏒AE鏀寔web.py.

1. svn check out
svn co https://svn.sinaapp.com/stone2083 sae

2. 鍒涘緩鐗堟湰鐩綍
mkdir 1
cd 1/

3. copy web.py鐩綍鍒板綋鍓嶇洰褰?/strong>
scp -r /usr/share/pyshared/web web

4. 緙栧啓姝e父鐨剋ebpy搴旂敤浠g爜
vi webpy.py 
 1 import web
 2 
 3 urls = (
 4     '/''Home',
 5 )
 6 
 7 class Home:
 8     def GET(self):
 9         web.header('Content-Type''text/html')
10         return 'Hello Web.py'
11 
12 app = web.application(urls, globals())

5. 緙栧啓index.wsgi
vi index.wsgi
1 import sae
2 from webpy import app
3 application = sae.create_wsgi_app(app.wsgifunc())

鏁翠綋鐩綍緇撴瀯濡備笅錛?/strong>


鎼炲畾錛?br />

stone2083 2011-11-24 15:48 鍙戣〃璇勮
]]>
SSL鐩稿叧鍛戒護闅忚http://www.tkk7.com/stone2083/archive/2011/10/17/361471.htmlstone2083stone2083Mon, 17 Oct 2011 12:22:00 GMThttp://www.tkk7.com/stone2083/archive/2011/10/17/361471.htmlhttp://www.tkk7.com/stone2083/comments/361471.htmlhttp://www.tkk7.com/stone2083/archive/2011/10/17/361471.html#Feedback2http://www.tkk7.com/stone2083/comments/commentRss/361471.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/361471.html鑳屾櫙
涔嬪墠鍒╃敤絎ㄩ噸鐨凧ava鍐欒繃鍐呯綉璁塊棶紼嬪簭錛圫SL鍙屽悜璁よ瘉緋葷粺錛夛紝浠婂ぉ鎵嶅彂鐜癱url絳夊懡浠ゅSSL閮芥湁鑹ソ鐨勬敮鎸併?br />鏁呰褰曠浉鍏崇偣婊淬?br />
鍒涘緩CA鏍硅瘉涔?/strong>

#鍒涘緩ca縐侀挜
openssl genrsa -out ca.key
#鍒涘緩璇佷功璇鋒眰鏂囦歡錛?span class="Apple-style-span" style="font-family: arial, 瀹嬩綋, sans-serif; line-height: 24px; background-color: #ffffff; ">Certificate Secure Request錛?br />openssl req -new -key ca.key -out ca.csr

#鍒涘緩CA鏍硅瘉涔?br /> openssl x509 -req -days 3650 -in ca.csr -signkey ca.key -out ca.crt

鍒涘緩鏈嶅姟鍣ㄨ瘉涔?br /> #鍒涘緩鏈嶅姟鍣ㄧ閽?br />

openssl genrsa -out server.key

#鍒涘緩鏈嶅姟鍣ㄨ瘉涔﹁姹傛枃浠?br />openssl req -new -key server.key -out server.csr

#鍒涘緩鏈嶅姟鍣ㄨ瘉涔?br /> openssl ca -in server.csr -cert ca.crt -keyfile ca.key -out server.crt

PFX璇佷功杞崲
#pfx鏍煎紡璇佷功瀵煎嚭鎴恜em鏍煎紡璇佷功

openssl pkcs12 -in jinli.pfx -nodes -out jinli.pem
#瀵煎嚭縐侀挜
openssl rsa -in jinli.pem -out jinli.key
#瀵煎嚭璇佷功錛屽叕閽?br /> openssl x509 -in jinli.pem -out jinli.crt


curl璁塊棶HTTPS鍛戒護
curl -E jinli.pem:${password} --cacert ca.crt https://www.cn.alibaba-inc.com/
curl --cacert gmail.pem https://mail.google.com/mail
curl --cert jinli.crt --key jinli.key --cacert ca.crt https://www.cn.alibaba-inc.com/
鍙傛暟瑙i噴錛?br />
    --cacert <file> CA certificate to verify peer against (SSL)
    --capath 
<directory> CA directory to verify peer against (SSL)
 -E/--cert 
<cert[:passwd]> Client certificate file and password (SSL)
    --cert-type 
<type> Certificate file type (DER/PEM/ENG) (SSL)
    --key 
<key>     Private key file name (SSL/SSH)

    --key-type 
<type> Private key file type (DER/PEM/ENG) (SSL)

python璁塊棶HTTPS浠g爜
from httplib import HTTPSConnection

con 
= HTTPSConnection('www.cn.alibaba-inc.com', cert_file='jinli.pem')
con.connect()
con.request(
'GET''/xxx')
res 
= con.getresponse()
print res.status
print res.read()
res.close()
con.close()

python鏌ョ湅璇佷功淇℃伅浠g爜
from OpenSSL import crypto
x509 
= crypto.load_certificate(crypto.FILETYPE_PEM, open('cert_file').read())
print x509.get_issuer()

pkcs 
= crypto.load_pkcs12(open(pkcs_file).read(),passphrase)
print pkcs.get_certificate().get_issuer()

 

HTTPSConnection涓嶇悊瑙g殑鍦版柟 

def wrap_socket(sock, keyfile=None, certfile=None,
                server_side
=False, cert_reqs=CERT_NONE,
                ssl_version
=PROTOCOL_SSLv23, ca_certs=None,
                do_handshake_on_connect
=True,
                suppress_ragged_eofs
=True, ciphers=None):

    
return SSLSocket(sock, keyfile=keyfile, certfile=certfile,
                     server_side
=server_side, cert_reqs=cert_reqs,
                     ssl_version
=ssl_version, ca_certs=ca_certs,
                     do_handshake_on_connect
=do_handshake_on_connect,
                     suppress_ragged_eofs
=suppress_ragged_eofs,
                     ciphers
=ciphers)

 

ssl wrap鐨勫嚱鏁版槸鏀寔ca_certs鍙傛暟鐨勶紝浣嗘槸HTTPSConnection涓嶆敮鎸乧a_certs鍙傛暟
class HTTPSConnection(HTTPConnection):
        
"This class allows communication via SSL."

        default_port 
= HTTPS_PORT

        
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict
=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address
=None):
            HTTPConnection.
__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file 
= key_file
            self.cert_file 
= cert_file

        
def connect(self):
            
"Connect to a host on a given (SSL) port."

            sock 
= socket.create_connection((self.host, self.port),
                                            self.timeout, self.source_address)
            
if self._tunnel_host:
                self.sock 
= sock
                self._tunnel()
            self.sock 
= ssl.wrap_socket(sock, self.key_file, self.cert_file)








stone2083 2011-10-17 20:22 鍙戣〃璇勮
]]>璋佽web.py鎬ц兘宸紵http://www.tkk7.com/stone2083/archive/2011/09/30/359860.htmlstone2083stone2083Fri, 30 Sep 2011 06:51:00 GMThttp://www.tkk7.com/stone2083/archive/2011/09/30/359860.htmlhttp://www.tkk7.com/stone2083/comments/359860.htmlhttp://www.tkk7.com/stone2083/archive/2011/09/30/359860.html#Feedback10http://www.tkk7.com/stone2083/comments/commentRss/359860.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/359860.html 瀵規瘮浜嗕竴鍦坧ython web framework鍚庯紝榪樻槸璁╂垜瀵箇eb.py鐨剆imple鍜屽畠鐨勮璁$悊蹇靛康蹇典笉蹇樸?br />
鏈哄櫒浠嬬粛
鏈哄瀷錛歍hinkPad R400 絎旇鏈?br /> CPU錛欼ntel(R) Core(TM)2 Duo CPU     P8700  @ 2.53GHz
Mem錛?2G
緋葷粺錛歎buntu11.04 32浣嶆搷浣滅郴緇?br /> 澶囨敞錛氭湇鍔″櫒涓婃病鏈塸ython鐜錛屾墍浠ュ彧鎷夸釜浜虹數鑴戝仛嫻嬭瘯銆?br />
嫻嬭瘯鍐呭
杈撳嚭褰撳墠鏃墮棿淇℃伅
1. <%= new Date() %>
2. time.ctime()

瀵規瘮嫻嬭瘯鏁版嵁
鏈嶅姟鍣?/td> 騫跺彂鏁伴噺 TPS 騫沖潎鍝嶅簲鏃墮棿
Tomcat6 + JDK6 50 6519.29 7.67MS
CherryPy + Webpy 25 1328.56 18.82MS
CherryPy + Webpy 30 Fail Fail
Lighttpd + Flup(FCGI) + Webpy 25 1535.98 16.28MS
Lighttpd + Flup(FCGI) + Webpy 50 1546.11 32.339MS

嫻嬭瘯鎰熷彈
1. webpy鑷甫鐨凜herryPy鏈嶅姟鍣ㄦц兘涔熸瘮浼犺鐨勫己澶氫簡錛屽彧鏄毦浠ユ敮鎾戦珮騫跺彂鐨勮姹傘備篃闅炬紝鏈潵灝辨槸涓涓敤浜庡紑鍙戠殑鏈嶅姟鍣紝涔熶笉鑳借姹傚お澶氾紱
2. Flup錛團CGI錛変笅錛孴PS杈懼埌1500宸﹀彸錛屽畬鍏ㄨ兘澶熸敮鎾戜竴鑸簲鐢ㄧ殑榪愯惀瑕佹眰浜嗭紱
3. 鍦ㄤ笓涓氭湇鍔″櫒涓嬶紝webpy fcgi tps鑷俊鑳借揪鍒?-5k宸﹀彸銆傝凍澶熶簡錛?br /> 4. 鍜孞ava鐩告瘮錛岀‘瀹炲瓨鍦ㄤ竴瀹氬樊璺濓紝浣嗘槸鍦ㄥ紑鍙戞晥鐜囦笂錛岃繙榪滃揩浜嶫ava錛?br /> 5. web.py鎴愪負鎴戞棩鍚巜eb寮鍙戦閫夛紱
6. 鍑′簨涓嶈閬撳惉閫旇錛岄渶瑕佺溂瑙佷負瀹炪?br />
闄勪笂嫻嬭瘯鎶ュ憡鍥劇墖錛?br />


stone2083 2011-09-30 14:51 鍙戣〃璇勮
]]>
DNS浠g悊鏈嶅姟鍣?/title><link>http://www.tkk7.com/stone2083/archive/2011/07/04/353664.html</link><dc:creator>stone2083</dc:creator><author>stone2083</author><pubDate>Mon, 04 Jul 2011 12:39:00 GMT</pubDate><guid>http://www.tkk7.com/stone2083/archive/2011/07/04/353664.html</guid><wfw:comment>http://www.tkk7.com/stone2083/comments/353664.html</wfw:comment><comments>http://www.tkk7.com/stone2083/archive/2011/07/04/353664.html#Feedback</comments><slash:comments>23</slash:comments><wfw:commentRss>http://www.tkk7.com/stone2083/comments/commentRss/353664.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stone2083/services/trackbacks/353664.html</trackback:ping><description><![CDATA[鑳屾櫙鎺ヤ笂鏂囷細<a href="http://www.tkk7.com/stone2083/archive/2011/05/23/350875.html">http://www.tkk7.com/stone2083/archive/2011/05/23/350875.html<br /></a>闅忕瑪鎽樿嚜6鏈?3鏃ラ偖浠跺垎浜?br />鐩墠姝よ蔣浠跺湪鍏徃嫻嬭瘯鐜涓婅繍琛岃壇濂斤紝鏁呭垎浜粰澶у銆?a href="http://www.tkk7.com/stone2083/archive/2011/05/23/350875.html"><br /><br /></a>浠ヤ笅涓哄垎浜唴瀹癸細<a href="http://www.tkk7.com/stone2083/archive/2011/05/23/350875.html"><br /><br /></a><div><span style="font-family: Arial, songti, 瀹嬩綋, sumsun, sans-serif; font-size: 13px; line-height: 13px; "><p id="yui_3_2_0_3_1309782060553110" style="color: #454545; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; "><strong><span style="font-family: 瀹嬩綋; color: #1f497d; ">濂藉</span></strong><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛?/span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">1.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">涓涓」鐩佸皬闇姹傦紝闇瑕佺粦瀹氱殑</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛屽彧闇瑕佷竴浠?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">淇℃伅鍗沖彲銆備笉蹇呮瘡涓敤鎴瘋嚜琛岀鐞嗗悇鑷數鑴戠殑</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">銆傝揪鍒頒竴浜洪厤緗紝澶氫漢浣跨敤鐨勭洰鐨?/span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">2.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">緇戝畾鐨?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛屾敮鎸侀氶厤絎︺傛柟渚跨被浼兼椇閾哄煙鍚嶇殑闇姹傦紝鍙渶瑕侀厤緗竴涓甫閫氶厤絎︾殑鍩熷悕鍗沖彲</span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">3.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">瑕佸湪涓嶅悓欏圭洰錛屽皬闇姹傚垏鎹笉鍚岀殑</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鏃訛紝鍙渶瑕佽交杞諱竴鐐癸紝鏂逛究</span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">4.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">瑕佹兂浣跨敤浠g悊鏈嶅姟鍣紝鍙渶瑕佹湰鍦?/span><span style="color: #1f497d; ">DNS</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">璁劇疆涓涓嬪嵆鍙紝鏂逛究</span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">5.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鏈満</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">閰嶇疆浼樺厛</span></p><p style="color: #454545; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; "> </p><p style="color: #454545; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; "><strong><span style="font-family: 瀹嬩綋; color: #1f497d; ">濡備綍浣跨敤錛?/span></strong><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛堜互</span><span style="color: #1f497d; ">10.20.131.207</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鐜浠嬬粛錛?/span><span style="font-family: 瀹嬩綋; color: red; ">澶囨敞錛氬叕鍙稿唴閮ㄧ幆澧冿紝澶栭儴鏃犳硶璁塊棶錛屽鏋滈渶瑕侊紝璇瘋嚜琛屾惌寤?/span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">1.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鐧婚檰</span><span style="color: #1f497d; ">DNS</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍚庡彴綆$悊欏甸潰</span><span style="color: #1f497d; ">URL</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛?/span><span style="color: #1f497d; "><a rel="nofollow" target="_blank" style="text-decoration: underline; color: blue; outline-style: none; outline-width: initial; outline-color: initial; "><span style="color: #1f497d; text-decoration: none; ">http://10.20.131.207:8000/</span></a></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛岀偣鍑?/span><span style="color: #1f497d; ">Add</span></p><p style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; font-size: 10.5pt; font-family: sans-serif; "><font class="Apple-style-span" color="#1f497d"><img src="http://www.tkk7.com/images/blogjava_net/stone2083/python/1.jpg" border="0" alt="" width="331" height="218" /><br /></font></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">2.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">娣誨姞涓涓」鐩殑</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">淇℃伅錛岀偣鍑繪坊鍔?/span></p><p style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; font-size: 10.5pt; font-family: sans-serif; "><font class="Apple-style-span" color="#1f497d"><img src="http://www.tkk7.com/images/blogjava_net/stone2083/python/2.jpg" border="0" alt="" width="292" height="248" /><br /></font></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">3.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍦?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">淇℃伅欏甸潰錛岀偣鍑?/span><span style="color: #1f497d; ">assign</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛岀粦瀹氳嚜宸辯數鑴?/span><span style="color: #1f497d; ">IP</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍜屾煇涓?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鐨勫叧鑱?/span></p><p style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; font-size: 10.5pt; font-family: sans-serif; "><font class="Apple-style-span" color="#1f497d"><img src="http://www.tkk7.com/images/blogjava_net/stone2083/python/3.jpg" border="0" alt="" width="331" height="211" /><br /></font></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">4.<span>       </span></span><span style="color: #1f497d; ">IP List</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">欏甸潰涓婏紝鏄劇ず浜嗕笉鍚?/span><span style="color: #1f497d; ">IP</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍜?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍏寵仈鐨勪俊鎭?/span></p><p style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; font-size: 10.5pt; font-family: sans-serif; "><font class="Apple-style-span" color="#1f497d"><img src="http://www.tkk7.com/images/blogjava_net/stone2083/python/4.jpg" border="0" alt="" width="266" height="231" /><br /></font></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; text-indent: 21pt; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; ">5.<span>       </span></span><span style="font-family: 瀹嬩綋; color: #1f497d; ">灝嗘湰鏈虹數鑴戠殑</span><span style="color: #1f497d; ">DNS</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鏈嶅姟鍣ㄨ緗垚</span><span style="color: #1f497d; ">DNS</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">浠g悊鏈嶅姟鍣ㄥ嵆鍙紙</span><span style="color: #1f497d; ">10.20.131.207</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">錛?/span><span style="color: #1f497d; ">-- </span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍙渶瑕佷竴嬈℃搷浣滃嵆鍙紝浠ュ悗涓鐩磋兘鐢?/span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; font-size: 10.5pt; font-family: sans-serif; "><span style="color: #1f497d; "><img src="http://www.tkk7.com/images/blogjava_net/stone2083/python/5.jpg" border="0" alt="" width="484" height="421" /><img src="http://www.tkk7.com/images/blogjava_net/stone2083/python/6.png" border="0" alt="" width="447" height="155" /></span></p><p style="color: #454545; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; text-align: justify; font-size: 10.5pt; font-family: sans-serif; "><span style="font-family: 瀹嬩綋; color: #1f497d; ">宸﹀浘涓?/span><span style="color: #1f497d; ">windows</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">閰嶇疆錛屽彸鍥句負</span><span style="color: #1f497d; ">linux</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">閰嶇疆</span></p><p id="yui_3_2_0_3_1309782060553126" style="color: #454545; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; "> </p><p style="color: #454545; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: normal; "><span style="font-family: 瀹嬩綋; color: #1f497d; ">姝ゆ椂錛屼綘璁塊棶鍩熷悕錛屽鏋滃湪</span><span style="color: #1f497d; ">2011tp hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">涓紝鍒欑洿鎺ヨ繑鍥?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">涓殑</span><span style="color: #1f497d; ">IP;</span><span style="font-family: 瀹嬩綋; color: #1f497d; ">鍙嶄箣錛屽垯榪斿洖鐪熷疄</span><span style="color: #1f497d; ">IP銆?br /><br /><br />濡備綍鍚姩鏈嶅姟<br />1. 鍚姩DNS浠g悊鏈嶅姟鍣ㄦ湇鍔?br />1.1 cd dns/dns<br />1.2 vi settings.py 淇敼閰嶇疆淇℃伅<br />1.3 python -u main.py<br /><br />2. 鍚姩DNS BackOffice鏈嶅姟<br />2.1 cd dns/config<br />2.2 vi settings.py 淇敼閰嶇疆淇℃伅<br />2.3 python -u manage.py runserver<br /><br /><br /></span><span style="color: #1f497d; "><strong>杞歡涓嬭澆錛?a title="DNS Proxy Server" href="/Files/stone2083/python/dns.zip">DNS Proxy Server</a></strong></span><span style="color: #1f497d; "><br /><br />============================================================================================<br />涓轟簡婊¤凍“閭伓”鐨勪漢浠兘鏇存柟渚跨殑浣跨敤榪欎釜杞歡錛堣矊浼奸偑鎭剁殑浜虹壒鍒湅閲嶈繖涓蔣浠墮氶厤絎︾殑鍔熻兘錛屽叿浣撻偑鎭跺湪鍝噷錛屾垜涓嶅叿浣撴弿榪頒簡錛岀粰涓?a title="閾炬帴"><strong>閾炬帴</strong></a>錛夛紝鎴戠壒鎰忓啓浜嗕竴涓猻tandalone鐨勭増鏈細<br />1. 鍘婚櫎鏃犵敤鐨刡ackoffice鍔熻兘<br />2. 鍘婚櫎閫氳繃浜嬩歡鏈哄埗reload hosts鏂囦歡鐨勫姛鑳?br />3. 鍘婚櫎澶嶆潅鐨剆ettings閰嶇疆鏂囦歡錛屾敼鐢ㄧ畝鍗曠殑鍛戒護琛屾柟寮?br />4. 鐗規剰涓簑indows鐢ㄦ埛鍒朵綔浜嗕竴涓猠xe鏂囦歡錛屽彲浠ョ洿鎺ヤ嬌鐢?br /><br />linux鐢ㄦ埛浣跨敤鏂規錛?br />python standalone.py -s xxx.xxx.xxx.xxx (涓婄駭dns鍦板潃)<br />python standalone.py -s xxx.xxx.xxx.xxx -f /etc/hosts2 (鎸囧畾hosts鏂囦歡錛岄粯璁ゆ槸/etc/hosts)<br /><br />windows鐢ㄦ埛浣跨敤鏂規錛岃繘鍏ist錛坋xe鍙戝竷鐩綍錛?br />dns.exe -s xxx.xxx.xxx.xxx (涓婄駭dns鍦板潃)<br />dns.exe -s xxx.xxx.xxx.xxx -f d:/hosts 錛堟寚瀹歨osts鏂囦歡錛岄粯璁ゆ槸c:/windows/system32/drivers/etc/hosts錛?br /><br />瀵逛簬涓嶆斁蹇冧嬌鐢╡xe鐨勫鎴鋒潵璇達紝鍙互榪涘叆dns鐩綍錛岄氳繃py2exe宸ュ叿鑷鍙戝竷鎴恊xe杞歡錛屾柟娉曞涓?br />python setup.py py2exe<br /><br /><a title="standalone鐗堟湰涓嬭澆" href="/Files/stone2083/python/standalone.zip"><strong>standalone鐗堟湰涓嬭澆</strong></a><br /><br /></span></p></span></div><img src ="http://www.tkk7.com/stone2083/aggbug/353664.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stone2083/" target="_blank">stone2083</a> 2011-07-04 20:39 <a href="http://www.tkk7.com/stone2083/archive/2011/07/04/353664.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎵╁睍Python MySQLdb Cursorhttp://www.tkk7.com/stone2083/archive/2011/06/18/352552.htmlstone2083stone2083Fri, 17 Jun 2011 16:41:00 GMThttp://www.tkk7.com/stone2083/archive/2011/06/18/352552.htmlhttp://www.tkk7.com/stone2083/comments/352552.htmlhttp://www.tkk7.com/stone2083/archive/2011/06/18/352552.html#Feedback1http://www.tkk7.com/stone2083/comments/commentRss/352552.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/352552.html 鍏墮粯璁ょ殑Cursor Class鏄嬌鐢╰uple錛堝厓緇勶級浣滀負鏁版嵁瀛樺偍瀵硅薄鐨勶紝鎿嶄綔闈炲父涓嶄究
1 = cursor.fetchone()
2 print(p[0], p[1])
濡傛灉鏈夊崄鍑犱釜瀛楁錛屽厜鏄暟鏁頒綅鏁幫紝灝辨妸鎴戞暟鏅曚簡銆?br />
褰撶劧錛孧ySqldb Cursor Class鏈韓灝辨彁渚涗簡鎵╁睍錛屾垜浠彲浠ュ垏鎹㈡垚DictCurosor浣滀負榛樿鏁版嵁瀛樺偍瀵硅薄錛屽
MySQLdb.connect(host='127.0.0.1', user='sample', passwd='123456', db='sample', cursorclass=DictCursor, charset='utf8')
#
= cursor.fetchone()
print(p['id'], p['name'])
瀛楀吀鐨勬柟寮忎紭浜庡厓紲栥?br />
浣嗘槸錛?[]"榪欎釜絎﹀彿鍐欏啓姣旇緝楹葷儲錛屽茍涓旀垜緙栫爜椋庢牸甯︽湁寮虹儓鐨凧ava涔犳儻錛屼竴鐩村枩嬈㈢被浼?p.id","p.name"鐨勫啓娉曘?br />浜庢槸錛屾墿灞曚箣
1. 鎵╁睍Dict綾伙紝浣垮叾鏀寔"."鏂瑰紡錛?br />
 1 class Dict(dict):
 2     
 3     def __getattr__(self, key):
 4         return self[key]
 5     
 6     def __setattr__(self, key, value):
 7         self[key] = value
 8     
 9     def __delattr__(self, key):
10         del self[key]
2. 鎵╁睍Curosor錛屼嬌鍏跺彇寰楃殑鏁版嵁浣跨敤Dict綾伙細
 1 class Cursor(CursorStoreResultMixIn, BaseCursor):
 2 
 3     _fetch_type = 1
 4 
 5     def fetchone(self):
 6         return Dict(CursorStoreResultMixIn.fetchone(self))
 7 
 8     def fetchmany(self, size=None):
 9         return (Dict(r) for r in CursorStoreResultMixIn.fetchmany(self, size))
10 
11     def fetchall(self):
12         return (Dict(r) for r in CursorStoreResultMixIn.fetchall(self))

榪欎笅錛屽氨絎﹀悎鎴戠殑涔犳儻浜嗭細
1 MySQLdb.connect(host='127.0.0.1', user='sample', passwd='123456', db='sample', cursorclass=Cursor, charset='utf8')
2 #
3 = cursor.fetchone()
4 print(p.id, p.name)



stone2083 2011-06-18 00:41 鍙戣〃璇勮
]]>
Hosts緇戝畾鏂版濊礬涔婦NS浠g悊鏈嶅姟鍣ㄥ疄鐜扮瘒http://www.tkk7.com/stone2083/archive/2011/05/23/350875.htmlstone2083stone2083Mon, 23 May 2011 13:24:00 GMThttp://www.tkk7.com/stone2083/archive/2011/05/23/350875.htmlhttp://www.tkk7.com/stone2083/comments/350875.htmlhttp://www.tkk7.com/stone2083/archive/2011/05/23/350875.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/350875.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/350875.html闃呰鍏ㄦ枃

stone2083 2011-05-23 21:24 鍙戣〃璇勮
]]>
Hosts緇戝畾鏂版濊礬涔婦NS浠g悊綃?/title><link>http://www.tkk7.com/stone2083/archive/2011/05/23/350871.html</link><dc:creator>stone2083</dc:creator><author>stone2083</author><pubDate>Mon, 23 May 2011 11:42:00 GMT</pubDate><guid>http://www.tkk7.com/stone2083/archive/2011/05/23/350871.html</guid><wfw:comment>http://www.tkk7.com/stone2083/comments/350871.html</wfw:comment><comments>http://www.tkk7.com/stone2083/archive/2011/05/23/350871.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/stone2083/comments/commentRss/350871.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stone2083/services/trackbacks/350871.html</trackback:ping><description><![CDATA[<div><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 14px;"><p style="margin: 0px;"><span style="color: #1f497d;"><strong>鍓嶈█</strong></span></p><p style="margin: 0px;"><span style="color: #1f497d;">姝ゆ枃鎽樿嚜2011騫?鏈?3鏃ラ偖浠跺垎浜紝涓恒奌osts緇戝畾鏂版濊礬涔婬TTP浠g悊綃囥嬬畫闆?/span></p><p style="margin: 0px;"><br /><span style="color: #1f497d;"></span></p><p style="margin: 0px;"><span style="color: #1f497d;"><br /></span></p><p style="margin: 0px;"><span style="color: #1f497d;">鐢佃鏈夌畫闆?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鐢靛獎涔熸湁緇泦</span><span style="color: #1f497d;">,Hosts</span><span style="color: #1f497d;">緇戝畾鎬濊礬鍚屾牱鏈夌畫闆?/span><span style="color: #1f497d;">.</span></p><p style="margin: 0px;"> </p><p style="margin: 0px;"><span style="color: #1f497d;">鎴戜滑鍏堢敤涓鍙ヨ瘽鏉ュ洖欏句笅</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">涓婇泦涓叧浜?/span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">緇戝畾鐨勬濊礬</span><span style="color: #1f497d;">:</span></p><p style="margin: 0px;"><strong><span style="color: #1f497d;">鍘熺悊</span></strong><span style="color: #1f497d;">:</span><span style="color: #1f497d;">鍒╃敤</span><span style="color: #1f497d;">Http</span><span style="color: #1f497d;">浠g悊鐨勬柟寮?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">灝嗗垎鏁e湪鍚勪釜瀹㈡埛绔殑</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;"><wbr>緇戝畾</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">闆嗕腑緇戝畾鍦?/span><span style="color: #1f497d;">Http</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣ㄤ笂</span></p><p style="margin: 0px;"><strong><span style="color: #1f497d;">浼樼偣</span></strong><span style="color: #1f497d;">:</span><span style="color: #1f497d;">闆嗕腑綆$悊</span></p><p style="margin: 0px;"><strong><span style="color: #1f497d;">緙虹偣</span></strong><span style="color: #1f497d;">:</span><span style="color: #1f497d;">涓鍙?/span><span style="color: #1f497d;">Http</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鍙兘緇戝畾涓緇?/span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">淇℃伅</span></p><p style="margin: 0px;"><span style="color: #1f497d;">(</span><span style="color: #1f497d;">璇︾粏鍐呭</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">璇瘋涔嬪墠鐨勯偖浠?/span><span style="color: #1f497d;">)</span></p><p style="margin: 0px;"> </p><p style="margin: 0px;"><span style="color: #1f497d;">鍦ㄥ綋鏃舵弿榪版柟妗堥偖浠剁殑鏃跺?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">涔熸剰璇嗗埌浜嗘柟妗堝瓨鍦ㄧ殑涓嶈凍</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鎵浠ヤ竴鐩?wbr>鍦ㄦ濊冩敼榪涙柟妗?/span><span style="color: #1f497d;">(</span><span style="color: #1f497d;">璇﹁涔嬪墠閭歡涓渶鍚庝竴鑺?/span><span style="color: #1f497d;">—</span><span style="color: #1f497d;">鏀硅繘鏂規鎬濊礬</span><span style="color: #1f497d;">).</span></p><p style="margin: 0px;"><span style="color: #1f497d;">緇忚繃涓孌墊椂闂寸殑鎬濊?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鏀硅繘鏂規鏈変簡澶ф鐨勯洀褰?/span><span style="color: #1f497d;">: </span><strong><span style="color: #1f497d;">灝嗕箣鍓嶇殑</span><span style="color: #1f497d;">HTTP</span></strong><strong><span style="color: #1f497d;">浠g悊鏂規</span><span style="color: #1f497d;"> </span></strong><strong><span style="color: #1f497d;">鏇挎崲鎴?/span><span style="color: #1f497d;"> DNS</span></strong><strong><span style="color: #1f497d;">浠g悊鏂規</span></strong></p><p style="margin: 0px;"><strong> </strong></p><p style="margin: 0px;"><span style="color: #1f497d;">淇楄瘽璇村緱濂?/span><span style="color: #1f497d;">:</span><span style="color: #1f497d;">鏈夊浘鏈夌湡鐩?/span><span style="color: #1f497d;">.</span><span style="color: #1f497d;">鍏堣創涓婁竴寮犳灦鏋勫浘</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">涔嬪悗鍐嶇敤鏂囧瓧鎱㈡參瑙?wbr>閲?/span><span style="color: #1f497d;"> </span><span style="font-family: Wingdings; color: #1f497d;"></span></p><p style="margin: 0px;"><span style="color: #1f497d;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h7.png" height="856" width="885" /><br /></span></p><p style="margin: 0px;"> </p><p style="margin: 0px;"><span style="color: #1f497d;">鏋舵瀯涓牳蹇冪粍浠舵槸</span><span style="color: #1f497d;">:<strong>DNS BackOffice</strong></span><strong><span style="color: #1f497d;">鏈嶅姟鍣?/span><span style="color: #1f497d;"> </span></strong><span style="color: #1f497d;">鍜?/span><strong><span style="color: #1f497d;">DNS</span></strong><strong><span style="color: #1f497d;">浠g悊鏈嶅姟鍣?/span></strong></p><p style="margin: 0px;"><span style="color: #1f497d;">DNS BackOffice</span><span style="color: #1f497d;">鏈嶅姟鍣ㄧ殑浣滅敤鏈?/span><span style="color: #1f497d;">:</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">1.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">寮鍙?/span><span style="color: #1f497d;">/</span><span style="color: #1f497d;">嫻嬭瘯綆$悊鍛橀氳繃</span><span style="color: #1f497d;">BackOffice</span><span style="color: #1f497d;">鏈嶅姟緇存姢鍚勮嚜欏圭洰鐨勭粦<wbr>瀹氫俊鎭?/span><span style="color: #1f497d;">,BackOffice</span><span style="color: #1f497d;">鏈嶅姟灝嗕箣鎸佷箙鍖?/span><span style="color: #1f497d;">         <wbr>       (</span><span style="color: #1f497d;">鍥句腑</span><span style="color: #1f497d;"> </span><span style="color: #1f497d;">钃濊壊铏氱嚎</span><span style="color: #1f497d;">)</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">2.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">寮鍙?/span><span style="color: #1f497d;">/</span><span style="color: #1f497d;">嫻嬭瘯浜哄憳閫氳繃</span><span style="color: #1f497d;">BackOffice</span><span style="color: #1f497d;">鏈嶅姟</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鍛婄煡闇瑕佸摢涓」鐩?wbr>鐨勭粦瀹氫俊鎭?/span><span style="color: #1f497d;">,BackOffice</span><span style="color: #1f497d;">鏈嶅姟灝嗕箣鎸佷箙鍖?/span><span style="color: #1f497d;">       <wbr>    (</span><span style="color: #1f497d;">鍥句腑</span><span style="color: #1f497d;"> </span><span style="color: #1f497d;">榛戣壊铏氱嚎</span><span style="color: #1f497d;">)</span></p><p style="margin: 0px;"> </p><p style="margin: 0px;"><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣ㄧ殑浣滅敤鏈?/span><span style="color: #1f497d;">:</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">1.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">鎷︽埅</span><span style="color: #1f497d;">Domain Name</span><span style="color: #1f497d;">鐨勮В鏋?/span><span style="color: #1f497d;">.</span><span style="color: #1f497d;">閫氳繃鏉ユ簮</span><span style="color: #1f497d;">IP</span><span style="color: #1f497d;">鍒ゆ柇闇瑕佺粦瀹氱殑</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">淇℃伅</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">閫?wbr>榪?/span><span style="color: #1f497d;">File/DB</span><span style="color: #1f497d;">寰楀埌瀵瑰簲鐨?/span><span style="color: #1f497d;">IP,</span><span style="color: #1f497d;">閫氳繃</span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">鍗忚榪斿洖</span><span style="color: #1f497d;">  (</span><span style="color: #1f497d;">鍥句腑</span><span style="color: #1f497d;"> </span><span style="color: #1f497d;">綰㈣壊瀹炵嚎</span><span style="color: #1f497d;"> </span><span style="color: #1f497d;">鍜?/span><span style="color: #1f497d;"> </span><span style="color: #1f497d;">榛戣壊瀹炵嚎</span><span style="color: #1f497d;">)</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">2.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">濡傛灉涓嶅湪緇戝畾涔嬪垪</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鍒欒姹備笂綰?/span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">鏈嶅姟鍣?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">榪斿洖鍏?/span><span style="color: #1f497d;">Respon<wbr>se.</span></p><p style="margin: 0px;"> </p><p style="margin: 0px;"><strong><span style="color: #1f497d;">姝ゆ柟妗堢殑浼樺娍</span></strong><span style="color: #1f497d;">:</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">1.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">鏈湴</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">緇戝畾浼樺厛</span><span style="color: #1f497d;">.</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">鍙鏈湴</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">鏈夌粦瀹?/span><span style="color: #1f497d;">IP,</span><span style="color: #1f497d;">鍒欎笉浼氳姹?/span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣?/span><span style="color: #1f497d;">.</span><span style="color: #1f497d;">鍙?wbr>璇鋒眰鏈湴</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">鏂囦歡</span><span style="color: #1f497d;">.</span><span style="color: #1f497d;">鑳芥弧瓚充釜鎬у寲闇姹?/span><span style="color: #1f497d;">.</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">2.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣ㄦ敮鎸佸縐嶇粦瀹氭柟寮?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">濡傞氶厤絎?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">姝e垯絳?/span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">瀵逛簬鐩墠鏃洪摵</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">瀹屽叏鍙互浣跨敤閫氶厤絎?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">濡?/span><span style="color: #1f497d;"> *.<a target="_blank" style="color: #0000cc;">cn.alibaba.com</a>,</span><span style="color: #1f497d;">綆鍖栭厤緗伐浣滈噺</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">3.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">鎿嶄綔綆鍗?/span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">鍙灝?/span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">鏈嶅姟鍣ㄨ緗垚</span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣?/span><span style="color: #1f497d;">IP</span><span style="color: #1f497d;">鍗沖彲</span><span style="color: #1f497d;"> (</span><span style="color: #1f497d;">闄勫綍涓湁璇︾粏璇存槑</span><span style="color: #1f497d;">)</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">4.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">鏈夋晥鍒╃敤鐜版湁鎴愭灉</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">鐩墠嫻嬭瘯鍚屽宸茬粡闆嗕腑緇存姢浜?/span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">緇戝畾淇℃伅</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鍙閮ㄧ講</span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;"><wbr>浠g悊鏈嶅姟鍣?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">騫跺仛綆鍗曠殑闆嗘垚鍗沖彲</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">5.<span style="font: 7pt 'Times New Roman';">       </span></span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">浠g悊鏈嶅姟鍣ㄤ唬鐮佽交閲忓皬宸?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鏄撲簬淇敼鎵╁睍</span></p><p style="margin-left: 18pt;"><span style="color: #1f497d;">鐩墠涓鍏卞彧鏈?/span><span style="color: #1f497d;">212</span><span style="color: #1f497d;">琛屼唬鐮?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">鍏朵腑</span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">鍗忚閮ㄥ垎</span><span style="color: #1f497d;">130</span><span style="color: #1f497d;">琛?/span><span style="color: #1f497d;">,DNS</span><span style="color: #1f497d;"><wbr>浠g悊閮ㄥ垎</span><span style="color: #1f497d;">82</span><span style="color: #1f497d;">琛?/span><span style="color: #1f497d;">.</span></p><p style="margin-left: 18pt;"> </p><p style="margin: 0px;"> </p><p style="margin: 0px;"><strong><span style="color: #1f497d;">闄勫綍</span></strong></p><p style="margin-left: 36pt;"><span style="color: #1f497d;">I.<span style="font: 7pt 'Times New Roman';">                    </span></span><span style="color: #1f497d;">瀹㈡埛绔浣曡緗?/span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">鏈嶅姟鍣?/span></p><p style="margin-left: 36pt;"><span style="color: #1f497d;">Windows</span><span style="color: #1f497d;">鐢ㄦ埛</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">瑙佸浘</span><span style="color: #1f497d;">:</span></p><p style="margin-left: 36pt;"><span style="color: #1f497d;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h8.jpg" height="421" width="484" /><br /></span></p><p style="margin-left: 36pt;"><span style="color: #1f497d;">Linux</span><span style="color: #1f497d;">鐢ㄦ埛</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">瑙佸浘</span><span style="color: #1f497d;">:</span></p><p style="margin-left: 36pt;"><span style="color: #1f497d;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h9.png" height="155" width="447" /><br /></span></p><p style="margin-left: 36pt;"><span style="color: #1f497d;">淇敼</span><span style="color: #1f497d;"> /etc/resolv.conf</span><span style="color: #1f497d;">鏂囦歡鍗沖彲</span></p></span></span></div><img src ="http://www.tkk7.com/stone2083/aggbug/350871.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stone2083/" target="_blank">stone2083</a> 2011-05-23 19:42 <a href="http://www.tkk7.com/stone2083/archive/2011/05/23/350871.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Hosts緇戝畾鏂版濊礬涔婬TTP浠g悊綃?/title><link>http://www.tkk7.com/stone2083/archive/2011/05/23/350868.html</link><dc:creator>stone2083</dc:creator><author>stone2083</author><pubDate>Mon, 23 May 2011 11:41:00 GMT</pubDate><guid>http://www.tkk7.com/stone2083/archive/2011/05/23/350868.html</guid><wfw:comment>http://www.tkk7.com/stone2083/comments/350868.html</wfw:comment><comments>http://www.tkk7.com/stone2083/archive/2011/05/23/350868.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/stone2083/comments/commentRss/350868.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stone2083/services/trackbacks/350868.html</trackback:ping><description><![CDATA[<div><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 14px;"><p style="margin: 0px;"><strong><span style="font-size: 16pt;">鍓嶈█</span></strong></p><p style="margin: 0px;"><strong><span style="font-size: 16pt;"><div><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 14px;">姝ゆ枃鎽樿嚜2011騫?鏈?2鏃ラ偖浠跺垎浜?/span></span></div></span></strong></p><br /><p style="margin: 0px;"><strong><span style="font-size: 16pt;">鐜扮姸</span></strong></p><p style="margin: 0px;">騫蟲椂寮鍙?嫻嬭瘯,鍔熻兘棰勬紨闃舵,涓轟簡鑳藉姝e父璁塊棶搴旂敤,闇瑕佸仛H<wbr>osts緇戝畾.闅忕潃搴旂敤鏁伴噺鐨勪笉鏂澶?緇戝畾閲忎篃鏄ュ墽涓婂崌.渚?wbr>濡傛渶榪戝伐浣滃鉤鍙頒笁鏈熼」鐩?闇瑕佺粦瀹氱殑鐜澶氳揪44涓?涓鏃︽湁鍙樺姩<wbr>,闇瑕侀氱煡鎵鏈変漢鍛樺仛鏈湴Hosts鐨勮皟鏁?緇存姢鎴愭湰閭f槸鐩稿綋鍦?wbr>澶?</p><p style="margin: 0px;"> </p><p style="margin: 0px;">鐢ㄤ竴寮犲浘,鏉ユ弿榪頒笅鐩墠鎴戜滑鐨勬柟妗?</p><p style="margin: 0px;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h1.jpg" height="382" width="487" /><br /></p><p style="margin: 0px;"> </p><p style="margin: 0px;">濡傛灉绔欏湪闈㈠悜瀵硅薄緙栫▼鐨勮搴?鏉ユ濊冭繖寮犲浘,鎴戜滑浼氬彂鐜?</p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>鍒╃敤瀹㈡埛绔湰鍦癏osts緇戝畾鏉ュ疄鐜?騫朵笖瀹㈡埛绔暟閲忎笉鍙帶—鍒?wbr>鐢ㄥ鎴風瑙e喅闇姹?浣嗗鎴風緇存姢涓嶅湪鍙帶鑼冨洿鍐?/p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>Hosts緇戝畾鏄潪甯鎬笉紼沖畾鐨?#8212;闇姹傛槗鍙?/p><p style="margin-left: 18pt;"> </p><p style="margin: 0px;">榪欐牱鐨勮璁?榪濆弽浜?#8221;灝佽鍙樺寲”鐨勮璁″師鍒?鏁呬竴鏃︽湁鍙樺姩,緇存姢<wbr>鎴愭湰闈炲父澶?</p><p style="margin: 0px;"> </p><p style="margin: 0px;"><strong><span style="font-size: 16pt;">鏂版柟妗堟濊礬</span></strong></p><p style="margin: 0px;">鎸夌収”灝佽鍙樺寲”鐨勮璁″師鍒?鎴戜滑灝卞簲璇ユ妸”鍩熷悕緇戝畾”榪欎釜鏄撳彉<wbr>闇姹?榪涜緇熶竴綆$悊.</p><p style="margin: 0px;">鐪嬩笂鍥?鎴戜滑浼氬彂鐜?DNS鐨勮亴璐e氨鏄仛鍩熷悕瑙f瀽鐨?騫朵笖DNS<wbr>綆$悊姣旇緝鍙帶.</p><p style="margin: 0px;">浜庢槸絎竴鍙嶅簲,鎴戜滑鍙互浣跨敤鍐呴儴鍩熷悕瑙f瀽鏈嶅姟鍣ㄦ潵緇戝畾榪欎簺鍩熷悕.</p><p style="margin: 0px;">浣嗘槸闂鍙堟潵浜?DNS鏉ュ仛嫻嬭瘯鐜鍩熷悕瑙f瀽,澶噸閲忕駭浜?鍚屼竴<wbr>涓煙鍚?瀵瑰簲嫻嬭瘯鏈嶅姟鍣↖P鏈夊涓?緇戝畾鍝竴涓ソ鍛?騫朵笖鍩熷悕瀵?wbr>搴擨P涓嶆柇鍙樺寲,IT DNS璐熻矗浜轟笉琚垜浠瘡姝誨晩? <span style="font-family: Wingdings;"></span></p><p style="margin: 0px;"> </p><p style="margin: 0px;">鏃㈢劧DNS涓婂仛鏂囩珷涓嶅彲琛?鍙堥渶瑕佺粺涓綆$悊鐨勫湴鏂?閭d箞鎴戜滑鍙兘<wbr>鍐嶆娊璞″嚭涓涓柊鐨勬蹇墊潵.</p><p style="margin: 0px;">鍚屾牱,鎴戜滑鍒╃敤涓寮犲浘,鏉ユ弿榪頒笅鏁翠綋鏋舵瀯.</p><p style="margin: 0px;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h2.jpg" /><br /></p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">涓庝笂鍥劇浉瀵?姝ゅ浘澶氫簡涓涓?#8221;浠g悊鏈嶅姟鍣?#8221;鐨勬蹇?鍗矵osts緇?wbr>瀹氬姩浣滃湪姝ゆ蹇典笂瀹屾垚.</p><p style="margin: 0px;">嫻佺▼濡備笅:</p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>瀹㈡埛绔祻瑙堝櫒璁劇疆浠g悊鏈嶅姟鍣?灝嗘墍鏈夎姹傚彂閫佸埌浠g悊鏈嶅姟鍣ㄤ笂</p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>浠g悊鏈嶅姟鍣ㄦ鏌ユ湰鍦癏osts緇戝畾,濡傜粦瀹氬垯鐩存帴瑙f瀽,鍙嶄箣榪涘叆<wbr>嫻佺▼3</p><p style="margin-left: 18pt;"><span>3.<span style="font: 7pt 'Times New Roman';">       </span></span>浠g悊鏈嶅姟鍣ㄩ氳繃鍐呴儴鍩熷悕鏈嶅姟鍣ㄨВ鏋愬煙鍚?/p><p style="margin-left: 18pt;"><span>4.<span style="font: 7pt 'Times New Roman';">       </span></span>浠g悊鏈嶅姟鍣ㄥ彂閫佽姹傚埌嫻嬭瘯鏈嶅姟鍣ㄤ笂,騫朵笖灝嗗搷搴斿唴瀹硅繑鍥炵粰瀹㈡埛绔?/p><p style="margin: 0px;"> </p><p style="margin: 0px;">鍏蜂綋灝濊瘯鎬у疄鏂芥柟妗堝涓?鍦╔X欏圭洰榪囩▼涓湁鎴愬姛妗堜緥)</p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>鍒╃敤squid鎼緩浠g悊鏈嶅姟鍣?nbsp;(浠g悊鍦板潃: <a target="_blank" style="color: #0000cc;">10.20.131.207:3128</a>)</p><p style="margin-left: 18pt;">澶囨敞:</p><p style="margin-left: 18pt;">Squid閰嶇疆浠嬬粛瑙侀檮褰旾</p><p style="margin-left: 18pt;"> </p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>嫻忚鍣ㄩ厤緗唬鐞?/p><p style="margin-left: 18pt;">鍏ㄥ眬浠g悊: 浠g悊鏈嶅姟鍣ㄤ笂,鐩存帴濉啓 10.20.131.207 3128</p><p style="margin-left: 18pt;">灞閮ㄤ唬鐞? 閫氳繃pac瀹炵幇,閫夋嫨”浣跨敤鑷姩閰嶇疆鑴氭湰”,鑴氭湰鏍煎紡鍐呭濡備笅:</p><p style="margin-left: 18pt;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h3.jpg" /><br /></p><p style="margin-left: 18pt;"><br /></p><p style="margin-left: 18pt;">澶囨敞:</p><p style="margin-left: 18pt;">Pac鑴氭湰璇︾粏浠嬬粛瑙侀檮褰旾I</p><p style="margin-left: 18pt;">涓轟簡闃叉灝嗛厤緗伐浣滃甫緇橮D,閿鍞瓑,鎴戜滑鍙互浣跨敤閰嶇疆濂界殑緇胯壊<wbr>嫻忚鍣ㄦ彁渚涚洿鎺ヤ嬌鐢?</p><p style="margin-left: 18pt;">鎺ㄨ崘涓嬈?GreenBrowser:<a > http://www.morequick.com/indexen.htm</a></p><p style="margin-left: 18pt;">  <br /></p><p style="margin-left: 18pt;">IE鍏蜂綋閰嶇疆,瑙佷笅鍥?</p><p style="margin: 0px 0px 0px 18pt;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h4.jpg" height="410" width="425" /><br /></p><p style="margin: 0px 0px 0px 18pt;"><br /></p><p style="margin: 0px;">Firefox鍚屾牱鏀寔浠g悊鍜宲ac鑴氭湰</p><p style="margin: 0px;">Chrome闇瑕佸畨瑁卲roxy switchy鎻掍歡鏉ユ敮鎸?</p><p style="margin: 0px;"> </p><p style="margin: 0px;"><strong><span style="font-size: 16pt;">鏀硅繘鏂規鎬濊礬</span></strong></p><p style="margin: 0px;">涓婅堪鐨勬柟妗堜腑,鏈変袱涓瘮杈冨ぇ鐨勭己闄?/p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>浠g悊鏈嶅姟鍣ㄦ病鏈夊瀹炰緥姒傚康</p><p style="margin-left: 18pt;">浠g悊鏈嶅姟鍣ㄩ氳繃hosts緇戝畾.hosts鏄叏灞鎬х殑,鎰忓懗鐫涓<wbr>鍙頒唬鐞嗘湇鍔″櫒鍙兘鏈嶅姟涓緇勯渶姹?鑰屼簨瀹炰笂,鎴戜滑涓嶅悓鐨勯」鐩渶瑕佺殑<wbr>緇戝畾閮芥槸涓嶄竴鏍風殑.</p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>鐗規у寲闇姹備笉鑳芥弧瓚?/p><p style="margin-left: 18pt;">緇戝畾鍏ㄥ湪浠g悊鏈嶅姟鍣ㄤ笂鍋氫簡,瀹㈡埛绔湰鍦頒釜鎬у寲闇姹傛棤娉曟敮鎸?/p><p style="margin: 0px;"> </p><p style="margin: 0px;">鎵浠?鎴戠悊鎯充腑鏁翠綋鏋舵瀯鏄繖鏍風殑,瑙佸浘:</p><p style="margin: 0px;"><img alt="" src="http://www.tkk7.com/images/blogjava_net/stone2083/python/h5.jpg" height="317" width="554" /><br /></p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>浼樺厛鏌ョ湅鏈湴hosts鏂囦歡</p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>浠g悊鏈嶅姟鍣ㄦ敮鎸佸瀹炰緥閮ㄧ講,涓嶅悓瀹炰緥鏈変笉鍚岀殑hosts緇戝畾閰嶇疆<wbr>.</p><p style="margin: 0px;"> </p><p style="margin: 0px;">鐩墠鍏蜂綋瀹炵幇鏂規,榪樺湪鏋勬濅腑.嬈㈣繋澶у鎻愪緵瀹炵幇鏂規鎬濊礬.</p><p style="margin: 0px;"> </p><p style="margin: 0px;"><strong><span style="font-size: 16pt;">闄勫綍</span></strong><strong><span style="font-size: 16pt;">I</span></strong></p><p style="margin: 0px;"><strong>Squid</strong><strong>鏉冨▉鎸囧崡(</strong><strong>涓枃鐗?:</strong> <a target="_blank" style="color: #0000cc;">http://home.arcor.de/pangj/<wbr>squid/chap01.html</a></p><p style="margin: 0px;"><strong><span style="font-size: 16pt;">闄勫綍</span></strong><strong><span style="font-size: 16pt;">II</span></strong></p><p style="margin: 0px;">Pac浠嬬粛:               <a target="_blank" style="color: #0000cc;">http://en.wikipedia.org/wiki/<wbr>Proxy_auto-config</a></p><p style="margin: 0px;">Pac鍑芥暟浠嬬粛:        <a target="_blank" style="color: #0000cc;">http://findproxyforurl.com/<wbr>pac_functions_explained.html</a></p><p style="margin: 0px;"> </p></span></span></div><img src ="http://www.tkk7.com/stone2083/aggbug/350868.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stone2083/" target="_blank">stone2083</a> 2011-05-23 19:41 <a href="http://www.tkk7.com/stone2083/archive/2011/05/23/350868.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>django妗嗘灦鐨勫嚑涓墿灞曠偣http://www.tkk7.com/stone2083/archive/2011/04/20/348662.htmlstone2083stone2083Wed, 20 Apr 2011 14:54:00 GMThttp://www.tkk7.com/stone2083/archive/2011/04/20/348662.htmlhttp://www.tkk7.com/stone2083/comments/348662.htmlhttp://www.tkk7.com/stone2083/archive/2011/04/20/348662.html#Feedback0http://www.tkk7.com/stone2083/comments/commentRss/348662.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/348662.html 浣滀負涓涓竴鐩存潵浣跨敤java鐨勪漢鏉ヨ錛屽垵嬈′嬌鐢╠jango錛岀湡姝d綋浼氬埌浜嗙畝鍗曠編瀛︺傦紙涓鍏?3涓姛鑳斤紝涓嶅埌500琛屼唬鐮侊級
姝ゆ枃錛屼富瑕佹葷粨涓媎jango妗嗘灦鐨勪竴浜涙墿灞曠偣:
MIDDLEWARE_CLASSES
鍦╮equest璇鋒眰涔嬪墠錛屾垨鑰卹esponse璇鋒眰涔嬪悗錛屽仛鎷︽埅錛屽厑璁歌嚜瀹氫箟閫昏緫銆傛湁浜涚被浼糐2EE Servlet涓殑Filter姒傚康銆?br /> TEMPLATE_CONTEXT_PROCESSORS
榪涘叆妯℃澘娓叉煋涔嬪墠錛屽厑璁告斁鍏ヤ竴緇勭敤浜庢ā鏉挎覆鏌撶殑Key-Value灞炴с?br /> TEMPLATE FILTER
妯℃澘涓殑綆¢亾璇硶錛岄氳繃鑷畾涔夎涓猴紝娣誨姞鐢ㄤ簬鏄劇ず鐨勪竴浜涢昏緫銆?br /> TEMPLATE TAG
妯℃澘tag錛屾坊鍔犱竴緇勮涓恒傛湁浜涚被浼糣elocity涓殑ToolSet鍔熻兘銆?br /> 妯℃澘tag+鎸囧畾妯℃澘錛屽厖褰撻〉闈㈢粍浠訛紙widgets錛夊姛鑳?br />
middleware婕旂ず
 1 from django.db import connection
 2 from django.http import HttpResponseRedirect
 3 
 4 #鎷︽埅response璇鋒眰涔嬪悗錛屾墦鍗拌姹備腑鐨勬墍鏈塻ql
 5 class SqlLogMiddleware(object):
 6     def process_response(self, req, res):
 7         for sql in connection.queries:
 8             print sql
 9         return res
10 
11 #鎷︽埅request璇鋒眰涔嬪墠錛屽仛鏉冮檺鏍¢獙
12 class Auth(object):
13     def process_request(self, req):
14         if req.path == '/admin/':
15             return
16         if not req.user.is_authenticated():
17             return HttpResponseRedirect('/admin/')
18 
1 MIDDLEWARE_CLASSES = (
2     'django.middleware.common.CommonMiddleware',
3     'django.contrib.sessions.middleware.SessionMiddleware',
4     'django.contrib.auth.middleware.AuthenticationMiddleware',
5     'finance.middleware.SqlLogMiddleware',
6     'finance.middleware.Auth',
7 )


template context processor婕旂ず
1 def version(request):
2     return {'name':'Stone.J',
3             'version':'1.0-beata',
4             'date':'2011-03-20'}
1 TEMPLATE_CONTEXT_PROCESSORS = (
2     'django.core.context_processors.request',
3     'django.core.context_processors.auth',
4     'django.core.context_processors.debug',
5     'django.core.context_processors.i18n',
6     'django.core.context_processors.media',
7     'finance.example.context_processors.version',
8 )

template filter婕旂ず
 1 def row(value):
 2     if not value:
 3         return 'row1'
 4     if value % 2 == 1:
 5         return 'row1'
 6     else:
 7         return 'row2'
 8     
 9 def math_mul(value, num):
10     return value * num
11 
12 def math_add(value, num):
13     return value + num
14 
15 register = template.Library()    
16 register.filter('row', row)
17 register.filter('math_add', math_add)
18 register.filter('math_mul', math_mul)
1 {% load my_filter %}
2 {% for c in page.object_list %}
3 <tr class="{{ forloop.counter|row }}">
4 <td>{{ c.amount | math_add:c.amount2}}</td>
5 <td>{{ c.amount | math_mul:12}}</td>
6 </tr>
7 {% endfor %}
閫氳繃綰﹀畾鐨勬柟寮忥紝鍦ㄤ換鎰忎竴涓猘pp涓嬶紝寤虹珛涓涓猼emplatetags鐩綍錛屼細鑷姩瀵繪壘鍒般傦紙涓嶈繃娌℃湁鍛藉悕絀洪棿錛屾槸涓涓瘮杈冪尌鐞愮殑浜嬫儏錛屽鏄撻犳垚涓嶅悓app涓嬬殑鍐茬獊錛?br />
template tag婕旂ず
 1 register = template.Library()
 2 
 3 class AccountNode(template.Node):
 4     def __init__(self, name):
 5         self.name = name
 6         
 7     def render(self, context):
 8         context[self.name] = Account.objects.get()
 9         return ''
10     
11 def get_account(parser, token):
12     try:
13         tag_name, name = token.split_contents()
14     except ValueError:        
15         raise template.TemplateSyntaxError, "%s tag requires argument" % tag_name
16     return AccountNode(name)
17 
18 register.tag('get_account', get_account)

1 {% load my_tag %}
2 {% get_account account %}<!-- 閫氳繃tag鍙栧埌鍐呭璧嬪肩粰account鍙橀噺 -->
3 {{ account.amount }}

template tag + template file婕旂ず
1 from django import template
2 register = template.Library()
3 
4 def version(context):
5     return {'name':'Stone.J',
6             'version':'1.0-beata',
7             'date':'2011-03-20'}
8 
9 register.inclusion_tag('example/version.html', takes_context=True)(version)
1 <!-- 榪欎喚鍐呭鍙互琚綋鎴恮idget澶嶇敤 -->
2 <table>
3     <tr>
4         <td>{{ name }}</td>
5         <td>{{ version }}</td>
6         <td>{{ data }}</td>
7     </tr>
8 </table>
9 
tag瀵繪壘妯″紡絳夊悓浜巉ilter銆?br />

stone2083 2011-04-20 22:54 鍙戣〃璇勮
]]>
鍛戒護琛屼笅緲昏瘧宸ュ叿http://www.tkk7.com/stone2083/archive/2011/04/17/348449.htmlstone2083stone2083Sun, 17 Apr 2011 11:49:00 GMThttp://www.tkk7.com/stone2083/archive/2011/04/17/348449.htmlhttp://www.tkk7.com/stone2083/comments/348449.htmlhttp://www.tkk7.com/stone2083/archive/2011/04/17/348449.html#Feedback3http://www.tkk7.com/stone2083/comments/commentRss/348449.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/348449.html 錛堝埄鐢ㄤ簡google 緲昏瘧 json api:http://translate.google.cn/translate_a/t?client=t&text=%s&hl=zh-CN&sl=%s&tl=%s錛?br />
鐗規э細
1. 鑷姩璇嗗埆涓炕鑻?鑻辯炕涓?br /> 2. 緲昏瘧

娑夊強鎶鏈細
1. python
2. urllib
3. json
4. re

鎴浘錛?br />

瀵瑰簲浠g爜錛?br />
 1 '''
 2 Created on 2010-11-28
 3 
 4 @author: stone
 5 '''
 6 import json
 7 import re
 8 import sys
 9 import urllib2
10 import types
11 
12 res = 'http://translate.google.cn/translate_a/t?client=t&text=%s&hl=zh-CN&sl=%s&tl=%s'
13 agent = 'Mozilla / 5.0 (X11; U; Linux i686; en - US) AppleWebKit / 534.7 (KHTML, like Gecko) Chrome / 7.0.517.44 Safari / 534.7'
14 
15 def get_data(text, sl='en', tl='zh-CN'):
16     req = urllib2.Request(res % (urllib2.quote(text), sl, tl))
17     req.add_header('user-agent', agent)
18     content = urllib2.urlopen(req).read()
19     return json.loads(to_standard_json(content))
20 
21 def show(data):
22     #step1
23     print u'緲昏瘧錛歕n  %s' % (data[4][0][0])
24     #step2
25     if types.ListType == type(data[1]):
26         print u'\n瀛楀吀錛?/span>'
27         for word in data[1]:
28             print word[0]
29             if len(word) > 1:
30                 for i, w in enumerate(word[1]):
31                     print '  %s.%s' % (i + 1, w) 
32 
33 def to_standard_json(json):
34     p = re.compile(r',([,\]])')
35     while(p.search(json)):
36         json = p.sub(lambda m:',null%s' % (m.group(1)), json)
37     return json
38 
39 def contains_cn(text):
40     for c in text:
41         if ord(c) > 127:
42             return True
43     return False
44 
45 if __name__ == '__main__':
46     if not len(sys.argv) == 2 or not sys.argv[1].strip():
47         print 'Useage:translate.py word'
48         sys.exit()
49     word = sys.argv[1].strip()
50     if contains_cn(word):
51         show(get_data(word, 'zh-CN''en'))
52     else:
53         show(get_data(word, 'en''zh-CN'))




stone2083 2011-04-17 19:49 鍙戣〃璇勮
]]>
Linux涓嬪熀浜庡懡浠よ鐨勯煶涔愭挱鏀懼櫒http://www.tkk7.com/stone2083/archive/2011/04/17/348447.htmlstone2083stone2083Sun, 17 Apr 2011 11:32:00 GMThttp://www.tkk7.com/stone2083/archive/2011/04/17/348447.htmlhttp://www.tkk7.com/stone2083/comments/348447.htmlhttp://www.tkk7.com/stone2083/archive/2011/04/17/348447.html#Feedback4http://www.tkk7.com/stone2083/comments/commentRss/348447.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/348447.html 鍒╃敤鏈榪戦」鐩氬鍙戝竷鐨勭┖闂叉椂闂翠腑錛屽啓浜嗕竴涓懡浠よ涓嬬殑闊充箰鎾斁鍣紝浠ユ弧瓚蟲垜鍦╨inux鍛戒護涓嬬殑闇姹傘?br />
鎾斁鍣ㄥ埄鐢ㄦ妧鏈細
Python+GST錛?a >http://gstreamer.freedesktop.org/modules/gst-python.html錛?Console瑙f瀽

鎾斁鍣ㄨ嚜鎸佹搷浣滐細
1. 鎾斁
2. 涓嬩竴棣?br /> 3. 涓婁竴棣?br /> 4. 鏆傚仠
5. 鏌ョ湅鎾斁鍒楄〃淇℃伅
6. 鏌ョ湅褰撳墠鎾斁淇℃伅
7. 鍋滄錛堥鍑猴級

鐪嬩竴寮犳埅鍥撅細


閫氳繃鍒嗘瀽meliae dump鍑烘潵鐨勫唴瀛樹俊鎭紝宸笉鍋氬崰鐢?.5M鍐呭瓨錛岀畻鐨勪笂姣旇緝灝忓閥浜嗐?br />
瀵瑰簲浠g爜錛氾紙闇瑕佸畨瑁卲y-gst錛寀buntu涓嬶細sudo apt-get install python-gst0.10錛?br />
  1 #!/usr/bin/env python
  2 
  3 import gst
  4 import gobject
  5 import sys
  6 #to avoid eclipse'warning
  7 eval('gobject.threads_init()'
  8 from threading import Thread
  9 
 10 class AudioPlayer:
 11     
 12     EVENT_PLAY_NEW = 1
 13     
 14     def __init__(self, advisor):
 15         self.main = gobject.MainLoop()
 16         self.player = gst.element_factory_make('playbin''player')
 17         self.index = -1
 18         self.list = None
 19         self.advisor = advisor
 20         
 21         bus = self.player.get_bus()
 22         bus.add_signal_watch()
 23         bus.connect('message', self.on_message)
 24         
 25         Thread(target=self.main.run).start()
 26        
 27     def add_list(self , list=[]):
 28         if list is None:
 29             list = []
 30         self.list = [(i, l.strip(), l[l.rfind('/'+ 1:]) for (i, l) in enumerate(list)]
 31         
 32     def play(self, index=None):
 33         #play specified tracks
 34         if 0 <= index < len(self.list):
 35             self.index = index
 36             self.player.set_state(gst.STATE_NULL)
 37             self.player.set_property('uri', self.list[index][1])
 38             self.player.set_state(gst.STATE_PLAYING)
 39             if self.advisor:
 40                 self.advisor.on_message(AudioPlayer.EVENT_PLAY_NEW, (self.index, self.get_title()))
 41         #resume playing
 42         if index is None:
 43             if self.index > -1:
 44                 self.player.set_state(gst.STATE_PLAYING)
 45     
 46     def pause(self):
 47         self.player.set_state(gst.STATE_PAUSED)
 48         
 49     def stop(self):
 50         self.player.set_state(gst.STATE_NULL)
 51         self.main.quit()
 52     
 53     def get_title(self):
 54         if self.index == -1 or len(self.list) == 0:
 55             return None
 56         return self.list[self.index][2
 57     
 58     def get_previous(self):
 59         if self.index == -1 or len(self.list) == 0:
 60             return - 1
 61         if self.index == 0:
 62             return 0
 63         return self.index - 1
 64     
 65     def get_next(self):
 66         if  len(self.list) == 0:
 67             return - 1
 68         if self.index + 1 == len(self.list):
 69             return 0
 70         return self.index + 1
 71     
 72     def on_message(self, bus, message):
 73         t = message.type
 74         if t == gst.MESSAGE_ERROR:
 75             self.play(self.get_next())
 76         elif t == gst.MESSAGE_EOS:
 77             self.play(self.get_next())
 78 
 79 class Console:
 80     
 81     def __init__(self, list):
 82         self.player = AudioPlayer(self)
 83         self.player.add_list(list)
 84         self.player.play(0)
 85 
 86         Thread(target=self.run).start()
 87         
 88     def run(self):
 89         while(True):
 90             self.on_cmd(raw_input())
 91     
 92     def on_cmd(self, cmd):
 93         if cmd is None:
 94             return
 95         if cmd.startswith('play'):
 96             self.player.play()
 97         elif cmd.startswith('next'):
 98             self.player.play(self.player.get_next())
 99         elif cmd.startswith('previous'):
100             self.player.play(self.player.get_previous())
101         elif cmd.startswith('pause'):
102             self.player.pause()
103         elif cmd.startswith('list'):
104             print '====================================='
105             for info in self.player.list:
106                 print '%s. %s' % (info[0], info[2])
107             print '====================================='
108         elif cmd.startswith('info'):
109             print '====================================='
110             print '%s. %s' % (self.player.index, self.player.get_title())
111             print '====================================='
112         elif cmd.startswith('stop'):
113             self.player.stop()
114             sys.exit(0)
115         elif cmd.startswith('dump'):
116             from meliae import scanner
117             scanner.dump_all_objects('./dump.txt')
118         else:
119             print '''=====================================
120 Usage:
121 play
122 next
123 previous
124 pause
125 list
126 info
127 stop
128 dump
129 ====================================='''
130     
131     def on_message(self, event, info):
132         if event == AudioPlayer.EVENT_PLAY_NEW:
133             print '====================================='
134             print 'Tracks: %s.%s' % (info[0], info[1])
135             print '====================================='
136 
137 
138 if len(sys.argv) != 2:
139     print 'player.py mp3.list'
140     sys.exit(-1)
141 list = [l.strip() for l in open(sys.argv[1]).readlines() if l.strip() != '']
142 Console(list)

涓嬭澆



stone2083 2011-04-17 19:32 鍙戣〃璇勮
]]>
ubuntu涓嬪畨瑁匬ython Imaging Library (PIL)http://www.tkk7.com/stone2083/archive/2009/10/27/299946.htmlstone2083stone2083Tue, 27 Oct 2009 09:25:00 GMThttp://www.tkk7.com/stone2083/archive/2009/10/27/299946.htmlhttp://www.tkk7.com/stone2083/comments/299946.htmlhttp://www.tkk7.com/stone2083/archive/2009/10/27/299946.html#Feedback1http://www.tkk7.com/stone2083/comments/commentRss/299946.htmlhttp://www.tkk7.com/stone2083/services/trackbacks/299946.html 榪欐槸鎴戞渶榪戝湪瀛︿範python鐨勪竴涓濅綋浼氾紝濂藉lib閮芥棤娉曢氳繃easy_install瀹夎錛屾瘮濡?Python Imaging Library (PIL)

鍙兘閫氳繃鎵嬪伐瀹夎鏂瑰紡瀹夎錛?br /> 錛奷ownload the pil_1.1.6
錛妕ar xvf Imaging-1.1.6.tar.gz & chmox +x setup.py
錛妏ython setup.py build

緇撴灉錛屽眳鐒訛細
 _imagingtk.c -o build/temp.linux-i686-2.6/_imagingtk.o
_imagingtk.c:
20:16: error: tk.h: No such file or directory
_imagingtk.c:
23: error: expected ‘)’ before ‘*’ token
_imagingtk.c:
31: error: expected specifier-qualifier-list before ‘Tcl_Interp’
_imagingtk.c: In function ‘_tkinit’:
_imagingtk.c:
37: error: ‘Tcl_Interp’ undeclared (first use in this function)
_imagingtk.c:
37: error: (Each undeclared identifier is reported only once
_imagingtk.c:
37: error: for each function it appears in.)
_imagingtk.c:
37: error: ‘interp’ undeclared (first use in this function)
_imagingtk.c:
45: error: expected expression before ‘)’ token
_imagingtk.c:
51: error: ‘TkappObject’ has no member named ‘interp’
_imagingtk.c:
55: warning: implicit declaration of function ‘TkImaging_Init’
error: command 'gcc' failed with exit status 
1

tk.h No such file or directory

浜嬪疄涓婏紝tk-dev鍖呮垜宸茬粡瀹夎浜嗭紝鏌ョ湅setup.py浠g爜錛屽彂鐜幫細
# Library pointers.
#
#
 Use None to look for the libraries in well-known library locations.
#
 Use a string to specify a single directory, for both the library and
#
 the include files.  Use a tuple to specify separate directories:
#
 (libpath, includepath).  Examples:
#
#
 JPEG_ROOT = "/home/libraries/jpeg-6b"
#
 TIFF_ROOT = "/opt/tiff/lib", "/opt/tiff/include"
#
#
 If you have "lib" and "include" directories under a common parent,
#
 you can use the "libinclude" helper:
#
#
 TIFF_ROOT = libinclude("/opt/tiff")

FREETYPE_ROOT 
= None
JPEG_ROOT 
= None
TIFF_ROOT 
= None
ZLIB_ROOT 
= None
TCL_ROOT 
= None

灝員CL_ROOT = None 淇敼鎴愶細TCL_ROOT = '/usr/include/tk'錛屽嵆鍙?br />
python setup.py build
python setup.py install

鎴愬姛 錛氾級



stone2083 2009-10-27 17:25 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 成人a毛片免费视频观看| 亚洲VA成无码人在线观看天堂| 亚洲国产精品免费观看| 免费无码国产V片在线观看| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 久久免费线看线看| 国产在线a不卡免费视频| 亚洲日韩AV一区二区三区四区| 又粗又大又黑又长的免费视频| 久久综合日韩亚洲精品色| 日本道免费精品一区二区| 亚洲av永久无码精品漫画| 香蕉成人免费看片视频app下载| 亚洲精品高清国产一线久久| h片在线观看免费| 国产亚洲精品a在线无码| 99爱免费观看视频在线| 亚洲一级高清在线中文字幕| 97碰公开在线观看免费视频| 亚洲av产在线精品亚洲第一站 | 99精品视频在线观看免费| 亚洲欧洲国产经精品香蕉网| 8x8×在线永久免费视频| 亚洲日韩中文在线精品第一| 亚洲色偷偷偷综合网| 午夜成年女人毛片免费观看| 久久99国产亚洲精品观看| 立即播放免费毛片一级| 国产美女被遭强高潮免费网站| 亚洲一级毛片免费在线观看| 国产免费av片在线无码免费看| 乱淫片免费影院观看| 4444亚洲国产成人精品| 日韩免费观看一级毛片看看 | 亚洲精品无码一区二区| 亚洲第一页综合图片自拍| 亚洲精品在线免费观看视频| 特黄特色大片免费| 亚洲成人午夜电影| 亚洲一区二区三区影院| 在线免费观看视频你懂的|