fix basic
This commit is contained in:
parent
274e1e2e59
commit
8479c378ee
@ -4,3 +4,7 @@ line-length = 140
|
||||
[tool.ruff]
|
||||
# Allow lines to be as long as 120.
|
||||
line-length = 140
|
||||
indent-width = 4
|
||||
|
||||
[tool.ruff.lint]
|
||||
ignore = ["F401","F403","F405","E402"]
|
12
tisbackup.py
12
tisbackup.py
@ -29,6 +29,7 @@ sys.path.insert(0,os.path.join(tisbackup_root_dir,'libtisbackup'))
|
||||
import errno
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
from iniparse import ConfigParser, ini
|
||||
@ -191,7 +192,7 @@ class tis_backup:
|
||||
finally:
|
||||
self.logger.debug('worst nagios status :"%i"',worst_nagiosstatus)
|
||||
print('%s (tisbackup V%s)' %(nagiosoutput,version))
|
||||
print('\n'.join(["[%s]:%s" % (l[0],l[1]) for l in globallog]))
|
||||
print('\n'.join(["[%s]:%s" % (log_elem[0],log_elem[1]) for log_elem in globallog]))
|
||||
sys.exit(worst_nagiosstatus)
|
||||
|
||||
def process_backup(self,sections=[]):
|
||||
@ -285,7 +286,6 @@ class tis_backup:
|
||||
|
||||
|
||||
def cleanup_backup_section(self,sections = []):
|
||||
log = ''
|
||||
processed = False
|
||||
if not sections:
|
||||
sections = [backup_item.backup_name for backup_item in self.backup_list]
|
||||
@ -321,9 +321,9 @@ class tis_backup:
|
||||
(nagiosstatus,log) = backup_item.checknagios(maxage_hours=maxage_hours)
|
||||
globallog.append('[%s] %s' % (backup_item.backup_name,log))
|
||||
self.logger.debug('[%s] nagios:"%i" log: %s',backup_item.backup_name,nagiosstatus,log)
|
||||
processed = True
|
||||
if nagiosstatus >= worst_nagiosstatus:
|
||||
worst_nagiosstatus = nagiosstatus
|
||||
#processed = True
|
||||
# if nagiosstatus >= worst_nagiosstatus:
|
||||
# worst_nagiosstatus = nagiosstatus
|
||||
|
||||
|
||||
def main():
|
||||
@ -398,7 +398,7 @@ def main():
|
||||
backup_sections = all_sections
|
||||
else:
|
||||
for b in backup_sections:
|
||||
if not b in all_sections:
|
||||
if b not in all_sections:
|
||||
raise Exception('Section %s is not defined in config file' % b)
|
||||
|
||||
if dry_run:
|
||||
|
@ -72,7 +72,7 @@ tasks_db = os.path.join(tisbackup_root_dir,"tasks.sqlite")
|
||||
def read_all_configs(base_dir):
|
||||
raw_configs = []
|
||||
list_config = []
|
||||
config_base_dir = base_dir
|
||||
#config_base_dir = base_dir
|
||||
|
||||
for file in os.listdir(base_dir):
|
||||
if isfile(join(base_dir,file)):
|
||||
@ -112,11 +112,12 @@ def read_all_configs(base_dir):
|
||||
backup_sections = all_sections
|
||||
else:
|
||||
for b in backup_sections:
|
||||
if not b in all_sections:
|
||||
if b not in all_sections:
|
||||
raise Exception('Section %s is not defined in config file' % b)
|
||||
|
||||
if not backup_sections:
|
||||
sections = [backup_item.backup_name for backup_item in backup.backup_list]
|
||||
# never used..
|
||||
# if not backup_sections:
|
||||
# sections = [backup_item.backup_name for backup_item in backup.backup_list]
|
||||
|
||||
for backup_item in backup.backup_list:
|
||||
if backup_item.backup_name in backup_sections:
|
||||
@ -190,12 +191,14 @@ def read_config():
|
||||
backup_sections = all_sections
|
||||
else:
|
||||
for b in backup_sections:
|
||||
if not b in all_sections:
|
||||
if b not in all_sections:
|
||||
raise Exception('Section %s is not defined in config file' % b)
|
||||
|
||||
result = []
|
||||
if not backup_sections:
|
||||
sections = [backup_item.backup_name for backup_item in backup.backup_list]
|
||||
|
||||
# not used ...
|
||||
# if not backup_sections:
|
||||
# sections = [backup_item.backup_name for backup_item in backup.backup_list]
|
||||
|
||||
for backup_item in backup.backup_list:
|
||||
if backup_item.backup_name in backup_sections:
|
||||
@ -261,7 +264,7 @@ def backup_all():
|
||||
@app.route('/config_number/')
|
||||
@app.route('/config_number/<int:id>')
|
||||
def set_config_number(id=None):
|
||||
if id != None and len(CONFIG) > id:
|
||||
if id is not None and len(CONFIG) > id:
|
||||
global config_number
|
||||
config_number=id
|
||||
read_config()
|
||||
@ -350,7 +353,7 @@ def run_command(cmd, info=""):
|
||||
result =""
|
||||
try:
|
||||
result = check_output(cmd, stderr=subprocess.STDOUT,shell=True)
|
||||
except CalledProcessError as e:
|
||||
except CalledProcessError:
|
||||
raise_error(result,info)
|
||||
return result
|
||||
|
||||
@ -376,7 +379,7 @@ def export_backup_status():
|
||||
exports = dbstat.query('select * from stats where TYPE="EXPORT" and backup_start>="%s"' % mindate)
|
||||
error = ""
|
||||
finish=not runnings_backups()
|
||||
if get_task() != None and finish:
|
||||
if get_task() is not None and finish:
|
||||
status = get_task().get()
|
||||
if status != "ok":
|
||||
error = "Export failing with error: "+status
|
||||
@ -386,8 +389,8 @@ def export_backup_status():
|
||||
|
||||
def runnings_backups():
|
||||
task = get_task()
|
||||
is_runnig = (task != None)
|
||||
finish = ( is_runnig and task.get() != None)
|
||||
is_runnig = (task is not None)
|
||||
finish = ( is_runnig and task.get() is not None)
|
||||
return is_runnig and not finish
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user