mirror of
https://github.com/ARM-software/devlib.git
synced 2025-07-26 23:49:10 +01:00
devlib
bin
derived
instrument
module
platform
trace
utils
__init__.py
android.py
csvutil.py
gem5.py
misc.py
parse_aep.py
rendering.py
serial_port.py
ssh.py
types.py
uboot.py
uefi.py
version.py
__init__.py
exception.py
host.py
target.py
doc
src
.gitignore
README.rst
setup.py
If an error occurs when attempting to decode the output from subprocess replace the offending character rather than raising an error.
16 lines
401 B
Python
16 lines
401 B
Python
import os
|
|
import sys
|
|
from subprocess import Popen, PIPE
|
|
|
|
def get_commit():
|
|
p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__),
|
|
stdout=PIPE, stderr=PIPE)
|
|
std, _ = p.communicate()
|
|
p.wait()
|
|
if p.returncode:
|
|
return None
|
|
if sys.version_info[0] == 3:
|
|
return std[:8].decode(sys.stdout.encoding, 'replace')
|
|
else:
|
|
return std[:8]
|