I'm trying to write a program that will detect whether or not a drive exists. The code I have works, but I get an annoying pop-up from PythonW.exe when I run the program.
import os, time, shutil, datetime, re, warnings
while True: #Loop until you close program
allDrives = re.findall(r"[A-Z]+:.*$",os.popen("mountvol /").read(),re.MULTILINE) #Find all drive letters
print("Found drives.")
for c in range(len(allDrives)):
drive = allDrives[c]
if os.path.isdir(drive) == False:
print("Hangs here.")
pass
else:
print(os.path.isdir(drive))
pathStr = drive + 'logs\\'
pathBool = os.path.exists(pathStr) #Check to see if 'logs' folder is visible
I've tried using os.path.exists(path)
instead of os.path.isdir(path)
, but that doesn't work either. I just want a way to disable the pop-up.