예제 #1
0
파일: releases.py 프로젝트: JnrnZEDb/usepy
	def processReleases(self, categorize, postproc, groupName):
		mdb = db.DB()
		console = consoletools.Consoletools()
		n = '\n'
		groupID = ''
		if groupName:
			groupInfo = groups.getByName(groupName)
			groupID = groupInfo['ID']

		self.processReleases = time.time()
		print 'Starting release update process %s' % strftime("%Y-%m-%d %H:%M:%S", gmtime())
		if not os.path.isdir(page.site().nzbpath):
			print 'Bad or missing nzb directory - %s' % page.site().nzbpath
			return

		self.processReleasesStage1(groupID)

		self.processReleasesStage2(groupID)

		self.processReleasesStage3(groupID)

		releasesAdded = self.processReleasesStage4_loop(groupID)

		self.processReleasesStage4dot5(groupID)

		self.processReleasesStage5_loop(groupID)

		self.processReleasesStage6(categorize, postproc, groupID)

		deletedCount = self.processReleasesStage7(groupID)

		# print amount of added releases and time it took

		timeUpdate = console.convertTime(int(time.time() - self.processReleases))
		where = ' WHERE groupID = %s' % groupID if groupID else ''

		cremain = mdb.queryOneRow("select count(ID) as ID from collections "+where)
		print 'Completed adding %d releases in %s. %d collections waiting to be created (still incomplete or in queue for creation.' % (releasesAdded, timeUpdate, cremain['ID'])
		return releasesAdded
예제 #2
0
파일: releases.py 프로젝트: JnrnZEDb/usepy
	def processReleasesStage7(self, groupID):
		mdb = db.DB()
		cat = category.Category()
		console = consoletools.Consoletools()
		n = self.n
		remcount = 0
		passcount = 0
		dupecount = 0
		relsizecount = 0
		completioncount = 0
		disabledcount = 0

		where = ' AND collections.groupID = %s' % groupID if groupID else ''

		# delete old releases and finished collections

		print n+'Stage 7 -> Delete old releases, finished collections and passworded releases.'
		stage7 = time.time()

		# old collections that were missed somehow
		mdb.queryDirect("DELETE collections, binaries, parts \
						FROM collections LEFT JOIN binaries ON collections.ID = binaries.collectionID LEFT JOIN parts on binaries.ID = parts.binaryID \
						WHERE (collections.filecheck = 5 OR (collections.dateadded < (now() - interval 72 hour))) "+where)
		reccount = mdb.getAffectedRows()

		where = ' AND groupID = %s' % groupID if not groupID else ''
		# releases past retention
		if page.site().releaseretentiondays != 0:
			result = mdb.query("SELECT ID, guid FROM releases WHERE postdate < now() - interval %s day " % page.site().releaseretentiondays)
			for rowrel in result:
				self.fastDelete(rowrel['ID'], rowrel['guid'], self.site)
				remcount += 1

		# passworded releases
		if page.site().deletepasswordedrelease == 1:
			result = mdb.query("SELECT ID, guid FROM releases WHERE passwordstatus > 0")
			for rowrel in result:
				self.fastDelete(rowrel['ID'], rowrel['guid'], self.site)
				passcount += 1

		# crossposted releases
		resrel = mdb.query("SELECT ID, guid FROM releases WHERE adddate > (now() - interval %s hour) GROUP BY name HAVING count(name) > 1" % self.crosspostt)
		for rowrel in resrel:
			self.fastDelete(rowrel['ID'], rowrel['guid'], self.site)
			dupecount += 1

		# releases below completion %
		if self.completion > 0:
			resrel = mdb.query("SELECT ID, guid FROM releases WHERE completion < %s and completion > 0" % self.completion)
			for rowrel in resrel:
				self.fastDelet(rowrel['ID'], rowrel['guid'], self.site)
				completioncount += 1

		# disabled categories
		catlist = cat.getDisabledIDs()
		if catlist:
			for dicks in catlist:
				rels = mdb.query("select ID, guid from releases where categoryID = %d", (dicks['ID'],))
				for rel in rels:
					disabledcount += 1
					self.fastDelete(rel['ID'], rel['guid'], self.site)

		print 'Removed releses: %d past rentention, %d passworded, %d crossposted, %d from disabled categories.' % (remcount, passcount, dupecount, disabledcount)
		if self.completion > 0:
			print 'Removed %d under %d%% completion. Removed %d parts/binaries/collection rows.' % (int(completioncount), int(self.completion), int(reccount))
		else:
			print 'Removed %d parts/binaries/collection rows.' % (reccount)

		print console.convertTime(int(time.time() - stage7))
예제 #3
0
파일: releases.py 프로젝트: JnrnZEDb/usepy
	def processReleasesStage5(self, groupID):
		mdb = db.DB()
 		nzbs = nzb.NZB()
		c = consoletools.Consoletools()
		n = self.n
		nzbcount = 0
		where = ' AND groupID = %s' % groupID if groupID else ''

		# create nzb.
		print 'Stage 5 -> Create the NZB, mark collections as ready for deletion.'
		stage5 = time.time()

		start_nzbcount = nzbcount
		resrel = mdb.queryDirect("SELECT ID, guid, name, categoryID FROM releases WHERE nzbstatus = 0 "+where+" LIMIT "+self.stage5limit)
		if resrel:
			for rowrel in resrel:
				if nzb.writeNZBforReleaseId(rowrel['ID'], rowrel['guid'], rowrel['name'], rowrel['categoryID'], nzb.getNZBPath(rowrel['guid'], page.site().nzbpath, True, page.site().nzbsplitlevel)):
					mdb.queryDirect("UPDATE releases SET nzbstatus = 1 WHERE ID = %s", (rowrel['ID'],))
					mdb.queryDirect("UPDATE collections SET filecheck = 5 WHERE releaseID = %s", (rowrel['ID'],))
					nzbcount += 1
					c.overWrite('Creating NZBs:'+c.percentString(nzbcount,len(resrel)))

		timing = c.convertTime(int(time.time() - stage5))
		print n+'%d NZBs created in %s.%s' % (nzbcount, timing, n)
		return nzbcount