32 lines
825 B
Python
32 lines
825 B
Python
#!/usr/bin/env python3
|
|
|
|
import requests
|
|
import json
|
|
import sqlite3
|
|
import os
|
|
import argparse
|
|
|
|
def getData():
|
|
url = "https://api.ovh.com/1.0/dedicated/server/availabilities?country=FR"
|
|
data = requests.get(url).text
|
|
|
|
availability = {}
|
|
|
|
for i in getData():
|
|
if not i["hardware"] in availability.keys():
|
|
availability[i["hardware"]] = {"available": {}, "unavailable": []}
|
|
|
|
for j in i["datacenters"]:
|
|
if j["availability"] == "unavailable":
|
|
availability[i["hardware"]]["unavailable"] += [j["datacenter"]]
|
|
else:
|
|
availability[i["hardware"]]["available"][j["datacenter"]] = j["availability"]
|
|
|
|
return availability
|
|
|
|
def setupDB(path):
|
|
conn = sqlite3.connect(path)
|
|
cur = conn.cursor()
|
|
|
|
if __name__ == "__main__":
|
|
setupDB()
|