如何动态地自动写入配置文件

2024-09-30 18:32:52 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我设计了一个函数来创建红移集群并获取其属性。 如何仅在群集状态可用时自动执行函数writeinconfig文件触发器

def prettyRedshiftProps(props):
    pd.set_option('display.max_colwidth', -1)
    keysToShow = ["ClusterIdentifier", "NodeType", "ClusterStatus", "MasterUsername", "DBName", 
   "Endpoint", "NumberOfNodes", 'VpcId']
    x = [(k, v) for k,v in props.items() if k in keysToShow]
    return pd.DataFrame(data=x, columns=["Key", "Value"])

myClusterProps = redshift.describe_clusters(ClusterIdentifier=DWH_CLUSTER_IDENTIFIER) 
['Clusters'][0]
prettyRedshiftProps(myClusterProps)

函数,用于在另一个配置文件中写入clusterprop的值

# trigger the function when cluster status become available  
def writeinconfig :
    {
      ''' write values of clusterprops in config file'''
    }

Tags: 文件函数in属性状态def集群props