Changeset 696 for branches/0.4


Ignore:
Timestamp:
03/21/13 12:56:12 (11 years ago)
Author:
ramonb
Message:
  • removed debug print statements
  • added some function descriptions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4/parse_ganglia.py

    r695 r696  
    1717        self.parse()
    1818
    19 
    2019    def __del__( self ):
     20
     21        """
     22        Cleanup: close file descriptor
     23        """
    2124
    2225        self.file_pointer.close()
     
    4447    def parse( self ):
    4548
     49        """
     50        Parse self.filename using shlex scanning.
     51        - Removes /* comments */
     52        - Traverses (recursively) through all include () statements
     53        - Stores complete valid config tokens in self.conf_list
     54
     55        i.e.:
     56            ['globals',
     57             '{',
     58             'daemonize',
     59             '=',
     60             'yes',
     61             'setuid',
     62             '=',
     63             'yes',
     64             'user',
     65             '=',
     66             'ganglia',
     67             'debug_level',
     68             '=',
     69             '0',
     70             <etc> ]
     71        """
     72
    4673        t = 'bogus'
    4774        c = False
     
    5885                    if t[:2] == '/*' and t[-2:] == '*/':
    5986
    60                         print 'comment line'
    61                         print 'skipping: %s' %t
     87                        #print 'comment line'
     88                        #print 'skipping: %s' %t
    6289                        continue
    6390
    6491                if t == '/*' or t[:2] == '/*':
    6592                    c = True
    66                     print 'comment start'
    67                     print 'skipping: %s' %t
     93                    #print 'comment start'
     94                    #print 'skipping: %s' %t
    6895                    continue
    6996
    7097                if t == '*/' or t[-2:] == '*/':
    7198                    c = False
    72                     print 'skipping: %s' %t
    73                     print 'comment end'
     99                    #print 'skipping: %s' %t
     100                    #print 'comment end'
    74101                    continue
    75102
    76103            if c:
    77                 print 'skipping: %s' %t
     104                #print 'skipping: %s' %t
    78105                continue
    79106
    80107            if t == 'include':
    81108                i = True
    82                 print 'include start'
    83                 print 'skipping: %s' %t
     109                #print 'include start'
     110                #print 'skipping: %s' %t
    84111                continue
    85112
    86113            if i:
    87114
    88                 print 'include start: %s' %t
     115                #print 'include start: %s' %t
    89116
    90117                t2 = self.removeQuotes( t )
     
    93120                for in_file in glob( self.removeQuotes(t2) ):
    94121
    95                     print 'including file: %s' %in_file
     122                    #print 'including file: %s' %in_file
    96123                    parse_infile = GangliaConfigParser( in_file )
    97124
     
    101128
    102129                i = False
    103                 print 'include end'
    104                 print 'skipping: %s' %t
    105                 continue
    106 
    107             print 'keep: %s' %t
     130                #print 'include end'
     131                #print 'skipping: %s' %t
     132                continue
     133
     134            #print 'keep: %s' %t
    108135            self.conf_lijst.append( t )
    109136
     
    113140
    114141    def confListToDict( self, parent_list=None ):
     142
     143        """
     144        Recursively traverses a conf_list and creates dictionary from it
     145        """
    115146
    116147        new_dict = { }
     
    121152            parent_list = self.conf_lijst
    122153
    123         print 'entering confListToDict(): (parent) list size %s' %len(parent_list)
     154        #print 'entering confListToDict(): (parent) list size %s' %len(parent_list)
    124155
    125156        for n, c in enumerate( parent_list ):
     
    127158            count = count + 1
    128159
    129             print 'CL: n %d c %s' %(n, c)
     160            #print 'CL: n %d c %s' %(n, c)
    130161
    131162            if skip > 0:
     
    156187                if parent_list[n] == '}':
    157188
    158                     #print 'parent_list = %s' %parent_list
    159                     print 'leaving confListToDict(): new dict = %s' %new_dict
     189                    #print 'leaving confListToDict(): new dict = %s' %new_dict
    160190                    return (new_dict, count)
    161191
     
    165195
    166196    def makeConfDict( self ):
     197
     198        """
     199        Walks through self.conf_list and creates a dictionary based upon config values
     200
     201        i.e.:
     202            'tcp_accept_channel': [{'acl': [{'access': [{'action': ['"allow"'],
     203                                                         'ip': ['"127.0.0.1"'],
     204                                                         'mask': ['32']}]}],
     205                                    'port': ['8649']}],
     206            'udp_recv_channel': [{'port': ['8649']}],
     207            'udp_send_channel': [{'host': ['145.101.32.3'],
     208                                  'port': ['8649']},
     209                                 {'host': ['145.101.32.207'],
     210                                  'port': ['8649']}]}
     211        """
    167212
    168213        new_dict = { }
    169214        skip     = 0
    170215
    171         print 'entering makeConfDict()'
     216        #print 'entering makeConfDict()'
    172217
    173218        for n, c in enumerate( self.conf_lijst ):
    174219
    175             print 'M: n %d c %s' %(n, c)
     220            #print 'M: n %d c %s' %(n, c)
    176221
    177222            if skip > 0:
    178223
    179                 print '- skipped'
     224                #print '- skipped'
    180225                skip = skip - 1
    181226                continue
     
    201246
    202247        self.conf_dict = new_dict
    203         print 'leaving makeConfDict(): conf dict size %d' %len( self.conf_dict )
     248        #print 'leaving makeConfDict(): conf dict size %d' %len( self.conf_dict )
    204249
    205250GMOND_LOCATION = '/etc/ganglia/gmond.conf'
Note: See TracChangeset for help on using the changeset viewer.