Ejemplo n.º 1
0
    def create_empty_configuration(self):
        """
        Creates and initialize empty configuration file
        :return: True if config file created successfully
        """
        create_directory(self.config_dir)
        with open(self.config_path, 'w+') as yaml_file:
            yaml.dump(self.initial_config, yaml_file, default_flow_style=False)

        return True
Ejemplo n.º 2
0
 def save_keystore(self, password):
     """
     Encrypts and save keystore to path
     :param password: user password from keystore
     :return: path
     """
     create_directory(self.conf.keystore_location)
     keystore_path = self.conf.keystore_location + self.conf.keystore_filename
     encrypted_private_key = Account.encrypt(self.account.privateKey,
                                             password)
     with open(keystore_path, 'w+') as outfile:
         json.dump(encrypted_private_key, outfile, ensure_ascii=False)
     return keystore_path
Ejemplo n.º 3
0
    def __update_configuration(self, parameter_name, parameter_value):
        """
        Updates configuration file.
        :param parameter_name: parameter name to change or append
        :param parameter_value: value to parameter_key
        :return: True if config file updated successfully
        """
        with open(self.config_path, 'r') as yaml_file:
            file = yaml.safe_load(yaml_file)

        file[parameter_name] = parameter_value

        create_directory(self.config_dir)
        with open(self.config_path, 'w+') as yaml_file:
            yaml.dump(file, yaml_file, default_flow_style=False)

        return True
Ejemplo n.º 4
0
def test_create_dictionary(tmp_path):
    create_directory(str(tmp_path) + '/test')
    assert len(list(tmp_path.iterdir())) == 1