Git使用教程:轻松掌握版本控制利器,提升开发效率!-(3)GitHub高级用法之GitHub Actions

GitHub Actions简介

在 GitHub Actions 的仓库中自动化、自定义和执行软件开发工作流程。 您可以发现、创建和共享操作以执行您喜欢的任何作业(包括 CI/CD),并将操作合并到完全自定义的工作流程中。

作为一个在工作中负责软件架构搭建和维护的开发者,作者对于CI/CD很熟悉,很长的一段时间内都是使用Jenkins来完成整个流程的搭建,Jenkins的优势是显而易见的,运行稳定,扩展性强,可视化界面操作,强大的社区支持,各方面似乎都很完美,可是,对于作者来说,有一个问题就是,Jenkins必须有设置在云服务器上或者是搭建一个拥有公网ip的服务器(或者在局域网服务器上做内网穿透),而GitHub Actions就完美的解决了这个问题,它不仅提供了免费的云服务器,支持各种操作系统的虚拟机,而且还不需要安装Jenkins这类的软件,只需要写workflow的脚本就可以实现CI/CD的功能。

创建GitHub Actions的workflow文件

GitHub Actions workflow 是可配置的自动化过程,由一个或多个作业组成。 您必须创建 YAML 文件来定义workflow配置。

1. worklow文件格式

工作流文件使用 YAML 语法,并且必须具有 .yml 或 .yaml 文件扩展名,下面是一个例子:

build.yaml

name: GitHub Actions Test workflow
on: push

jobs:
 my-job:
   name: Job example
   runs-on: windows-2019
   steps:
   - uses: actions/checkout@v4
   - uses: actions/setup-python@v4
     with:
       python-version: '3.11'
   - run: python --version
   - run: python .\XTest.py 

2. workflow文件存放

按照GitHub的文件夹要求,我们要把 build.yaml放在工程子目录的.github/workflows文件夹里面

PS D:\test> tree /f
卷 新加卷 的文件夹 PATH 列表
卷序列号为 000001EA 4C26:E148
D:.
│  README.md
│  XTest.py
│  
└─.github
   └─workflows
           build.yaml

3. 测试用python脚本

为了测试整个流程是否运行完美,我们编写一个在打印Windows用户名的python脚本

XTest.py

import getpass
username = getpass.getuser()
print("Windows username: "+username)

4. 把python脚本和workflow文件都push到远程仓库中

PS D:\test> git status
Your branch is up to date with 'origin/main'.

Untracked files:
 (use "git add <file>..." to include in what will be committed)
       .github/
       XTest.py

nothing added to commit but untracked files present (use "git add" to track)
PS D:\test> git add .
PS D:\test> git commit -m "Add github workflow yaml file and test script"
[main dbfe33b] Add github workflow yaml file and test script
2 files changed, 17 insertions(+)
create mode 100644 .github/workflows/build.yaml
create mode 100644 XTest.py
PS D:\test> git push origin HEAD
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 665 bytes | 221.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:xxx/GitHubTest.git
  c22855b..dbfe33b  HEAD -> main

5. 查看GitHub的对应仓库的Actions

图中我们可以看到我们刚刚push好的commit Add github workflow yaml file and test script仓库actions点击进去就可以看到整个workflow,脚本已经打印了Windows用户的 Username:runneradmin在这里插入图片描述

workflow高级用法

利用前面的例程,我们演示了GitHub workflow的基本用法,明白了原理,我们就可以利用其来完成项目的CI/CD流程,下面就是我在前文
基于python的EC800物联网mqtt协议开发指南:从入门到实战(1)
中用到的流程,也在此分析给大家,代码包也已经上传到csdn上,欢迎大家下载探讨mqtt工程下载

name: mqtt device interface
on: push

jobs:
  my-job:
    name: mqtt device interface build && Release
    runs-on: windows-2019
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v4
      with:
        python-version: '3.11'
    - run: python -m pip install paho-mqtt==1.6.1
    - run: python -m pip install pyinstaller==6.5.0
    - run: python -m pip install pyserial==3.5
    - run: python --version
    - name: build project
      run: |
        .\build.bat
        .\mqtt_main.exe mqtt_device_air780.xml
        .\mqtt_main.exe mqtt_device_ec800_usb.xml
        .\mqtt_main.exe mqtt_device_pyclient.xml

打印出来的流程如下
在这里插入图片描述

2024-04-02T08:09:50.7088720Z Current runner version: '2.314.1'
2024-04-02T08:09:50.7168301Z ##[group]Operating System
2024-04-02T08:09:50.7169078Z Microsoft Windows Server 2019
2024-04-02T08:09:50.7169542Z 10.0.17763
2024-04-02T08:09:50.7169818Z Datacenter
2024-04-02T08:09:50.7170140Z ##[endgroup]
2024-04-02T08:09:50.7170471Z ##[group]Runner Image
2024-04-02T08:09:50.7170820Z Image: windows-2019
2024-04-02T08:09:50.7171154Z Version: 20240322.1.0
2024-04-02T08:09:50.7172094Z Included Software: https://github.com/actions/runner-images/blob/win19/20240322.1/images/windows/Windows2019-Readme.md
2024-04-02T08:09:50.7173410Z Image Release: https://github.com/actions/runner-images/releases/tag/win19%2F20240322.1
2024-04-02T08:09:50.7174185Z ##[endgroup]
2024-04-02T08:09:50.7174563Z ##[group]Runner Image Provisioner
2024-04-02T08:09:50.7175007Z 2.0.361.1
2024-04-02T08:09:50.7175297Z ##[endgroup]
2024-04-02T08:09:50.7176232Z ##[group]GITHUB_TOKEN Permissions
2024-04-02T08:09:50.7177947Z Contents: read
2024-04-02T08:09:50.7178397Z Metadata: read
2024-04-02T08:09:50.7178772Z Packages: read
2024-04-02T08:09:50.7179091Z ##[endgroup]
2024-04-02T08:09:50.7182087Z Secret source: Actions
2024-04-02T08:09:50.7182620Z Prepare workflow directory
2024-04-02T08:09:50.7828732Z Prepare all required actions
2024-04-02T08:09:50.7992238Z Getting action download info
2024-04-02T08:09:50.9598908Z Download action repository 'actions/checkout@v4' (SHA:b4ffde65f46336ab88eb53be808477a3936bae11)
2024-04-02T08:09:51.0865994Z Download action repository 'actions/setup-python@v4' (SHA:65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236)
2024-04-02T08:09:51.4753317Z Complete job name: mqtt device interface build && Release
2024-04-02T08:09:51.5971718Z ##[group]Run actions/checkout@v4
2024-04-02T08:09:51.5972267Z with:
2024-04-02T08:09:51.5972574Z   repository: ZhaoBoxiong/mqtt_uart
2024-04-02T08:09:51.5973215Z   token: ***
2024-04-02T08:09:51.5973484Z   ssh-strict: true
2024-04-02T08:09:51.5973792Z   persist-credentials: true
2024-04-02T08:09:51.5974131Z   clean: true
2024-04-02T08:09:51.5974429Z   sparse-checkout-cone-mode: true
2024-04-02T08:09:51.5974807Z   fetch-depth: 1
2024-04-02T08:09:51.5975074Z   fetch-tags: false
2024-04-02T08:09:51.5975350Z   show-progress: true
2024-04-02T08:09:51.5975632Z   lfs: false
2024-04-02T08:09:51.5975873Z   submodules: false
2024-04-02T08:09:51.5976161Z   set-safe-directory: true
2024-04-02T08:09:51.5976485Z ##[endgroup]
2024-04-02T08:09:53.3477596Z Syncing repository: ZhaoBoxiong/mqtt_uart
2024-04-02T08:09:53.3479782Z ##[group]Getting Git version info
2024-04-02T08:09:53.3480406Z Working directory is 'D:\a\mqtt_uart\mqtt_uart'
2024-04-02T08:09:53.3481503Z [command]"C:\Program Files\Git\bin\git.exe" version
2024-04-02T08:09:53.3482190Z git version 2.44.0.windows.1
2024-04-02T08:09:53.3483955Z ##[endgroup]
2024-04-02T08:09:53.3499337Z Temporarily overriding HOME='D:\a\_temp\982c168d-df6d-4ae6-8d70-23a9dd37b9a9' before making global git config changes
2024-04-02T08:09:53.3501040Z Adding repository directory to the temporary git global config as a safe directory
2024-04-02T08:09:53.3502589Z [command]"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\mqtt_uart\mqtt_uart
2024-04-02T08:09:53.3504494Z Deleting the contents of 'D:\a\mqtt_uart\mqtt_uart'
2024-04-02T08:09:53.3505558Z ##[group]Initializing the repository
2024-04-02T08:09:53.3506394Z [command]"C:\Program Files\Git\bin\git.exe" init D:\a\mqtt_uart\mqtt_uart
2024-04-02T08:09:53.3507466Z Initialized empty Git repository in D:/a/mqtt_uart/mqtt_uart/.git/
2024-04-02T08:09:53.3509488Z [command]"C:\Program Files\Git\bin\git.exe" remote add origin https://github.com/ZhaoBoxiong/mqtt_uart
2024-04-02T08:09:53.3511349Z ##[endgroup]
2024-04-02T08:09:53.3512099Z ##[group]Disabling automatic garbage collection
2024-04-02T08:09:53.3513050Z [command]"C:\Program Files\Git\bin\git.exe" config --local gc.auto 0
2024-04-02T08:09:53.3514731Z ##[endgroup]
2024-04-02T08:09:53.3515388Z ##[group]Setting up auth
2024-04-02T08:09:53.3516346Z [command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp core\.sshCommand
2024-04-02T08:09:53.3522571Z [command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c \"git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :\""
2024-04-02T08:09:53.6063555Z [command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2024-04-02T08:09:53.6355434Z [command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c \"git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :\""
2024-04-02T08:09:54.1032950Z [command]"C:\Program Files\Git\bin\git.exe" config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ***"
2024-04-02T08:09:54.1308259Z ##[endgroup]
2024-04-02T08:09:54.1309252Z ##[group]Fetching the repository
2024-04-02T08:09:54.1326756Z [command]"C:\Program Files\Git\bin\git.exe" -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +bd75bbaf2b2a49242f018b00ba3ee0796e6e954f:refs/remotes/origin/master
2024-04-02T08:09:56.6178943Z From https://github.com/ZhaoBoxiong/mqtt_uart
2024-04-02T08:09:56.6192793Z  * [new ref]         bd75bbaf2b2a49242f018b00ba3ee0796e6e954f -> origin/master
2024-04-02T08:09:56.6355371Z ##[endgroup]
2024-04-02T08:09:56.6377330Z ##[group]Determining the checkout info
2024-04-02T08:09:56.6396536Z ##[endgroup]
2024-04-02T08:09:56.6407240Z ##[group]Checking out the ref
2024-04-02T08:09:56.6414491Z [command]"C:\Program Files\Git\bin\git.exe" checkout --progress --force -B master refs/remotes/origin/master
2024-04-02T08:09:56.8069904Z branch 'master' set up to track 'origin/master'.
2024-04-02T08:09:56.8082403Z Reset branch 'master'
2024-04-02T08:09:56.8111576Z ##[endgroup]
2024-04-02T08:09:56.8425510Z [command]"C:\Program Files\Git\bin\git.exe" log -1 --format='%H'
2024-04-02T08:09:56.8654447Z 'bd75bbaf2b2a49242f018b00ba3ee0796e6e954f'
2024-04-02T08:09:56.9166931Z ##[group]Run actions/setup-python@v4
2024-04-02T08:09:56.9167444Z with:
2024-04-02T08:09:56.9167727Z   python-version: 3.11
2024-04-02T08:09:56.9168027Z   check-latest: false
2024-04-02T08:09:56.9168479Z   token: ***
2024-04-02T08:09:56.9168778Z   update-environment: true
2024-04-02T08:09:56.9169103Z   allow-prereleases: false
2024-04-02T08:09:56.9169428Z ##[endgroup]
2024-04-02T08:09:57.1080310Z ##[group]Installed versions
2024-04-02T08:09:57.1250041Z Successfully set up CPython (3.11.8)
2024-04-02T08:09:57.1252345Z ##[endgroup]
2024-04-02T08:09:57.1515611Z ##[group]Run python -m pip install paho-mqtt==1.6.1
2024-04-02T08:09:57.1516304Z [36;1mpython -m pip install paho-mqtt==1.6.1[0m
2024-04-02T08:09:57.1583596Z shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
2024-04-02T08:09:57.1584151Z env:
2024-04-02T08:09:57.1584552Z   pythonLocation: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:09:57.1585278Z   PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.11.8\x64/lib/pkgconfig
2024-04-02T08:09:57.1585908Z   Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:09:57.1586497Z   Python2_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:09:57.1587090Z   Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:09:57.1587530Z ##[endgroup]
2024-04-02T08:10:18.8744253Z Collecting paho-mqtt==1.6.1
2024-04-02T08:10:19.1159382Z   Downloading paho-mqtt-1.6.1.tar.gz (99 kB)
2024-04-02T08:10:19.2078389Z      ---------------------------------------- 99.4/99.4 kB 1.1 MB/s eta 0:00:00
2024-04-02T08:10:19.3218524Z   Installing build dependencies: started
2024-04-02T08:10:22.7118464Z   Installing build dependencies: finished with status 'done'
2024-04-02T08:10:22.7135939Z   Getting requirements to build wheel: started
2024-04-02T08:10:23.4608372Z   Getting requirements to build wheel: finished with status 'done'
2024-04-02T08:10:23.4640916Z   Installing backend dependencies: started
2024-04-02T08:10:24.9842561Z   Installing backend dependencies: finished with status 'done'
2024-04-02T08:10:24.9865793Z   Preparing metadata (pyproject.toml): started
2024-04-02T08:10:25.3646340Z   Preparing metadata (pyproject.toml): finished with status 'done'
2024-04-02T08:10:25.3719321Z Building wheels for collected packages: paho-mqtt
2024-04-02T08:10:25.3745244Z   Building wheel for paho-mqtt (pyproject.toml): started
2024-04-02T08:10:25.7311588Z   Building wheel for paho-mqtt (pyproject.toml): finished with status 'done'
2024-04-02T08:10:25.7341265Z   Created wheel for paho-mqtt: filename=paho_mqtt-1.6.1-py3-none-any.whl size=65648 sha256=d1ef2da66483df0418d78c2ba51a366dd60323083a4784fed6bb5066ead34643
2024-04-02T08:10:25.7343869Z   Stored in directory: c:\users\runneradmin\appdata\local\pip\cache\wheels\29\ea\a5\ba9a63aaf4cd4e16e8a87ee31fb4d11b04ff5e1735d312619a
2024-04-02T08:10:25.7405091Z Successfully built paho-mqtt
2024-04-02T08:10:25.7737840Z Installing collected packages: paho-mqtt
2024-04-02T08:10:25.8620555Z Successfully installed paho-mqtt-1.6.1
2024-04-02T08:10:26.2644407Z ##[group]Run python -m pip install pyinstaller==6.5.0
2024-04-02T08:10:26.2644979Z [36;1mpython -m pip install pyinstaller==6.5.0[0m
2024-04-02T08:10:26.2679124Z shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
2024-04-02T08:10:26.2679572Z env:
2024-04-02T08:10:26.2679901Z   pythonLocation: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:26.2680497Z   PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.11.8\x64/lib/pkgconfig
2024-04-02T08:10:26.2681088Z   Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:26.2681603Z   Python2_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:26.2682122Z   Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:26.2682518Z ##[endgroup]
2024-04-02T08:10:27.3571533Z Collecting pyinstaller==6.5.0
2024-04-02T08:10:27.6165865Z   Downloading pyinstaller-6.5.0-py3-none-win_amd64.whl.metadata (8.3 kB)
2024-04-02T08:10:27.6449086Z Requirement already satisfied: setuptools>=42.0.0 in c:\hostedtoolcache\windows\python\3.11.8\x64\lib\site-packages (from pyinstaller==6.5.0) (65.5.0)
2024-04-02T08:10:27.6733033Z Collecting altgraph (from pyinstaller==6.5.0)
2024-04-02T08:10:27.6942905Z   Downloading altgraph-0.17.4-py2.py3-none-any.whl.metadata (7.3 kB)
2024-04-02T08:10:27.7624507Z Collecting pyinstaller-hooks-contrib>=2024.3 (from pyinstaller==6.5.0)
2024-04-02T08:10:27.7836535Z   Downloading pyinstaller_hooks_contrib-2024.3-py2.py3-none-any.whl.metadata (16 kB)
2024-04-02T08:10:27.8498847Z Collecting packaging>=22.0 (from pyinstaller==6.5.0)
2024-04-02T08:10:27.8711143Z   Downloading packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
2024-04-02T08:10:27.9200435Z Collecting pefile>=2022.5.30 (from pyinstaller==6.5.0)
2024-04-02T08:10:27.9408918Z   Downloading pefile-2023.2.7-py3-none-any.whl.metadata (1.4 kB)
2024-04-02T08:10:27.9815346Z Collecting pywin32-ctypes>=0.2.1 (from pyinstaller==6.5.0)
2024-04-02T08:10:28.0022054Z   Downloading pywin32_ctypes-0.2.2-py3-none-any.whl.metadata (3.8 kB)
2024-04-02T08:10:28.0804165Z Downloading pyinstaller-6.5.0-py3-none-win_amd64.whl (1.3 MB)
2024-04-02T08:10:28.2124981Z    ---------------------------------------- 1.3/1.3 MB 10.4 MB/s eta 0:00:00
2024-04-02T08:10:28.2341561Z Downloading packaging-24.0-py3-none-any.whl (53 kB)
2024-04-02T08:10:28.2601732Z    ---------------------------------------- 53.5/53.5 kB 2.7 MB/s eta 0:00:00
2024-04-02T08:10:28.2810736Z Downloading pefile-2023.2.7-py3-none-any.whl (71 kB)
2024-04-02T08:10:28.3031372Z    ---------------------------------------- 71.8/71.8 kB 3.8 MB/s eta 0:00:00
2024-04-02T08:10:28.3248562Z Downloading pyinstaller_hooks_contrib-2024.3-py2.py3-none-any.whl (329 kB)
2024-04-02T08:10:28.3478494Z    --------------------------------------- 329.0/329.0 kB 19.9 MB/s eta 0:00:00
2024-04-02T08:10:28.3727675Z Downloading pywin32_ctypes-0.2.2-py3-none-any.whl (30 kB)
2024-04-02T08:10:28.4101390Z Downloading altgraph-0.17.4-py2.py3-none-any.whl (21 kB)
2024-04-02T08:10:28.5058612Z Installing collected packages: altgraph, pywin32-ctypes, pefile, packaging, pyinstaller-hooks-contrib, pyinstaller
2024-04-02T08:10:34.1575158Z Successfully installed altgraph-0.17.4 packaging-24.0 pefile-2023.2.7 pyinstaller-6.5.0 pyinstaller-hooks-contrib-2024.3 pywin32-ctypes-0.2.2
2024-04-02T08:10:34.4543477Z ##[group]Run python -m pip install pyserial==3.5
2024-04-02T08:10:34.4544025Z [36;1mpython -m pip install pyserial==3.5[0m
2024-04-02T08:10:34.4579923Z shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
2024-04-02T08:10:34.4580367Z env:
2024-04-02T08:10:34.4580692Z   pythonLocation: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:34.4581286Z   PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.11.8\x64/lib/pkgconfig
2024-04-02T08:10:34.4581872Z   Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:34.4582411Z   Python2_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:34.4582923Z   Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:34.4583327Z ##[endgroup]
2024-04-02T08:10:35.5954175Z Collecting pyserial==3.5
2024-04-02T08:10:35.8453684Z   Downloading pyserial-3.5-py2.py3-none-any.whl.metadata (1.6 kB)
2024-04-02T08:10:35.8858257Z Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
2024-04-02T08:10:35.9801171Z    ---------------------------------------- 90.6/90.6 kB 1.0 MB/s eta 0:00:00
2024-04-02T08:10:36.0479799Z Installing collected packages: pyserial
2024-04-02T08:10:36.2110637Z Successfully installed pyserial-3.5
2024-04-02T08:10:36.4738222Z ##[group]Run python --version
2024-04-02T08:10:36.4738654Z [36;1mpython --version[0m
2024-04-02T08:10:36.4772972Z shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
2024-04-02T08:10:36.4773421Z env:
2024-04-02T08:10:36.4773750Z   pythonLocation: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.4774356Z   PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.11.8\x64/lib/pkgconfig
2024-04-02T08:10:36.4774943Z   Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.4775467Z   Python2_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.4775977Z   Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.4776382Z ##[endgroup]
2024-04-02T08:10:36.7642382Z Python 3.11.8
2024-04-02T08:10:36.8752868Z ##[group]Run .\build.bat
2024-04-02T08:10:36.8753265Z [36;1m.\build.bat[0m
2024-04-02T08:10:36.8753590Z [36;1m.\mqtt_main.exe mqtt_device_air780.xml[0m
2024-04-02T08:10:36.8754016Z [36;1m.\mqtt_main.exe mqtt_device_ec800_usb.xml[0m
2024-04-02T08:10:36.8754447Z [36;1m.\mqtt_main.exe mqtt_device_pyclient.xml[0m
2024-04-02T08:10:36.8790965Z shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
2024-04-02T08:10:36.8791748Z env:
2024-04-02T08:10:36.8792315Z   pythonLocation: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.8793053Z   PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.11.8\x64/lib/pkgconfig
2024-04-02T08:10:36.8793649Z   Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.8794178Z   Python2_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.8794693Z   Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.8\x64
2024-04-02T08:10:36.8795096Z ##[endgroup]
2024-04-02T08:10:37.1595476Z 
2024-04-02T08:10:37.1596634Z D:\a\mqtt_uart\mqtt_uart>pyinstaller -F .\mqtt_main.py -n mqtt_main.exe 
2024-04-02T08:10:39.1138161Z 1835 INFO: PyInstaller: 6.5.0, contrib hooks: 2024.3
2024-04-02T08:10:39.1139307Z 1835 INFO: Python: 3.11.8
2024-04-02T08:10:39.1212686Z 1851 INFO: Platform: Windows-10-10.0.17763-SP0
2024-04-02T08:10:39.1217651Z 1851 INFO: wrote D:\a\mqtt_uart\mqtt_uart\mqtt_main.exe.spec
2024-04-02T08:10:39.1250166Z 1851 INFO: Extending PYTHONPATH with paths
2024-04-02T08:10:39.1251317Z ['D:\\a\\mqtt_uart\\mqtt_uart']
2024-04-02T08:10:39.2852348Z 2007 INFO: checking Analysis
2024-04-02T08:10:39.2853526Z 2007 INFO: Building Analysis because Analysis-00.toc is non existent
2024-04-02T08:10:39.2854743Z 2007 INFO: Initializing module dependency graph...
2024-04-02T08:10:39.3052762Z 2023 INFO: Caching module graph hooks...
2024-04-02T08:10:39.3175970Z 2038 INFO: Analyzing base_library.zip ...
2024-04-02T08:10:40.7343222Z 3461 INFO: Loading module hook 'hook-heapq.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks'...
2024-04-02T08:10:40.9909087Z 3711 INFO: Loading module hook 'hook-encodings.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks'...
2024-04-02T08:10:43.3516014Z 6068 INFO: Loading module hook 'hook-pickle.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks'...
2024-04-02T08:10:46.7247439Z 9447 INFO: Caching module dependency graph...
2024-04-02T08:10:46.8198734Z 9541 INFO: Running Analysis Analysis-00.toc
2024-04-02T08:10:46.8199930Z 9541 INFO: Looking for Python shared library...
2024-04-02T08:10:46.9109463Z 9635 INFO: Using Python shared library: C:\hostedtoolcache\windows\Python\3.11.8\x64\python311.dll
2024-04-02T08:10:46.9111032Z 9635 INFO: Analyzing D:\a\mqtt_uart\mqtt_uart\mqtt_main.py
2024-04-02T08:10:47.2935963Z 10025 INFO: Loading module hook 'hook-platform.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks'...
2024-04-02T08:10:47.8443555Z 10573 INFO: Loading module hook 'hook-xml.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks'...
2024-04-02T08:10:47.8614953Z 10589 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks'...
2024-04-02T08:10:47.8635434Z 10589 INFO: Processing module hooks...
2024-04-02T08:10:47.9896189Z 10714 INFO: Performing binary vs. data reclassification (2 entries)
2024-04-02T08:10:47.9905786Z 10714 INFO: Looking for ctypes DLLs
2024-04-02T08:10:48.0142662Z 10745 INFO: Analyzing run-time hooks ...
2024-04-02T08:10:48.0158130Z 10745 INFO: Including run-time hook 'C:\\hostedtoolcache\\windows\\Python\\3.11.8\\x64\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
2024-04-02T08:10:48.0197706Z 10745 INFO: Looking for dynamic libraries
2024-04-02T08:10:48.1275059Z 10855 INFO: Extra DLL search directories (AddDllDirectory): []
2024-04-02T08:10:48.1276422Z 10855 INFO: Extra DLL search directories (PATH): []
2024-04-02T08:10:49.4612006Z 12191 INFO: Warnings written to D:\a\mqtt_uart\mqtt_uart\build\mqtt_main.exe\warn-mqtt_main.exe.txt
2024-04-02T08:10:49.4836936Z 12207 INFO: Graph cross-reference written to D:\a\mqtt_uart\mqtt_uart\build\mqtt_main.exe\xref-mqtt_main.exe.html
2024-04-02T08:10:49.4973211Z 12222 INFO: checking PYZ
2024-04-02T08:10:49.4974343Z 12222 INFO: Building PYZ because PYZ-00.toc is non existent
2024-04-02T08:10:49.4975975Z 12222 INFO: Building PYZ (ZlibArchive) D:\a\mqtt_uart\mqtt_uart\build\mqtt_main.exe\PYZ-00.pyz
2024-04-02T08:10:49.8159565Z 12535 INFO: Building PYZ (ZlibArchive) D:\a\mqtt_uart\mqtt_uart\build\mqtt_main.exe\PYZ-00.pyz completed successfully.
2024-04-02T08:10:49.8524046Z 12582 INFO: checking PKG
2024-04-02T08:10:49.8525364Z 12582 INFO: Building PKG because PKG-00.toc is non existent
2024-04-02T08:10:49.8526646Z 12582 INFO: Building PKG (CArchive) mqtt_main.pkg
2024-04-02T08:10:52.3401157Z 15071 INFO: Building PKG (CArchive) mqtt_main.pkg completed successfully.
2024-04-02T08:10:52.3419406Z 15071 INFO: Bootloader C:\hostedtoolcache\windows\Python\3.11.8\x64\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe
2024-04-02T08:10:52.3421346Z 15071 INFO: checking EXE
2024-04-02T08:10:52.3422206Z 15071 INFO: Building EXE because EXE-00.toc is non existent
2024-04-02T08:10:52.3424038Z 15071 INFO: Building EXE from EXE-00.toc
2024-04-02T08:10:52.3428591Z 15071 INFO: Copying bootloader EXE to D:\a\mqtt_uart\mqtt_uart\dist\mqtt_main.exe
2024-04-02T08:10:52.3448172Z 15071 INFO: Copying icon to EXE
2024-04-02T08:10:52.3468166Z 15071 INFO: Copying 0 resources to EXE
2024-04-02T08:10:52.3469198Z 15071 INFO: Embedding manifest in EXE
2024-04-02T08:10:52.3486332Z 15071 INFO: Appending PKG archive to EXE
2024-04-02T08:10:52.3545705Z 15071 INFO: Fixing EXE headers
2024-04-02T08:10:52.4321210Z 15149 INFO: Building EXE from EXE-00.toc completed successfully.
2024-04-02T08:10:52.4945958Z 
2024-04-02T08:10:52.4947105Z D:\a\mqtt_uart\mqtt_uart>copy dist\mqtt_main.exe . 
2024-04-02T08:10:52.4998265Z         1 file(s) copied.
2024-04-02T08:10:53.1054748Z Air780_Device is a virtual Type
2024-04-02T08:10:53.1055550Z AT
2024-04-02T08:10:53.1099054Z 
2024-04-02T08:10:53.1100010Z AT+CGMI
2024-04-02T08:10:53.1100657Z 
2024-04-02T08:10:53.1101856Z AT+CGMR
2024-04-02T08:10:53.1105893Z 
2024-04-02T08:10:53.1106219Z AT+CPIN?
2024-04-02T08:10:53.1106576Z 
2024-04-02T08:10:53.1106829Z AT+CSQ
2024-04-02T08:10:53.1107175Z 
2024-04-02T08:10:53.1107429Z AT+CREG?
2024-04-02T08:10:53.1107762Z 
2024-04-02T08:10:53.1108033Z AT+CGATT?
2024-04-02T08:10:53.1108366Z 
2024-04-02T08:10:53.1109927Z AT+MCONFIG="k0xdkIcKpaP.89861123215034907597|securemode=2,signmethod=hmacsha256,timestamp=1710730515363|","89861123215034907597&k0xdkIcKpaP","f6a692da7ccf00821d14243887034e2362c488d44b9e19c7c9ad846e5b07ef4b"
2024-04-02T08:10:53.1111438Z 
2024-04-02T08:10:53.1111945Z AT+MIPSTART="iot-06z00iy3y7dwo78.mqtt.iothub.aliyuncs.com",1883
2024-04-02T08:10:53.1112646Z 
2024-04-02T08:10:53.1112899Z AT+MCONNECT=0,600
2024-04-02T08:10:53.1113261Z 
2024-04-02T08:10:53.1114161Z AT+MPUB="/broadcast/k0xdkIcKpaP/ComBetweenDevice",0,0," data send from air780 time stamp : 2024-04-02 08:10:53.104618"
2024-04-02T08:10:53.1115265Z 
2024-04-02T08:10:53.1115526Z AT+MDISCONNECT 
2024-04-02T08:10:53.1115875Z 
2024-04-02T08:10:53.6757857Z Traceback (most recent call last):
2024-04-02T08:10:53.6768162Z   File "mqtt_main.py", line 78, in <module>
2024-04-02T08:10:53.6768842Z EC800_USB is a virtual Type
2024-04-02T08:10:53.6773137Z     main()
2024-04-02T08:10:53.6773479Z AT+QMTDISC=0 
2024-04-02T08:10:53.6775209Z 
2024-04-02T08:10:53.6775756Z   File "mqtt_main.py", line 67, in main
2024-04-02T08:10:53.6776404Z AT
2024-04-02T08:10:53.6777101Z     mqttInterface.Message_Receive()
2024-04-02T08:10:53.6777584Z 
2024-04-02T08:10:53.6778900Z   File "mqtt_api.py", line 87, in Message_Receive
2024-04-02T08:10:53.6779660Z AT+CGMI
2024-04-02T08:10:53.6780148Z     if self.uart.in_waiting > 0:
2024-04-02T08:10:53.6780608Z 
2024-04-02T08:10:53.6780855Z        ^^^^^^^^^
2024-04-02T08:10:53.6781301Z AT+CGMM
2024-04-02T08:10:53.6781901Z AttributeError: 'ec800Type' object has no attribute 'uart'
2024-04-02T08:10:53.6782525Z 
2024-04-02T08:10:53.6783032Z [6240] Failed to execute script 'mqtt_main' due to unhandled exception!
2024-04-02T08:10:53.6783892Z AT+CGMR
2024-04-02T08:10:53.6784316Z 
2024-04-02T08:10:53.6784592Z AT+CGSN
2024-04-02T08:10:53.6784941Z 
2024-04-02T08:10:53.6785209Z AT+CCID
2024-04-02T08:10:53.6785546Z 
2024-04-02T08:10:53.6785834Z AT+CPIN?
2024-04-02T08:10:53.6786192Z 
2024-04-02T08:10:53.6786457Z AT+CSQ
2024-04-02T08:10:53.6786806Z 
2024-04-02T08:10:53.6787078Z AT+CREG?
2024-04-02T08:10:53.6787443Z 
2024-04-02T08:10:53.6787721Z AT+CGATT?
2024-04-02T08:10:53.6788074Z 
2024-04-02T08:10:53.6788400Z AT+QMTCFG="recv/mode",0,0,1
2024-04-02T08:10:53.6788893Z 
2024-04-02T08:10:53.6789458Z AT+QMTOPEN=0,"iot-06z00iy3y7dwo78.mqtt.iothub.aliyuncs.com",1883
2024-04-02T08:10:53.6790258Z 
2024-04-02T08:10:53.6790550Z AT+QMTOPEN?
2024-04-02T08:10:53.6790931Z 
2024-04-02T08:10:53.6792304Z AT+QMTCONN=0,"k0xdkIcKpaP.EC800_usb|securemode=2,signmethod=hmacsha256,timestamp=1711603334820|","EC800_usb&k0xdkIcKpaP","f7a0b6e2c171d32e4fd204a018eb3d079ae9372de2c93a27189750d1798ca161"
2024-04-02T08:10:53.6793935Z 
2024-04-02T08:10:53.6794419Z AT+QMTCONN?
2024-04-02T08:10:53.6794752Z 
2024-04-02T08:10:56.2220173Z Python MQTT Client is a virtual Type
2024-04-02T08:10:56.2221062Z Transmit Message
2024-04-02T08:10:56.2221745Z Topic: /broadcast/k0xdkIcKpaP/ComBetweenDevice
2024-04-02T08:10:56.2222687Z Data:  data send from pyClient time stamp : 2024-04-02 08:10:54.247102
2024-04-02T08:10:56.2223512Z python mqtt client closed
2024-04-02T08:10:56.3577363Z Post job cleanup.
2024-04-02T08:10:56.5454607Z Post job cleanup.
2024-04-02T08:10:56.7626936Z [command]"C:\Program Files\Git\bin\git.exe" version
2024-04-02T08:10:56.7956272Z git version 2.44.0.windows.1
2024-04-02T08:10:56.8036023Z Temporarily overriding HOME='D:\a\_temp\b06e2c3f-50f5-49cb-853d-5b1aa4589191' before making global git config changes
2024-04-02T08:10:56.8037993Z Adding repository directory to the temporary git global config as a safe directory
2024-04-02T08:10:56.8051908Z [command]"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\mqtt_uart\mqtt_uart
2024-04-02T08:10:56.8321705Z [command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp core\.sshCommand
2024-04-02T08:10:56.8588372Z [command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c \"git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :\""
2024-04-02T08:10:57.2634936Z [command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2024-04-02T08:10:57.2855444Z http.https://github.com/.extraheader
2024-04-02T08:10:57.2970236Z [command]"C:\Program Files\Git\bin\git.exe" config --local --unset-all http.https://github.com/.extraheader
2024-04-02T08:10:57.3228390Z [command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c \"git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :\""
2024-04-02T08:10:57.7515952Z Cleaning up orphan processes

关联文章

基于python的EC800物联网mqtt协议开发指南:从入门到实战(1)

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

废柴程序员-熊熊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值