summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2014-09-09 09:14:54 +0300
committerFathi Boudra <fathi.boudra@linaro.org>2014-09-09 09:14:54 +0300
commit6381bf7e26812b8b234ba0f42676771dea834eda (patch)
tree9645ef7e2cfbbc54c54658495c2b8fe4d3838414
parentadbbf5d90c53ae06b439c3986549d40756e84f3d (diff)
dtb-to-device: handle unsupported dtb and some cleanup
Change-Id: If24ed53a6a1b5cbe865133649209b3bb82ebed97 Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
-rw-r--r--dtb-to-device.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/dtb-to-device.py b/dtb-to-device.py
index 2b19921..1d2645a 100644
--- a/dtb-to-device.py
+++ b/dtb-to-device.py
@@ -4,6 +4,7 @@ import json
import os
import re
import string
+import xmlrpclib
import yaml
# mapping device tree blob - device type
@@ -46,16 +47,14 @@ def lava_submit(config, lava_server):
# LAVA user
lava_user = os.environ.get('LAVA_USER')
if lava_user is None:
- f = open('/var/run/lava/lava-user')
- lava_user = f.read().strip()
- f.close()
+ with open('/var/run/lava/lava-user') as f:
+ lava_user = f.read().strip()
# LAVA token
lava_token = os.environ.get('LAVA_TOKEN')
if lava_token is None:
- f = open('/var/run/lava/lava-token')
- lava_token = f.read().strip()
- f.close()
+ with open('/var/run/lava/lava-token') as f:
+ lava_token = f.read().strip()
# LAVA server base URL
lava_server_root = lava_server.rstrip('/')
@@ -77,7 +76,7 @@ def lava_submit(config, lava_server):
print 'LAVA Job Id: %s, URL: http://%s/scheduler/job/%s' % \
(lava_job_id, lava_server_root, lava_job_id)
else:
- print 'LAVA job submission skipped.'
+ print 'INFO: LAVA job submission skipped.'
def main():
@@ -87,10 +86,14 @@ def main():
for root, dirs, dtb_files in os.walk('out/dtb'):
for dtb_file in dtb_files:
- with open('custom_lava_job_definition.yaml') as f:
- buffer = f.read()
- template = string.Template(buffer)
- buffer = template.safe_substitute(
+ device_type = device.get(dtb_file, None)
+ if device_type is None:
+ print 'INFO: %s is not mapped to a device' % dtb_file
+ else:
+ with open('custom_lava_job_definition.yaml') as f:
+ template = string.Template(f.read())
+
+ lava_template = template.safe_substitute(
DTB_FILE_NAME=dtb_file,
KERNEL_FILE_NAME=os.environ.get('KERNEL_FILE_NAME'),
defconfig=os.environ.get('defconfig'),
@@ -106,11 +109,11 @@ def main():
GIT_COMMIT=os.environ.get('GIT_COMMIT'),
BUNDLE_STREAM_NAME=os.environ.get('BUNDLE_STREAM_NAME'),
LAVA_SERVER=lava_server,
- DEVICE_TYPE=device[dtb_file],
+ DEVICE_TYPE=device_type,
BUILD_URL=os.environ.get('BUILD_URL')
)
- config = json.dumps(yaml.safe_load(buffer), indent=2)
+ config = json.dumps(yaml.safe_load(lava_template), indent=2)
lava_submit(config, lava_server)