Exemplo n.º 1
0
def get_available_centers_by_pin(pincode: str) -> List[VaccinationCenter]:
    vaccination_centers = CoWinAPIObj.calender_by_pin(pincode, CoWinAPI.today())
    if vaccination_centers:
        vaccination_centers = [
            vc for vc in vaccination_centers if vc.has_available_sessions()
        ]
    return vaccination_centers
Exemplo n.º 2
0
# Whenever an exception occurs, we sleep for these many seconds hoping things will be fine
# when we wake up. This surprisingly works most of the times.
EXCEPTION_SLEEP_INTERVAL = 10
# the amount of time we sleep in background workers whenever we hit their APIs
COWIN_API_DELAY_INTERVAL = 180  # 3 minutes
# the amount of time we sleep when we get 403 from CoWin
LIMIT_EXCEEDED_DELAY_INTERVAL = 60 * 5  # 5 minutes

# Enable logging
logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)

logger = logging.getLogger(__name__)

CoWinAPIObj = CoWinAPI()

db = SqliteDatabase(
    SQLITE_DB_PATH,
    pragmas={
        "journal_mode": "wal",
        "cache_size": -1 * 64000,  # 64MB
        "foreign_keys": 1,
        "ignore_check_constraints": 0,
    },
)


class AgeRangePref(Enum):
    Unknown = 0
    MinAge18 = 1