Commit 6fe33b95 authored by Jelte Jansen's avatar Jelte Jansen

update literal_eval calls to also use json.loads

json has a few things tiny bit different, and the parser in python is stricter than absolutely necessary, so had to update a few spec and test data files


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac284@2441 e5f2f494-b856-4b98-b285-d166d9295462
parent 4b50c1a4
......@@ -5,7 +5,7 @@
"config_data": [
{ "item_name": "database_file",
"item_type": "string",
"item_optional": True,
"item_optional": true,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
}
],
......
......@@ -35,7 +35,7 @@ import os, time, random, re
import getpass
from hashlib import sha1
import csv
import ast
import json
import pwd
import getpass
import traceback
......@@ -564,7 +564,7 @@ class BindCmdInterpreter(Cmd):
else:
parsed_value = None
try:
parsed_value = ast.literal_eval(cmd.params['value'])
parsed_value = json.loads(cmd.params['value'])
except Exception as exc:
# ok could be an unquoted string, interpret as such
parsed_value = cmd.params['value']
......
......@@ -6,20 +6,20 @@
{
"item_name": "key_file",
"item_type": "string",
"item_optional": False,
"item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-keyfile.pem'
"item_optional": false,
"item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-keyfile.pem"
},
{
"item_name": "cert_file",
"item_type": "string",
"item_optional": False,
"item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-certfile.pem'
"item_optional": false,
"item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-certfile.pem"
},
{
"item_name": "accounts_file",
"item_type": "string",
"item_optional": False,
"item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-accounts.csv'
"item_optional": false,
"item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-accounts.csv"
}
],
"commands": [
......@@ -32,7 +32,7 @@
"command_name": "shutdown",
"command_description": "shutdown cmdctl",
"command_args": []
},
}
]
}
}
......
......@@ -279,6 +279,7 @@ class TestSecureHTTPRequestHandler(unittest.TestCase):
rcode, reply = self.handler._handle_post_request()
self.assertEqual(http.client.BAD_REQUEST, rcode)
import sys
class MyCommandControl(CommandControl):
def _get_modules_specification(self):
return {}
......
......@@ -6,37 +6,37 @@
{
"item_name": "transfers_in",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 10
}
],
"commands": [
{
'command_name': 'retransfer',
"command_description": 'retransfer a single zone without checking zone serial number',
'command_args': [ {
"command_name": "retransfer",
"command_description": "retransfer a single zone without checking zone serial number",
"command_args": [ {
"item_name": "zone_name",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
},
{
"item_name": "master",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
},
{
"item_name": "port",
"item_type": "integer",
"item_optional": True,
"item_optional": true,
"item_default": 53
},
{
"item_name": "db_file",
"item_type": "string",
"item_optional": True,
"item_default": '@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3'
"item_optional": true,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
}
]
},
......
......@@ -5,43 +5,43 @@
{
"item_name": "transfers_out",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 10
},
{
"item_name": "db_file",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
},
{
"item_name": "log_name",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "Xfrout"
},
{
"item_name": "log_file",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/log/Xfrout.log"
},
{
"item_name": "log_severity",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "debug"
},
{
"item_name": "log_versions",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 5
},
{
"item_name": "log_max_bytes",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 1048576
}
],
......
{'TestModule': {'test': 125}, 'version': 1}
{"version": 1, "TestModule": {"test": 125}}
{
"value1": 1,
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": True },
"value6": { "v61": "bar", "v62": true },
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
}
{
"value1": "asdf",
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": True }
"value6": { "v61": "bar", "v62": true }
}
{
"value1": 1,
"value2": False,
"value3": True,
"value2": false,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": True }
"value6": { "v61": "bar", "v62": true }
}
{
"value1": 1,
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, "a" ],
"value6": { "v61": "bar", "v62": True }
"value6": { "v61": "bar", "v62": true }
}
{
"value1": 1,
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": "Break" }
......
{
"value1": 1,
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": True },
"value7": [ 1, 2.2, "str", True ],
"value6": { "v61": "bar", "v62": true },
"value7": [ 1, 2.2, "str", true ],
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
}
{
"value1": 1,
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": True },
"value6": { "v61": "bar", "v62": true },
"value8": [ { "a": "d" }, { "a": "e" } ],
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
}
{
"value1": 1,
"value2": 2.3,
"value3": True,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": True },
"value6": { "v61": "bar", "v62": true },
"value8": [ { "a": "d" }, { "a": 1 } ]
}
......@@ -4,7 +4,7 @@
"config_data": [
{ "item_name": "item1",
"item_type": "real",
"item_optional": False,
"item_optional": false,
"item_default": 1
}
]
......
......@@ -4,7 +4,7 @@
"config_data": [
{ "item_name": "item1",
"item_type": "boolean",
"item_optional": False,
"item_optional": false,
"item_default": 1
}
]
......
......@@ -4,7 +4,7 @@
"config_data": [
{ "item_name": "item1",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": 1
}
]
......
......@@ -4,7 +4,7 @@
"config_data": [
{ "item_name": "item1",
"item_type": "list",
"item_optional": False,
"item_optional": false,
"item_default": 1
}
]
......
......@@ -4,7 +4,7 @@
"config_data": [
{ "item_name": "item1",
"item_type": "map",
"item_optional": False,
"item_optional": false,
"item_default": 1
}
]
......
......@@ -4,7 +4,7 @@
"config_data": [
{ "item_name": "item1",
"item_type": "badname",
"item_optional": False,
"item_optional": false,
"item_default": 1
}
]
......
......@@ -7,7 +7,7 @@
"command_args": [ {
"item_name": "message",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
} ]
}
......
......@@ -4,48 +4,48 @@
"config_data": [
{ "item_name": "item1",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 1
},
{ "item_name": "item2",
"item_type": "real",
"item_optional": False,
"item_optional": false,
"item_default": 1.1
},
{ "item_name": "item3",
"item_type": "boolean",
"item_optional": False,
"item_default": True
"item_optional": false,
"item_default": true
},
{ "item_name": "item4",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "test"
},
{ "item_name": "item5",
"item_type": "list",
"item_optional": False,
"item_optional": false,
"item_default": [ "a", "b" ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
}
},
{ "item_name": "item6",
"item_type": "map",
"item_optional": False,
"item_optional": false,
"item_default": {},
"map_item_spec": [
{ "item_name": "value1",
"item_type": "string",
"item_optional": True,
"item_optional": true,
"item_default": "default"
},
{ "item_name": "value2",
"item_type": "integer",
"item_optional": True
"item_optional": true
}
]
}
......@@ -57,7 +57,7 @@
"command_args": [ {
"item_name": "message",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
} ]
},
......
......@@ -8,7 +8,7 @@
"command_args": [ {
"item_name": "message",
"item_type": "somethingbad",
"item_optional": False,
"item_optional": false,
"item_default": ""
} ]
}
......
......@@ -4,75 +4,75 @@
"config_data": [
{ "item_name": "value1",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 9
},
{ "item_name": "value2",
"item_type": "real",
"item_optional": False,
"item_optional": false,
"item_default": 9.9
},
{ "item_name": "value3",
"item_type": "boolean",
"item_optional": False,
"item_default": False
"item_optional": false,
"item_default": false
},
{ "item_name": "value4",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "default_string"
},
{ "item_name": "value5",
"item_type": "list",
"item_optional": False,
"item_optional": false,
"item_default": [ "a", "b" ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 8
}
},
{ "item_name": "value6",
"item_type": "map",
"item_optional": False,
"item_optional": false,
"item_default": {},
"map_item_spec": [
{ "item_name": "v61",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "def"
},
{ "item_name": "v62",
"item_type": "boolean",
"item_optional": False,
"item_default": False
"item_optional": false,
"item_default": false
}
]
},
{ "item_name": "value7",
"item_type": "list",
"item_optional": True,
"item_optional": true,
"item_default": [ ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "any",
"item_optional": True
"item_optional": true
}
},
{ "item_name": "value8",
"item_type": "list",
"item_optional": True,
"item_optional": true,
"item_default": [ ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "map",
"item_optional": True,
"item_optional": true,
"item_default": { "a": "b" },
"map_item_spec": [
{ "item_name": "a",
"item_type": "string",
"item_optional": True,
"item_optional": true,
"item_default": "empty"
}
]
......@@ -80,28 +80,28 @@
},
{ "item_name": "value9",
"item_type": "map",
"item_optional": False,
"item_optional": false,
"item_default": {},
"map_item_spec": [
{ "item_name": "v91",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "def"
},
{ "item_name": "v92",
"item_type": "map",
"item_optional": False,
"item_optional": false,
"item_default": {},
"map_item_spec": [
{ "item_name": "v92a",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "Hello"
} ,
{
"item_name": "v92b",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 47806
}
]
......
......@@ -8,7 +8,7 @@
"command_args": [ {
"item_name": "message",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
} ]
}
......
......@@ -4,11 +4,11 @@
"config_data": [
{ "item_name": "item",
"item_type": "list",
"item_optional": True,
"item_optional": true,
"list_item_spec": {
"item_name": "list_element",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
}
}
......
......@@ -3,81 +3,81 @@
"module_name": "Spec27",
"commands": [
{
'command_name': 'cmd1',
"command_name": "cmd1",
"command_description": "command_for_unittest",
'command_args': [
"command_args": [
{
"item_name": "value1",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 9
},
{ "item_name": "value2",
"item_type": "real",
"item_optional": False,
"item_optional": false,
"item_default": 9.9
},
{ "item_name": "value3",
"item_type": "boolean",
"item_optional": False,
"item_default": False
"item_optional": false,
"item_default": false
},
{ "item_name": "value4",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "default_string"
},
{ "item_name": "value5",
"item_type": "list",
"item_optional": False,
"item_optional": false,
"item_default": [ "a", "b" ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 8
}
},
{ "item_name": "value6",
"item_type": "map",
"item_optional": False,
"item_optional": false,
"item_default": {},
"map_item_spec": [
{ "item_name": "v61",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "def"
},
{ "item_name": "v62",
"item_type": "boolean",
"item_optional": False,
"item_default": False
"item_optional": false,
"item_default": false
}
]
},
{ "item_name": "value7",
"item_type": "list",
"item_optional": True,
"item_optional": true,
"item_default": [ ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "any",
"item_optional": True
"item_optional": true
}
},
{ "item_name": "value8",
"item_type": "list",
"item_optional": True,
"item_optional": true,
"item_default": [ ],
"list_item_spec": {
"item_name": "list_element",
"item_type": "map",
"item_optional": True,
"item_optional": true,
"item_default": { "a": "b" },
"map_item_spec": [
{ "item_name": "a",
"item_type": "string",
"item_optional": True,
"item_optional": true,
"item_default": "empty"
}
]
......@@ -85,28 +85,28 @@