mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-11-03 11:48:17 +00:00
Add argparse with help.
This commit is contained in:
19
tools/onlplatform.py
Normal file → Executable file
19
tools/onlplatform.py
Normal file → Executable file
@@ -8,6 +8,7 @@ the platform package metadata.
|
||||
|
||||
import sys, os
|
||||
import itertools
|
||||
import argparse
|
||||
|
||||
toolsdir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(toolsdir)
|
||||
@@ -23,9 +24,11 @@ from onlpm import *
|
||||
|
||||
pm = defaultPm()
|
||||
|
||||
platform = sys.argv[1]
|
||||
arch = sys.argv[2]
|
||||
key = sys.argv[3]
|
||||
ap = argparse.ArgumentParser("ONL Platform Data Extractor.")
|
||||
ap.add_argument("platform", help="Platform name")
|
||||
ap.add_argument("arch", help="Architecture")
|
||||
ap.add_argument("key", help="Lookup key.")
|
||||
ops = ap.parse_args()
|
||||
|
||||
def extractKey(platform, arch, key):
|
||||
|
||||
@@ -71,12 +74,12 @@ def extractVendor(platform, arch):
|
||||
l = [x for x in l if x.startswith('onl-vendor-config-')]
|
||||
return "\n".join(l)
|
||||
|
||||
if key in ('kernel', 'initrd', 'dtb', 'itb',):
|
||||
print extractKey(platform, arch, key)
|
||||
if ops.key in ('kernel', 'initrd', 'dtb', 'itb',):
|
||||
print extractKey(ops.platform, ops.arch, ops.key)
|
||||
sys.exit(0)
|
||||
|
||||
if key == 'vendor':
|
||||
print extractVendor(platform, arch)
|
||||
if ops.key == 'vendor':
|
||||
print extractVendor(ops.platform, ops.arch)
|
||||
sys.exit(0)
|
||||
|
||||
raise SystemExit("invalid key %s" % key)
|
||||
raise SystemExit("invalid key %s" % ops.key)
|
||||
|
||||
Reference in New Issue
Block a user