Merge pull request #1209 from JackDanger/jack/store-as-python
Store JSON in Python for instance types
This commit is contained in:
commit
2a3fdf6b64
2
Makefile
2
Makefile
@ -29,7 +29,7 @@ tag_github_release:
|
||||
git tag `python setup.py --version`
|
||||
git push origin `python setup.py --version`
|
||||
|
||||
publish: upload_pypi_artifact build_dockerhub_image tag_github_release
|
||||
publish: upload_pypi_artifact push_dockerhub_image tag_github_release
|
||||
|
||||
scaffold:
|
||||
@pip install -r requirements-dev.txt > /dev/null
|
||||
|
@ -67,6 +67,7 @@ from .exceptions import (
|
||||
MotoNotImplementedError,
|
||||
FilterNotImplementedError
|
||||
)
|
||||
from .resources.instance_types import instance_types_data
|
||||
from .utils import (
|
||||
EC2_RESOURCE_TO_PREFIX,
|
||||
EC2_PREFIX_TO_RESOURCE,
|
||||
@ -112,7 +113,7 @@ from .utils import (
|
||||
)
|
||||
|
||||
RESOURCES_DIR = os.path.join(os.path.dirname(__file__), 'resources')
|
||||
INSTANCE_TYPES = json.load(open(os.path.join(RESOURCES_DIR, 'instance_types.json'), 'r'))
|
||||
INSTANCE_TYPES = json.loads(instance_types_data)
|
||||
|
||||
|
||||
def utc_date_and_time():
|
||||
|
0
moto/ec2/resources/__init__.py
Normal file
0
moto/ec2/resources/__init__.py
Normal file
File diff suppressed because one or more lines are too long
2164
moto/ec2/resources/instance_types.py
Normal file
2164
moto/ec2/resources/instance_types.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -141,10 +141,20 @@ def main():
|
||||
result[instance_id] = instance_data
|
||||
|
||||
root_dir = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).decode().strip()
|
||||
dest = os.path.join(root_dir, 'moto/ec2/resources/instance_types.json')
|
||||
dest = os.path.join(root_dir, 'moto/ec2/resources/instance_types.py')
|
||||
print("Writing data to {0}".format(dest))
|
||||
with open(dest, 'w') as open_file:
|
||||
json.dump(result, open_file)
|
||||
triple_quote = '\"\"\"'
|
||||
|
||||
open_file.write("# Imported via `scripts/get_instance_info.py`\n")
|
||||
open_file.write('instance_types_data = {}\n'.format(triple_quote))
|
||||
json.dump(result,
|
||||
open_file,
|
||||
sort_keys=True,
|
||||
indent=4,
|
||||
separators=(',', ': '))
|
||||
open_file.write('{}\n'.format(triple_quote))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user