2020-10-28 18:07:13 +00:00
|
|
|
import os
|
|
|
|
|
2021-08-23 10:33:04 +00:00
|
|
|
from staking_deposit.key_handling.keystore import Keystore
|
|
|
|
from staking_deposit.utils.constants import DEFAULT_VALIDATOR_KEYS_FOLDER_NAME
|
2020-10-28 18:07:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def clean_key_folder(my_folder_path: str) -> None:
|
|
|
|
validator_keys_folder_path = os.path.join(my_folder_path, DEFAULT_VALIDATOR_KEYS_FOLDER_NAME)
|
|
|
|
if not os.path.exists(validator_keys_folder_path):
|
|
|
|
return
|
|
|
|
|
|
|
|
_, _, key_files = next(os.walk(validator_keys_folder_path))
|
|
|
|
for key_file_name in key_files:
|
|
|
|
os.remove(os.path.join(validator_keys_folder_path, key_file_name))
|
|
|
|
os.rmdir(validator_keys_folder_path)
|
|
|
|
os.rmdir(my_folder_path)
|
2020-11-03 18:01:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_uuid(key_file: str) -> str:
|
2020-11-05 09:13:32 +00:00
|
|
|
keystore = Keystore.from_file(key_file)
|
2020-11-03 18:01:18 +00:00
|
|
|
return keystore.uuid
|
2020-12-18 15:53:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_permissions(path: str, file_name: str) -> str:
|
|
|
|
return oct(os.stat(os.path.join(path, file_name)).st_mode & 0o777)
|