mirror of
https://github.com/ARM-software/devlib.git
synced 2025-05-05 07:34:34 +01:00
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]
|