コード例 #1
0
ファイル: mnadapt.py プロジェクト: freighthouse/code
	def receivedNews(self, msg):
		#print >>sys.stderr, timeLog() + "NEWS"
		m = mnimsg.mnimsg(msg)

		time = 0
		embargo = 0
		death = 0
		price = 0
		if cfgGet("cfg.advanced"):
			(embargo, death, price, tops) = \
				self.mp.gettopicdata(m.getselectors() + \
						m.gettopics())
		else:
			(time, tops) = \
				self.mp.gettimetopics(m.getselectors() + \
						m.gettopics())


		print >>sys.stderr, self.name+" "+str(m.getselectors() + m.gettopics())+" "+str(time)+" "+str(tops)

		if time < 0 or embargo < 0 or len(tops) == 0:
			return
		elif time == 0:
			mydir = self.dirDelivery
		else:
			mydir = self.dirEmbargo

		xts = self.ts.getnameseq()

		myname = xts[0]+repr(xts[1])+'.xml'

		try:
			myfile = os.path.join(mydir, myname)

			fmyfile = open(myfile, 'wb')

			if(self.shouldLog):
				print timeLog() + "NEWS - " + self.name + \
					" - " + myname + " - " + \
					stripHeadline(m.getheadline())
				logData()
			if cfgGet("cfg.advanced"):
				mx = mniblogxml.mniblogxml(m,tops,self.year,\
							embargo,death,price)
			else:
				mx = mniblogxml.mniblogxml(m,tops,self.year)
			fmyfile.write(mx.toxml())
			fmyfile.close()
		except Exception, e:
			print timeLog() + "EXCEPTION IS " + repr(e)
コード例 #2
0
ファイル: mngenerate.py プロジェクト: freighthouse/code
	def receivedNews(self, msg):
		print >>sys.stderr, "NEWS"
		m = mnimsg.mnimsg(msg)

		(time, tops) = self.mp.gettimetopics(m.getselectors()+m.gettopics())

		if time < 0:
			return
		elif time == 0:
			mydir = '../delivery'
		else:
			mydir = '../queue'

		nt = m.getiso8601timestamp(self.year)
		nt = nt.split('-')[0]
		if nt == self.t:
			self.seq = self.seq + 1
		else:
			self.seq = 0
		self.t = nt

		myname = nt+repr(self.seq)+'.xml'

		try:
			myfile = os.path.join(mydir, myname)

			fmyfile = open(myfile, 'wb')

			print "I'LL PUBLISH "+m.gettimestamp()+" "+stripHeadline(m.getheadline())+" to "+repr(tops)+" in "+repr(time)+" seconds to "+repr(myfile)
			mx = mniblogxml.mniblogxml(m,tops, self.year)
			fmyfile.write(mx.toxml())
			fmyfile.close()
		except Exception, e:
			print "EXCEPTION IS "+repr(e)
コード例 #3
0
ファイル: mnrichwatch.py プロジェクト: freighthouse/code
def handle(msg, mp, ts, delivery="delivery", embargo="queue", name="default"):

        time = 0
        embargo = 0
        death = 0
        price = 0
        if cfgGet("cfg.advanced"):
            (embargo, death, price, tops) = mp.gettopicdata( \
                                                msg.getselectors() + \
                                                msg.gettopics())
        else:
            (time, tops) = mp.gettimetopics(msg.getselectors() + \
                                                 msg.gettopics())

        if time < 0 or embargo < 0 or len(tops) == 0:
                return True
        elif time == 0:
                mydir = delivery
        else:
                mydir = embargo
        xts = ts.getnameseq()
        myname = xts[0]+repr(xts[1])+'.xml'
        try:
                myfile = os.path.join(mydir, myname)

                fmyfile = open(myfile, 'wb')

                print timeLog() + "NEWS - " + name + " - " + myname + \
                    " - " +  stripHeadline(m.getheadline())
                #print "I'LL PUBLISH "+msg.gettimestamp()+" " \
                #        +stripHeadline(msg.getheadline())+" to " \
                #        +repr(tops)+" in "+repr(time)+" seconds to " \
                #        +repr(myfile)
                mx = mniblogxml.mniblogxml(msg,tops)

                # Add our Content type, probably should be in
                # mniblogxml to begin with, but I'm probably rewriting
                # that in mniblog3 anyway, so this will do for now.
                # - Gerg 4/14/11
                mxml = mx.toxml()
                s = mxml.find("<xn:vendorData>MKTNEWS_:")
                mxml = mxml[:s] + "<xn:vendorData>MKTNEWS_:ContentType=" \
                        + msg.getcontenttype() + "</xn:vendorData>" + '\n' \
                        + "    " + mxml[s:]

                fmyfile.write(mxml)
                fmyfile.close()
        except Exception, e:
                print timeLog() + "EXCEPTION IS "+repr(e)
                return False
コード例 #4
0
ファイル: filter_nmainwire.py プロジェクト: freighthouse/code
	def receivedNews(self, msg):
		#print >>sys.stderr, "NEWS"
		m = mnimsg.mnimsg(msg)

		tt = m.getselectors() + m.gettopics()
		a0 = ('A0000000' in tt)
		if a0:
			tt.remove('A0000000')

		(time, tops) = self.mp.gettimetopics(tt)

		if time < 0 and not a0:
			return
		if time < 1:
			mydir = '../delivery'
		else:
			mydir = '../queue'

		nt = m.getiso8601timestamp(self.year)
		nt = nt.split('-')[0]
		if nt == self.t:
			self.seq = self.seq + 1
		else:
			self.seq = 0
		self.t = nt

		myname = nt+repr(self.seq)+'.xml'

		if (a0 and (len(tops) == 0)):
			tops = ['mainwire']
			try:
				myfile = os.path.join(mydir, myname)

				fmyfile = open(myfile, 'wb')

				print stripHeadline(m.getheadline()) + "-" + str(tops)
				#print "I'LL PUBLISH "+m.gettimestamp()+" "+stripHeadline(m.getheadline())+" to "+repr(tops)+" in "+repr(time)+" seconds to "+repr(myfile)
				mx = mniblogxml.mniblogxml(m,tops, self.year)
				fmyfile.write(mx.toxml())
				fmyfile.close()
			except Exception, e:
				print "EXCEPTION IS "+repr(e)