def _get_git_version():
		"""Function gets latest revision of the working copy.
		It only works in git repositories, and is actually a hack.
		"""
		try:
			from run_uh import find_uh_position

			uh_path = find_uh_position()
			git_head_path = os.path.join(uh_path, '.git', 'HEAD')
			if os.path.exists(git_head_path):
				head = open(git_head_path).readline().strip().partition(' ')
				if head[2]:
					head_file = os.path.join(uh_path, '.git', head[2])
				else:
					head_file = git_head_path
				if os.path.exists(head_file):
					return unicode(open(head_file).readline().strip()[0:7])
		#if there is no .git directory then check for gitversion.txt
		except ImportError:
			try:
				return unicode(open(os.path.join("content", "gitversion.txt")).read())
			except IOError:
				return u"<unknown>"

		return u"<unknown>"
Esempio n. 2
0
	def _set_version(version=None):
		"""Function gets latest revision of the working copy.
		It only works in svn or git-svn repositories, and is acctually a hack.
		@param version: String to display instead of revision."""
		if version == None:
			try:
				from run_uh import find_uh_position
			except ImportError:
				return unicode("SVN")

			rev = None
			uh_path = find_uh_position()
			svn_entries_path = os.path.join(uh_path, '.svn', 'entries')
			git_svn_path = os.path.join(uh_path, '.git', 'logs', 'refs', 'remotes', 'git-svn')
			if os.path.exists(svn_entries_path):
				entries_file = open(svn_entries_path).read()
				if re.match('\d', entries_file):
					rev = re.search('\d+\s+dir\s+(\d+)', entries_file).groups()[0]
				else:
					from xml.dom import minidom
					rev = minidom.parse(entries_file).getElementsByTagName("entry")[0].getAttribute("revision")
				rev = u"r" + rev
				return unicode(rev)
			elif os.path.exists(git_svn_path):
				log_file = open(git_svn_path, 'r').read()
				rev  = re.search('\s+r+(\d+)$', log_file).groups()[0]
				rev = u"r" + rev
				return unicode(rev)
			else:
				return u""
		else:
			return unicode(version)
Esempio n. 3
0
	def _get_git_version():
		"""Function gets latest revision of the working copy.
		It only works in git repositories, and is actually a hack.
		"""
		try:
			from run_uh import find_uh_position

			uh_path = find_uh_position()
			git_head_path = os.path.join(uh_path, '.git', 'HEAD')
			if os.path.exists(git_head_path):
				head = open(git_head_path).readline().strip().partition(' ')
				if head[2]:
					head_file = os.path.join(uh_path, '.git', head[2])
				else:
					head_file = git_head_path
				if os.path.exists(head_file):
					return unicode(open(head_file).readline().strip()[0:7])
		#if there is no .git directory then check for gitversion.txt
		except ImportError:
			try:
				return unicode(open(os.path.join("content", "gitversion.txt")).read())
			except IOError:
				return u"<unknown>"

		return u"<unknown>"
Esempio n. 4
0
	def _set_version():
		"""Function gets latest revision of the working copy.
		It only works in git repositories, and is actually a hack.
		"""
		try:
			from run_uh import find_uh_position
		except ImportError:
			return u"<unknown>"

		uh_path = find_uh_position()
		git_head_path = os.path.join(uh_path, '.git', 'HEAD')
		if os.path.exists(git_head_path):
			head = open(git_head_path).readline().strip().partition(' ')
			if head[2]:
				head_file = os.path.join(uh_path, '.git', head[2])
			else:
				head_file = git_head_path
			if os.path.exists(head_file):
				return unicode(open(head_file).readline().strip()[0:7])
		return u"<unknown>"
Esempio n. 5
0
	def _set_version():
		"""Function gets latest revision of the working copy.
		It only works in git repositories, and is acctually a hack.
		"""
		try:
			from run_uh import find_uh_position
		except ImportError:
			return u"<unknown>"

		uh_path = find_uh_position()
		git_head_path = os.path.join(uh_path, '.git', 'HEAD')
		if os.path.exists(git_head_path):
			head = open(git_head_path).readline().strip().partition(' ')
			if head[2]:
				head_file = os.path.join(uh_path, '.git', head[2])
			else:
				head_file = git_head_path
			if os.path.exists(head_file):
				return unicode(open(head_file).readline().strip()[0:7])
		return u"<unknown>"