mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 10:17:45 +08:00
px4.py: get release version from Git
This commit is contained in:
+35
-13
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
# Copyright (c) 2017-2020 PX4 Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -32,37 +32,59 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
#
|
"""
|
||||||
# Basic central executable for PX4 maintenance
|
Basic central executable for PX4 maintenance.
|
||||||
#
|
"""
|
||||||
|
|
||||||
# for python2.7 compatibility
|
# For python2.7 compatibility
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import array
|
||||||
|
import base64
|
||||||
import binascii
|
import binascii
|
||||||
|
import json
|
||||||
|
import os
|
||||||
import serial
|
import serial
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import json
|
import subprocess
|
||||||
import zlib
|
import sys
|
||||||
import base64
|
|
||||||
import time
|
import time
|
||||||
import array
|
import zlib
|
||||||
import os
|
|
||||||
|
|
||||||
from sys import platform as _platform
|
from sys import platform as _platform
|
||||||
|
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
"""
|
||||||
|
Get PX4 Firmware latest Git tag.
|
||||||
|
"""
|
||||||
|
px4_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
if os.path.isdir(os.path.join(px4_dir, '.git')):
|
||||||
|
# Get the version using "git describe".
|
||||||
|
cmd = 'git describe --abbrev=0 --tags'.split()
|
||||||
|
try:
|
||||||
|
version = subprocess.check_output(
|
||||||
|
cmd, cwd=px4_dir).decode().strip()
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print('Unable to get version number from git tags')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
# Detect python version
|
# Detect python version
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
runningPython3 = False
|
runningPython3 = False
|
||||||
else:
|
else:
|
||||||
runningPython3 = True
|
runningPython3 = True
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
print("PX4 release v1.6")
|
def main():
|
||||||
|
print("PX4 release", get_version())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user