Update __repr__ and __str__ funcs
This commit is contained in:
parent
3191710b66
commit
81e7379024
|
@ -71,14 +71,6 @@ class BuildConfig:
|
|||
self.s3_bucketname = aws_resource_names_dict['s3bucketname']
|
||||
self.post_build_hook = recipe_config_dict['post-build-hook']
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Print the class.
|
||||
|
||||
Returns:
|
||||
String representation of the class
|
||||
"""
|
||||
return "BuildConfig Object:\n" + pprint.pformat(vars(self), indent=10)
|
||||
|
||||
def get_chisel_triplet(self) -> str:
|
||||
"""Get the unique build-specific '-' deliminated triplet.
|
||||
|
||||
|
@ -105,3 +97,11 @@ class BuildConfig:
|
|||
Fully specified make command.
|
||||
"""
|
||||
return f"""make {"" if self.TARGET_PROJECT is None else "TARGET_PROJECT=" + self.TARGET_PROJECT} DESIGN={self.DESIGN} TARGET_CONFIG={self.TARGET_CONFIG} PLATFORM_CONFIG={self.PLATFORM_CONFIG} {recipe}"""
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"< {type(self)}(name={self.name!r}, build_config_file={self.build_config_file!r}) @{id(self)} >"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return pprint.pformat(vars(self), width=1, indent=10)
|
||||
|
||||
|
||||
|
|
|
@ -162,10 +162,8 @@ class BuildConfigFile:
|
|||
return build
|
||||
return None
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Print the class.
|
||||
def __repr__(self) -> str:
|
||||
return f"< {type(self)}(file={self.args.buildconfigfile!r}, recipes={self.args.buildrecipesconfigfile!r}, build_farm={self.build_farm!r}) @{id(self)} >"
|
||||
|
||||
Returns:
|
||||
String representation of the class.
|
||||
"""
|
||||
return pprint.pformat(vars(self))
|
||||
def __str__(self) -> str:
|
||||
return pprint.pformat(vars(self), width=1, indent=10)
|
||||
|
|
|
@ -35,6 +35,13 @@ class BuildHost:
|
|||
self.ip_address = ip_address
|
||||
self.dest_build_dir = dest_build_dir
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{type(self)}(build_config={self.build_config!r}, dest_build_dir={self.dest_build_dir} ip_address={self.ip_address})"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return pprint.pformat(vars(self), width=1, indent=10)
|
||||
|
||||
|
||||
class BuildFarm(metaclass=abc.ABCMeta):
|
||||
"""Abstract class representing a build farm managing multiple build hosts (request, wait, release, etc).
|
||||
|
||||
|
@ -211,6 +218,12 @@ class IPAddrBuildFarm(BuildFarm):
|
|||
"""
|
||||
return
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{type(self)}(NAME={self.NAME()}, build_hosts={self.build_hosts!r} build_hosts_allocated={self.build_hosts_allocated})"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return pprint.pformat(vars(self), width=1, indent=10)
|
||||
|
||||
class EC2BuildHost(BuildHost):
|
||||
"""Class representing an EC2-specific build host instance.
|
||||
|
||||
|
@ -223,6 +236,13 @@ class EC2BuildHost(BuildHost):
|
|||
super().__init__(build_config)
|
||||
self.launched_instance_object = inst_obj
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{type(self)}(build_config={self.build_config!r}, dest_build_dir={self.dest_build_dir}, ip_address={self.ip_address}, launched_instance_object={self.launched_instance_object})"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return pprint.pformat(vars(self), width=1, indent=10)
|
||||
|
||||
|
||||
class EC2BuildFarm(BuildFarm):
|
||||
"""Build farm to manage AWS EC2 instances as the build hosts.
|
||||
|
||||
|
@ -323,3 +343,10 @@ class EC2BuildFarm(BuildFarm):
|
|||
instance_ids = get_instance_ids_for_instances([build_host.launched_instance_object])
|
||||
rootLogger.info(f"Terminating build instance {instance_ids}. Please confirm in your AWS Management Console")
|
||||
terminate_instances(instance_ids, dryrun=False)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{type(self)}(NAME={self.NAME()}, build_hosts={self.build_hosts!r} instance_type={self.instance_type} build_instance_market={self.build_instance_market} spot_interruption_behavior={self.spot_interruption_behavior} spot_max_price={self.spot_max_price})"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return pprint.pformat(vars(self), width=1, indent=10)
|
||||
|
||||
|
|
Loading…
Reference in New Issue