IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2019, 1:34:52 PM (7 years ago)
Author:
fairlamb
Message:

define schema in the program (rather than using the default)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-259_genericise_backups/tools/backups/jira_backup.py

    r40949 r40950  
    44import os.path as path
    55
    6 import backups.backup as bck
     6import backups.utils.config_parse_helper as cfg_help
     7import backups.utils.errors as errs
    78import backups.utils.subprocess_utils as sub_utils
    8 import backups.utils.errors as errs
    99from backups.backup import Backup
    10 from backups.utils.config_parse_helper import ConfigSchema
     10from backups.utils.config_parse_helper import ConfigSchema, ConfigSchemaSection, ConfigSchemaLine
    1111
    1212EXPECTED_CONFIG_FILE = path.join(path.dirname(__file__), './jira_backup.config')
    1313
    14 
    15 def make_jira_schema():
    16     schema = ConfigSchema(None)
    17     schema.add_section(bck.DEFAULT_SCHEMA_SECTION)
    18     schema.add_section(bck.COPY_SCHEMA_SECTION)
    19     schema.add_section(bck.TAR_SCHEMA_SECTION)
    20     schema.add_section(bck.MYSQLDUMP_SCHEMA_SECTION)
    21     return schema
     14JIRA_SCHEMA = ConfigSchema(
     15    [ ConfigSchemaSection('DEFAULT',
     16        [ ConfigSchemaLine('backup_paths',   True,  list,
     17            cfg_help.SpecialSchemaProcessing.commma_separated)
     18        , ConfigSchemaLine('source_machine', True,  str)
     19        , ConfigSchemaLine('verbose',        False, bool)
     20        , ConfigSchemaLine('make_dirs',      False, bool)
     21        ])
     22    , ConfigSchemaSection('COPY',
     23        [ ConfigSchemaLine('sources',         True,  list,
     24            cfg_help.SpecialSchemaProcessing.commma_separated)
     25        , ConfigSchemaLine('additional_args', False, list,
     26            cfg_help.SpecialSchemaProcessing.space_separated)
     27        ])
     28    , ConfigSchemaSection('TAR',
     29        [ ConfigSchemaLine('sources',         True,  list,
     30            cfg_help.SpecialSchemaProcessing.commma_separated)
     31        , ConfigSchemaLine('additional_args', False, list,
     32            cfg_help.SpecialSchemaProcessing.space_separated)
     33        , ConfigSchemaLine('target_filename', True,  str)
     34        , ConfigSchemaLine('prefix_date',     True,  bool)
     35        ])
     36    , ConfigSchemaSection('MYSQLDUMP',
     37        [ ConfigSchemaLine('user',            True,  str)
     38        , ConfigSchemaLine('password',        True,  str)
     39        , ConfigSchemaLine('db_name',         True,  str)
     40        , ConfigSchemaLine('additional_args', False, list,
     41            cfg_help.SpecialSchemaProcessing.space_separated)
     42        , ConfigSchemaLine('target_filename', True,  str)
     43        , ConfigSchemaLine('prefix_date',     True,  bool)
     44        ])
     45    ]
     46)
    2247
    2348
    2449class JiraBackup(Backup):
    2550
    26     def __init__(self, config_file=EXPECTED_CONFIG_FILE, schema=None):
    27         if schema is None:
    28             schema = make_jira_schema()
     51    def __init__(self, config_file=EXPECTED_CONFIG_FILE, schema=JIRA_SCHEMA):
    2952        self.load_config(config_file, schema)
    3053
Note: See TracChangeset for help on using the changeset viewer.