Browse Source

px4.py: get release version from Git

sbg
TSC21 5 years ago committed by Lorenz Meier
parent
commit
18df0240df
  1. 46
      Tools/px4.py

46
Tools/px4.py

@ -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(): def main():
print("PX4 release", get_version())
print("PX4 release v1.6")
if __name__ == '__main__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save