def is_tor_data_dir_usable(tor_data_dir):
"""
Checks if the Tor data dir specified is usable. This means that
it is not being locked and we have permissions to write to it.
"""
if not os.path.exists(tor_data_dir):
return True
try:
fcntl.flock(open(os.path.join(tor_data_dir, 'lock'), 'w'),
fcntl.LOCK_EX | fcntl.LOCK_NB)
return True
except (IOError, OSError) as err:
if err.errno == errno.EACCES:
# Permission error
return False
elif err.errno == errno.EAGAIN:
# File locked
return False
评论列表
文章目录