From b0efab0df1a34f40e848589d09454920b22f7b4c Mon Sep 17 00:00:00 2001 From: rogersun Date: Fri, 10 Jul 2026 14:05:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=9B=AE=E6=A0=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=97=B6=E5=A2=9E=E5=8A=A0=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=98=AF=E5=90=A6=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E5=BA=93=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update/utils/git_util.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/update/utils/git_util.py b/update/utils/git_util.py index cd8a406..0a014ab 100644 --- a/update/utils/git_util.py +++ b/update/utils/git_util.py @@ -113,6 +113,24 @@ class GitUtil: # print('create_cine_sql', output) return True + # 查看对应的服务器上是否有对应的库 + def template_db_exist(self): + if self.target_ip.startswith('10.'): + db = self.db_config['10'] + else: + db = self.db_config['172'] + db_conn = pymysql.connect(host=db['host'], user=db['user'], passwd=db['password']) + db_cur = db_conn.cursor() + print('template_db_exist', self.db_name) + db_cur.execute('select 1 from information_schema.schemata where schema_name=%s', (self.db_name,)) + result = db_cur.fetchone() + print('template_db_exist', result) + db_cur.close() + db_conn.close() + if result: + return False + return True + # 将生成的cine.sql写入数据库 def write_cine_sql_by_mysql(self): print('开始将cine.sql写入数据库') @@ -167,7 +185,7 @@ class GitUtil: # 写入cine.sql def handle_create_cine(self): # 如果生成了新的文件则写库,如果sql没有变化则跳过 - if self.create_cine_sql(): + if self.create_cine_sql() and self.template_db_exist(): self.write_cine_sql_by_mysql() return '成功' @@ -208,6 +226,7 @@ class GitDbUtil: # 从git中获取版本列表后和数据库对比,添加新的版本到数据库 def set_release_to_db(self): + print('local_repo = Repo(self.local_code_path)', self.local_code_path) local_repo = Repo(self.local_code_path) local_repo.git.execute(command='git remote update origin --prune', shell=True) # 更新远程列表 local_repo.git.execute(command='git fetch --all', shell=True)