78 lines
2.3 KiB
Python
78 lines
2.3 KiB
Python
import os, django
|
|
import requests
|
|
import requests.exceptions as rex
|
|
import sys
|
|
import calendar
|
|
import uuid
|
|
import datetime as DT
|
|
import pytz
|
|
import json
|
|
#import maya
|
|
import random
|
|
import time
|
|
import traceback
|
|
from dateutil import tz
|
|
from tqdm import tqdm
|
|
|
|
import folium
|
|
|
|
from datetime import datetime, timedelta,date
|
|
from requests.auth import HTTPBasicAuth
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mfssogr.settings')
|
|
django.setup()
|
|
|
|
from django.db.models import Q
|
|
|
|
import apps.schedulers.tasks
|
|
|
|
from apps.seismicproc.models.model_earthquake import Earthquake
|
|
from apps.gto.models.model_sensors import Sensors
|
|
from apps.gto.models.model_indicators import Indicators
|
|
from apps.schedulers import tasks
|
|
|
|
from bs4 import BeautifulSoup
|
|
from sabron.util import logging
|
|
|
|
def zone_check():
|
|
try:
|
|
response = requests.get('http://www.gsras.ru/cgi-bin/new/mapCustom.pl?l=0&lat=55&lon=86&num=50&rad=1000')
|
|
bs = BeautifulSoup(response.text,"lxml")
|
|
table = bs.find(id="tableQuakes")
|
|
table_body = table.find('tbody')
|
|
rows = table_body.find_all('tr')
|
|
data = []
|
|
for row in rows:
|
|
cols = row.find_all('td')
|
|
date = cols[1].text.strip()
|
|
latitude = cols[2].text.strip()
|
|
longitude = cols[3].text.strip()
|
|
depth = cols[4].text.strip()
|
|
magnitude = cols[7].text.strip()
|
|
region = cols[9].text.strip()
|
|
print(region)
|
|
myfileter = Q(date_time = date)
|
|
myfileter &= Q(latitude = latitude)
|
|
myfileter &= Q(longitude = longitude)
|
|
earthquake = Earthquake.objects.filter(myfileter).first()
|
|
if earthquake is None:
|
|
Earthquake.objects.create(date_time = date,
|
|
latitude = latitude,
|
|
longitude = longitude,
|
|
depth = depth,
|
|
magnitude = magnitude,
|
|
region = region)
|
|
except Exception as err:
|
|
logging.error(traceback.format_exc())
|
|
|
|
|
|
def save_s():
|
|
place = folium.Map(location=[52.3,89.18])
|
|
place.save('index.html')
|
|
|
|
|
|
if __name__ == "__main__":
|
|
#Indicators.objects.all().delete()
|
|
#Sensors.objects.all().delete()
|
|
|
|
tasks.load_navigation()
|