(self)
return config
override config load to allow operation without a config file
override config load to allow operation without a config file
override config load to allow operation without a config file
def load_config(self):
        """override config load to allow operation without a config file"""

        if len(self.args) < 1:
            # no config file, generate default

            # guess the job name from cmdline options
            if self.options.init_master:
                job_name = 'wal-master'
            elif self.options.init_slave:
                job_name = 'wal-slave'
            else:
                job_name = 'walmgr'

            # common config settings
            opt_dict = {
                'use_skylog':       '0',
                'job_name':         job_name,
            }

            # master configuration settings
            master_opt_dict = {
                'master_db':        'dbname=template1',
                'completed_wals':   '%%(slave)s:%%(walmgr_data)s/logs.complete',
                'partial_wals':     '%%(slave)s:%%(walmgr_data)s/logs.partial',
                'full_backup':      '%%(slave)s:%%(walmgr_data)s/data.master',
                'config_backup':    '%%(slave)s:%%(walmgr_data)s/config.backup',
                'keep_symlinks':    '1',
                'compression':      '0',
                'walmgr_data':      '~/walshipping',
                'logfile':          '~/log/%(job_name)s.log',
                'pidfile':          '~/pid/%(job_name)s.pid',
                'use_skylog':       '1',
            }

            # slave configuration settings
            slave_opt_dict = {
                'completed_wals':   '%%(walmgr_data)s/logs.complete',
                'partial_wals':     '%%(walmgr_data)s/logs.partial',
                'full_backup':      '%%(walmgr_data)s/data.master',
                'config_backup':    '%%(walmgr_data)s/config.backup',
                'walmgr_data':      '~/walshipping',
                'logfile':          '~/log/%(job_name)s.log',
                'pidfile':          '~/pid/%(job_name)s.pid',
                'use_skylog':       '1',
            }

            if self.options.init_master:
                opt_dict.update(master_opt_dict)
            elif self.options.init_slave:
                opt_dict.update(slave_opt_dict)

            self.is_master = self.options.init_master

            config = skytools.Config(self.service_name, None,
                user_defs = opt_dict, override = self.cf_override)
        else:
            # default to regular config handling
            config = skytools.DBScript.load_config(self)

            self.is_master = config.has_option('master_data')

        # create the log and pid files if needed
        for cfk in [ "logfile", "pidfile" ]:
            if config.has_option(cfk):
                dirname = os.path.dirname(config.getfile(cfk))
                if not os.path.isdir(dirname):
                    os.makedirs(dirname)

        return config
def load_config ( self ) : if len ( self . args ) < 1 : # no config file, generate default # guess the job name from cmdline options if self . options . init_master : job_name = 'wal-master' elif self . options . init_slave : job_name = 'wal-slave' else : job_name = 'walmgr' # common config settings opt_dict = { 'use_skylog' : '0' , 'job_name' : job_name , } # master configuration settings master_opt_dict = { 'master_db' : 'dbname=template1' , 'completed_wals' : '%%(slave)s:%%(walmgr_data)s/logs.complete' , 'partial_wals' : '%%(slave)s:%%(walmgr_data)s/logs.partial' , 'full_backup' : '%%(slave)s:%%(walmgr_data)s/data.master' , 'config_backup' : '%%(slave)s:%%(walmgr_data)s/config.backup' , 'keep_symlinks' : '1' , 'compression' : '0' , 'walmgr_data' : '~/walshipping' , 'logfile' : '~/log/%(job_name)s.log' , 'pidfile' : '~/pid/%(job_name)s.pid' , 'use_skylog' : '1' , } # slave configuration settings slave_opt_dict = { 'completed_wals' : '%%(walmgr_data)s/logs.complete' , 'partial_wals' : '%%(walmgr_data)s/logs.partial' , 'full_backup' : '%%(walmgr_data)s/data.master' , 'config_backup' : '%%(walmgr_data)s/config.backup' , 'walmgr_data' : '~/walshipping' , 'logfile' : '~/log/%(job_name)s.log' , 'pidfile' : '~/pid/%(job_name)s.pid' , 'use_skylog' : '1' , } if self . options . init_master : opt_dict . update ( master_opt_dict ) elif self . options . init_slave : opt_dict . update ( slave_opt_dict ) self . is_master = self . options . init_master config = skytools . Config ( self . service_name , None , user_defs = opt_dict , override = self . cf_override ) else : # default to regular config handling config = skytools . DBScript . load_config ( self ) self . is_master = config . has_option ( 'master_data' ) # create the log and pid files if needed for cfk in [ "logfile" , "pidfile" ] : if config . has_option ( cfk ) : dirname = os . path . dirname ( config . getfile ( cfk ) ) if not os . path . isdir ( dirname ) : os . makedirs ( dirname ) return config