Git Product home page Git Product logo

pynet's Introduction

pynet

python的网络通信模板,V010

环境

pip install pyyaml
pip loguru
pip install paho-mqtt

测试

修改config.yaml,设置自己的mqtt服务器 启动

python main.py

然后使用mqtt客户端发送 主题:unknown/test/test/task2

"url":"https://123.jpg",
"msgId":"123"

使用

  • 将pynet扔进工程中
  • 修改messageBox.py,作为接收命令处理,例如引入
sys.path.append("..") 
from app.actionDetection import actionDetection
from net.utils import download
  • 主函数,yaml的位置根据自己配置文件位置改
from net.mqttClient import mqttClient
from net.messageBox import messageBox
import yaml

with open("./config.yaml") as config:
    cfg = yaml.safe_load(config)
netTask = mqttClient(
    cfg["mqtt"]["serverName"],
    cfg["mqtt"]["serverPassword"],
    cfg["mqtt"]["serverIp"],
    cfg["mqtt"]["serverPort"],
    cfg["mqtt"]["id"],
    cfg["mqtt"]["reciveTopic"],
)

box = messageBox()
netTask.setCallback(netStatusCb,box.input)
netTask.start()

其他

yaml

  • 大小写敏感
  • 使用缩进表示层级关系
  • 缩进时不允许使用Tab键,只允许使用空格。
  • 缩进的空格数目不重要,只要相同层级的元素左侧对齐即可
  • #表示注释,从这个字符一直到行尾,都会被解析器忽略,这个和python的注释一样

pynet's People

Contributors

lissettecarlr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.