Пример #1
0
 def __init__(self, pub):
     super(SamBCoutHTML, self).__init__()
     self.conf = WPConfig()
     self.wp_publisher = pub
     self.wp_publisher.register(self)
     self.gapis = blog_api.google_api_services()
     self.elog = logger.WPLogger()
     self.elog.set_publisher(self)
     # get bloggerAPI authenticated service
     self.service, self.flags = WPConfig.get_authenticated_service(
         self.conf)
Пример #2
0
    def pollForChange(self):    

        prevModDate = None    
        stop = False

        while not stop:
            nowModDate = self.getLastMod() 
            if prevModDate == None:
                # first start up -- publish the playlist page to blogger
                #####################################################
                #   copy SB file, renaming current dest file, if exists, to name+timestamp,
                #          to bloggerAPI working directory
                self.sbFileCopy()
                
                dict = {'msg':self.NEWFILE,'timestamp':WPConfig.get_timestamp(), 'filename':self.dest_n}
                wp_ev = WPEvent(dict)
                self.dispatch(wp_ev)
                #self.logger.log(wp_ev)                  
                prevModDate = nowModDate
                
            elif prevModDate < nowModDate:
                # playlist has changed -- update/replace playlist blogger site
                self.sbFileCopy()
                dict = {'msg':self.FILE_CHANGE,'timestamp':WPConfig.get_timestamp(), 'filename':self.dest_n}
                wp_ev = WPEvent(dict)
                self.dispatch(wp_ev)
                #self.logger.log(wp_ev)                
                prevModDate = nowModDate
            elif prevModDate == nowModDate:
                dict = {'msg':self.NO_CHANGE,'timestamp':WPConfig.get_timestamp(), 'filename':self.dest_n}
                wp_ev = WPEvent(dict)
                self.dispatch(wp_ev)
                
                # no change in playist file: not update/replace

            else:
                msg = ('ERROR Invalid Mod Date: previous time cannot be greater than now time (' + 
                            prevModDate + ',' + nowModDate + ')')
                self.dispatch(TraceEvent(msg))
                stop=True
            start_time = datetime.now()
            if self.DEBUG:
                self.dispatch(TraceEvent('poll start time: ' + str(start_time)))
            wait = True
            if self.DEBUG:
                self.dispatch(TraceEvent("poll waiting..."))
            while wait:
                time_delta = datetime.now() - start_time
                if time_delta.seconds >=30:
                    wait = False
                    if self.DEBUG:
                        self.dispatch(TraceEvent("Poll Waiting is over: " + str(time_delta.seconds)))
Пример #3
0
 def __init__(self, sn='blogger', sv='v3'):
     self.conf = WPConfig()
     self.SCOPES = self.conf.ids['scope']
     self.API_SERVICE_NAME = self.conf.ids['service']
     self.API_VERSION = self.conf.ids['version']
     self.posts = None
     self.request = None
     self.response = None
Пример #4
0
 def __init__(self):
     WPPollPub.__init__(self)
     self.conf = WPConfig()
     self.file_to_listen = self.conf.ids['src_file']
     self.dest_copy_file = self.conf.ids['dest_file']
     self.dest_p, self.dest_n = os.path.split(self.dest_copy_file)
     self.logger = log.WPLogger()
     self.DEBUG = self.conf.ids['DEBUG']
     self.logger.rotate_log()
Пример #5
0
 def buildBAPIdic(self,
                  msg,
                  method='None',
                  blogid='None',
                  itemid='None',
                  response='None'):
     d = {}
     d['msg'] = msg
     d['timestamp'] = WPConfig.get_timestamp()
     d['service'] = self.conf.ids['service']
     d['method'] = method
     d['content'] = self.body
     d['blogid'] = blogid
     d['itemid'] = itemid
     d['response'] = response
     return d
Пример #6
0
 def __init__(self):
     self.conf = WPConfig()
     self.logname = self.conf.ids.get('logname')
     self.listener = self.log_listener()
     self.listener.logname = self.logname
Пример #7
0
def main():
    sbplay = SBPlaylistObserver()
    sbo = sboh(sbplay)
    conf = WPConfig()

    return (sbplay, sbo, conf)