mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
[mod] avoid useless get
This commit is contained in:
parent
8f3aa7cf0e
commit
af45f67cc5
1 changed files with 24 additions and 20 deletions
|
@ -26,6 +26,7 @@ allowed_operations = {
|
|||
### Script ###
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import psycopg2
|
||||
from urllib import urlopen
|
||||
|
@ -40,6 +41,29 @@ lines = ['// Generated by Dynette CRON']
|
|||
|
||||
with psycopg2.connect(postgresql_dsn) as postgresql_connection:
|
||||
with postgresql_connection.cursor() as psql:
|
||||
# look in the job queue if we have tasks to handle
|
||||
need_rewrite = False
|
||||
need_bind9_cache_flush = False
|
||||
|
||||
# DataMapper convert table names to lower cases and add a "s" at the
|
||||
# end
|
||||
# consume all available tasks at once to merge them and avoir doing
|
||||
# useless jobs
|
||||
for task in psql.execute("SELECT task FROM jobqueues ORDER BY id ASC;"):
|
||||
task = task[0]
|
||||
if task == "conf_rewrite":
|
||||
need_rewrite = True
|
||||
elif task == "bind9_cache_flush":
|
||||
need_bind9_cache_flush = True
|
||||
|
||||
if not need_rewrite and not need_bind9_cache_flush:
|
||||
sys.exit(0)
|
||||
|
||||
# we have consume all the jobs, flush it
|
||||
# because we are in a SQL transaction we won't have situation where a
|
||||
# job could be added just after we read them all
|
||||
psql.execute("DELETE FROM jobqueues;")
|
||||
|
||||
# Loop through Dynette servers
|
||||
for url in subs_urls:
|
||||
|
||||
|
@ -105,26 +129,6 @@ with psycopg2.connect(postgresql_dsn) as postgresql_connection:
|
|||
'};',
|
||||
])
|
||||
|
||||
# look in the job queue if we have tasks to handle
|
||||
need_rewrite = False
|
||||
need_bind9_cache_flush = False
|
||||
|
||||
# DataMapper convert table names to lower cases and add a "s" at the
|
||||
# end
|
||||
# consume all available tasks at once to merge them and avoir doing
|
||||
# useless jobs
|
||||
for task in psql.execute("SELECT task FROM jobqueues ORDER BY id ASC;"):
|
||||
task = task[0]
|
||||
if task == "conf_rewrite":
|
||||
need_rewrite = True
|
||||
elif task == "bind9_cache_flush":
|
||||
need_bind9_cache_flush = True
|
||||
|
||||
# we have consume all the jobs, flush it
|
||||
# because we are in a SQL transaction we won't have situation where a
|
||||
# job could be added just after we read them all
|
||||
psql.execute("DELETE FROM jobqueues;")
|
||||
|
||||
# update bind9 zone
|
||||
if need_rewrite:
|
||||
# Backup old Bind configuration file.
|
||||
|
|
Loading…
Reference in a new issue