Commit 64daeb01 authored by Takhir Fakhrutdinov's avatar Takhir Fakhrutdinov

Отладка allskay

parent 02bd1f21
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -170,6 +170,10 @@ def _create_allskyFile():
from .meteoFile import allskyFile
return allskyFile
def _create_allsky_hcFile():
from .meteoFile import allsky_hcFile
return allsky_hcFile
def _create_reqFile():
from .reqFile import reqFile
return reqFile
......@@ -534,3 +538,36 @@ allsky = {
}
}
factory.register_file('ASKY', _create_allskyFile, schema=allsky)
allksy_hc = {
"type": "array",
"items": {
"allOf": [
{
"type": "object",
"required": ["header","allsky"],
"properties": {
"header": {
"type": "object",
"required": ["originator","message_type","message_id"],
"properties": {
"creation_date":{"$ref": "#/$defs/timestamp"},
"originator": {"type": "string"},
"message_type": {"type": "string","enum":["meteo"]},
"message_id": {"type": "string"},
"time_system": {"type": "string","enum":["UTC"]},
"comment": {"type": "string"}
}
},
"allsky":{"$ref": "#/$defs/base64"}
}
}
]
},
"$defs": {
"timestamp": {"type":"string","pattern":"^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2})(:(\\d{2}(?:\\.\\d+)?))?)?$"},
"base64": {"type":"string","pattern":"^(?=(.{4})*$)[A-Za-z0-9+\\/]*={0,2}$"}
}
}
factory.register_file('BSKY', _create_allsky_hcFile, schema=allsky_hc)
......@@ -277,7 +277,7 @@ class allskyFile(meteoBaseFile):
await super().load(fd,args)
data = json.load(fd)
fo,devs = io.BytesIO(), set()
devs = set()
self.fid = await self.getfid()
async with self.transaction():
......@@ -298,3 +298,53 @@ class allskyFile(meteoBaseFile):
self.fileattr = dict(devs=list(devs))
self.create_doc()
class allsky_hcFile(meteoBaseFile):
""" Загрузка данных ЭОП 2М
"""
def __init__(self,*args,**kwargs):
""" Конструктор.
.. literalinclude:: ../../../../fte/lib/libpy/rrdFile.py
:language: python
:lines: 229,238-240
:linenos:
:caption: __init__
"""
super().__init__(*args,**kwargs)
self.dbtype = 'asky'
async def load(self,fd,args):
""" Метод. Загрузка файла.
.. literalinclude:: ../../../../fte/lib/libpy/weaFile.py
:language: python
:lines: 27,36-
:linenos:
:caption: load_data
"""
import base64
logger.info('Загрузка файла...')
await super().load(fd,args)
data = json.load(fd)
fo,devs = io.BytesIO(), set()
self.fid = await self.getfid()
dev = await self.get_device('Web-camera TPLINK','12345678')
await self.check_priv_device(dev)
devs.add(dev)
async with self.transaction():
for m in data:
crops = base64.b64decode(m['allsky'])
tm = datetime.fromisoformat(m['header']['creation_date']).replace(microsecond=0)
self.tbeg, self.tend = min(self.tbeg,tm), max(self.tend,tm)
night = await self.fetchval("select * from main.devget_night($1,$2)",dev,tm)
await self.execute("select * from template.partition_table('xd.t_allsky'::regclass,$1)",tm)
await self.execute("insert into xd.t_allsky values($1,$2,$3,$4,$5)",self.fid,dev,tm,night,crops)
self.fileattr = dict(devs=list(devs))
self.create_doc()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment