Quickly detect local network paths
up vote
1
down vote
favorite
Does Python have a way to quickly detect the existence of a local network path?
I have tried using os.path.exists and urllib2.urlopen. When the path does not exist, they take at least tens of seconds to detect if the path exists.
Is it possible to reduce the time to less than ten seconds?
This is my test code:
# -*- coding: utf-8 -*-
import os
import sys
from urllib2 import urlopen
path = "file:////192.168.199.249/Users"
try:
urlopen(path, timeout=1)
print "exist"
except Exception, e:
print "not exist"
if os.path.exists(path):
print "exist"
else:
print "not exist"
python urllib2
add a comment |
up vote
1
down vote
favorite
Does Python have a way to quickly detect the existence of a local network path?
I have tried using os.path.exists and urllib2.urlopen. When the path does not exist, they take at least tens of seconds to detect if the path exists.
Is it possible to reduce the time to less than ten seconds?
This is my test code:
# -*- coding: utf-8 -*-
import os
import sys
from urllib2 import urlopen
path = "file:////192.168.199.249/Users"
try:
urlopen(path, timeout=1)
print "exist"
except Exception, e:
print "not exist"
if os.path.exists(path):
print "exist"
else:
print "not exist"
python urllib2
you url (the "path") seems a windows network shared dir.
– georgexsh
Nov 10 at 11:32
Yes, it is a network Shared directory
– 郭德纲
Nov 10 at 14:38
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Does Python have a way to quickly detect the existence of a local network path?
I have tried using os.path.exists and urllib2.urlopen. When the path does not exist, they take at least tens of seconds to detect if the path exists.
Is it possible to reduce the time to less than ten seconds?
This is my test code:
# -*- coding: utf-8 -*-
import os
import sys
from urllib2 import urlopen
path = "file:////192.168.199.249/Users"
try:
urlopen(path, timeout=1)
print "exist"
except Exception, e:
print "not exist"
if os.path.exists(path):
print "exist"
else:
print "not exist"
python urllib2
Does Python have a way to quickly detect the existence of a local network path?
I have tried using os.path.exists and urllib2.urlopen. When the path does not exist, they take at least tens of seconds to detect if the path exists.
Is it possible to reduce the time to less than ten seconds?
This is my test code:
# -*- coding: utf-8 -*-
import os
import sys
from urllib2 import urlopen
path = "file:////192.168.199.249/Users"
try:
urlopen(path, timeout=1)
print "exist"
except Exception, e:
print "not exist"
if os.path.exists(path):
print "exist"
else:
print "not exist"
python urllib2
python urllib2
asked Nov 10 at 3:27
郭德纲
194110
194110
you url (the "path") seems a windows network shared dir.
– georgexsh
Nov 10 at 11:32
Yes, it is a network Shared directory
– 郭德纲
Nov 10 at 14:38
add a comment |
you url (the "path") seems a windows network shared dir.
– georgexsh
Nov 10 at 11:32
Yes, it is a network Shared directory
– 郭德纲
Nov 10 at 14:38
you url (the "path") seems a windows network shared dir.
– georgexsh
Nov 10 at 11:32
you url (the "path") seems a windows network shared dir.
– georgexsh
Nov 10 at 11:32
Yes, it is a network Shared directory
– 郭德纲
Nov 10 at 14:38
Yes, it is a network Shared directory
– 郭德纲
Nov 10 at 14:38
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235765%2fquickly-detect-local-network-paths%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you url (the "path") seems a windows network shared dir.
– georgexsh
Nov 10 at 11:32
Yes, it is a network Shared directory
– 郭德纲
Nov 10 at 14:38