Fix gettransports

This commit is contained in:
Kevin Froman 2020-04-14 22:40:31 -05:00
parent 039d791b90
commit 026901ce90
7 changed files with 91 additions and 59 deletions

View file

@ -21,11 +21,28 @@ import filepaths
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
files = [filepaths.tor_hs_address_file]
files = []
class _GetTor:
def __init__(self):
self.tor_hs = None
def get(self):
if self.tor_hs is None:
try:
with open(filepaths.tor_hs_address_file, 'r') as transport_file:
self.tor_hs = transport_file.read().strip()
if not self.tor_hs:
self.tor_hs = None
except FileNotFoundError:
pass
return self.tor_hs
_tor_getter = _GetTor()
def get():
transports = []
transports = [_tor_getter.get()]
for file in files:
try:
with open(file, 'r') as transport_file: