Add script to quickly sanity check json files
Change-Id: I0982ddb50b196beb899d01557c5fb44436b03bb5
This commit is contained in:
parent
50ecdbf138
commit
799ee44546
32
testprojectinfo.py
Executable file
32
testprojectinfo.py
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2013 - Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import utils
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
# Make sure all projects info load successfully
|
||||
projects = utils.get_projects_info('', True)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
8
utils.py
8
utils.py
@ -26,6 +26,8 @@ import logging
|
||||
|
||||
CACHE_AGE = 3600 # Seconds
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_projects_info(project=None, all_projects=False, base_dir='./projects'):
|
||||
if all_projects:
|
||||
@ -38,7 +40,11 @@ def get_projects_info(project=None, all_projects=False, base_dir='./projects'):
|
||||
for fn in files:
|
||||
if os.path.isfile(fn):
|
||||
with open(fn, 'r') as f:
|
||||
project = json.loads(f.read())
|
||||
try:
|
||||
project = json.loads(f.read())
|
||||
except Exception:
|
||||
LOG.error('Failed to parse %s' % fn)
|
||||
raise
|
||||
if not (all_projects and project.get('unofficial')):
|
||||
projects.append(project)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user