Move get state function to main module
This commit is contained in:
parent
fae3258c72
commit
86592b837a
@ -1,2 +1,3 @@
|
|||||||
"""Initness reports the initialization state and entry-point variables for the contract migrations process of the CIC services deployment.
|
"""Initness reports the initialization state and entry-point variables for the contract migrations process of the CIC services deployment.
|
||||||
"""
|
"""
|
||||||
|
from .state import *
|
||||||
|
@ -12,6 +12,9 @@ from http.server import (
|
|||||||
# external imports
|
# external imports
|
||||||
import confini
|
import confini
|
||||||
|
|
||||||
|
# local imports
|
||||||
|
from initness import get_state
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -47,36 +50,6 @@ config.dict_override(args_override, 'cli flag')
|
|||||||
logg.debug('loaded config: {}\n'.format(config))
|
logg.debug('loaded config: {}\n'.format(config))
|
||||||
|
|
||||||
|
|
||||||
def get_state(state_store_dir):
|
|
||||||
init_path = os.path.join(state_store_dir, 'init')
|
|
||||||
init_level = 0
|
|
||||||
registry_address = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
f = open(init_path, 'r')
|
|
||||||
init_level = f.read()
|
|
||||||
init_level = init_level.rstrip()
|
|
||||||
f.close()
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
registry_path = os.path.join(state_store_dir, 'registry')
|
|
||||||
try:
|
|
||||||
f = open(registry_path, 'r')
|
|
||||||
registry_address = f.read()
|
|
||||||
registry_address = registry_address.rstrip()
|
|
||||||
f.close()
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
o = {
|
|
||||||
'runlevel': init_level,
|
|
||||||
'registry': registry_address,
|
|
||||||
}
|
|
||||||
|
|
||||||
return o
|
|
||||||
|
|
||||||
|
|
||||||
class StateRequestHandler(BaseHTTPRequestHandler):
|
class StateRequestHandler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
state_store_dir = None
|
state_store_dir = None
|
||||||
|
31
apps/util/initness/initness/state.py
Normal file
31
apps/util/initness/initness/state.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# standard imports
|
||||||
|
import os
|
||||||
|
|
||||||
|
def get_state(state_store_dir):
|
||||||
|
init_path = os.path.join(state_store_dir, 'init')
|
||||||
|
init_level = 0
|
||||||
|
registry_address = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = open(init_path, 'r')
|
||||||
|
init_level = f.read()
|
||||||
|
init_level = init_level.rstrip()
|
||||||
|
f.close()
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
registry_path = os.path.join(state_store_dir, 'registry')
|
||||||
|
try:
|
||||||
|
f = open(registry_path, 'r')
|
||||||
|
registry_address = f.read()
|
||||||
|
registry_address = registry_address.rstrip()
|
||||||
|
f.close()
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
o = {
|
||||||
|
'runlevel': init_level,
|
||||||
|
'registry': registry_address,
|
||||||
|
}
|
||||||
|
|
||||||
|
return o
|
Loading…
Reference in New Issue
Block a user