Use ONIONR_HOME or DATA_DIR env vars

This commit is contained in:
Arinerron 2019-03-28 12:08:07 -07:00
parent 9bd5efce1f
commit 8bae211a8d
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
4 changed files with 18 additions and 26 deletions

View File

@ -20,12 +20,10 @@
import os, json, logger
try:
dataDir = os.environ['ONIONR_HOME']
# set data dir
dataDir = os.environ.get('ONIONR_HOME', os.environ.get('DATA_DIR', 'data/'))
if not dataDir.endswith('/'):
dataDir += '/'
except KeyError:
dataDir = 'data/'
_configfile = os.path.abspath(dataDir + 'config.json')
_config = {}

View File

@ -39,12 +39,10 @@ class Core:
Initialize Core Onionr library
'''
try:
self.dataDir = os.environ['ONIONR_HOME']
# set data dir
self.dataDir = os.environ.get('ONIONR_HOME', os.environ.get('DATA_DIR', 'data/'))
if not self.dataDir.endswith('/'):
self.dataDir += '/'
except KeyError:
self.dataDir = 'data/'
try:
self.onionrInst = None

View File

@ -46,12 +46,10 @@ class NetController:
'''
def __init__(self, hsPort, apiServerIP='127.0.0.1'):
try:
self.dataDir = os.environ['ONIONR_HOME']
# set data dir
self.dataDir = os.environ.get('ONIONR_HOME', os.environ.get('DATA_DIR', 'data/'))
if not self.dataDir.endswith('/'):
self.dataDir += '/'
except KeyError:
self.dataDir = 'data/'
self.torConfigLocation = self.dataDir + 'torrc'
self.readyState = False

View File

@ -21,12 +21,10 @@
import os, re, importlib, config, logger
import onionrevents as events
try:
dataDir = os.environ['ONIONR_HOME']
# set data dir
dataDir = os.environ.get('ONIONR_HOME', os.environ.get('DATA_DIR', 'data/'))
if not dataDir.endswith('/'):
dataDir += '/'
except KeyError:
dataDir = 'data/'
_pluginsfolder = dataDir + 'plugins/'
_instances = dict()