<commit_before>#!/usr/bin/python

""" Module to handle attributes related to the sge jobmanager configuration """

import ConfigParser, os, re, types, logging

from osg_configure.modules import utilities
from osg_configure.modules import configfile
from osg_configure.modules import validation
from osg_configure.modules import exceptions
from osg_configure.modules.jobmanagerbase import JobManagerConfiguration

__all__ = ['SGEConfiguration']


class SGEConfiguration(JobManagerConfiguration):
  """Class to handle attributes related to sge job manager configuration"""

  SGE_CONFIG_FILE = '/etc/grid-services/available/jobmanager-sge'
  GRAM_CONFIG_FILE = '/etc/globus/globus-pbs.conf'
  
  def __init__(self, *args, **kwargs):
    # pylint: disable-msg=W0142
    super(SGEConfiguration, self).__init__(*args, **kwargs)
    self.log('SGEConfiguration.__init__ started') 
    # option information
    self.options = {'sge_root' : 
                      configfile.Option(name = 'sge_root',
                                        mapping = 'OSG_SGE_ROOT'),
                    'sge_cell' : 
                      configfile.Option(name = 'sge_CELL',
                                        mapping = 'OSG_SGE_CELL'),
                    'job_contact' : 
                      configfile.Option(name = 'job_contact',
                                        mapping = 'OSG_JOB_CONTACT'),
                    'util_contact' : 
                      configfile.Option(name = 'util_contact',
                                        mapping = 'OSG_UTIL_CONTACT'),
                    'seg_enabled' : 
                      configfile.Option(name = 'seg_enabled',
                                        required = configfile.Option.OPTIONAL,
                                        type = bool,
                                        default_value = False),
                    'log_directory' : 
                      configfile.Option(name = 'log_directory',
                                        required = configfile.Option.OPTIONAL,
                                        default_value = ''),
                    'default_queue' : 
                      configfile.Option(name = 'default_queue',
                                        required = configfile.Option.OPTIONAL,
                                        default_value = ''),
                    'validate_queues' : 
                      configfile.Option(name = 'validate_queues',
                                        required = configfile.Option.OPTIONAL,
                                        type = bool,
                                        default_value = False),
                    'available_queues' : 
                      configfile.Option(name = 'available_queues',
                                        required = configfile.Option.OPTIONAL,
                                        default_value = ''),
                    'accept_limited' : 
                      configfile.Option(name = 'accept_limited',
                                        required = configfile.Option.OPTIONAL,
                                        type = bool,
                                        default_value = False)}               
    self.__set_default = True
    self.config_section = "SGE"
    self.log('SGEConfiguration.__init__ completed')    
      
  def parseConfiguration(self, configuration):
    """Try to get configuration information from ConfigParser or SafeConfigParser object given
    by configuration and write recognized settings to attributes dict
    """
    self.log('SGEConfiguration.parseConfiguration started')    

    self.checkConfig(configuration)

    if not configuration.has_section(self.config_section):
      self.log('SGE section not found in config file')
      self.log('SGEConfiguration.parseConfiguration completed')    
      return
    
    if not self.setStatus(configuration):
      self.log('SGEConfiguration.parseConfiguration completed')    
      return True
       
    self.getOptions(configuration, ignore_options = ['enabled'])
        
    # fill in values for sge_location and home
    self.options['job_manager'] = configfile.Option(name = 'job_manager',
                                                    value = 'SGE',
                                                    mapping = 'OSG_JOB_MANAGER')
    self.options['home'] = configfile.Option(name = 'job_manager_home',
                                             value = self.options['sge_root'].value,
                                             mapping = 'OSG_JOB_MANAGER_HOME')
    self.options['osg_sge_location'] = configfile.Option(name = 'osg_sge_location',
                                                         value = self.options['sge_root'].value,
                                                         mapping = 'OSG_SGE_LOCATION')
    # used to see if we need to enable the default fork manager, if we don't 
    # find the managed fork service enabled, set the default manager to fork
    # needed since the managed fork section could be removed after managed fork
    # was enabled 
    if (configuration.has_section('Managed Fork') and
        configuration.has_option('Managed Fork', 'enabled') and
        configuration.getboolean('Managed Fork', 'enabled')):
      self.__set_default = False
   
    self.log('SGEConfiguration.parseConfiguration completed')    
  
# pylint: disable-msg=W0613
  def checkAttributes(self, attributes):
    """Check attributes currently stored and make sure that they are consistent"""
    self.log('SGEConfiguration.checkAttributes started')    
    attributes_ok = True
    if not self.enabled:
      self.log('SGE not enabled, returning True')
      self.log('SGEConfiguration.checkAttributes completed')    
      return attributes_ok
    
    if self.ignored:<commit_msg>Fixes for bugs in goc ticket 11570<commit_after>#!/usr/bin/python

""" Module to handle attributes related to the sge jobmanager configuration """

import ConfigParser, os, re, types, logging

from osg_configure.modules import utilities
from osg_configure.modules import configfile
from osg_configure.modules import validation
from osg_configure.modules import exceptions
from osg_configure.modules.jobmanagerbase import JobManagerConfiguration

__all__ = ['SGEConfiguration']


class SGEConfiguration(JobManagerConfiguration):
  """Class to handle attributes related to sge job manager configuration"""

  SGE_CONFIG_FILE = '/etc/grid-services/available/jobmanager-sge'
  GRAM_CONFIG_FILE = '/etc/globus/globus-sge.conf'
  
  def __init__(self, *args, **kwargs):
    # pylint: disable-msg=W0142
    super(SGEConfiguration, self).__init__(*args, **kwargs)
    self.log('SGEConfiguration.__init__ started') 
    # option information
    self.options = {'sge_root' : 
                      configfile.Option(name = 'sge_root',
                                        mapping = 'OSG_SGE_ROOT'),
                    'sge_cell' : 
                      configfile.Option(name = 'sge_CELL',
                                        mapping = 'OSG_SGE_CELL'),
                    'job_contact' : 
                      configfile.Option(name = 'job_contact',
                                        mapping = 'OSG_JOB_CONTACT'),
                    'util_contact' : 
                      configfile.Option(name = 'util_contact',
                                        mapping = 'OSG_UTIL_CONTACT'),
                    'seg_enabled' : 
                      configfile.Option(name = 'seg_enabled',
                                        required = configfile.Option.OPTIONAL,
                                        type = bool,
                                        default_value = False),
                    'log_directory' : 
                      configfile.Option(name = 'log_directory',
                                        required = configfile.Option.OPTIONAL,
                                        default_value = ''),
                    'default_queue' : 
                      configfile.Option(name = 'default_queue',
                                        required = configfile.Option.OPTIONAL,
                                        default_value = ''),
                    'validate_queues' : 
                      configfile.Option(name = 'validate_queues',
                                        required = configfile.Option.OPTIONAL,
                                        type = bool,
                                        default_value = False),
                    'available_queues' : 
                      configfile.Option(name = 'available_queues',
                                        required = configfile.Option.OPTIONAL,
                                        default_value = ''),
                    'accept_limited' : 
                      configfile.Option(name = 'accept_limited',
                                        required = configfile.Option.OPTIONAL,
                                        type = bool,
                                        default_value = False)}               
    self.__set_default = True
    self.config_section = "SGE"
    self.log('SGEConfiguration.__init__ completed')    
      
  def parseConfiguration(self, configuration):
    """Try to get configuration information from ConfigParser or SafeConfigParser object given
    by configuration and write recognized settings to attributes dict
    """
    self.log('SGEConfiguration.parseConfiguration started')    

    self.checkConfig(configuration)

    if not configuration.has_section(self.config_section):
      self.log('SGE section not found in config file')
      self.log('SGEConfiguration.parseConfiguration completed')    
      return
    
    if not self.setStatus(configuration):
      self.log('SGEConfiguration.parseConfiguration completed')    
      return True
       
    self.getOptions(configuration, ignore_options = ['enabled'])
        
    # fill in values for sge_location and home
    self.options['job_manager'] = configfile.Option(name = 'job_manager',
                                                    value = 'SGE',
                                                    mapping = 'OSG_JOB_MANAGER')
    self.options['home'] = configfile.Option(name = 'job_manager_home',
                                             value = self.options['sge_root'].value,
                                             mapping = 'OSG_JOB_MANAGER_HOME')
    self.options['osg_sge_location'] = configfile.Option(name = 'sge_location',
                                                         value = self.options['sge_root'].value,
                                                         mapping = 'OSG_SGE_LOCATION')
    # used to see if we need to enable the default fork manager, if we don't 
    # find the managed fork service enabled, set the default manager to fork
    # needed since the managed fork section could be removed after managed fork
    # was enabled 
    if (configuration.has_section('Managed Fork') and
        configuration.has_option('Managed Fork', 'enabled') and
        configuration.getboolean('Managed Fork', 'enabled')):
      self.__set_default = False
   
    self.log('SGEConfiguration.parseConfiguration completed')    
  
# pylint: disable-msg=W0613
  def checkAttributes(self, attributes):
    """Check attributes currently stored and make sure that they are consistent"""
    self.log('SGEConfiguration.checkAttributes started')    
    attributes_ok = True
    if not self.enabled:
      self.log('SGE not enabled, returning True')
      self.log('SGEConfiguration.checkAttributes completed')    
      return attributes_ok
    
    if self.ignored:
{'fraction_non_alphanumeric': 0.07925207993824514, 'fraction_numerical': 0.0018011836349601166, 'mean_word_length': 1.5870867539383182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 68, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6068261', 'n_tokens_mistral': 2657, 'n_tokens_neox': 2570, 'n_words': 619}