I tried to search a lot on the forums but just couldn't find the right answer.
One of my python scripts, which runs on a windows machine looks for the existence of a network path as the first thing.
myPath = "Y:\\Windows\\Builds\\"
if not os.path.exists(myPath):
print("This one can't be reached : "+myPath)
This works perfectly fine from a windows 7 machine (The output is true). But running the same on a windows 10 machine, results in false. All three machines, the windows 7 one, windows 10 one and Y: (a mac) are on the same local network.
Y: is a mapped drive. I have also tried to repeat with the IP instead of the mapped drive name, without luck. I have checked the paths are correct knowing the command is case sensitive.
Any help here will be highly appreciated. Thanks.
You may try os.path.join()
to join paths:
path = os.path.join("Y:","windows","Build")
This will create a path string with regard to OS - for Windows7 windows\\\\Build
and for Linux windows/Build
.
use os.path.isdir(path)
Return True if path is an existing directory.
If it is a network share you have to use the full path eg:
from pathlib import Path
myPath = Path('//server/sharename/Windows/Builds/')
if not os.path.exists(myPath):
print("This one can't be reached : " + myPath)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.