Changeset 1094


Ignore:
Timestamp:
Sep 21, 2012, 11:47:40 AM (12 years ago)
Author:
joergs
Message:

cleanup output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opsi/products/opsi-bacula-server-conf.py

    r1028 r1094  
    33# get client properties for bacula
    44
     5import logging
    56import subprocess
    67import json
     
    7980#
    8081
     82#logging.basicConfig(format='%(asctime)s %(levelname)8s %(message)s')
     83logging.basicConfig(format='%(message)s')
     84logger = logging.getLogger(__name__)
     85#logger.setLevel(logging.INFO)
     86logger.setLevel(logging.DEBUG)
     87
     88logger.debug( "start" )
     89
    8190try:
    8291    clientsWithBacula=json.loads( subprocess.check_output( opsiCallPrefix + opsiCallClientsWithBacula ) )
    83 except subprocess.CalledProcessError:
    84     print "failed"
    85     exit( 1 )
     92#except subprocess.CalledProcessError as e:
     93except e:
     94    logger.exception( "%s: failed:" %(clientId) )
     95    exit(1)
    8696
    87 pprint( clientsWithBacula )
     97#pprint( clientsWithBacula )
    8898       
    8999for client in clientsWithBacula:
    90100    clientId = client['clientId']
    91     print clientId
    92101   
    93102    try:
    94103        clientBaculaProperties=json.loads( subprocess.check_output( opsiCallPrefix + opsiCallClientBaculaProperties + [ client['clientId'] ] ) )
    95     except subprocess.CalledProcessError:
    96         print "failed"
    97         exit( 1 )
    98        
    99     pprint( clientBaculaProperties )
    100     write_client_conf( client, clientBaculaProperties )
    101     write_job_conf( client, clientBaculaProperties )
     104    except ValueError as e:
     105        logger.warn( "%s: no valid information found: %s" %(clientId, e) )
     106    except subprocess.CalledProcessError as e:
     107        logger.exception( "%s: failed:" %(clientId) )
     108        #exit( 1 )
     109    else:           
     110        #pprint( clientBaculaProperties )
     111        write_client_conf( client, clientBaculaProperties )
     112        write_job_conf( client, clientBaculaProperties )
     113        logger.info( "%s: OK" % clientId )
     114
     115logger.debug( "finished" )
Note: See TracChangeset for help on using the changeset viewer.