diff --git a/mpcdf_common.py b/mpcdf_common.py index 3ce2cf995ab9fad63eed9ecb711ec8fe850549f3..936c5a92a33aacd62858e136675d20c9e7668fc6 100644 --- a/mpcdf_common.py +++ b/mpcdf_common.py @@ -58,14 +58,19 @@ def check_for_update(): else: setattr(sys.modules["mpcdf_common"], "checked_for_updates", 1) + if (sys.version_info > (3, 0)): + set_encoding = {"encoding" : "utf-8"} + else: + set_encoding = {} + plugin_dir = os.path.dirname(os.path.realpath(__file__)) git_dir = os.path.join(plugin_dir, ".git") - local_rev = check_output(["git", "--git-dir", git_dir, "rev-parse", "HEAD"], encoding="utf-8").strip() + local_rev = check_output(["git", "--git-dir", git_dir, "rev-parse", "HEAD"], **set_encoding).strip() url = "https://gitlab.mpcdf.mpg.de/mpcdf/osc-plugins.git" def update_server_rev(): - server_rev, _ = check_output(["git", "ls-remote", url, "master"], encoding="utf-8").split(maxsplit=1) + server_rev, _ = check_output(["git", "ls-remote", url, "master"], **set_encoding).split(maxsplit=1) with open(rev_file, "w") as fd: fd.write(server_rev)