mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 12:57:27 +08:00
[tools] Phyton-based Airframe File Editor
Squashed commit of the following: commit 67afebebdf3a2743b6c97ebac1a267c16aeff9b6 Author: Felix Ruess <felix.ruess@gmail.com> Date: Mon Sep 30 18:02:23 2013 +0200 [tools] airframe editor: minor fixes and pep8 commit f7ea77c13ea6d9df89afc098d033dae88d876b7d Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Mar 5 17:41:22 2013 +0100 New Group identification tag commit 0c20d2824ec4739954e7ee6930ec9c99966683fa Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Mar 5 16:28:47 2013 +0100 Delete old grouping tags to avoid growing in time commit 43902b8810711dba167c87fc9c35babc9c833a31 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Mar 5 16:01:09 2013 +0100 Better xml loading error handling commit a2590591708787fa2ba13b69dc8f64ea932d5979 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Mar 5 14:13:28 2013 +0100 Run xml_airframe standalone for batch conversions commit 1092bf0db9785e9434e41a69a460e6e00a19e81e Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Mar 5 14:07:48 2013 +0100 Save DTD path and initial comment from airframe.xml commit bf2a10603e20a66d7de3f6a097a4c5f091695047 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Mar 5 10:12:15 2013 +0100 Do not forget airframe name commit 44ddc63a181219c74e9a25d4c3a2a6a1e96acdb8 Author: Christophe De Wagter <dewagter@gmail.com> Date: Fri Feb 15 16:28:48 2013 +0100 Commenting change in airframe commit 172724335a78abd140f442518857e65a46e5ed97 Author: Christophe De Wagter <dewagter@gmail.com> Date: Fri Feb 15 16:26:26 2013 +0100 XML Structure commit 15e6cc8daf05b00d64b93f86a1b1322d991fffad Author: Christophe De Wagter <dewagter@gmail.com> Date: Fri Feb 15 09:26:12 2013 +0100 MenuBar commit 896303a1717e9efa5824bc3765267c55434ee0b9 Author: Christophe De Wagter <dewagter@gmail.com> Date: Thu Feb 14 22:39:11 2013 +0100 auto-grep commit 808339828f7e6c69d92112f91064716b59f66cc5 Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 21:55:21 2013 +0100 Search for defines commit 28bfce357b7b047c54d960dda992acd12a5a898e Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 20:35:23 2013 +0100 Show section content - editable commit 2dbfc5aed93d0f336c6509cab74d94f97c4b9d61 Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 18:54:26 2013 +0100 Boards commit 97ebb81240795ba4740018f17fc31e9a695111db Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 17:53:35 2013 +0100 Finally Fixed XML Output commit b27ddfb401abf8c7aa81770db9f0410ab66da27f Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 16:25:38 2013 +0100 Better Size Management commit e7fa8a66786d2ad15236211e80852f188a608b0f Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 07:54:12 2013 +0100 Rename commit 129bdda836b8d7d3064f7b79e54a7cae8a29bae9 Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 02:16:14 2013 +0100 Generate Nice and Grouped XML commit b6fc1f53ade5fc7f0e6b6cdadc9d07ab1307c414 Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 01:24:22 2013 +0100 Editor Update commit 996e70fe0db7737325ec24b0960e504aff58b105 Author: Christophe De Wagter <dewagter@gmail.com> Date: Wed Feb 13 00:28:34 2013 +0100 Restructure commit abcaedb90ae5f3de1ea520e354337008c06f3db2 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 18:48:13 2013 +0100 Automatic Airframe Re-Origanization commit 2faeb74a7d604d3a07b647692737af063bf9e2f6 Author: Felix Ruess <felix.ruess@gmail.com> Date: Tue Feb 12 17:40:38 2013 +0100 fix typo commit c991428d6411277a4d293a2e8e50b4da091ede96 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 16:54:17 2013 +0100 Pretty Print commit 8eac7f8f2cfe8b5eeaf4e2e90ec470be0a56dacc Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 15:38:19 2013 +0100 Open Files commit daf9a4723d71222e111b1c1274e45273eb275029 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 14:54:45 2013 +0100 Open File commit fb0a2eb10451bb19989ef35311ac10d69ba0f937 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 14:47:15 2013 +0100 Cleanup commit 6d7aeef7bf31e7c05738d8ccd90e91468bae24db Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 14:29:33 2013 +0100 Grouped paparazzi commit 2ec961acd51fd64337697152c92f49b82c560048 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 13:29:32 2013 +0100 paparazzi.py commit d0cb88cbbb7dc763d5a5545948c494fcad906b26 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 10:10:57 2013 +0100 Attempt to add comments in xml commit c10455d93e700438c91e34198d96bda5791d5aa9 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 10:10:33 2013 +0100 Paparazzi-Common commit 74214985f45b4c590af3702c2ec6a9e351b45895 Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 09:54:15 2013 +0100 Rename for Clarity commit 8ce5ecbd2477dffba9c06ca8e51357e83783aaef Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 09:48:54 2013 +0100 Module for gui stuff commit 293d776409c150e826b37d815a6198176fc2cacb Author: Christophe De Wagter <dewagter@gmail.com> Date: Tue Feb 12 09:12:26 2013 +0100 Read SubBlocks commit f166629579088fb905dfdfdfcc52632c524eb506 Author: Christophe De Wagter <dewagter@gmail.com> Date: Mon Feb 11 23:15:33 2013 +0100 DataGrid commit ab06a1e1f6a50aaa1fe92109993fe3ea80ba3cdb Author: Christophe De Wagter <dewagter@gmail.com> Date: Mon Feb 11 21:59:50 2013 +0100 Solve Merge Errors commit 90e3f626ad46657ebc9720e15de8b39e327afeea Author: Christophe De Wagter <dewagter@gmail.com> Date: Mon Feb 11 21:27:52 2013 +0100 TreeView commit 730cb7960d9c291ec3a9a2cdd3d05606c0d7c2b7 Author: Felix Ruess <felix.ruess@gmail.com> Date: Mon Feb 11 19:02:42 2013 +0100 get paparazzi_home from env, indentation 4spaces as in pep8 commit 2df5c4c972ec994fe3d42810e26c3b4166acc381 Author: Christophe De Wagter <dewagter@gmail.com> Date: Mon Feb 11 17:49:50 2013 +0100 Airframe Editor commit f71e2dd434121ecc16dbd2c682e1b6f89281388b Author: Christophe De Wagter <dewagter@gmail.com> Date: Mon Feb 11 15:55:02 2013 +0100 Phyton-based Airframe File Editor
This commit is contained in:
committed by
Felix Ruess
parent
81d3759f73
commit
84be7ddba2
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import glob
|
||||
|
||||
from collections import namedtuple
|
||||
from os import path, getenv
|
||||
#from subprocess import call
|
||||
import commands
|
||||
|
||||
import lxml.etree as ET
|
||||
|
||||
# if PAPARAZZI_HOME not set, then assume the tree containing this
|
||||
# file is a reasonable substitute
|
||||
home_dir = getenv("PAPARAZZI_HOME", path.normpath(path.join(
|
||||
path.dirname(path.abspath(__file__)), '../../../')))
|
||||
|
||||
# Directories
|
||||
firmwares_dir = path.join(home_dir, "conf/firmwares/")
|
||||
modules_dir = path.join(home_dir, "conf/modules/")
|
||||
airframes_dir = path.join(home_dir, "conf/airframes/")
|
||||
boards_dir = path.join(home_dir, "conf/boards/")
|
||||
|
||||
# Structures
|
||||
PprzModule = namedtuple("PprzModule", "description defines configures")
|
||||
|
||||
# List Of Stuff
|
||||
def get_list_of_files(directory, extension):
|
||||
mylist = glob.glob(path.join(directory, "*" + extension))
|
||||
mylist.sort()
|
||||
ret = []
|
||||
for it in mylist:
|
||||
ret.append( it.replace(directory, "").replace(extension, ""))
|
||||
return ret
|
||||
|
||||
def get_list_of_modules():
|
||||
return get_list_of_files( modules_dir, ".xml")
|
||||
|
||||
def get_list_of_firmwares():
|
||||
return get_list_of_files( firmwares_dir, ".makefile")
|
||||
|
||||
def get_list_of_boards():
|
||||
return get_list_of_files( boards_dir, ".makefile")
|
||||
|
||||
def get_list_of_subsystems(firmware):
|
||||
subsys_dir = path.join( firmwares_dir, "subsystems/" + firmware + "/")
|
||||
# \todo how about shared
|
||||
#subsys_dir = path.join( firmwares_dir, "subsystems/shared/" )
|
||||
return get_list_of_files(subsys_dir, ".makefile")
|
||||
|
||||
def get_list_of_servo_drivers():
|
||||
# \todo where do we know this?
|
||||
return ["Ppm", "Asctec", "Scilab"]
|
||||
|
||||
def get_module_information(module_name):
|
||||
str_desc = ""
|
||||
lst_def = []
|
||||
lst_conf = []
|
||||
try:
|
||||
xml = ET.parse(path.join(modules_dir, module_name + ".xml"))
|
||||
root = xml.getroot().find("doc")
|
||||
str_desc = root.find("description").text
|
||||
for block in root.iter("define"):
|
||||
lst_def.append([block.get("name"), block.get("value"), block.get("unit"), block.get("description")])
|
||||
for block in root.iter("configure"):
|
||||
lst_conf.append([block.get("name"), block.get("value"), block.get("unit"), block.get("description")])
|
||||
except (IOError, ET.XMLSyntaxError) as e:
|
||||
print(e.__str__())
|
||||
|
||||
return PprzModule(description=str_desc, defines=lst_def, configures=lst_conf)
|
||||
|
||||
|
||||
def search(string):
|
||||
#return call(["grep", "-r", string , home_dir + "/sw/airborne/"])
|
||||
#return system("grep -r " + string + " " + home_dir + "/sw/airborne/")
|
||||
cmd = "grep -r " + string + " " + home_dir + "/sw/airborne/"
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
return output.replace(home_dir + "/sw/airborne/", "")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("====HOME==== ", home_dir)
|
||||
print("----MODULES---- ", modules_dir)
|
||||
print(get_list_of_modules())
|
||||
for mod in get_list_of_modules():
|
||||
print(mod, " ---> ", get_module_information(mod))
|
||||
print("----FIRMWARES---- ", firmwares_dir)
|
||||
print(get_list_of_firmwares())
|
||||
for firm in get_list_of_firmwares():
|
||||
print(firm, " ---> ", get_list_of_subsystems(firm))
|
||||
print("shared", " ---> ", get_list_of_subsystems("shared"))
|
||||
print("----BOARDS---- ", firmwares_dir)
|
||||
print(get_list_of_boards())
|
||||
|
||||
Reference in New Issue
Block a user