Esempio n. 1
0
    def conf_files(self, **kwargs):
        """Get conf files for this server

        :param: number, if supplied will only lookup the nth server

        :returns: list of conf files
        """

        found_conf_files = search_tree(GATE_DIR, '%s-server*'
                % self.type, '.conf')
        number = kwargs.get('number')
        if number:
            try:
                conf_files = [found_conf_files[number - 1]]
            except IndexError:
                conf_files = []
        else:
            conf_files = found_conf_files
        if not conf_files:

            # maybe there's a config file(s) out there, but I couldn't find it!

            if not kwargs.get('quiet'):
                print _('Unable to locate config %sfor %s') \
                    % (('number %s ' % number if number else ''),
                       self.server)
            if kwargs.get('verbose') and not kwargs.get('quiet'):
                if found_conf_files:
                    print _('Found configs:')
                for (i, conf_file) in enumerate(found_conf_files):
                    print '  %d) %s' % (i + 1, conf_file)

        return conf_files
Esempio n. 2
0
    def pid_files(self, **kwargs):
        """Get pid files for this server

        :param: number, if supplied will only lookup the nth server

        :returns: list of pid files
        """

        pid_files = search_tree(self.run_dir, '%s*' % self.server,
                                '.pid')
        if kwargs.get('number', 0):
            conf_files = self.conf_files(**kwargs)

            # filter pid_files to match the index of numbered conf_file

            pid_files = [pid_file for pid_file in pid_files
                         if self.get_conf_file_name(pid_file)
                         in conf_files]
        return pid_files