Skip to content

Commit

Permalink
remove Path cast
Browse files Browse the repository at this point in the history
  • Loading branch information
miiu96 committed Oct 27, 2022
1 parent 3fed07b commit b57115b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
28 changes: 14 additions & 14 deletions scripts/observers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def update_toml_indexer(path, shard_id):
# prefs.toml
path_prefs = Path(path / "prefs.toml")
path_prefs = path / "prefs.toml"
prefs_data = toml.load(str(path_prefs))
prefs_data['config']['web-socket']['server-url'] = str(shard_id)
if shard_id != METACHAIN:
Expand All @@ -23,15 +23,15 @@ def update_toml_indexer(path, shard_id):

def update_toml_node(path, shard_id):
# prefs.toml
path_prefs = Path(path / "prefs.toml")
path_prefs = path / "prefs.toml"
prefs_data = toml.load(str(path_prefs))
prefs_data['Preferences']['DestinationShardAsObserver'] = str(shard_id)
f = open(path_prefs, 'w')
toml.dump(prefs_data, f)
f.close()

# external.toml
path_external = Path(path / "external.toml")
path_external = path / "external.toml"
external_data = toml.load(str(path_external))
external_data['WebSocketConnector']['Enabled'] = True
if shard_id != METACHAIN:
Expand All @@ -46,25 +46,25 @@ def update_toml_node(path, shard_id):
def prepare_observer(shard_id, working_dir, config_folder):
observer_dir = str(os.getenv('OBSERVER_DIR_PREFIX'))
current_observer = observer_dir + str(shard_id)
working_dir_observer = Path(working_dir / current_observer)
working_dir_observer = working_dir / current_observer
os.mkdir(working_dir_observer)
os.mkdir(Path(working_dir_observer / "indexer"))
os.mkdir(Path(working_dir_observer / "node"))
os.mkdir(working_dir_observer / "indexer")
os.mkdir(working_dir_observer / "node")

node_config = Path(working_dir_observer / "node" / "config")
indexer_config = Path(working_dir_observer / "indexer" / "config")
node_config = working_dir_observer / "node" / "config"
indexer_config = working_dir_observer / "indexer" / "config"

shutil.copytree(config_folder, node_config)
shutil.copytree("../../cmd/elasticindexer/config", indexer_config)
shutil.copyfile("../../cmd/elasticindexer/elasticindexer", Path(working_dir_observer / "indexer/elasticindexer"))
shutil.copyfile("../../cmd/elasticindexer/elasticindexer", working_dir_observer / "indexer/elasticindexer")

elastic_indexer_exec = Path(working_dir_observer / "indexer/elasticindexer")
st = os.stat(elastic_indexer_exec)
os.chmod(elastic_indexer_exec, st.st_mode | stat.S_IEXEC)

shutil.copyfile(Path(working_dir / "elrond-go/cmd/node/node"), Path(working_dir_observer / "node/node"))
shutil.copyfile(working_dir / "elrond-go/cmd/node/node", working_dir_observer / "node/node")

node_exec_path = Path(working_dir_observer / "node/node")
node_exec_path = working_dir_observer / "node/node"
st = os.stat(node_exec_path)
os.chmod(node_exec_path, st.st_mode | stat.S_IEXEC)

Expand All @@ -84,7 +84,7 @@ def main():

# CLONE elrond-config
print("cloning elrond-config....")
config_folder = Path(working_dir / "config")
config_folder = working_dir / "config"
if not os.path.isdir(config_folder):
Repo.clone_from(os.getenv('ELROND_CONFIG_URL'), config_folder)

Expand All @@ -93,7 +93,7 @@ def main():

# CLONE elrond-go
print("cloning elrond-go....")
elrond_go_folder = Path(working_dir / "elrond-go")
elrond_go_folder = working_dir / "elrond-go"
if not os.path.isdir(elrond_go_folder):
Repo.clone_from(os.getenv('ELROND_GO_URL'), elrond_go_folder)

Expand All @@ -102,7 +102,7 @@ def main():

# build binary elrond-go
print("building node...")
subprocess.check_call(["go", "build"], cwd=Path(elrond_go_folder / "cmd/node"))
subprocess.check_call(["go", "build"], cwd=elrond_go_folder / "cmd/node")

# build binary indexer
print("building indexer...")
Expand Down
6 changes: 3 additions & 3 deletions scripts/observers/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

def start_observer(shard_id, working_dir):
current_observer = str(os.getenv('OBSERVER_DIR_PREFIX')) + str(shard_id)
working_dir_observer = Path(working_dir / current_observer)
working_dir_observer = working_dir / current_observer

current_directory = os.getcwd()
# start observer
os.chdir(Path(working_dir_observer / "node"))
os.chdir(working_dir_observer / "node")
command = "./node" + " --log-level *:DEBUG --no-key --log-save"
os.system("screen -d -m -S obs" + str(shard_id) + " " + command)

# start indexer
os.chdir(Path(working_dir_observer / "indexer"))
os.chdir(working_dir_observer / "indexer")
command = "./elasticindexer" + " --log-level *:DEBUG --log-save"
os.system("screen -d -m -S indexer" + str(shard_id) + " " + command)

Expand Down
2 changes: 1 addition & 1 deletion scripts/observers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def get_working_dir():
print("working directory folder name cannot be empty")
sys.exit()

return Path(Path.home() / working_dir_var)
return Path.home() / working_dir_var

0 comments on commit b57115b

Please sign in to comment.