diff --git a/avocado/core/job.py b/avocado/core/job.py index f5e9ee03a479295aac55b9430f982a8d1d22f73e..c49654b83c9a19138d659622fa4290b172d0a767 100644 --- a/avocado/core/job.py +++ b/avocado/core/job.py @@ -329,23 +329,28 @@ class Job(object): @staticmethod def _get_avocado_git_version(): + # if running from git sources, there will be a ".git" directory + # 3 levels up + base_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + git_dir = os.path.join(base_dir, '.git') + if not os.path.isdir(git_dir): + return + if not os.path.exists(os.path.join(base_dir, 'python-avocado.spec')): + return + try: git = path.find_command('git') except path.CmdNotFoundError: return - # We need to get git root as `py2to3` creates this file in BUILD + olddir = os.getcwd() try: - os.chdir(os.path.dirname(__file__)) - git_root = process.run('%s rev-parse --show-toplevel' % git, - ignore_status=True, verbose=False) - if git_root.exit_status == 0 and os.path.exists(os.path.join( - git_root.stdout.strip(), 'python-avocado.spec')): - cmd = "%s show --summary --pretty='%%H'" % git - res = process.run(cmd, ignore_status=True, verbose=False) - if res.exit_status == 0: - top_commit = res.stdout.splitlines()[0][:8] - return " (GIT commit %s)" % top_commit + os.chdir(base_dir) + cmd = "%s show --summary --pretty='%%H'" % git + res = process.run(cmd, ignore_status=True, verbose=False) + if res.exit_status == 0: + top_commit = res.stdout.splitlines()[0][:8] + return " (GIT commit %s)" % top_commit finally: os.chdir(olddir) diff --git a/avocado/utils/process.py b/avocado/utils/process.py index debac007a155a2ca63ed9771db2b9d6b726ae978..16bc87e4c3c325d760c2a600216b845540ffc271 100644 --- a/avocado/utils/process.py +++ b/avocado/utils/process.py @@ -257,12 +257,18 @@ class CmdResult(object): """ Command execution result. - :param command: String containing the command line itself - :param exit_status: Integer exit code of the process - :param stdout: String containing stdout of the process - :param stderr: String containing stderr of the process - :param duration: Elapsed wall clock time running the process + :param command: the command line itself + :type command: str + :param exit_status: exit code of the process + :type exit_status: int + :param stdout: content of the process stdout + :type stdout: str + :param stderr: content of the process stderr + :type stderr: str + :param duration: elapsed wall clock time running the process + :type duration: float :param pid: ID of the process + :type pid: int """ def __init__(self, command="", stdout="", stderr="", diff --git a/setup.py b/setup.py index f673d57e9f611f908d05f678055da618c4d7123d..1ef325683a82bef690508873bc0e20752103a857 100755 --- a/setup.py +++ b/setup.py @@ -154,6 +154,7 @@ if __name__ == '__main__': "Operating System :: POSIX", "Topic :: Software Development :: Quality Assurance", "Topic :: Software Development :: Testing", + "Programming Language :: Python :: 2.7", ], packages=find_packages(exclude=('selftests*',)), data_files=get_data_files(),