This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws_access_key = "AWS_ACCESS_KEY_HERE" | |
aws_secret_key = "AWS_SECRET_KEY_HERE" | |
key_name = "AWS_KEY_NAME_HERE" | |
private_key = "AWS_PRIVATE_KEY_PATH_HERE" | |
# aws | |
region = "ap-south-1" | |
ami = "ami-073c8c0760395aab8" | |
instance_type = "t2.micro" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_object(queryset, index=None, get_last=False): | |
""" | |
:param queryset: django Queryset | |
:param index: (integer) index of Queryset. 0 will return first object of queryset | |
:param get_last: (bool) if True returns last object of queryset | |
:return: django Model object | |
""" | |
from django.db.models.query import QuerySet | |
if not isinstance(queryset, QuerySet): | |
raise ValueError('{} is not a Queryset instance'.format(queryset.__class__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = "Parag Tyagi" | |
# set environment | |
import os | |
import sys | |
import django | |
sys.path.append('../') | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') | |
django.setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
def get_property(data, prop, is_data=False): | |
""" | |
Input: | |
1) data: object, dictionary, list, tuples, or any complex combination of these | |
2) prop: string (property separated by dots) | |
Output: | |
If value found returns value, else None |