/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Properties | Private Member Functions
Scraper::base::regime::Regime Class Reference

List of all members.

Public Member Functions

def __init__
def dryrun
def initialize
def __call__
def setsignals
def sigreceiver

Public Attributes

 signal

Properties

 target = property( lambda self:Target(self) )

Private Member Functions

def _initialize_custom
def _initialize_scraper
def _initialize_averager
def _initialize_faker

Detailed Description

The regime class ctor takes the cfg as its sole argument,
which being a dict takes the cfg into itself.   

Definition at line 7 of file regime.py.


Constructor & Destructor Documentation

def Scraper::base::regime::Regime::__init__ (   self,
  args,
  kwa 
)

Definition at line 14 of file regime.py.

00015                                      :
00016         dict.__init__(self, *args, **kwa )
00017         os.environ['DBCONF'] = self['target']      ## moved earlier to avoid having regression noted in #1288
        self.initialize()

Member Function Documentation

def Scraper::base::regime::Regime::dryrun (   self)

Definition at line 18 of file regime.py.

00019                     :
00020         log.info( "dryrun\n%s" % pformat(self) ) 
00021 
00022         from DybPython import DBConf
00023         for _ in ('source','target',):
00024             dbconf = self.get(_,None)
00025             if dbconf:
00026                 dbc = DBConf(dbconf)
00027                 log.info("%s %s %r " % ( _, dbconf, dict(dbc,password="***") )) 

def Scraper::base::regime::Regime::initialize (   self)
Preparations done prior to calling the regime class, including:

Definition at line 28 of file regime.py.

00029                           :
00030         """
00031         Preparations done prior to calling the regime class, including:
00032         """
00033 
00034 
00035         mode = self['mode']
00036         if mode == 'faker':
00037             self._initialize_faker()
00038         elif mode == 'scraper':
00039             self._initialize_scraper()
00040         elif mode == 'averager':
00041             self._initialize_averager()
00042         elif mode == 'custom':
00043             self._initialize_custom()
00044         else:
00045             assert 0, "mode %s is not recognized " % mode
00046 
00047         if self['DROP_TARGET_TABLES']:
00048             utl = Utils(self)
00049             utl.drop_dbi_tables() 
00050 

def Scraper::base::regime::Regime::_initialize_custom (   self) [private]

Definition at line 51 of file regime.py.

00052                                 :
00053         assert self['mode'] == 'custom'
00054         pass

def Scraper::base::regime::Regime::_initialize_scraper (   self) [private]

Definition at line 55 of file regime.py.

00056                                  :
00057         assert self['mode'] == 'scraper'
00058         pass

def Scraper::base::regime::Regime::_initialize_averager (   self) [private]

Definition at line 59 of file regime.py.

00060                                   :
00061         assert self['mode'] == 'averager'
00062         pass

def Scraper::base::regime::Regime::_initialize_faker (   self) [private]
#. drop/create/load of fake source DB (for faker mode with ``faker_dropsrc=True`` )  

Definition at line 63 of file regime.py.

00064                                :
00065         """
00066         #. drop/create/load of fake source DB (for faker mode with ``faker_dropsrc=True`` )  
00067         """
00068         assert self['mode'] == 'faker'
00069         faker_dropsrc = bool(self.get('faker_dropsrc','False'))
00070         log.info("_initialize_faker faker_dropsrc %s " % ( faker_dropsrc ))
00071         if faker_dropsrc == True:
00072             log.warn("initialize : proceeding to drop/create/load ")
00073             utl = Utils(self)
00074             utl.setup_faker_source()
00075         else:
00076             log.info("initialize : skipping drop/create/load of source DB ")
00077 
 
def Scraper::base::regime::Regime::__call__ (   self)
Accesses the attribute pointed to by ``mode`` config value 
eg ``scraper or faker`` and calls the class returned

Definition at line 78 of file regime.py.

00078                       :     
00079         """
00080         Accesses the attribute pointed to by ``mode`` config value 
00081         eg ``scraper or faker`` and calls the class returned
00082         """
00083         if self['dryrun']:
00084             self.dryrun()
00085             return 
00086 
00087         call = getattr( self, self['mode'] )   
00088         assert callable(call), "error the mode attribute %s is not callable" % self['mode'] 
00089         if call:
00090             call()
00091         else: 
00092             log.fatal("mode %s not supported" % self['mode'] ) 
00093 
def Scraper::base::regime::Regime::setsignals (   self)
signal handling following the approach of supervisord    

Definition at line 94 of file regime.py.

00095                         :
00096         """
00097         signal handling following the approach of supervisord    
00098         """     
00099         self.signal = None 
00100         signal.signal(signal.SIGHUP,  self.sigreceiver)
00101         signal.signal(signal.SIGTERM, self.sigreceiver)

def Scraper::base::regime::Regime::sigreceiver (   self,
  sig,
  frame 
)

Definition at line 102 of file regime.py.

00103                                      :
00104         self.signal = sig
00105 
00106 


Member Data Documentation

Definition at line 96 of file regime.py.


Property Documentation

Scraper::base::regime::Regime::target = property( lambda self:Target(self) ) [static]

Definition at line 12 of file regime.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:03 for Scraper by doxygen 1.7.4