html中用户输入信息,由Django的view.py处理,大致用到了以下几类格式:

1. 文本框

<input type="text" name="vid" size="10" height="20">
或由bootcss修饰的
<div class="col-sm-2" >
<input type="text" class="form-control" id="username" name="username" placeholder="Username">
</div>

这种相对比较简单

version_num=request.GET.get("vid")

2. 文本框

<td width="30%" align="center" valign="top">粘帖需要发布的其他所有UI</td>
<td><textarea rows="10" cols="40" id="newui" name="newui" ></textarea></td>

这种要这样接收,返回结果是一个列表,相对比较好处理

    otherNewUI=request.GET.get("newui").encode('utf8').split("\r\n")
'''return result like this:
[u'GameStub.swf.new', u'giftui.swf', u'zhuui2.swf']
'''

3. 多选按钮,返回值也是一个列表

        <td width="30%" align="center" valign="top" >选择ini.xml中需要发布的ui</td>
<td>
<input type="checkbox" name="ui_list" value="GameStub.swf.new" />GameStub.swf.new<br />
<input type="checkbox" name="ui_list" value="giftui.swf" />giftui.swf<br />
<input type="checkbox" name="ui_list" value="zhuui2.swf" />zhuui2.swf<br />
<input type="checkbox" name="ui_list" value="vipui.swf" />vipui.swf<br />
<input type="checkbox" name="ui_list" value="giftboxui.swf" />giftboxui.swf<br />
<input type="checkbox" name="ui_list" value="baseui.swf" />baseui.swf<br />
<input type="checkbox" name="ui_list" value="xinshouui.swf" />xinshouui.swf<br />
<input type="checkbox" name="ui_list" value="buildingui.swf" />buildingui.swf<br />
<input type="checkbox" name="ui_list" value="jiuguanui.swf" />jiuguanui.swf<br />
</td>
    newUiList=request.GET.getlist("ui_list")
'''return result like this:
[u'GameStub.swf.new', u'giftui.swf', u'zhuui2.swf']
'''

4. cookie用法

写cookie,并执行跳转
response=render_to_response('verIntegration/uiPrepare.html',{"current_version":current_version,"gameName":gameName})
response.set_cookie("game",game,600)
return response 读cookie,判断cookie是否失效
if "game" in request.COOKIES:
game=request.COOKIES["game"]
gameName=CONFIG[game]['name']
print "cookie still in "
else:
gameName="未知"
print "cookie has gone"
return render_to_response('verIntegration/uiPrepare.html',{"gameName":gameName})

5. pexpect方法执行交互式操作

def pullFile(gameConfig,remoteFileName,localFileName):
#使用目录均为相对路径,绝对路径从字典中读取
cmd="scp -P %s %s@%s:%s/%s %s/%s" % (gameConfig['port'],gameConfig['user'],gameConfig['ip'],gameConfig['remote_dir'],remoteFileName,gameConfig['local_dir'],localFileName)
expect1="password: "
child = pexpect.spawn(cmd)
child.expect(expect1)
child.sendline(gameConfig['password'])
child.read()
return None

6. pexpect远程执行脚本,这个可以参考pexpect的example中的hive.py

def remoteRun(gameConfig,cmd):
srv_ip=gameConfig['ip']
srv_port=gameConfig['port']
srv_username=gameConfig['user']
srv_password=gameConfig['password']
try:
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(srv_ip,srv_port,srv_username,srv_password,timeout=5)
stdin, stdout, stderr = ssh.exec_command(cmd) outlist=[]
for out in stdout:
outlist.append(out.strip('\n'))
except Exception,e:
print "Error"
print e
return None

最新文章

  1. Android版本
  2. Socket模块学习
  3. 解决:eclipse 非正常关闭,导致无法正常启动
  4. Echarts-画堆积柱状图
  5. python学习(5)
  6. cocos2d-x 技能冷却特效
  7. c++(smart pointer)
  8. bootstrap 导航布局
  9. cocos2d-x-2.2.0_win7+vs2010
  10. PHP是什么文件? 如何打开?
  11. golang如何使用channel控制goroutine退出
  12. RestTemplate通过InputStreamResource上传文件
  13. [SCOI2016]萌萌哒
  14. 【Machine Translation】CMU的NMT教程论文:最全面的神经机器翻译学习教程
  15. 书上关于*(p++)表达式的几种变形形式的思考题
  16. Shell 与正则表达式part1
  17. Installation Guide Ubuntu 16.04
  18. Statement、PreparedStatemnt、CallableStatement
  19. Qt中容器类应该如何存储对象(对象加入到容器时会发生拷贝,容器析构时,容器内的对象也会析构)
  20. Android 7.0正式版工厂镜像下载

热门文章

  1. Vue服务端渲染 VS Vue浏览器端渲染)
  2. JSON-JSON 百科
  3. ubuntu live cd修复grub引导项
  4. Android服务Service具体解释(作用,生命周期,AIDL)系列文章-为什么须要服务呢?
  5. component-scan和annotation-driven
  6. python学习心得
  7. [GraphQL] Reuse Query Fields with GraphQL Fragments
  8. notepad++ 在每一行最后加上逗号
  9. bzoj2115【WC2001】Xor
  10. linux驱动current,引用当前进程,及task_struct(转)