/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 | Static Public Attributes
Scraper::mucalcopy::MuCalCopyScraper Class Reference
Inheritance diagram for Scraper::mucalcopy::MuCalCopyScraper:
Inheritance graph
[legend]
Collaboration diagram for Scraper::mucalcopy::MuCalCopyScraper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __call__
def changed
def propagate
def seed
def writer

Public Attributes

 maxiter

Static Public Attributes

tuple lcr_matcher = LCR()
tuple nsf_matcher = NSF()

Detailed Description

Definition at line 45 of file mucalcopy.py.


Member Function Documentation

def Scraper::mucalcopy::MuCalCopyScraper::__call__ (   self)
Spin the scrape infinite loop, sleeping at each pass.
Within each pass loop over source vectors and check for propagate readyiness 

Local copy to pick up local copy of output writer

Definition at line 49 of file mucalcopy.py.

00050                       :
00051         """
00052         Spin the scrape infinite loop, sleeping at each pass.
00053         Within each pass loop over source vectors and check for propagate readyiness 
00054 
00055         Local copy to pick up local copy of output writer
00056         """
00057         i,w = 0,0
00058         while i<self.maxiter or self.maxiter==0:
00059             i += 1
00060             log.debug("i %s " % i )
00061             for sv in self:
00062                 proceed = sv()  
00063                 if not proceed:
00064                     continue 
00065 
00066                 wrt = self.writer( sv ) 
00067                 #log.debug("wrt %r " % wrt )
00068 
00069                 for td in self.propagate( sv ):           ## iterate over "yield" supplier of target dicts   
00070                     log.debug("td %r " % td )
00071                     tdi = self.target.instance(**td)      ## may fail with type errors
00072                     log.debug("tdi %r " % tdi )
00073                     wrt.Write(tdi)                        ## RuntimeError basic_string::_S_construct NULL not valid (C++ exception) here
00074 
00075                 if wrt.Close():                           ## hits target DB here
00076                     log.debug("write %s succeeded %s " % ( w, sv) )
00077                     timeend = wrt.ctx.contextrange.timeend     ## UTC TimeStamp
00078                     sv.tcursor = timeend.UTCtoNaiveLocalDatetime + self.interval
00079                     self.tunesleep(w) 
00080                     w += 1
00081                 else:
00082                     log.fatal("writing failed %s " %  sv )
00083                     assert 0
00084             self.handle_signal()
00085             time.sleep(self.sleep.seconds) ## uncomfortable with common sleep here ... 
00086         pass
00087 

def Scraper::mucalcopy::MuCalCopyScraper::changed (   self,
  sv 
)
Always copy new entries, but only IWS/OWS for IWS/OWS valididy

Definition at line 88 of file mucalcopy.py.

00089                            :
00090         """
00091         Always copy new entries, but only IWS/OWS for IWS/OWS valididy
00092         """
00093         inststr= str(sv[-1])
00094         for k,v in sv[-1].asdict.items():
00095             if k == 'IOW_CAL_LED_ID':
00096                 ledid=v
00097         checkpool = int((ledid - 10000*int(ledid/10000))/1000)
00098         if ((checkpool == 0) and (inststr.find("OWS") > 0)):
00099             return True
00100         elif ((checkpool != 0) and (inststr.find("IWS") > 0)):
00101             return True
00102         else:
00103             return False

def Scraper::mucalcopy::MuCalCopyScraper::propagate (   self,
  sv 
)
Copy values directly from sourcevector

Definition at line 104 of file mucalcopy.py.

00105                             :
00106         """
00107         Copy values directly from sourcevector
00108         """
00109 
00110         for k,v in sv[-1].asdict.items():
00111             if k == 'IOW_CAL_LED_ID':
00112                 ledid=v
00113             if k == 'IOW_CAL_LED_ID_Voltage':
00114                 voltage=v
00115             if k == 'IOW_CAL_LED_ID_Frequency':
00116                 frequency=v
00117             if k == 'IOW_CAL_Channel_ID':
00118                 chanid=v
00119             if k == 'IOW_CAL_ErrorCode':
00120                 error=v
00121         d = dict(LedId=ledid,Voltage=voltage,Frequency=frequency,ChannelId=chanid,ErrorCode=error)
00122         yield d

def Scraper::mucalcopy::MuCalCopyScraper::seed (   self,
  sc 
)
Used for seeding target DB when testing into empty tables

:param sc: source class, potentially different seeds will be needed 
   for each source that feeds into a single target

Definition at line 123 of file mucalcopy.py.

00124                       :
00125         """
00126         Used for seeding target DB when testing into empty tables
00127 
00128         :param sc: source class, potentially different seeds will be needed 
00129                    for each source that feeds into a single target
00130         """
00131         return dict(LedId=1,Voltage=0.0,Frequency=0.0,ChannelId=1,ErrorCode=0)

def Scraper::mucalcopy::MuCalCopyScraper::writer (   self,
  sv,
  localstart = None,
  localend = None 
)
Prepare DybDbi writer for target class, with contextrange/subsite appropriate for the source instance

Local copy for writing MuCal table - want the validity to be based on the LED
start and stop times from the DCS table

:param sv:  source vector instance that contains instances of an SA mapped class
:param localstart: default of `None` corresponds to `sv[0].date_time`
:param localend: default of `None` corresponds to `sv[-1].date_time`

Definition at line 132 of file mucalcopy.py.

00133                                                           :
00134         """
00135         Prepare DybDbi writer for target class, with contextrange/subsite appropriate for the source instance
00136 
00137         Local copy for writing MuCal table - want the validity to be based on the LED
00138         start and stop times from the DCS table
00139 
00140         :param sv:  source vector instance that contains instances of an SA mapped class
00141         :param localstart: default of `None` corresponds to `sv[0].date_time`
00142         :param localend: default of `None` corresponds to `sv[-1].date_time`
00143         """
00144 
00145         for k,v in sv[-1].asdict.items():
00146             if k == 'IOW_CAL_LED_ID_timestamp_begin':
00147                 start=v
00148             if k == 'IOW_CAL_LED_ID_timestamp_end':
00149                 end=v
00150 
00151         return Target._wrt( sv[0].__class__ , self.target.kls , start, end ) 


Member Data Documentation

Definition at line 46 of file mucalcopy.py.

Definition at line 47 of file mucalcopy.py.

Definition at line 54 of file mucalcopy.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