Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not spawn uname(1) every time version info is needed #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions asana/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from types import ModuleType
import json
import platform
import os
import time
import string
import warnings
Expand Down Expand Up @@ -324,12 +325,18 @@ def _version_header(self):

def _version_values(self):
"""Generate the values to go in the client version header."""
# Prefer os.uname() over platform.*() on systems that support
# it, as it does not call the uname(1) binary.
# Using [0] instead of .sysname and [2] instead of .release for
# python2 compatibility.
return {
'language': 'Python',
'version': __version__,
'language_version': platform.python_version(),
'os': platform.system(),
'os_version': platform.release()
'os': (
hasattr(os, 'uname') and os.uname()[0] or platform.system()),
'os_version': (
hasattr(os, 'uname') and os.uname()[2] or platform.release())
}

@classmethod
Expand Down