Rss聚合
Posts
Comments

Next »

grep -rnI –include=*py personal_order_pick *

http://tinyurl.com/2elrv23

vim笔记

跳转到函数、变量定义处:
[+ctrl+i 跳转到函数、变量和#define
[+ctrl+d 跳转到#define处
ctrl+i 向前跳到前几次光标位置
ctrl+o 向后跳到后几次光标位置

函数体跳转:
[[
]]
[]
][
{}

2009-07-07 17:31 补充

如何选中括号中的内容 进行:
将光标移至括号内,按shift+v进入行选模式,然后

i{ - 选小括号中内容,不包括小括号
a{ - 选小括号中内容,包括小括号
ib - 选中括号中内容,不包括括号
ab - 选中括号中内容,包括括号
i{ - 选大括号中内容,不包括大括号
a{ - 选大括号中内容,包括大括号

:h text-objects

下面还有些相关的tips,未全部验证:
vi{ 选中{}中间的内容,不包括{}
va{ 选中{}中间内容,包括{}
vi( 选中()中间内容
vi< 选中<>中间内容
vi[ 选中[]中间内容
vit 选中中间的内容
vi” 选中””中间内容
vi’ 选中”中间的内容
vis 选中一个句子
vib 选中一个block
viw选中一个单词
vip 选中一个段落

http://www.msfn.org/board/topic/139298-winpe-30-wds-problems/

笔记

Hello,

I think you can try putting the following entries in front of the “\sources\setup.exe /wds /wdsdiscover /WdsServer:wds-server.ddpo.local” line:

Ping <IP address>

Pause

Ping <IP address>

Pause

You need to interactive with the commands in Windows PE in this scenario. If you want the process to be achieved more automatically, you can try the command “ping <IP address> -n [count]” in front of the setup.exe line. You should adjust the [count] to a large number so that there is enough time for the network to be initialized. In this way, the winpeshl.ini file should look like:

Ping <IP address> -n 100

\sources\setup.exe /wds /wdsdiscover /WdsServer:wds-server.ddpo.local

I hope this helps.

Best regards,

in soaplib/wsgi_soap.py

there are somethings like

if payload:

and this will cause a futurewarning

FutureWarning: The behavior of this method will change in future versions. Use specific ‘len(elem)’ or ‘elem is not None’ test instead.

and the invoke from java client with axis 1.4 will be failed,so we need to change it as it describes:

change

if payload:

to

if payload is not None:

then it goes well.

On Sat, Aug 29, 2009 at 10:33 AM, Maksymus007<maksymus...@gmail.com> wrote:
> On Sat, Aug 29, 2009 at 5:40 AM, Wombatpm<bruce.brombe...@gmail.com> wrote:
>>
>> For the record.  SOAPLIB 0.8.1 has a bug in generating the WSDL file
>> for Arrays.
>>
>>> <xs:complexType name="stringArray">
>>> -
>>> <xs:sequence>
>>> <xs:element minOccurs="0" maxOccurs="unbounded" type="tns:string"
>>> name="string"/>
>>> </xs:sequence>
>>> </xs:complexType>
>>
>> the type declaration should be type="xs:string"
>>
>>
>> The unicode issue is being raised by lxml inside of soaplib.  Calls
>> from .NET clients include an xml declaration and an encoding type.
>> Calls from SOAPUI do not include the xml declaration.  Under python
>> 2.6 strings are unicode so lxml raises the error.
>>
>> Question to django world:  Where is the best place to fix this bug?
>> lxml where they punted on unicode strings effectively?  Soaplib which
>> should sanitize its calls?  or Django since it knows what it received
>> over the intertubes and is in the best position to create the string
>> correctly?
>>
>> WombatPM
>>
>
> I was debugging till 3am yesterday to fix this, but not everything works now.
> I fixed this unicode bug (but didn't test this with real unicode chars)
> Generating arrays is another strange thing, 'cause my simple service
> does not use it.
> Hope today or tomorrow I fix it and then will post patch here and to
> soaplib developers
>

OK, so mi fixes are simple.
Open serializers/primitive.py

and change line 445 to

"%s:%s" % (self.serializer.get_namespace_id(), self.serializer.get_datatype()))

and

soaplib/soap.py line 118 to

root, xmlids = ElementTree.XMLID(xml_string.encode())

and this makes by services and WSDL files working both in SoapUI and
standard PHP SOAP without any problems (remember to name parameters in
PHP :) )

by the way, We also need to modify the proxy generated by .net.(References.cs),
We should remove the Namespace on the Response type.
Otherwise we will get null in every invoke.

And more, we should look some output response ,and remove the code in proxy code(Reference.cs)
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="archweb.views.Service"><SOAP-ENV:Body><get_sub_departResponse><get_sub_departResult type="tns:WsTreeArray"><WsTree><deptid xsi:type="xs:string">00882</deptid><src_desc xsi:type="xs:string">B2B</src_desc><pid xsi:type="xs:int">0</pid><desc xsi:type="xs:string">B2B</desc></WsTree><WsTree><deptid xsi:type="xs:string">00002</deptid><src_desc xsi:type="xs:string">CFO</src_desc><pid xsi:type="xs:int">0</pid><desc xsi:type="xs:string">CFO</desc></WsTree><WsTree><deptid xsi:type="xs:string">00529</deptid><src_desc xsi:type="xs:string">顾问</src_desc><pid xsi:type="xs:int">0</pid><desc xsi:type="xs:string">顾问</desc></WsTree></get_sub_departResult></get_sub_departResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
we should remove the get_sub_ResponseResult and get_sub_departResult 's decorator below
//[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
//[System.Xml.Serialization.XmlArrayItemAttribute(Form=System.Xml.Schema.XmlSchemaForm..Unqualified, IsNullable=false,Namespace="")]

django静态url

urlpatterns.append(
    url(r'^$', 'django.views.static.serve', dict(document_root='static', path='index.html')))

在使用twisted的application模式编程的时候,往往会用到twisted的log系统。该系统会将stdout重载,加入自己的机制,然而该机制对于unicode字符串的编码有一些问题。

比如在程序中print了一条string

s = u’中文’

print s

也许会很惊奇的得到下面这个异常

exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
position 60: ordinal not in range(128)

这个异常是因为

当将一个unicode对象传给print时,在内部会将该unicode对象进行一次转换,转换成本地的默认编码(这仅是个人猜测)在python中str和unicode在编码和解码过程中,如果将一个str直接编码成另一种编码,会先把str解码成unicode,采用的编码为默认编码,一般默认编码是anscii,所以在上面示例代码中第一次转换的时候会出错,当设定当前默认编码为'gbk'后,就不会出错了。

在程序的入口处,设置默认python编码,方法如下:
import sys
reload(sys)
sys.setdefaultencoding('gbk')

出自:http://blog.csdn.net/magicbreaker/archive/2008/03/09/2159289.aspx
傻B式的Vista,折磨人的操作系统收藏
用了2个月VISTA之后,我坚定的把它给卸载了。虽然还是正版的business。我一直觉得微软很人性化,98到2000,2000到XP,每次升级我都是很高兴的,可这次升级我实在太痛苦了。首先是该死的UAC,我启动一个程序它给我跳出来耀武扬威一番,刚装上系统这个功能就被我和谐了。另外启动慢,任务管理器里乱七八糟我都不认识,没启动过的程序横七竖八的在里面躺着。速度慢,打补丁时间长,对硬件要求高,兼容性差都不说啥了,你把我们已经熟悉的管理配置工具搞得面目全非算什么呢?

另外还有其他朋友总结出来的:

1、注册表变得更加臃肿了

注册表对于系统速度的影响,有点说不清道不明。微软设计注册表,给应用程序一个统一存放配置信息的地方,因为注册表在系统启动时加载,所以应用程序在启动时,使用注册表项比使用外部配置文件要快。但是如果注册表太大的话,将消耗很多的系统资源,为什么有那么多注册表清理软件存在,因为注册表垃圾太多了,不光是应用软件制造注册表垃圾,Windows自己也制造注册表垃圾。在制造注册表垃圾的软件当上,微软的软件应该是名列前矛,像Office、.NET Framework,都是写注册表达数量巨大的软件。Windows Vista的注册表,据估计至少比Windows XP臃肿一倍。

2、预装了更多的字体

Windows XP/2003只预装了60种左右的TrueType字体,到了Windows Vista,居然达到了190种之多,数量翻了三倍还多,大家应该知道,系统安装的字体越多,越影响速度。根据这篇文章的测试,安装100种字体,系统延迟增加5.33秒,Windows Vista预装190多种字体,那么系统启动速度将会增加延迟近10秒。而且问题是,这些字体我们需要吗?我们需要用这些字体写文档吗?需要用它们来做设计吗?基本上是不需要的。微软推出什么所谓的雅黑字体,号称花费上亿美元,一个字100美元,抄袭Mac OSX,也只是东施效颦而已,Windows Vista的界面,还是那么丑陋,和Mac OSX根本没法比。而且更搞笑的是,居然传出Windows Vista某个字体有缺字的情况。

3、捆绑了不止一个的.NET运行环境

这个东西是个速度杀手,而且是一般用户所不需要的。搞软件开发的都知道,.NET用来做Web应用还好,但是如果用来做桌面应用,是不好的,它实在太慢了,用户不能忍受一个启动时慢吞吞的,处理工作时延迟太久。所以到目前为止,用.NET开发的桌面应用软件仍然是少之又少,就像微软,也不敢用它来做Office的主要开发工具,最多只是在一些小功能上用到.NET。.NET的可恶之处,在于它与系统紧密结合,所以十分影响操作系统的速度。首先它在安装的时候写了太多的注册表项,至少几万条。第二点就是它在Windows启动时就加载了许多DLL,微软为了造成.NET速度快的假像,于是就在Windows启动时预先加载.NET的DLL(手法如同Office)。而且,Windows Vista还不止预装一个.NET运行环境。不信你去C:WINDOWSMicrosoft.NETFramework这个目录看一下,看有几个以版本号命名的目录。相比之下,.NET的对手Java就不是这样,在Windows平台上,它只注册了很少的DLL,而且并不在系统启动时加载。在非Windows平台上,Java还可以是绿色软件。

4、使用了更加复杂、花哨的界面技术

Windows Vista使用了所谓的Aero、Flip 3D界面技术,可惜这些东西并不能给用户带来方便,而且外观设计并不优秀,甚至比较丑陋。最可恶的一点是,它们消耗极大的系统资源。微软的界面技术,又是东施效颦,越效越恶心。没想到微软这种保守的跟屁虫公司居然敢把任务栏和标题栏做成黑色调,菜单栏做成青色,控制按钮搞得大小不一,而且尺寸加大,变成扁平状,这种设计好像很大胆,很有创意,但是不难发现,这种设计十分丑陋。如果说Mac OSX就像水晶一样美丽的话,那么Windows Vista看起来就像劣质的塑料和破麻布一般丑陋,要知道Mac OSX的界面那是6年前的设计呢。微软东施效颦算是效到底了,这回把图标也搞大了,可是那些图标除了带来系统垃圾以外,有什么用呢,谁要用你的大图标啊,再看看shell32.dll里面,新图标旧图标夹在一块,就是那么的不协调。什么Aero、Flip 3D,不仅是视觉垃圾,更是系统垃圾。

出自:http://app.arat.us/blog/?p=112

Writing an AMQP connector with Python, Twisted, Trial and txAMQP
Published on April 24th, 2009 by Dan Reverri in apparatus Tools:

In this article we’ll be writing an AMQP connector that we can re-use in future AMQP based projects. We’ll be using the Twisted testing component Trial to test our code as we develop it. To start let’s create our project directory, setup a test case, and run our first test.

mkdir connector
cd connector
mkdir test
vi test/test.py

The resulting directory structure will be:
connector/
connector/test/
connector/test/test.py

In test.py:

from twisted.trial import unittest

class AmqpConnectorTest(unittest.TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test_connector_init(self):
connector = AmqpConnector()

Now we can run our first test and enjoy the sweet, sweet failure. Note that tests are run from within the connector directory.

trial test/test.py
test
AmqpConnectorTest
test_connector_init … [ERROR]

===============================================================================
[ERROR]: test.AmqpConnectorTest.test_connector_init

Traceback (most recent call last):
File “test/test.py”, line 11, in test_connector_init
connector = AmqpConnector()
exceptions.NameError: global name ‘AmqpConnector’ is not defined
——————————————————————————-
Ran 1 tests in 0.018s

FAILED (errors=1)

Ok, let’s fix this by implementing connector.py in the connector/ directory.

class AmqpConnector():
pass

Our directory structure is now:
connector/
connector/connector.py
connector/test/
connector/test/test.py

We update our test to import the new connector and run trial.

from connector import AmqpConnector
from twisted.trial import unittest

class AmqpConnectorTest(unittest.TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test_connector_init(self):
connector = AmqpConnector()

trial test/*.py
test
AmqpConnectorTest
test_connector_init … [OK]

——————————————————————————-
Ran 1 tests in 0.003s

PASSED (successes=1)

Thinking about what our connector must do and referencing the examples provided with txAMQP we’ll implement tests for the following:

* connect
* authenticate
* channel_open

And here are the tests:

from twisted.trial import unittest
from twisted.internet.defer import inlineCallbacks
from connector import AmqpConnector

class AmqpConnectorTest(unittest.TestCase):
def setUp(self):
self.connector = AmqpConnector()

def tearDown(self):
pass

@inlineCallbacks
def test_connect(self):
connector = self.connector
yield connector.connect()

@inlineCallbacks
def test_authenticate(self):
connector = self.connector
yield connector.connect()
yield connector.authenticate()

@inlineCallbacks
def test_channel_open(self):
connector = self.connector
yield connector.connect()
yield connector.authenticate()
yield connector.channel_open()

You’ll notice that I’ve added an additional import to provide the inlineCallbacks decorator. This allows us to write asynchronous code as if it were synchronous code. I’ve also moved the connector initialization to setUp() and removed the init test. The setUp() method is run before each test and the tearDown() method is run after each test. This means that each test method will be passed a new connector object to work with (self.connector).

To get an idea of how to start writing our connector lets review the test code that comes with txAMQP. In a previous article I went over fetching txAQMP from launchpad. If you have not done that yet you should do it now. Review the file “src/txamqp/testlib.py”. We’re going to “borrow” the init() and connect() methods but re-arrange it a bit to move authentication into a separate method.

I’ve also changed the reference to the spec file. We’ll need to copy “amqp0-8.xml” into the connector directory.

from twisted.internet.defer import inlineCallbacks, Deferred
from txamqp.protocol import AMQClient, TwistedDelegate
from twisted.internet import protocol, reactor
import txamqp.spec

class AmqpConnector():
def __init__(self):
self.host = “localhost”
self.port = 5672
self.spec = “amqp0-8.xml”
self.user = “guest”
self.password = “guest”
self.vhost = “/”

@inlineCallbacks
def connect(self,host=None,port=None,spec=None,vhost=None):
host = host or self.host
port = port or self.port
spec = spec or self.spec
vhost = vhost or self.vhost

delegate = TwistedDelegate()
onConn = Deferred()
f = protocol._InstanceFactory(reactor, AMQClient(delegate, vhost, txamqp.spec.load(spec)), onConn)

self.cnx = reactor.connectTCP(host, port, f)

self.connection = yield onConn

@inlineCallbacks
def authenticate(self, user=None, password=None):
user = user or self.user
password = password or self.password

yield self.connection.start({”LOGIN”: user, “PASSWORD”: password})

@inlineCallbacks
def channel_open(self):
self.channel = yield self.connection.channel(1)
yield self.channel.channel_open()

When I first ran these tests they all failed:
1

exceptions.IOError: [Errno 2] No such file or directory: ‘amqp0-8.xml’

This stumped me for a while until I realized local files were being searched for in the “_trial_temp” directory that Trial uses. A simple fix to setUp() resolved the issue:

def setUp(self):
self.connector = AmqpConnector()
self.connector.spec = “../amqp0-8.xml”

Please remember that these tests assume you have a RabbitMQ instance running locally on port 5672 that responds to the user “guest” with the password “guest”. I only mention that because my next test run failed because RabbitMQ was not running.

With RabbitMQ running the next test run with slightly more successful:

test
AmqpConnectorTest
test_authenticate … [OK]
[ERROR]
test_channel_open … [OK]
[ERROR]
test_connect … [OK]
[ERROR]

===============================================================================
[ERROR]: test.AmqpConnectorTest.test_authenticate

Traceback (most recent call last):
Failure: twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.
Selectables:
< to (’localhost’, 5672) at 12cfdd0>
===============================================================================
[ERROR]: test.AmqpConnectorTest.test_channel_open

Traceback (most recent call last):
Failure: twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.
Selectables:
< to (’localhost’, 5672) at 149de70>
===============================================================================
[ERROR]: test.AmqpConnectorTest.test_connect

Traceback (most recent call last):
Failure: twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.
Selectables:
< to (’localhost’, 5672) at 16a0b70>
——————————————————————————-
Ran 3 tests in 1.199s

FAILED (errors=3, successes=3)

The message “Reactor was unclean.” indicates our tests are leaving an open connection. We can fix this by closing the connection in tearDown():

@inlineCallbacks
def tearDown(self):
yield self.connector.cnx.disconnect()

One final test run should give us all green lights:

test
AmqpConnectorTest
test_authenticate … [OK]
test_channel_open … [OK]
test_connect … [OK]

——————————————————————————-
Ran 3 tests in 1.195s

PASSED (successes=3)

Next »

京ICP备05029144