ITeye博客

linkyou66的博客

linkyou66 · 共 266 篇文章

extjs之combobox setValue无效解决方法

1.combobox定义如下 mu_project_ds_add = new Ext.data.JsonStore({ url : 'GetProjectSelectList', root : 'root', autoLoad : true, fields : [ 'projectid', 'projectname' ] }); mu_combo_project_add = new Ext.form.ComboBox({ fieldLabel : '项目(*)', name : 'mu_combo_project_add', editable : true, mode : 'remote',…

2011-07-07 11:02 · 评论(0)

extjs 之Ext.data.Store变更单行记录值【修改】

1.record声明如下 machineuse_record = Ext.data.Record.create([{ name : 'id', type : 'int' }, { name : 'projectname', type : 'string' }, { name : 'projectid', type : 'int' }, { name : 'ip', type : 'string' }, { name : 'server', type : 'string' }]); 2.datastor声明如下 machineuse_list_grid_store = new Ext.data…

2011-07-07 10:12 · 评论(0)

extjs 之Ext.data.Store[Grid]操作(增删)

Ext.data.Store是extjs的数据结构。 主要用于extjs的grid和combobox等控件的数据加载和操作。实际上对grid的增删改可以通过对store的操作来控制. 例子:对grid的增删操作 A.增加一条记录 1. 首先需要定义每条record的结构,这点很重要,方便后面对记录的操作。也是很好的编程习惯 machine_record = Ext.data.Record.create([{ name : 'id', type : 'int' }, { name : 'ip', type : 'string' }, { name : 'env', type : 'string…

2011-07-05 18:57 · 评论(0)

linux 下写socket遭遇broken pipe(SIGPIPE C++)

原代码片段如下,程序在第08行报错,但是try,,,catch无法抓到错误,经过debug分析是由于收到broken pipe的信号。看来程序此时被终止了;那么我期望不被终止,该怎么做了。 01 int sendLen = 0; 02 int totalLen = 0; 03 int packSize = pack.size(); 04 while(packSize != totalLen) 05 { 06 try 07 { 08 sendLen = write(fd, const_cast<char*>(pack.c_str())+totalLen, packSize-totalLen);…

2011-05-26 16:57 · 评论(0)

python assert dict 断言@对比@之递归断言

在测试工作中经常要对两个dict进行校验,而且dict可能是多层嵌套的,为此写了个递归函数。工作方便多了 代码如下 知识点:递归函数中必须有全局变量(C++中传引用的变量),所以在python中使用字典来保存每次递归结果 如例子中的dicresult. #递归函数 def _assertdict(expobj=None,actobj=None,dicresult=None,key=None): spacestr = " " bresult = dicresult['result'] if (type(actobj) != type(expobj)): tempstr = "actobj's …

2011-05-23 17:34 · 评论(0)

linux 下python 调用C++ .so如何debug c++代码

1. 在python入口的函数写如下代码 time.sleep(50) #休眠若干秒,休眠的时间根据你操作速度定。为了有足够的时间启动gdb,并且attach到python的进程 为了防止操作过慢,程序没等gdb起来就已经跑远了,最好把要debug的代码行,另外记录到文本中 如: b cmdswitch.cpp:321 #要debug的行数 2.先查看一下python的进程号 ps -ef|grep python 记下线程号。 3.启动gdb 4.如果多线程需加入 handle SIGPIPE nostop noprint 5.attach (python进程id) 如: attach 12…

2011-05-12 18:52 · 评论(0)

linux shell编程之修改环境变量

啥都别说,上代码先 #!/bin/bash dir=${PWD} icepath=/opt/ICE/bin oraclehome=/opt/instantclient_11_2 icehome=/opt/ICE pypath=/opt/IcePy-3.2.1/python boostpath=/usr/local/boost_143 boostlib=$boostpath/lib icelib=$icehome/lib bfinder=`echo $PATH|grep $dir` echo $bfinder if [ "$bfinder" == "" ] then echo "export …

2011-05-11 11:37 · 评论(0)

linux shell之一键式安装测试框架

昨日写了一个一键式安装测试框架的脚本,因为是第一次写shell脚本遇到很多新知识,特将工作成果记录如下 知识点1:一个shell脚本如果用不同的sh执行,那么要分成多个脚本编写 如部分代码rm,echo用的是bash,在第一行使用#!/bin/bash 而spawn用的是expect,需要在第一行使用#!/usr/bin/expect -f,那么就要分开多个脚本,在母脚本中调用子脚本的形式。 知识点2:调用系统命令获取结果,需要用关键字单上引号。如key1 知识点3:可以用if [ ! -s "/usr/lib64/libmysqlclient_r.so.16" ] 来判断文件是否存在 源码…

2011-05-11 11:32 · 评论(0)

LINUX SHELL编程之远程拷贝

使用expect,进行远程拷贝 1.首先确认你的系统安装有expect which expect 如果显示如下,说明已经安装完expect,如果没有执行2 /usr/bin/expect 2. yum install expect 3.远程拷贝代码 #!/usr/bin/expect -f set password /{0j4jn*/{ spawn scp -r root@10.249.194.47:/usr/local/python /usr/local/python set timeout 300 expect "root@10.249.194.47's password:" set t…

2011-05-11 11:25 · 评论(0)

5w 留贴纪念日期

5w 留贴纪念日期

2011-05-09 14:25 · 评论(0)

C++ python 交互之 python.dict to c++ map

代码片段如下, typedef map<string ,string> smap;//要转换的目的map 转换函数 string req_update_userprofile_pack_data2(std::string workkey,PyObject *dict_user) { Py_ssize_t i, j; i = 0; PyObject *key; PyObject *value; smap m_profilelist; while (PyDict_Next(dict_user, &i, &key, &value)) //C++中遍历python的dict对象。此为关键代码 { c…

2011-05-06 20:49 · 评论(0)

linux C++ 类成员函数中创建线程,且能访问类中其他成员变量

最近刚开始玩C++,遇到一些基础问题,下面就是其中之一,将源代码公布一下方便大家查找。 linux C++ 类成员函数中创建线程,且能访问类中其他成员变量. 重点:将线程执行函数声明为非类成员函数,通过参数*arg 将this指针传入线程函数体中。 test.h #ifndef TEST_H #define TEST_H class test { public: test(); ~test(); public: int p; void sayHello(int r); void createThread(); private: int q; }; #endif test.cpp #inclu…

2011-05-04 12:49 · 评论(0)

linux C++ 类成员函数中创建线程,且能访问类中其他成员变量

最近刚开始玩C++,遇到一些基础问题,下面就是其中之一,将源代码公布一下方便大家查找。 linux C++ 类成员函数中创建线程,且能访问类中其他成员变量. 重点:将线程执行函数声明为非类成员函数,通过参数*arg 将this指针传入线程函数体中。 test.h #ifndef TEST_H #define TEST_H class test { public: test(); ~test(); public: int p; void sayHello(int r); void createThread(); private: int q; }; #endif test.cpp #inclu…

2011-05-04 12:49 · 评论(0)

python 如何传递字典型变量(不定参数)给c++

今天遇到一个难题,python要调用c++一个函数 c++函数是可变长的变量如add(int cmd,...) 然后再c++中使用va_list取得变长参数。 那么python 该如何调用该函数呢。弄了半天也没有发现boost.python如何支持该类型的参数。 后来一想,python dict不是就是可变长的参数吗,里边放什么都可以。 那么问题就转化问如何传递dict给c++。 贴源码如下: 1.src.cpp #include <iostream> #include <string> #include<stdarg.h> #include <Python.h> using namespa…

2011-04-29 13:50 · 评论(0)

python 如何传递字典型变量(不定参数)给c++

今天遇到一个难题,python要调用c++一个函数 c++函数是可变长的变量如add(int cmd,...) 然后再c++中使用va_list取得变长参数。 那么python 该如何调用该函数呢。弄了半天也没有发现boost.python如何支持该类型的参数。 后来一想,python dict不是就是可变长的参数吗,里边放什么都可以。 那么问题就转化问如何传递dict给c++。 贴源码如下: 1.src.cpp #include <iostream> #include <string> #include<stdarg.h> #include <Python.h> using namespa…

2011-04-29 13:50 · 评论(0)