diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7a0270..8009a6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,7 @@ jobs: pip3 install pyinstaller pip3 install requests pip3 install tencentcloud-sdk-python + pip3 install pillow - name: Build run: | python3 -m PyInstaller main.py -F -i icon.ico @@ -35,7 +36,7 @@ jobs: - name: Upload uses: actions/upload-artifact@v3.1.2 with: - name: qcip-${{ github.event.inputs.version }}-linux-x86_64 + name: qcip-${{ github.event.inputs.version }}-linux-x64 path: dist/* Windows: runs-on: windows-2022 @@ -55,14 +56,13 @@ jobs: pip3 install pillow - name: Build run: | - mv upx/upx.exe upx.exe - python3 -m PyInstaller main.py -F -i icon.ico + python3 -m PyInstaller main.py -F -i icon.ico --upx-dir upx mv dist/main.exe dist/qcip.exe mv config.json dist/config.json - name: Upload uses: actions/upload-artifact@v3.1.2 with: - name: qcip-${{ github.event.inputs.version }}-windows-x86_64 + name: qcip-${{ github.event.inputs.version }}-windows-x64 path: dist/* MacOS: runs-on: macos-12 @@ -79,6 +79,7 @@ jobs: pip3 install pyinstaller pip3 install requests pip3 install tencentcloud-sdk-python + pip3 install pillow - name: Build run: | python3 -m PyInstaller main.py -F -i icon.ico @@ -87,5 +88,5 @@ jobs: - name: Upload uses: actions/upload-artifact@v3.1.2 with: - name: qcip-${{ github.event.inputs.version }}-macos-x86_64 + name: qcip-${{ github.event.inputs.version }}-macos-x64 path: dist/* diff --git a/main.py b/main.py index d4b9e09..3a4bae0 100644 --- a/main.py +++ b/main.py @@ -41,11 +41,26 @@ # Get IP if 'GetIPAPI' in config: if config['GetIPAPI'] == "LanceAPI": - ip = requests.get('https://get.lance.fun/ip/').text + try: + ip = requests.get('https://get.lance.fun/ip/').text + except Exception as e: + print('This api may not work anymore, please replace it and try again') + print('Detail: ' + str(e)) + exit() elif config['GetIPAPI'] == "IPIP": - ip = requests.get('http://myip.ipip.net/').text.split(' ')[1][3:] + try: + ip = json.loads(requests.get('https://myip.ipip.net/ip').text)['ip'] + except Exception as e: + print('This api may not work anymore, please replace it and try again') + print('Detail: ' + str(e)) + exit() else: - ip = requests.get('https://get.lance.fun/ip/').text + try: + ip = requests.get('https://get.lance.fun/ip/').text + except Exception as e: + print('This api may not work anymore, please replace it and try again') + print('Detail: ' + str(e)) + exit() # Check Secret if 'SecretId' not in config and 'SecretKey' not in config: print('Both SecretId and SecretKey not found') @@ -96,7 +111,9 @@ except TencentCloudSDKException as err: print(err) exit() - +except Exception as e: + print('Unknown error: ' + str(e)) + exit() # Modify Firewall Rules for a in range(0, len(resp)): @@ -130,5 +147,8 @@ except TencentCloudSDKException as err: print(err) exit() + except Exception as e: + print('Unknown error: ' + str(e)) + exit() elif needupdate == False: print("IP相同 无需更新")