Create dockerfile, changed apply_commits method
This commit is contained in:
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM reg.ivazh.ru/infra-oodb
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . ./
|
||||||
|
RUN cd deps/pygost-5.12/ && \
|
||||||
|
python3 setup.py install && \
|
||||||
|
cd ../.. && \
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
ENV LD_LIBRARY_PATH "/app"
|
||||||
|
ENV PYTHONPATH "${PYTHONPATH}:/app"
|
||||||
|
EXPOSE 9000
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["python3", "main.py"]
|
||||||
13
db.py
13
db.py
@@ -54,6 +54,7 @@ class User(Base):
|
|||||||
'profiles': [x.to_dict() for x in self.profiles],
|
'profiles': [x.to_dict() for x in self.profiles],
|
||||||
'schedule': [x.to_dict() for x in self.schedule],
|
'schedule': [x.to_dict() for x in self.schedule],
|
||||||
'queue': [x.to_dict() for x in self.queue],
|
'queue': [x.to_dict() for x in self.queue],
|
||||||
|
'income_branches': [x.to_dict() for x in self.income_branches],
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_active_now(self):
|
def is_active_now(self):
|
||||||
@@ -74,8 +75,8 @@ class Profile(Base):
|
|||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'))
|
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'))
|
||||||
scheme: Mapped[str]
|
scheme: Mapped[str]
|
||||||
branch: Mapped[str]
|
branch: Mapped[str] = mapped_column(String, nullable=True)
|
||||||
json: Mapped[str]
|
json: Mapped[str] = mapped_column(String, nullable=True)
|
||||||
|
|
||||||
user: Mapped['User'] = relationship(back_populates='profiles')
|
user: Mapped['User'] = relationship(back_populates='profiles')
|
||||||
|
|
||||||
@@ -84,7 +85,6 @@ class Profile(Base):
|
|||||||
'id': self.id,
|
'id': self.id,
|
||||||
'scheme': self.scheme,
|
'scheme': self.scheme,
|
||||||
'branch': self.branch,
|
'branch': self.branch,
|
||||||
'upstream': self.upstream,
|
|
||||||
'json': self.json,
|
'json': self.json,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +99,13 @@ class IncomeBranch(Base):
|
|||||||
|
|
||||||
user: Mapped['User'] = relationship(back_populates='income_branches')
|
user: Mapped['User'] = relationship(back_populates='income_branches')
|
||||||
|
|
||||||
|
def to_dict(self) -> dict:
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'scheme': self.scheme,
|
||||||
|
'branch': self.branch,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Schedule(Base):
|
class Schedule(Base):
|
||||||
__tablename__ = 'schedule'
|
__tablename__ = 'schedule'
|
||||||
|
|||||||
9
infra.py
Normal file
9
infra.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from libcommon import *
|
||||||
|
from libdatabase import *
|
||||||
|
from libgeodata import *
|
||||||
|
from libgeodriver import *
|
||||||
|
from libgeodesy import *
|
||||||
|
from libgeom import *
|
||||||
|
from libipdutilities import *
|
||||||
|
from liboodriver import *
|
||||||
|
|
||||||
14
main.py
14
main.py
@@ -564,12 +564,14 @@ def apply_commits(params, files, url):
|
|||||||
res = ws.init(con)
|
res = ws.init(con)
|
||||||
logger.warning(res)
|
logger.warning(res)
|
||||||
oe = IpdExporter(ws)
|
oe = IpdExporter(ws)
|
||||||
oe.improtFromOsm(os.path.join(dir.name, 'export.o5c'))
|
if not oe.importChanges(os.path.join(dir.name, 'export.o5c'), os.path.join(dir.name, 'export.mbtiles')):
|
||||||
oe.improtFromMbtiles(os.path.join(dir.name, 'export.mbtiles'))
|
logging.warning(f'Error importing commit {commit}: {oe.lastError().text()}')
|
||||||
with open(os.path.join(dir.name, 'export_files.json'), 'r') as f:
|
else:
|
||||||
files_data = json.load(f)
|
logging.warning(f'Importing commit {commit} finished successfully')
|
||||||
for file_data in files_data:
|
with open(os.path.join(dir.name, 'export_files.json'), 'r') as f:
|
||||||
upload_file(os.path.join(dir.name, file_data['key']), file_data['key'], file_data['bucket'])
|
files_data = json.load(f)
|
||||||
|
for file_data in files_data:
|
||||||
|
upload_file(os.path.join(dir.name, file_data['key']), file_data['key'], file_data['bucket'])
|
||||||
ws.clearData(True)
|
ws.clearData(True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ graphql-core==3.3.0a3
|
|||||||
greenlet==2.0.2
|
greenlet==2.0.2
|
||||||
h11==0.14.0
|
h11==0.14.0
|
||||||
idna==3.4
|
idna==3.4
|
||||||
infra
|
|
||||||
jmespath==1.0.1
|
jmespath==1.0.1
|
||||||
multidict==6.0.4
|
multidict==6.0.4
|
||||||
pika==1.3.2
|
pika==1.3.2
|
||||||
|
|||||||
32
test.py
Normal file
32
test.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import db
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
|
||||||
|
def get_branch(bndname: str, scheme: str):
|
||||||
|
conn = db.connect_db()
|
||||||
|
with Session(conn) as session:
|
||||||
|
item = session.query(db.IncomeBranch).filter_by(scheme=scheme).join(db.User).filter_by(bndname=bndname).one_or_none()
|
||||||
|
if item:
|
||||||
|
return item.branch
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def is_replication_scheme(bndname: str, scheme: str):
|
||||||
|
conn = db.connect_db()
|
||||||
|
with Session(conn) as session:
|
||||||
|
item = session.query(db.User).filter_by(bndname=bndname).one_or_none()
|
||||||
|
if not item:
|
||||||
|
return False
|
||||||
|
profiles = {x.scheme: x.to_dict() for x in item.profiles}
|
||||||
|
if len(profiles) == 0 or scheme in profiles:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# print(get_branch('bnd128', 'ood'))
|
||||||
|
print(is_replication_scheme('bnd128', 'documents_src'))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user