From 94b485c245d20980c2b99089fd22fc4c0f0adab7 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 17 Jul 2023 11:19:44 +0800 Subject: [PATCH] correct lint format --- .gitignore | 1 + sql/engines/__init__.py | 22 +++++++++------------- sql/models.py | 4 +++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index f50115ed2e..9481b98969 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +.venv/ *.swp *.lock *.log diff --git a/sql/engines/__init__.py b/sql/engines/__init__.py index fb8a5c0900..ac8ffcc629 100644 --- a/sql/engines/__init__.py +++ b/sql/engines/__init__.py @@ -23,16 +23,14 @@ def __init__(self, instance=None): self.mode = instance.mode self.awsSecretId = instance.awsSecretId self.is_ssl = instance.is_ssl - + if not self.awsSecretId == None and self.awsSecretId.strip(): - client = boto3.client('secretsmanager') - response = client.get_secret_value( - SecretId=self.awsSecretId - ) - secret = json.loads(response['SecretString']) + client = boto3.client("secretsmanager") + response = client.get_secret_value(SecretId=instance.awsSecretId) + secret = json.loads(response["SecretString"]) self.user = secret["username"] self.password = secret["password"] - + # 判断如果配置了隧道则连接隧道,只测试了MySQL if self.instance.tunnel: self.ssh = SSHConnection( @@ -74,13 +72,11 @@ def remote_instance_conn(self, instance=None): self.remote_port = instance.port self.remote_user = instance.user self.remote_password = instance.password - + if not instance.awsSecretId == None and instance.awsSecretId.strip(): - client = boto3.client('secretsmanager') - response = client.get_secret_value( - SecretId=instance.awsSecretId - ) - secret = json.loads(response['SecretString']) + client = boto3.client("secretsmanager") + response = client.get_secret_value(SecretId=instance.awsSecretId) + secret = json.loads(response["SecretString"]) self.remote_user = secret["username"] self.remote_password = secret["password"] diff --git a/sql/models.py b/sql/models.py index f3fde57881..9ade232048 100755 --- a/sql/models.py +++ b/sql/models.py @@ -202,7 +202,9 @@ class Instance(models.Model): "Oracle service name", max_length=50, null=True, blank=True ) sid = models.CharField("Oracle sid", max_length=50, null=True, blank=True) - awsSecretId = models.CharField("AWS Secret Id", max_length=50, null=True, blank=True) + awsSecretId = models.CharField( + "AWS Secret Id", max_length=50, null=True, blank=True + ) resource_group = models.ManyToManyField( ResourceGroup, verbose_name="资源组", blank=True )