def main(args): # Parse cfg files global cfg if(args[1] == "-m"): cfg = ConfigParser.ConfigParser() cfg.read(args[2]) feeds = [f for f in cfg.sections() if f.startswith('feed.')] feeddata = list() for f in feeds: d = dict() d["delivery"] = cfg.get(f, "delivery") d["prodcfg"] = mniprod.mniprod(getProdData( cfg.get(f,"production.cfg"))) d["feedname"] = cfg.get(f, "name") feeddata.append(d) else: cfg = ConfigParser.ConfigParser() cfg.read(args[2]) mp = mniprod.mniprod(getProdData(args[1])) bloghome = cfg.get("mniblogpub.shared", "bloghome") scpDelivery = cfgGet("dir.scp.delivery") ts = timeseq() while(True): l = os.listdir(scpDelivery) l = [x.strip() for x in l] l.remove(".svn") l.sort() for x in l: # Separate pdf and xml m = seperateAndArchive(x) #m = mnimsgxml.mnimsgfromfile(x) # Multi Feed if(args[1] == "-m"): anySuccess = False for d in feeddata: r = handle(m, d["prodcfg"], ts, d["delivery"], d["feedname"]) if not r: print timeLog() + "ERROR - " + d["feedname"] + \ " - Error in xml generation." anySuccess = (anySuccess or r) if anySuccess: os.remove(scpDelivery + "/" + x) # Single Feed else: if handle(m, mp, ts): os.remove(scpDelivery + "/" + x) sys.stdout.flush() time.sleep(float(cfgGet("loopdelay"))) return 0
def __init__(self, proddata=None, feedName="default", \ delivery="/usr/local/mniblog2/delivery", \ embargo="/usr/local/mniblog2/queue", shouldLog=False, year=-1): self.mp = mniprod.mniprod(proddata) self.dirDelivery = delivery self.dirEmbargo = embargo self.name = feedName self.log = shouldLog self.year = year self.shouldLog = shouldLog if(self.shouldLog): print timeLog() + "DELIVERY - " + self.dirDelivery
def main(args): mp = mniprod.mniprod(mproddata) print timeLog() + "mniblog2 - mnemb.py - " \ + "V: $Id: mnemb.py 2643 2011-09-20 15:20:06Z jcerda $" while 1: x = os.walk('queue') y = None for xx in x: y = xx[2] break if y is None: y = list() for xy in y: print repr(xy) mypath = os.path.join('queue', xy) fxy = file(mypath) dfxy = xml.dom.minidom.parse(fxy) prefix = 'MKTNEWS_:Special Code=' mytags = [q[0].nodeValue[len(prefix):].split('/')[1].replace('-','=') for q in [z.childNodes for z in dfxy.getElementsByTagName('xn:vendorData')] if q[0].nodeValue.startswith(prefix)] (thetime, tops) = mp.gettimetopics(mytags) if thetime < 0: print "This should never happen." else: mypathtime = os.path.getctime(mypath) # THIS NEW PUBTIME CODE IS UNTESTED mypubtime = dfxy.getElementsByTagName('xn:publicationTime')[0].childNodes[0].nodeValue tz = mypubtime[-5:] if(tz == "-0500"): mypubtime = mypubtime[:-5] + " EST" elif(tz == "-0400"): mypubtime = mypubtime[:-5] + " EDT" mypubtime = time.mktime(time.strptime(mypubtime, "%Y%m%dT%H%M%S %Z")) # THIS NEW PUBTIME CODE IS UNTESTED #if mypathtime + thetime <= time.time(): if mypubtime + thetime <= time.time(): deliverypath = os.path.join('delivery', xy) shutil.move(mypath, deliverypath) print "I MOVE "+mypath else: print "NOT TIME TO MOVE "+mypath+" YET." print "PUBTIME : " + str(mypubtime) print "PATHTIME: " + str(mypathtime) fxy.close() sys.stdout.flush() time.sleep(10) return 0