Exemple #1
0
 def __init__ (self, query=False, remote=False):
     """
     Class constructor.
     
     @author: Miguel Branco
     @contact: [email protected]
     @since: 0.3
     @version: $Id: DQDashboardTool.py,v 1.1 2008-05-29 11:15:39 psalgado Exp $
     
     @param query: Boolean indicating if default query options are available
         or not
     @param remote: Boolean indicating if default remote access (service, port)
         options are available or not
     """
     self.__class__._logger = logging.getLogger(self.__module__)
         
     self.parser = OptionParser(usage=self.usage, version=self.version,
                                description=self.description)
     
     # default options are always available
     options = self.defaultOptions
     # if this is a 'query' tool, default query options are available
     if query:
         options.extend(self.defaultQueryOptions)
     # if this is a 'remote access' tool, service, port and alike options
     # are also available
     if remote:
         options.extend(self.remoteOptions)
     # finally, tool specific options should be added
     options.extend(self.toolOptions)
     
     # add all the options to the parser
     for option in options:
         self.parser.add_option(option)
     
     # parse the command line arguments and options and update the options
     (self.options, self.args) = self.parser.parse_args()
Exemple #2
0
"""
Main module 

@copyright: European Organization for Nuclear Research (CERN)
@author: Fernando H. Barreiro U{[email protected]<mailto:[email protected]>}, CERN, 2011
@license: Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at U{http://www.apache.org/licenses/LICENSE-2.0}
"""
from dq2.common.optparse import OptionParser
from dq2.victor.victor import Victor

parser = OptionParser()
parser.add_option(
    "-c",
    "--conf",
    type="string",
    dest="config",
    default="/opt/dq2/etc/dq2.cfg",
    help="Path to the configuration to be used by victor.",
)

(options, args) = parser.parse_args()

victor = Victor("victor", options.config)
victor.run()
Exemple #3
0
class DQDashboardTool:
    """
    @since: 0.3.0
    
    @cvar defaultOptions: overwritten default set of options that apply to all the CLI tools.
    @type defaultOptions: list
    @cvar defaultQueryOptions: .
    @type defaultQueryOptions: list
    @cvar package: .
    @type package: str
    @cvar remoteOptions: .
    @type remoteOptions: list
    @cvar version: DQ2 own version.
    @type version: str
    """
    
    defaultOptions = []
    defaultQueryOptions = []
    package = None
    remoteOptions = []
    version = '$Revision 0.3 $'


    def __init__ (self, query=False, remote=False):
        """
        Class constructor.
        
        @author: Miguel Branco
        @contact: [email protected]
        @since: 0.3
        @version: $Id: DQDashboardTool.py,v 1.1 2008-05-29 11:15:39 psalgado Exp $
        
        @param query: Boolean indicating if default query options are available
            or not
        @param remote: Boolean indicating if default remote access (service, port)
            options are available or not
        """
        self.__class__._logger = logging.getLogger(self.__module__)
            
        self.parser = OptionParser(usage=self.usage, version=self.version,
                                   description=self.description)
        
        # default options are always available
        options = self.defaultOptions
        # if this is a 'query' tool, default query options are available
        if query:
            options.extend(self.defaultQueryOptions)
        # if this is a 'remote access' tool, service, port and alike options
        # are also available
        if remote:
            options.extend(self.remoteOptions)
        # finally, tool specific options should be added
        options.extend(self.toolOptions)
        
        # add all the options to the parser
        for option in options:
            self.parser.add_option(option)
        
        # parse the command line arguments and options and update the options
        (self.options, self.args) = self.parser.parse_args()


# PRIVATE methods


    def _get_parameters (self):
        """
        Abstract method to be implemented in subclasses if needed.
        
        @since: 0.3.0
        """
        pass