liuyuqi-dellpc 3 years ago
parent
commit
cbc9ccf07e

+ 0 - 0
Docs/.gitkeep


BIN
Docs/screenshot/Android.png


BIN
Docs/screenshot/BaiduHi_2021-3-24_11-10-53.png


+ 2 - 1
Python/Dockerfile

@@ -2,4 +2,5 @@ FROM python:3.6 as builder
 WORKDIR /app
 ADD . /app
 RUN pip install -r requirements.txt
-CMD [ "python","-m","wifi_qecode.py" ]
+CMD [ "python","-m","wifi_qecode.py" ]
+

+ 14 - 11
Python/wifi_qrcode.py

@@ -3,23 +3,26 @@
 '''
 @Contact :   liuyuqi.gov@msn.cn
 @Time    :   2021/01/28 20:47:55
-@License :   Copyright © 2017-2020 liuyuqi. All Rights Reserved.
+@License :   Copyright © 2021 liuyuqi.gov@msn.cn. All Rights Reserved. Licensed under the Apache 2.0 license.
 @Desc    :   wifi 转化为 QRcode 方便扫码连接wifi。
 '''
 
 import re,os,sys
 import qrcode
-
+import logging
 import pathlib
 import subprocess
 from shutil import which
 
+# 是否输出图片
+image=True 
+
 def getSSID():
     if sys.platform == "darwin":
         airport = pathlib.Path(
             "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport")
         if not airport.is_file():
-            print_error(f"Can't find 'airport' command at {airport}")
+            logging.error(f"Can't find 'airport' command at {airport}")
 
         ssid = run_command(
             f"{airport} -I | awk '/ SSID/ {{print substr($0, index($0, $2))}}'")
@@ -27,7 +30,7 @@ def getSSID():
 
     elif sys.platform == "linux":
         if which("iwgetid") is not None:
-            print_error("Can't find the 'iwgetid' command")
+            logging.error("Can't find the 'iwgetid' command")
 
         ssid = run_command("iwgetid -r")
         ssid = ssid.replace("\n", "")
@@ -47,7 +50,7 @@ def getPasswordWithSSID(ssid):
     elif sys.platform == "linux":
         # Check if the user is running with super user privilages
         if os.geteuid() != 0:
-            print_error(f"You need to run '{sys.argv[0]}' as root")
+            logging.error(f"You need to run '{sys.argv[0]}' as root")
 
         password = run_command(f"cat /etc/NetworkManager/system-connections/{ssid} | grep psk=")
         password = password.replace("\n", "")
@@ -57,7 +60,7 @@ def getPasswordWithSSID(ssid):
         password = re.findall(r"Key Content\s+:\s(.*)", password)[0]
 
     if password == "":
-        print_error("Cound not find password")
+        logging.error("Cound not find password")
 
     return password
 
@@ -72,7 +75,7 @@ def genQRCode(text):
         file_name = ssid.replace(" ", "_") + ".png"
         img = qr.make_image()
         img.save(file_name)
-        print(f"QR code has been saved to {file_name}")
+        logging.info(f"QR code has been saved to {file_name}")
     else:
         qr.make()
         qr.print_tty()
@@ -83,10 +86,10 @@ def run_command(command):
     return output.decode("utf-8")
 
 if __name__ == "__main__":
-    ssid=getSSID()
-    if(ssid!=""):
-        password=getPasswordWithSSID(ssid)
+    ssid = getSSID()
+    if(ssid != ""):
+        password = getPasswordWithSSID(ssid)
         text = f"WIFI:T:WPA;S:{ssid};P:{password};;"
         genQRCode(text)
     else:
-        print("Please connect to Wifi.")
+        logging.info("Please connect to Wifi.")

+ 14 - 1
README.md

@@ -1,8 +1,17 @@
 # WifiQRCode
 
-
 wifi share with QRCode.
 
+## preview
+
+win:
+
+![](Docs/screenshot/BaiduHi_2021-3-24_11-10-53.png)
+
+android:
+
+![](Docs/screenshot/Android.png)
+
 # Develop
 
 ## Python
@@ -15,6 +24,10 @@ pip install -r requirements.txt
 python wifi_qrcode.py
 ```
 
+## Contributing
+
+If you are interested in fixing issues and contributing directly to the code base, please see the document [How to Contribute](CONTRIBUTING.md).
+
 ## License
 
 Copyright (c) 2021 [liuyuqi.gov@msn.cn](mailto:liuyuqi.gov@msn.cn). All rights reserved.

+ 2 - 2
Win/ShareWifi/Properties/AssemblyInfo.cs

@@ -6,9 +6,9 @@ using System.Runtime.InteropServices;
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("ShareWifi")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("get current pc's wifi password.")]
 [assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
+[assembly: AssemblyCompany("zhizhou informathon lnc.")]
 [assembly: AssemblyProduct("ShareWifi")]
 [assembly: AssemblyCopyright("Copyright ©  2021")]
 [assembly: AssemblyTrademark("")]