Skip to content

Commit c70b5d2

Browse files
author
Dmitry Surnin
committed
Remove system folders reference from python setup; remove exception from config loader;
1 parent 08de996 commit c70b5d2

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

plenum/common/config_util.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ def extend_with_external_config(extendee: object, extender: Tuple[str, str], req
3838

3939

4040
def extend_with_default_external_config(extendee: object, user_config_dir: str = None) -> object:
41-
extend_with_external_config(extendee,
42-
(extendee.GENERAL_CONFIG_DIR,
43-
extendee.GENERAL_CONFIG_FILE),
44-
required=True)
41+
extend_with_external_config(extendee, (extendee.GENERAL_CONFIG_DIR, extendee.GENERAL_CONFIG_FILE))
4542

4643
# fail if network is not set
4744
if not extendee.NETWORK_NAME:
48-
raise Exception('NETWORK_NAME must be set')
45+
return
46+
# raise Exception('NETWORK_NAME must be set')
4947

5048
network_config_dir = os.path.join(extendee.GENERAL_CONFIG_DIR,
5149
extendee.NETWORK_NAME)

plenum/common/test_network_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def domain_ledger_file_name(cls, config, envName):
166166

167167
@classmethod
168168
def setup_base_dir(cls, config):
169-
baseDir = config.baseDir
169+
baseDir = os.path.join(config.baseDir, config.NETWORK_NAME)
170170
if not os.path.exists(baseDir):
171171
os.makedirs(baseDir, exist_ok=True)
172172
return baseDir

plenum/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
baseDir = '~/.plenum/'
2828
walletsDir = 'wallets'
29-
NODE_BASE_DATA_DIR = '/var/plenum'
29+
NODE_BASE_DATA_DIR = baseDir
3030
nodeDataDir = 'data/nodes'
3131
clientDataDir = 'data/clients'
32-
LOG_DIR = '/var/log/plenum/'
32+
LOG_DIR = os.path.join(baseDir, "log")
3333
GENERAL_CONFIG_DIR = '/etc/plenum/'
3434
# walletDir = 'wallet'
3535

plenum/server/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ def __init__(self,
129129
self.created = time.time()
130130
self.name = name
131131
self.config = config or getConfig()
132-
self.basedirpath = basedirpath or os.path.join(config.baseDir, config.NETWORK_NAME)
132+
self.basedirpath = basedirpath or os.path.join(self.config.baseDir, self.config.NETWORK_NAME)
133133
self.dataDir = self.config.nodeDataDir or "data/nodes"
134134
self.base_data_dir = base_data_dir or os.path.join(self.config.NODE_BASE_DATA_DIR,
135-
config.NETWORK_NAME)
135+
self.config.NETWORK_NAME)
136136

137137
self._view_change_timeout = self.config.VIEW_CHANGE_TIMEOUT
138138

setup.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
exec(compile(open(METADATA).read(), METADATA, 'exec'))
3232

3333
BASE_DIR = os.path.join(os.path.expanduser("~"), ".plenum")
34-
BASE_DATA_DIR = '/var/plenum'
35-
LOG_DIR = '/var/log/plenum'
36-
GENERAL_CONFIG_DIR = '/etc/plenum'
37-
CONFIG_FILE = os.path.join(GENERAL_CONFIG_DIR, "plenum_config.py")
34+
LOG_DIR = os.path.join(BASE_DIR, "log")
35+
CONFIG_FILE = os.path.join(BASE_DIR, "plenum_config.py")
3836

39-
for path in [BASE_DIR, BASE_DATA_DIR, LOG_DIR, GENERAL_CONFIG_DIR]:
37+
for path in [BASE_DIR, LOG_DIR]:
4038
if not os.path.exists(path):
4139
os.makedirs(path)
4240

@@ -119,6 +117,4 @@ def changeOwnerAndGrpToLoggedInUser(directory, raiseEx=False):
119117

120118

121119
changeOwnerAndGrpToLoggedInUser(BASE_DIR)
122-
changeOwnerAndGrpToLoggedInUser(BASE_DATA_DIR)
123120
changeOwnerAndGrpToLoggedInUser(LOG_DIR)
124-
changeOwnerAndGrpToLoggedInUser(GENERAL_CONFIG_DIR)

0 commit comments

Comments
 (0)