simple json key returner for what we dump
This commit is contained in:
parent
fbedc5fb60
commit
1efa8496d5
2 changed files with 30 additions and 1 deletions
25
scripts/keyreturn
Executable file
25
scripts/keyreturn
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/python -tt
|
||||||
|
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# take json in
|
||||||
|
# return keys from data if they exist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
infile = sys.stdin
|
||||||
|
obj = json.load(infile)
|
||||||
|
for name in sys.argv[1:]:
|
||||||
|
if type(obj) != dict:
|
||||||
|
print >> sys.stderr, "No dict found"
|
||||||
|
sys.exit(1)
|
||||||
|
if name in obj:
|
||||||
|
print '%s: %s' % (name, obj.get(name, None))
|
||||||
|
else:
|
||||||
|
print >> sys.stderr, "No key %s found" % name
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
|
@ -30,7 +30,10 @@ do
|
||||||
else
|
else
|
||||||
if [ "$verbose" == 'yes' ]; then
|
if [ "$verbose" == 'yes' ]; then
|
||||||
echo $json| python -m json.tool
|
echo $json| python -m json.tool
|
||||||
fi
|
else
|
||||||
|
echo $json| /srv/web/infra/ansible/scripts/keyreturn task_userid
|
||||||
|
echo $json| /srv/web/infra/ansible/scripts/keyreturn cmd
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -64,6 +67,7 @@ fi
|
||||||
|
|
||||||
for pb in $logpath/$where/; do
|
for pb in $logpath/$where/; do
|
||||||
if [ -d $pb/$ts ]; then
|
if [ -d $pb/$ts ]; then
|
||||||
|
echo `basename $pb`
|
||||||
search_logs $pb/$ts/*/*.log
|
search_logs $pb/$ts/*/*.log
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue