Пример #1
0
class CommitScheduler(object):

	def __init__(self, repo_name, repo_path, since_date = datetime.now()):
		self._repo_name = repo_name
		self._repo_path = repo_path
		self._commit_parser = CommitParser(repo_name)

		self._since_date = since_date
		self._until_date = since_date + ONE_MINUTE_TIME_DELTA
	
	def __to_commit_tuples(self, commits):
		return [commit.to_tuple() for commit in commits]

	def job(self):
	
		logging.info("start job ... repo_name:{0} - since_date:{1} - until_date:{2}".format(
					self._repo_name, 
					self._since_date, 
					self._until_date))
		try:
			commits = self._commit_parser.get_needed_commit_message(self._since_date, self._until_date)
		except Exception:
			logging.error("parser commit failed ...")
		else:	
			if len(commits) > 0:
				logging.debug("start insert into table ...")
				commitdao.batch_add_commits(self.__to_commit_tuples(commits))
			self._since_date = self._until_date

		self._until_date = self._until_date + ONE_MINUTE_TIME_DELTA

	def run(self):
		os.chdir(self._repo_path)
		schedule.every(FREQUENCE).minutes.do(self.job)
Пример #2
0
	def __init__(self, repo_name, repo_path, since_date = datetime.now()):
		self._repo_name = repo_name
		self._repo_path = repo_path
		self._commit_parser = CommitParser(repo_name)

		self._since_date = since_date
		self._until_date = since_date + ONE_MINUTE_TIME_DELTA
Пример #3
0
 def parse_commit(self, commit):
     parsed_commit = CommitParser(commit)
     return parsed_commit.to_map()