手把手教你学网站建设,拼多多采用了哪些网络营销方式,网站制作建设公司,沈阳网势科技有限公司怎么样部署与升级-会议的远程安装 技术路线界面规划flaskAPI以及socketio.emit shellout浏览器和后端交互到处是偶遇 技术路线
运行的基础是Flask-Soketio, 并借鉴了后台运行系统指令的代码 和scrncpy项目,app安装的脚本 #mermaid-svg-8H9rbzbpgpnAXfA3 {font-family:trebuche… 部署与升级-会议的远程安装 技术路线界面规划flaskAPI以及socketio.emit shellout浏览器和后端交互到处是偶遇 技术路线
运行的基础是Flask-Soketio, 并借鉴了后台运行系统指令的代码 和scrncpy项目,app安装的脚本 #mermaid-svg-8H9rbzbpgpnAXfA3 {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 .error-icon{fill:#552222;}#mermaid-svg-8H9rbzbpgpnAXfA3 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-8H9rbzbpgpnAXfA3 .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-8H9rbzbpgpnAXfA3 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-8H9rbzbpgpnAXfA3 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-8H9rbzbpgpnAXfA3 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-8H9rbzbpgpnAXfA3 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-8H9rbzbpgpnAXfA3 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-8H9rbzbpgpnAXfA3 .marker.cross{stroke:#333333;}#mermaid-svg-8H9rbzbpgpnAXfA3 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-8H9rbzbpgpnAXfA3 .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-8H9rbzbpgpnAXfA3 text.actortspan{fill:black;stroke:none;}#mermaid-svg-8H9rbzbpgpnAXfA3 .actor-line{stroke:grey;}#mermaid-svg-8H9rbzbpgpnAXfA3 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 .sequenceNumber{fill:white;}#mermaid-svg-8H9rbzbpgpnAXfA3 #sequencenumber{fill:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 .messageText{fill:#333;stroke:#333;}#mermaid-svg-8H9rbzbpgpnAXfA3 .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-8H9rbzbpgpnAXfA3 .labelText,#mermaid-svg-8H9rbzbpgpnAXfA3 .labelTexttspan{fill:black;stroke:none;}#mermaid-svg-8H9rbzbpgpnAXfA3 .loopText,#mermaid-svg-8H9rbzbpgpnAXfA3 .loopTexttspan{fill:black;stroke:none;}#mermaid-svg-8H9rbzbpgpnAXfA3 .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-8H9rbzbpgpnAXfA3 .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-8H9rbzbpgpnAXfA3 .noteText,#mermaid-svg-8H9rbzbpgpnAXfA3 .noteTexttspan{fill:black;stroke:none;}#mermaid-svg-8H9rbzbpgpnAXfA3 .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-8H9rbzbpgpnAXfA3 .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-8H9rbzbpgpnAXfA3 .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-8H9rbzbpgpnAXfA3 .actorPopupMenu{position:absolute;}#mermaid-svg-8H9rbzbpgpnAXfA3 .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-8H9rbzbpgpnAXfA3 .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-8H9rbzbpgpnAXfA3 .actor-man circle,#mermaid-svg-8H9rbzbpgpnAXfA3 line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-8H9rbzbpgpnAXfA3 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 网页浏览器 router() subprocess.Popen socketio 你好 打开连接(安装,卸载)? $.get(/api/connect(install..)以及 onmessage(shellout) 连接(安装,卸载) 可能时间太长 适合放thread中执行., callback,emmit shellout 已经执行,结果发送. 连接(安装,卸载)的回馈来了! 网页浏览器 router() subprocess.Popen socketio 界面规划 固定标题不会滚动消失,texarea滚动回馈,断开连接,释放,以让其他管理机使用.
head
stylebody {padding-top: 100px; /* Required padding for .navbar-fixed-top */}/stylemeta charsetUTF-8title部署和撤销/titlelink href/static/bootstrap.min1.css relstylesheet script typetext/javascript src/js/socket.io.min.js/scriptscript typetext/javascript src/js/jquery.min.js/scriptbodynav classnavbar navbar-default navbar-fixed-top rolenavigationdiv classcontainer-fluiddiv classnavbar-headera classnavbar-brand href#运行结果:/a/divdivform classnavbar-form navbar-left rolesearch styleheight: 80px;width:80%; div classform-group styleheight: 80px;width:80%; textarea idshstatus styleheight: 80px;width:100%; /textarea /divbutton typebutton classbtn btn-default onclick$.get(/api/disconnect)断开连接/button/li /button/form/div/nav table classtable
caption classh4 部署和撤销/caption
theadtrth点位名/thth状态/thth更新时刻/thth操作/ththIP/th
tbody idmytable/table
/body/html
初始化列表
$.get(/list function (stas)
{Object.keys( stas).forEach(function(key) {$(#mytable).append(trtd${stas[key].sta}/td.........tdbutton onclick$.get(/api/myconnect/${stas[key].sta})连接/button/td...}})flaskAPI以及socketio.emit ‘shellout’
分二部分.执行和回馈 参考关于socketio的配置
from checkout.she import sh
.......
app.route(/api/myinstall/sta)
def install(sta):if ip4sta(sta):targetip4sta(sta):Portsh.install(target)return json.dumps(installip4sta(sta))
app.route(/api/myconnect/sta)
def connect(sta):if ip4sta(sta):targetip4sta(sta):Portsh.connect(target)return json.dumps(installip4sta(sta))
app.route(/api/myuninstall/sta)
def uninstall(sta):if ip4sta(sta):targetip4sta(sta):Portsh.uninstall(target)return json.dumps(uninstallip4sta(sta))
app.route(/api/mydisconnect)
def disconnect():sh.disconnect()return OK
def shellout(msg):socketio.emit(shellout,msg,namespace/chat)
sh.callbackshellout #运行本地shell的py 上代码
# 存储ping数据的redis 1号库
#from redis import StrictRedis
import subprocess
import os
import threading
#redis_sh StrictRedis(host192.168.1.231, port6379, decode_responsesTrue, db2)callbackprint
def sh(command, callback):cwdos.getcwd()if (not cwd.endswith(she)):cwdos.getcwd()/shep subprocess.Popen(command, shellTrue, stdoutsubprocess.PIPE, stderrsubprocess.STDOUT,cwdcwd)callback(command)for line in iter(p.stdout.readline, b):callback(line.decode())def run(command):global callbacktry:# 起线程执行命令task threading.Thread(targetsh, args(command, callback))task.start()except Exception as e:print(e)def install(target):command ./sndcpy.sh %s i % targetrun(command)
def uninstall(target):command [./adb -s %s remount % target,./adb -s %s uninstall com.tumuyan.fixedplay % target,./adb -s %s shell mv /tmp/Launcher_1.apk /system/app/ % target]for com in command:run(com )
def connect(target):command ./adb connect %s % targetrun(command)
def disconnect():run(./adb disconnect)
if __name____main__:ipip:Portuninstall(ip) 根据网友关于redis,flask ip的代码做出的调节,
redis换成socketio,简化前端的逻辑,和信息的处理.callback了所有.flask的threading,转移到了sh.py其中一个函数,让所有command共用.对目录进行了分级,subprocess.Popen使用了cwd参数.一般来说,flask的当前路径在上一级. 附加: 针对adb connect等待时间过长,使用ping3判断在线 pip install ping3
app.route(/api/connect/sta)
def connect(sta):if ip4sta(sta):targetip4sta(sta)tgpping3.ping( target,timeout1) if tgp is not False and tgp is not None:shellout(ping SUUCESS, 连接中--%s\n %target)sh.connect(target:5555)else:shellout(ping FAIL,设备离线 %s\n %target)shellout(请联系[%s],开机后再测试!\n%sta)return json.dumps(connecttarget)
浏览器和后端交互
以前文章的内容 取得所有当前信息表格,布局页面. 取得当前已经安装app的客户端信息,方便查看安装结果 定制功能按钮,获取回馈消息通知 onclick$.get(/api/mydisconnect)---断开连接...button onclick$.get(/api/myconnect/${stas[key].sta})连接/button 取得io的消息shellout var socket io.connect(http://ip:port/chat );socket.on(shellout,handleshell);function handleshell(msg){var text document.getElementById(shstatus);text.scrollTop text.scrollHeight; //滚动到最后$(#shstatus).text($(#shstatus).text()msg)}到处是偶遇
那天在逛微信,推送了一个开源手机同屏控制的项目QTscncpy.结果会议机版本低4个数字,无法安装.在ubuntu下,才25M.一个前端,窗口程序,一个adb.一个apk,一段安装脚本.前端在调试时的输出代码,有不错的监测,一直的等待安装后的启动,可惜我这里都是错误. 在很多天无聊之后,浏览了一下它的内容. 如下 #!/bin/bashecho Begin Runing...
SNDCPY_PORT28200
SNDCPY_APKsndcpy.apk
ADB./adbserial
if [[ $# -ge 2 ]]
thenserial-s $1SNDCPY_PORT$2
fiecho Waiting for device $1...
$ADB $serial wait-for-device
echo Find device $1sndcpy_installed$($ADB $serial shell pm path com.rom1v.sndcpy)
if [[ $sndcpy_installed ]]; thenecho Install $SNDCPY_APK... $ADB $serial uninstall com.rom1v.sndcpy || echo uninstall failed$ADB $serial install -t -r -g $SNDCPY_APKecho Install $SNDCPY_APK success
fiecho Request PROJECT_MEDIA permission...
$ADB $serial shell appops set com.rom1v.sndcpy PROJECT_MEDIA allowecho Forward port $SNDCPY_PORT...
$ADB $serial forward tcp:$SNDCPY_PORT localabstract:sndcpyecho Start $SNDCPY_APK...
$ADB $serial shell am start com.rom1v.sndcpy/.MainActivitywhile ((1))
doecho Waiting $SNDCPY_APK start...sleep 0.1sndcpy_started$($ADB shell ps | grep com.rom1v.sndcpy)if [[ $sndcpy_started ! ]]; thenbreakfi
doneecho Ready playing...
短短一段代码, 提供了,一客户监测等待, 安装后的赋权,启动后的观测.几乎涵盖了我需要的所有,所有唯一目前我没有的就是web端的便捷.于是把以前搁置的功能补齐了.