??xml version="1.0" encoding="utf-8" standalone="yes"?>国产在线精品免费,久久经典视频,国产欧美一区二区三区久久http://www.aygfsteel.com/stone2083/category/42431.htmlzh-cnFri, 30 Mar 2018 15:06:00 GMTFri, 30 Mar 2018 15:06:00 GMT60图片{成HTML格式--原理&代码http://www.aygfsteel.com/stone2083/archive/2013/12/20/407809.htmlstone2083stone2083Fri, 20 Dec 2013 06:28:00 GMThttp://www.aygfsteel.com/stone2083/archive/2013/12/20/407809.htmlhttp://www.aygfsteel.com/stone2083/comments/407809.htmlhttp://www.aygfsteel.com/stone2083/archive/2013/12/20/407809.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/407809.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/407809.html
@see http://www.aygfsteel.com/stone2083/archive/2013/12/20/407807.html

原理

使用table,tr/td作ؓ一个像素点Q画炏V?br />


代码

 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 发表评论
]]>
图片{成HTML格式Q-用HTMLdhttp://www.aygfsteel.com/stone2083/archive/2013/12/20/407807.htmlstone2083stone2083Fri, 20 Dec 2013 06:18:00 GMThttp://www.aygfsteel.com/stone2083/archive/2013/12/20/407807.htmlhttp://www.aygfsteel.com/stone2083/comments/407807.htmlhttp://www.aygfsteel.com/stone2083/archive/2013/12/20/407807.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/407807.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/407807.html阅读全文

stone2083 2013-12-20 14:18 发表评论
]]>
pystack--python stack trace--让python打印U程栈信?/title><link>http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2013/08/19/403028.html</guid><wfw:comment>http://www.aygfsteel.com/stone2083/comments/403028.html</wfw:comment><comments>http://www.aygfsteel.com/stone2083/archive/2013/08/19/403028.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stone2083/comments/commentRss/403028.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/stone2083/services/trackbacks/403028.html</trackback:ping><description><![CDATA[pystack: python stack trace. cMjava中的jstack功能.<br /> 使用方式:<br /> 1. https://pypi.python.org/pypi/pdbx/0.3.0 下蝲, 或者直接通过easyinstall安装<br /> 2. python scripts? import pdbx; pdbx.enable_pystack(); 开启pystack功能<br /> 3. kill -30 pid , 可以打印stack信息? <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 /> 核心代码:<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.aygfsteel.com/stone2083/aggbug/403028.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stone2083/" target="_blank">stone2083</a> 2013-08-19 13:15 <a href="http://www.aygfsteel.com/stone2083/archive/2013/08/19/403028.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>rpdb更名为pdbxq发布到pypihttp://www.aygfsteel.com/stone2083/archive/2013/03/23/396903.htmlstone2083stone2083Sat, 23 Mar 2013 08:11:00 GMThttp://www.aygfsteel.com/stone2083/archive/2013/03/23/396903.htmlhttp://www.aygfsteel.com/stone2083/comments/396903.htmlhttp://www.aygfsteel.com/stone2083/archive/2013/03/23/396903.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/396903.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/396903.htmlrpdb更名为pdbxQ发布到pypi


stone2083 2013-03-23 16:11 发表评论
]]>
RPDB V0.2.0 Release (值得推广)http://www.aygfsteel.com/stone2083/archive/2013/03/22/396862.htmlstone2083stone2083Fri, 22 Mar 2013 09:23:00 GMThttp://www.aygfsteel.com/stone2083/archive/2013/03/22/396862.htmlhttp://www.aygfsteel.com/stone2083/comments/396862.htmlhttp://www.aygfsteel.com/stone2083/archive/2013/03/22/396862.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/396862.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/396862.html软g已更斎ͼ最新请查看Q?/span>https://code.google.com/p/stonelab/wiki/pdbx
原文Qhttps://code.google.com/p/stonelab/wiki/RemotePDB

软g介绍

rpdb:q程PDB调试工具Q是对pdb的扩展?nbsp;

在pdb基础上,做了功能加强Q主要特性如下:

1. 兼容pdb一切语法和使用习惯 

2. 增加了远E调试功能, 允许你客L通过telnetq接到指定调试端口,q行q程调试 

3. 增加了rq/rquit命oQ支持安全退出模式,避免默认的quik会导致pythonE序异常退出的情况 

4. 允许多次调试 

5. 增加suspend模式Q在启动时强制或者非强制q入断点 



stone2083 2013-03-22 17:23 发表评论
]]>
RPDB-让PDBQPython调试工具Q支持远E调试功?/title><link>http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2013/03/21/396812.html</guid><wfw:comment>http://www.aygfsteel.com/stone2083/comments/396812.html</wfw:comment><comments>http://www.aygfsteel.com/stone2083/archive/2013/03/21/396812.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stone2083/comments/commentRss/396812.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/stone2083/services/trackbacks/396812.html</trackback:ping><description><![CDATA[<div class="wmqeeuq" id="wikicontent"><div class="wmqeeuq" 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;">软g已更斎ͼ最新请查看Q?/span><span style="font-size: 14px; color: red;">https://code.google.com/p/stonelab/wiki/pdbx</span><br /><br />软g介绍</h1><blockquote style="margin: 20px; max-width: 60em;">rpdb扩展了pdbQ让pdb支持q程调试功能?br /><br />使用了rpdb的python脚本在远E启动,本地通过telnet方式q接上rpdb提供的调试端口,接下来的操作和本地完全一致?/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.pyQ扩展pdb的类库; example.py 演示E序</blockquote><li style="margin-bottom: 0.3em;">安装</li><blockquote style="margin: 20px; max-width: 60em;">rpdb.py拯到PYTHONPATH卛_Q或者直接拷贝rpdb.py上内容到你的python脚本卛_Q程序非常小巧,30+代码行)</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;"># cM于pdb=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;"># 指定q程调试端口?/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;">如example.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>本地l端输入Q?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>操作和pdb完全一致?/blockquote></ul><h1><a name="PDB常用命o"></a>PDB常用命o</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;">命o</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或者help 列出pdb支持的所有命令, h command<a style="color: #0000cc;">?</a> 介绍指定命o</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;">列出当前调试所在行Q一般会使用 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;">q入函数?/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;">l箋Q直到遇C一个断?/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;">执行到函Cl束那行</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;">讄断点Q可以是代码行号Q方法名Q?q可以加q入条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;">讄临时断点Q进入一ơ后Q自动消?/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;">l断Ҏ加条ӞW合条g的才q入断点</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;">x指定?/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;">打印函数体参C?/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;">同上Q打印得漂亮一?/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;">执行代码Q非常有用,可用来修改变量?/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的quit很黄很暴力)</td></tr></tbody></table><p style="line-height: 1.25em; max-width: 64em;"></p></div></div><img src ="http://www.aygfsteel.com/stone2083/aggbug/396812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stone2083/" target="_blank">stone2083</a> 2013-03-21 16:19 <a href="http://www.aygfsteel.com/stone2083/archive/2013/03/21/396812.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>分n几个工?-推荐lLinux的用?/title><link>http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2013/03/19/396660.html</guid><wfw:comment>http://www.aygfsteel.com/stone2083/comments/396660.html</wfw:comment><comments>http://www.aygfsteel.com/stone2083/archive/2013/03/19/396660.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stone2083/comments/commentRss/396660.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/stone2083/services/trackbacks/396660.html</trackback:ping><description><![CDATA[<div>自己写的几个工P分nl需要的人:<br /><br />https://code.google.com/p/stonelab/wiki/BaiduMp3<br />癑ֺMP3扚w下蝲工具<br /><br /><div>https://code.google.com/p/stonelab/wiki/FileConvertor<br />文g~码转换工具<br /><br /><div>https://code.google.com/p/stonelab/wiki/MyZip<br />扩展zip命oQ支持文件名~码<br /><br /><div>https://code.google.com/p/stonelab/wiki/Translate<br />命o行下的翻译Y?br /><br /><div>https://code.google.com/p/stonelab/wiki/HostsX<br />扩展HostsQ别名DnsProxyQDNS代理服务</div></div></div></div></div><img src ="http://www.aygfsteel.com/stone2083/aggbug/396660.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stone2083/" target="_blank">stone2083</a> 2013-03-19 15:12 <a href="http://www.aygfsteel.com/stone2083/archive/2013/03/19/396660.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BaiduMp3--Z命o行的癑ֺMP3扚w下蝲工具http://www.aygfsteel.com/stone2083/archive/2013/03/19/396645.htmlstone2083stone2083Tue, 19 Mar 2013 03:28:00 GMThttp://www.aygfsteel.com/stone2083/archive/2013/03/19/396645.htmlhttp://www.aygfsteel.com/stone2083/comments/396645.htmlhttp://www.aygfsteel.com/stone2083/archive/2013/03/19/396645.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/396645.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/396645.html

软g介绍

BaiduMp3Q基于命令行下的癑ֺMP3歌曲扚w下蝲工具?br />
主要支持功能Q?/p>

  • 搜烦 Ҏ关键词搜索匹配的歌曲
  • 下蝲 Ҏ搜烦出来的歌曲IDQ下载到本地指定目录
  • 扚w下蝲 Ҏ关键词,扚w下蝲匚w的歌Ԍ到本地指定目?/li>

软g使用

  • 命o参数介绍
  • 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关键词指定分页面号Q默认一|C?0条数据?br />
    比如Q?/baidump3.py -m list -k 70?-p 2 

    效果Q?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>                   别让我一个h?/span>
    209442    彭佳?/span>                   相见恨晚
    2121730 杨钰?毛宁                心雨
    216206    许美?/span>                   蔓g
    226444    陈淑?/span>                   ?/span>
    253833    张学?/span>                   U意?/span>
    274172    张学?/span>                   三天两夜
    580824    孟庭?/span>                   伤了你的心的我伤?/span>
    582858    莫文?/span>                   电台情歌
    650924    姜育?/span>                   其实我真的很在乎
    7274415 满文?/span>                   我需要你
    7277793 林志?/span>                   单n情歌
    7280177 林志?/span>                   Mh
    7302437 李寿?/span>                   张三的歌
    844889    陈淑?/span>                   光飞舞
    1039139 王菲                    Ҏ受伤的女?/span>
    1243712 |大?/span>                   恋曲1980
    2076242 李宗?/span>                   我是一只小鸟
    2121739 杨钰?/span>                   轻轻的告诉你
  • 下蝲
  • 通过-m download指定Z载模?-k参数指定下蝲歌曲ID?-o参数指定下蝲路径Q默认ؓ当前目录?br />
    比如Q?/baidump3.py -m download -k 1007797 -o ~/Tmp/ 

    效果Q?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
  • 扚w下蝲
  • 通过-m multidownload指定为批量下载模?-k参数指定歌曲关键词, -o参数指定下蝲路径Q默认位为当前目录)Q?-f参数指定下蝲开始页面(默认为第一)Q?-t参数指定下蝲l束面Q默认ؓ搜烦到的最后一)

    比如Q?/baidump3.py -m multidownload -k 70?-o ~/Tmp/baidu -f 2 -t 3 

    效果Q?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 >>> 别让我一个h?mp3
    Downloading >>> 相见恨晚.mp3
    Downloading >>> y冮z?mp3
    Downloading >>> 蔓g.mp3
    Downloading >>> ?mp3
    Downloading >>> U意?mp3
    Downloading >>> 三天两夜.mp3
    Downloading >>> 伤了你的心的我伤?mp3
    Downloading >>> 电台情歌.mp3
    Downloading >>> 其实我真的很在乎.mp3
    Downloading >>> 鎴戦渶瑕L.mp3
    Downloading >>> 单n情歌.mp3
    Downloading >>> Mh.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 >>> l束不是我要的结?mp3
    Downloading >>> 鍛抽?mp3
    Downloading >>> 来生~?mp3
    Downloading >>> 相思风雨中.mp3
    Downloading >>> 你我的爱只能擦肩而过.mp3
    Downloading >>> 忘情?mp3
    Downloading >>> 爱如潮水.mp3
    Downloading >>> 特别的爱l特别的?mp3
    Downloading >>> 千千阙歌.mp3
    Downloading >>> 涛声依旧.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备注Q?有小概率会出Cؕ码,以及小概率出现下蝲p|?/blockquote>


stone2083 2013-03-19 11:28 发表评论
]]>
RaspCTL V0.1.0 Releasedhttp://www.aygfsteel.com/stone2083/archive/2013/01/16/394311.htmlstone2083stone2083Wed, 16 Jan 2013 08:23:00 GMThttp://www.aygfsteel.com/stone2083/archive/2013/01/16/394311.htmlhttp://www.aygfsteel.com/stone2083/comments/394311.htmlhttp://www.aygfsteel.com/stone2083/archive/2013/01/16/394311.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/394311.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/394311.html转自Qhttps://code.google.com/p/stonelab/wiki/RaspCTL
COPYq来格式比较乱,就地看吧。原文直接看googlecode wiki?Q)

什么是RaspCTL
RaspCTL是Raspberry Pi和Control字母的组合,表示树莓z控制端?RaspCTL是一N过手机l端Q泛义上包括手机Q^板,电脑{设备)控制树莓z?/a>的Y件?br /> 目前Q通过Raspberry&RaspCTLl合Q打造成家庭多媒体播放机盒Q在此场景中QRaspCTL非常cMXBMCq_?/span>未来Q会不断扩展RaspCTL功能Q成为控制家庭物联网的设备中心,比如控制摄像_I开关等。此乃后话,按下不表?/span>


Z么选择Raspberry Pi&RaspCTL
Z么选择Raspberry Pi

我们先来看看Raspberry Pi的相兛_敎ͼ

CPU 700 MHzQ?ARM1176JZF-S
GPUQ显卡) Broadcom VideoCore? IVQOpenGL ES 2.0Q?1080p30 h.264/MPEG-4 AVC high-profile decoder
MEMQ内存) 512M
分L?/td> 1080P
输出接口 1*SD?2*USB?1*音频?1*HDMI?1*|卡
85.6 x 53.98 x 17mm Q一张信用卡大小Q?/td>
h $35


好吧Q一hȝ下Raspberry Pi的优势吧

  • yQ只有一张信用卡大小
  • GPU强悍Q?解1080PQ?0?SQ通俗地将Q差不多是iphone4S手机?倍性能
  • 输出接口丰富Q?包括2*USBQ?*HDMI
  • 性h比高Q?35

    从这些特性看QRaspberry非常合适充当高清视频播放机盒Q来替代目前的华数机盒Q华数官方垄断,费用高,质量差)?家庭中,只要购置了Raspberry Pi和宽带,高清电媄电视Q免费看?Q)

Z么选择RaspCTL
只有一个原因:Raspberry Pi CPU很弱Q?00MHZ?同样Q我们来看一l数据:

  • Raspbian Terminal?CPU LOAD?.2左右
  • Raspbian XWindows下, CPU占用率差不多?0%以上
  • XBian下,CPU占用率在95%以上
    如果QRaspberry Pi CPU能强悍那么一点点Q那么XBian一定是首选,我也不会重新创造RaspCTLq个轮子了。只是目前,XBMC在Raspberry PiQXBianQ上的性能太糟p了?从数据看Q只有在Raspbian Terminal下的性能Q才能符合用L期望Q所以作者编写了RaspCTLq个控制端。通过手机l端的界面,来操作Raspbian TerminalQ实现多媒体播放的功能?/span>

RaspCTL(V0.1.0)功能Ҏ?/h1>
  1. 支持视屏Q音频播?/li>
    • 支持播放Q暂停,停止Q快q,快退Q播攑ֈ表,上一首,下一首等
  2. 支持本地文g查看
    • 查看多媒体文?/li>
  3. 配置pȝ信息
    • 配置多媒体文件根路径{?/li>
  4. 视频|站真实URL分析
    • 支持包括优酷Q土豆,q雷Q百度等82个网站视频URL分析
  5. 制定Plugins规范
    • 可非常方便开发RaspCTL Pugin

使用者文?/h1>

如何安装RaspCTL

  1. 下蝲RaspCTL
    1. 下蝲Q解压到指定目录
    2. 或者直接用svn地址Q?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. 会自动安装RaspCTL依赖的第三方库,主要是python-webpy python-jinja2 python-pexpect依赖

如何使用RaspCTL

  1. 启动RaspCTL服务
  2. 关闭RaspCTL服务
    • bin/shutdown.sh

常见问题

  • QQ如何自启动RaspCTL服务
    • ?bin/start.sh 配置到树莓派?etc/rc.local exit之前?同理Q你在rc.local中可以启动其他Q何服务;
  • QQ如何?0端口
    • debianpȝ用了小?024的端口,所以RaspCTL只有使用8000端口。可以通过iptable?0端口h转发?000端口Q?iptables -t nat -A PREROUTING -p tcp --dport 81 -j REDIRECT --to-ports 8080

开发者文?/h1>

cdAPI

Omxplayer

play 播放Q可以指定播攑ֈ表中M一个资?/td>
pause 暂停播放
resume 恢复播放
stop 停止播放
lseek 快退Q?快退30U, 参数为True的话Q快退10分钟
rseek 快进Q?快进30U,参数为True的话Q快q?0分钟
prev 播放上一?/td>
next 播放下一?/td>
set_playlist 讄播放列表
add_playitem d多媒体资源到播放列表? 参数?('url', 'name') 资源地址Q?资源昄?/td>
del_playitem 清空播放列表
sort_playitem 播放列表排序
set_dev 讄输出讑֤Q?hdmi接口 或?本地音频接口
set_loop 讄播放模式Q顺序,循环
get_info 获取播放器信息,如播攄态等

LocalFile?

get_mediapath 获得多媒体文件根目录路径
list 获取一个目录下的所有资?/td>
list_all 递归获取一个目录下的所有资?/td>

Config

load 获取raspctl.cnf中的配置信息
save 更新raspctl.cnf中的配置信息

MediaUrl?

get_urls 获取|站url对应的真实视屏url地址信息Q?fmt=high 获取高清视屏地址

Ajax规范

使用Ajax的目的:ZRaspCTL提供的服务可以同时被WAPQ?Android APP, IOS APP使用QRaspCTL服务均以Ajax形式提供。希望Plugins开发者也늅q个规约Q但不强制?br /> cd中,只要被标志@classmethod的方法,会直接暴露成Ajax服务Q如Q?/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 --> 插g名字
    __init__
.py --> 插gE序
    index
.html --> 插g模板 【可选择?/span>

init.py 内容为:

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

# 必须创徏plugin实例Q参数分别ؓ插g名,作者名Q版本号Q?支持功能的urls
#其中Qplugin中包含RaspCTLcd的所有方法,可直接调?/span>
plugin
= Plugin('youku','stone2083', '0.1', urls)

#web.py写法Q插件规范ƈ不引入新的学习成本?/span>
class Index:
   
def GET(self):
       
return 'youku-NotSupported.'  #可以直接输出
       
#return plugin.render.index()  #可以渲染某个模板信息

写在最?/h1>
  • RaspCTL作者联pM息:stone2083#yahoo.cn E序的Q何问题可直接联系q个邮箱
  • 招募UED设计前端界面 0.1.0前端非常p糕Q急待重构
  • 招募Plugin开发者,丰富RaspCTL
  • 期待白鼠适用RaspCTL


stone2083 2013-01-16 16:23 发表评论
]]>SAE Python 支持web.py (非官Ҏ?http://www.aygfsteel.com/stone2083/archive/2011/11/24/364738.htmlstone2083stone2083Thu, 24 Nov 2011 07:48:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/11/24/364738.htmlhttp://www.aygfsteel.com/stone2083/comments/364738.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/11/24/364738.html#Feedback3http://www.aygfsteel.com/stone2083/comments/commentRss/364738.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/364738.html 首次倒腾SAEQ不熟悉Q瞎搞,W一件干的事情,是试如何让SAE支持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. ~写正常的webpy应用代码
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())

整体目录l构如下Q?/strong>


搞定Q?br />

stone2083 2011-11-24 15:48 发表评论
]]>
SSL相关命o随记http://www.aygfsteel.com/stone2083/archive/2011/10/17/361471.htmlstone2083stone2083Mon, 17 Oct 2011 12:22:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/10/17/361471.htmlhttp://www.aygfsteel.com/stone2083/comments/361471.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/10/17/361471.html#Feedback2http://www.aygfsteel.com/stone2083/comments/commentRss/361471.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/361471.html背景
之前利用W重的Java写过内网讉KE序QSSL双向认证pȝQ,今天才发现curl{命令对SSL都有良好的支持?br />故记录相关点滴?br />
创徏CA根证?/strong>

#创徏caU钥
openssl genrsa -out ca.key
#创徏证书h文gQ?span class="Apple-style-span" style="font-family: arial, 宋体, sans-serif; line-height: 24px; background-color: #ffffff; ">Certificate Secure RequestQ?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格式证书导出成pem格式证书

openssl pkcs12 -in jinli.pfx -nodes -out jinli.pem
#导出U钥
openssl rsa -in jinli.pem -out jinli.key
#导出证书Q公?br /> openssl x509 -in jinli.pem -out jinli.crt


curl讉KHTTPS命o
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/
参数解释Q?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讉KHTTPS代码
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查看证书信息代码
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不理解的地方 

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不支持ca_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.aygfsteel.com/stone2083/archive/2011/09/30/359860.htmlstone2083stone2083Fri, 30 Sep 2011 06:51:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/09/30/359860.htmlhttp://www.aygfsteel.com/stone2083/comments/359860.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/09/30/359860.html#Feedback10http://www.aygfsteel.com/stone2083/comments/commentRss/359860.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/359860.html Ҏ了一圈python web framework后,q是让我对web.py的simple和它的设计理念念念不忘?br />
机器介绍
机型QThinkPad R400 W记?br /> CPUQIntel(R) Core(TM)2 Duo CPU     P8700  @ 2.53GHz
MemQ?2G
pȝQUbuntu11.04 32位操作系l?br /> 备注Q服务器上没有python环境Q所以只拿个人电脑做试?br />
试内容
输出当前旉信息
1. <%= new Date() %>
2. time.ctime()

Ҏ试数据
服务?/td> q发数量 TPS q_响应旉
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自带的CherryPy服务器性能也比传说的强多了Q只是难以支撑高q发的请求。也难怪,本来是一个用于开发的服务器,也不能要求太多;
2. FlupQFCGIQ下QTPS辑ֈ1500左右Q完全能够支撑一般应用的q营要求了;
3. 在专业服务器下,webpy fcgi tps自信能达?-5k左右。够了Q?br /> 4. 和Java相比Q确实存在一定差距,但是在开发效率上Q远q快于JavaQ?br /> 5. web.py成ؓ我日后web开发首选;
6. 凡事不要道听途说Q需要眼见ؓ实?br />
附上试报告囄Q?br />


stone2083 2011-09-30 14:51 发表评论
]]>
DNS代理服务?/title><link>http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2011/07/04/353664.html</guid><wfw:comment>http://www.aygfsteel.com/stone2083/comments/353664.html</wfw:comment><comments>http://www.aygfsteel.com/stone2083/archive/2011/07/04/353664.html#Feedback</comments><slash:comments>23</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stone2083/comments/commentRss/353664.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/stone2083/services/trackbacks/353664.html</trackback:ping><description><![CDATA[背景接上文:<a href="http://www.aygfsteel.com/stone2083/archive/2011/05/23/350875.html">http://www.aygfsteel.com/stone2083/archive/2011/05/23/350875.html<br /></a>随笔摘自6?3日邮件分?br />目前此Y件在公司试环境上运行良好,故分享给大家?a href="http://www.aygfsteel.com/stone2083/archive/2011/05/23/350875.html"><br /><br /></a>以下为分享内容:<a href="http://www.aygfsteel.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; ">Q?/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; ">Q只需要一?/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; ">。达C人配|,多h使用的目?/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; ">l定?/span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 宋体; color: #1f497d; ">Q支持通配W。方便类似旺铺域名的需求,只需要配|一个带通配W的域名卛_</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; ">要在不同目Q小需求切换不同的</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 宋体; color: #1f497d; ">Ӟ只需要轻M点,方便</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; ">要想使用代理服务器,只需要本?/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; ">如何使用Q?/span></strong><span style="font-family: 宋体; color: #1f497d; ">Q以</span><span style="color: #1f497d; ">10.20.131.207</span><span style="font-family: 宋体; color: #1f497d; ">环境介绍Q?/span><span style="font-family: 宋体; color: red; ">备注Q公司内部环境,外部无法讉KQ如果需要,误行搭?/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; ">Q?/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; ">Q点?/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.aygfsteel.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; ">d一个项目的</span><span style="color: #1f497d; ">Hosts</span><span style="font-family: 宋体; color: #1f497d; ">信息Q点L?/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.aygfsteel.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; ">信息面Q点?/span><span style="color: #1f497d; ">assign</span><span style="font-family: 宋体; color: #1f497d; ">Q绑定自q?/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.aygfsteel.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.aygfsteel.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; ">代理服务器即可(</span><span style="color: #1f497d; ">10.20.131.207</span><span style="font-family: 宋体; color: #1f497d; ">Q?/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.aygfsteel.com/images/blogjava_net/stone2083/python/5.jpg" border="0" alt="" width="484" height="421" /><img src="http://www.aygfsteel.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; ">配置Q右图ؓ</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; ">此时Q你讉K域名Q如果在</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; ">反之Q则q回真实</span><span style="color: #1f497d; ">IP?br /><br /><br />如何启动服务<br />1. 启动DNS代理服务器服?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>软g下蝲Q?a title="DNS Proxy Server" href="/Files/stone2083/python/dns.zip">DNS Proxy Server</a></strong></span><span style="color: #1f497d; "><br /><br />============================================================================================<br />Z满“邪恶”的h们能更方便的使用q个软gQ貌似邪恶的人特别看重这个Y仉配W的功能Q具体邪恶在哪里Q我不具体描qCQ给?a title="链接"><strong>链接</strong></a>Q,我特意写了一个standalone的版本:<br />1. 去除无用的backoffice功能<br />2. 去除通过事g机制reload hosts文g的功?br />3. 去除复杂的settings配置文gQ改用简单的命o行方?br />4. Ҏ为windows用户制作了一个exe文gQ可以直接?br /><br />linux用户使用ҎQ?br />python standalone.py -s xxx.xxx.xxx.xxx (上dns地址)<br />python standalone.py -s xxx.xxx.xxx.xxx -f /etc/hosts2 (指定hosts文gQ默认是/etc/hosts)<br /><br />windows用户使用ҎQ进入distQexe发布目录Q?br />dns.exe -s xxx.xxx.xxx.xxx (上dns地址)<br />dns.exe -s xxx.xxx.xxx.xxx -f d:/hosts Q指定hosts文gQ默认是c:/windows/system32/drivers/etc/hostsQ?br /><br />对于不放心用exe的客h_可以q入dns目录Q通过py2exe工具自行发布成exe软gQ方法如?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.aygfsteel.com/stone2083/aggbug/353664.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stone2083/" target="_blank">stone2083</a> 2011-07-04 20:39 <a href="http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2011/06/18/352552.htmlstone2083stone2083Fri, 17 Jun 2011 16:41:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/06/18/352552.htmlhttp://www.aygfsteel.com/stone2083/comments/352552.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/06/18/352552.html#Feedback1http://www.aygfsteel.com/stone2083/comments/commentRss/352552.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/352552.html 光认的Cursor Class是用tupleQ元l)作ؓ数据存储对象的,操作非常不便
1 = cursor.fetchone()
2 print(p[0], p[1])
如果有十几个字段Q光是数C敎ͼ把我数晕了?br />
当然QMySqldb Cursor Class本n提供了扩展Q我们可以切换成DictCurosor作ؓ默认数据存储对象Q如
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 />
但是Q?[]"q个W号写写比较ȝQƈ且我~码风格带有强烈的Java习惯Q一直喜Ƣ类?p.id","p.name"的写法?br />于是Q扩展之
1. 扩展Dictc,使其支持"."方式Q?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. 扩展CurosorQ其取得的数据使用Dictc:
 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))

q下Q就W合我的习惯了:
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 发表评论
]]>
Hostsl定新思\之DNS代理服务器实现篇http://www.aygfsteel.com/stone2083/archive/2011/05/23/350875.htmlstone2083stone2083Mon, 23 May 2011 13:24:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/05/23/350875.htmlhttp://www.aygfsteel.com/stone2083/comments/350875.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/05/23/350875.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/350875.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/350875.html阅读全文

stone2083 2011-05-23 21:24 发表评论
]]>
Hostsl定新思\之DNS代理?/title><link>http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2011/05/23/350871.html</guid><wfw:comment>http://www.aygfsteel.com/stone2083/comments/350871.html</wfw:comment><comments>http://www.aygfsteel.com/stone2083/archive/2011/05/23/350871.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stone2083/comments/commentRss/350871.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.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;">此文摘自2011q??3日邮件分享,为《Hostsl定新思\之HTTP代理》箋?/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;">电媄也有l集</span><span style="color: #1f497d;">,Hosts</span><span style="color: #1f497d;">l定思\同样有箋?/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;">l定的思\</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;">代理的方?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">分散在各个客户端的</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;"><wbr>l定</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">集中l定?/span><span style="color: #1f497d;">Http</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></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;">代理服务?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">只能l定一l?/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;">在当时描q方案邮件的时?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">也意识到了方案存在的不</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">所以一?wbr>在思考改q方?/span><span style="color: #1f497d;">(</span><span style="color: #1f497d;">详见之前邮g中最后一?/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;">l过一D|间的思?/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;">代理Ҏ</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;">代理Ҏ</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.aygfsteel.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;">代理服务?/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;">服务l护各自目的绑<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;">代理服务器的作用?/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>q?/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;">协议q回</span><span style="color: #1f497d;">  (</span><span style="color: #1f497d;">图中</span><span style="color: #1f497d;"> </span><span style="color: #1f497d;">U色实线</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;">如果不在l定之列</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">则请求上U?/span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;">服务?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">q回?/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;">l定优先</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;">代理服务?/span><span style="color: #1f497d;">.</span><span style="color: #1f497d;">?wbr>h本地</span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">文g</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;">代理服务器支持多U绑定方?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">如通配W?/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;">,</span><span style="color: #1f497d;">完全可以使用通配W?/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;">代理服务?/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;">目前试同学已经集中l护?/span><span style="color: #1f497d;">Hosts</span><span style="color: #1f497d;">l定信息</span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">只要部v</span><span style="color: #1f497d;">DNS</span><span style="color: #1f497d;"><wbr>代理服务?/span><span style="color: #1f497d;">,</span><span style="color: #1f497d;">q做单的集成卛_</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;">代理服务器代码轻量小?/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>代理部分</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.aygfsteel.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.aygfsteel.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;">文g卛_</span></p></span></span></div><img src ="http://www.aygfsteel.com/stone2083/aggbug/350871.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stone2083/" target="_blank">stone2083</a> 2011-05-23 19:42 <a href="http://www.aygfsteel.com/stone2083/archive/2011/05/23/350871.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hostsl定新思\之HTTP代理?/title><link>http://www.aygfsteel.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.aygfsteel.com/stone2083/archive/2011/05/23/350868.html</guid><wfw:comment>http://www.aygfsteel.com/stone2083/comments/350868.html</wfw:comment><comments>http://www.aygfsteel.com/stone2083/archive/2011/05/23/350868.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stone2083/comments/commentRss/350868.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.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;">此文摘自2011q??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;">qx开?试,功能预演阶段,Z能够正常讉K应用,需要做H<wbr>ostsl定.随着应用数量的不断增?l定量也是急剧上升.?wbr>如最q工作^C期项?需要绑定的环境多达44?一旦有变动<wbr>,需要通知所有h员做本地Hosts的调?l护成本那是相当?wbr>?</p><p style="margin: 0px;"> </p><p style="margin: 0px;">用一张图,来描qC目前我们的方?</p><p style="margin: 0px;"><img alt="" src="http://www.aygfsteel.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>利用客户端本地Hostsl定来实?q且客户端数量不可控—?wbr>用客L解决需?但客Ll护不在可控范围?/p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>Hostsl定是非怸E_?#8212;需求易?/p><p style="margin-left: 18pt;"> </p><p style="margin: 0px;">q样的设?q反?#8221;装变化”的设计原?故一旦有变动,l护<wbr>成本非常?</p><p style="margin: 0px;"> </p><p style="margin: 0px;"><strong><span style="font-size: 16pt;">新方案思\</span></strong></p><p style="margin: 0px;">按照”装变化”的设计原?我们应该把”域名l定”q个易变<wbr>需?q行l一理.</p><p style="margin: 0px;">看上?我们会发?DNS的职责就是做域名解析?q且DNS<wbr>理比较可控.</p><p style="margin: 0px;">于是W一反应,我们可以使用内部域名解析服务器来l定q些域名.</p><p style="margin: 0px;">但是问题又来?DNS来做试环境域名解析,太重量?同一<wbr>个域?对应试服务器IP有多?l定哪一个好?q且域名?wbr>应IP不断变化,IT DNS负责Z被我们篏d? <span style="font-family: Wingdings;"></span></p><p style="margin: 0px;"> </p><p style="margin: 0px;">既然DNS上做文章不可?又需要统一理的地?那么我们只能<wbr>再抽象出一个新的概忉|.</p><p style="margin: 0px;">同样,我们利用一张图,来描qC整体架构.</p><p style="margin: 0px;"><img alt="" src="http://www.aygfsteel.com/images/blogjava_net/stone2083/python/h2.jpg" /><br /></p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">与上囄?此图多了一?#8221;代理服务?#8221;的概?即Hostsl?wbr>定动作在此概念上完成.</p><p style="margin: 0px;">程如下:</p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>客户端浏览器讄代理服务?所有请求发送到代理服务器上</p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>代理服务器检查本地Hostsl定,如绑定则直接解析,反之q入<wbr>程3</p><p style="margin-left: 18pt;"><span>3.<span style="font: 7pt 'Times New Roman';">       </span></span>代理服务器通过内部域名服务器解析域?/p><p style="margin-left: 18pt;"><span>4.<span style="font: 7pt 'Times New Roman';">       </span></span>代理服务器发送请求到试服务器上,q且响应内容返回给客户?/p><p style="margin: 0px;"> </p><p style="margin: 0px;">具体试性实施方案如?在XX目q程中有成功案例)</p><p style="margin-left: 18pt;"><span>1.<span style="font: 7pt 'Times New Roman';">       </span></span>利用squid搭徏代理服务?nbsp;(代理地址: <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配置介绍见附录I</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;">全局代理: 代理服务器上,直接填写 10.20.131.207 3128</p><p style="margin-left: 18pt;">局部代? 通过pac实现,选择”使用自动配置脚本”,脚本格式内容如下:</p><p style="margin-left: 18pt;"><img alt="" src="http://www.aygfsteel.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脚本详细介绍见附录II</p><p style="margin-left: 18pt;">Z防止配|工作带lPD,销售等,我们可以使用配置好的l色<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.aygfsteel.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同样支持代理和pac脚本</p><p style="margin: 0px;">Chrome需要安装proxy switchy插g来支?</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>代理服务器没有多实例概念</p><p style="margin-left: 18pt;">代理服务器通过hostsl定.hosts是全局性的,意味着一<wbr>C理服务器只能服务一l需?而事实上,我们不同的项目需要的<wbr>l定都是不一L.</p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>Ҏ化需求不能满?/p><p style="margin-left: 18pt;">l定全在代理服务器上做了,客户端本C性化需求无法支?/p><p style="margin: 0px;"> </p><p style="margin: 0px;">所?我理想中整体架构是这L,见图:</p><p style="margin: 0px;"><img alt="" src="http://www.aygfsteel.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文g</p><p style="margin-left: 18pt;"><span>2.<span style="font: 7pt 'Times New Roman';">       </span></span>代理服务器支持多实例部v,不同实例有不同的hostsl定配置<wbr>.</p><p style="margin: 0px;"> </p><p style="margin: 0px;">目前具体实现Ҏ,q在构思中.Ƣ迎大家提供实现Ҏ思\.</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.aygfsteel.com/stone2083/aggbug/350868.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stone2083/" target="_blank">stone2083</a> 2011-05-23 19:41 <a href="http://www.aygfsteel.com/stone2083/archive/2011/05/23/350868.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>django框架的几个扩展点http://www.aygfsteel.com/stone2083/archive/2011/04/20/348662.htmlstone2083stone2083Wed, 20 Apr 2011 14:54:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/04/20/348662.htmlhttp://www.aygfsteel.com/stone2083/comments/348662.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/04/20/348662.html#Feedback0http://www.aygfsteel.com/stone2083/comments/commentRss/348662.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/348662.html 作ؓ一个一直来使用java的h来说Q初ơ用djangoQ真正体会到了简单美学。(一?3个功能,不到500行代码)
此文Q主要ȝ下django框架的一些扩展点:
MIDDLEWARE_CLASSES
在requesth之前Q或者responseh之后Q做拦截Q允许自定义逻辑。有些类似J2EE Servlet中的Filter概念?br /> TEMPLATE_CONTEXT_PROCESSORS
q入模板渲染之前Q允许放入一l用于模板渲染的Key-Value属性?br /> TEMPLATE FILTER
模板中的道语法Q通过自定义行为,d用于昄的一些逻辑?br /> TEMPLATE TAG
模板tagQ添加一l行为。有些类似Velocity中的ToolSet功能?br /> 模板tag+指定模板Q充当页面组ӞwidgetsQ功?br />
middleware演示
 1 from django.db import connection
 2 from django.http import HttpResponseRedirect
 3 
 4 #拦截responseh之后Q打印请求中的所有sql
 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 #拦截requesth之前Q做权限校验
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 %}
通过U定的方式,在Q意一个app下,建立一个templatetags目录Q会自动L到。(不过没有命名I间Q是一个比较猥琐的事情Q容易造成不同app下的冲突Q?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 <!-- q䆾内容可以被当成widget复用 -->
2 <table>
3     <tr>
4         <td>{{ name }}</td>
5         <td>{{ version }}</td>
6         <td>{{ data }}</td>
7     </tr>
8 </table>
9 
tagL模式{同于filter?br />

stone2083 2011-04-20 22:54 发表评论
]]>
命o行下译工具http://www.aygfsteel.com/stone2083/archive/2011/04/17/348449.htmlstone2083stone2083Sun, 17 Apr 2011 11:49:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/04/17/348449.htmlhttp://www.aygfsteel.com/stone2083/comments/348449.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/04/17/348449.html#Feedback3http://www.aygfsteel.com/stone2083/comments/commentRss/348449.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/348449.html Q利用了google 译 json api:http://translate.google.cn/translate_a/t?client=t&text=%s&hl=zh-CN&sl=%s&tl=%sQ?br />
Ҏ:
1. 自动识别中翻?q?br /> 2. 译

涉及技术:
1. python
2. urllib
3. json
4. re

截图Q?br />

对应代码Q?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'译Q\n  %s' % (data[4][0][0])
24     #step2
25     if types.ListType == type(data[1]):
26         print u'\n字典Q?/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.aygfsteel.com/stone2083/archive/2011/04/17/348447.htmlstone2083stone2083Sun, 17 Apr 2011 11:32:00 GMThttp://www.aygfsteel.com/stone2083/archive/2011/04/17/348447.htmlhttp://www.aygfsteel.com/stone2083/comments/348447.htmlhttp://www.aygfsteel.com/stone2083/archive/2011/04/17/348447.html#Feedback4http://www.aygfsteel.com/stone2083/comments/commentRss/348447.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/348447.html 利用最q项目通宵发布的空闲时间中Q写了一个命令行下的音乐播放器,以满x在linux命o下的需求?br />
播放器利用技术:
Python+GSTQ?a >http://gstreamer.freedesktop.org/modules/gst-python.htmlQ?Console解析

播放器自持操作:
1. 播放
2. 下一?br /> 3. 上一?br /> 4. 暂停
5. 查看播放列表信息
6. 查看当前播放信息
7. 停止Q退出)

看一张截图:


通过分析meliae dump出来的内存信息,差不做占?.5M内存Q算的上比较y了?br />
对应代码Q(需要安装py-gstQubuntu下:sudo apt-get install python-gst0.10Q?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下安装Python Imaging Library (PIL)http://www.aygfsteel.com/stone2083/archive/2009/10/27/299946.htmlstone2083stone2083Tue, 27 Oct 2009 09:25:00 GMThttp://www.aygfsteel.com/stone2083/archive/2009/10/27/299946.htmlhttp://www.aygfsteel.com/stone2083/comments/299946.htmlhttp://www.aygfsteel.com/stone2083/archive/2009/10/27/299946.html#Feedback1http://www.aygfsteel.com/stone2083/comments/commentRss/299946.htmlhttp://www.aygfsteel.com/stone2083/services/trackbacks/299946.html q是我最q在学习python的一丝体会,好多lib都无法通过easy_install安装Q比?Python Imaging Library (PIL)

只能通过手工安装方式安装Q?br /> Qdownload the pil_1.1.6
Qtar xvf Imaging-1.1.6.tar.gz & chmox +x setup.py
Qpython setup.py build

l果Q居Ӟ
 _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代码Q发玎ͼ
# 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

TCL_ROOT = None 修改成:TCL_ROOT = '/usr/include/tk'Q即?br />
python setup.py build
python setup.py install

成功 Q)



stone2083 2009-10-27 17:25 发表评论
]]>
վ֩ģ壺 ƶ| | Ӣɳ| Ȫ| ϴ| | ˮ| ī񹤿| »| Դ| | Ԫı| | | ʦ| | ̶| Ȩ| | ˮ| | ũ| ƽ| Ľ| | | Ӣɳ| ʻ| Ͳ| ͬ| | | | | | | | | | ޶| |