Merge from static-files into main
Some checks failed
Amarillo/amarillo-gitea/amarillo-core/pipeline/head There was a failure building this commit
Some checks failed
Amarillo/amarillo-gitea/amarillo-core/pipeline/head There was a failure building this commit
This commit is contained in:
commit
0e3d727e1b
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -171,4 +171,11 @@ data/failed/
|
||||||
data/trash/
|
data/trash/
|
||||||
data/gtfs/
|
data/gtfs/
|
||||||
data/tmp/
|
data/tmp/
|
||||||
data/agencyconf
|
data/agencyconf
|
||||||
|
|
||||||
|
|
||||||
|
#these files are under app/static but they get copied to the outside directory on startup
|
||||||
|
logging.conf
|
||||||
|
config
|
||||||
|
static/*
|
||||||
|
templates/*
|
||||||
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
recursive-include amarillo/static/ *
|
||||||
|
|
@ -6,14 +6,19 @@ import uvicorn
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from starlette.staticfiles import StaticFiles
|
from starlette.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
|
||||||
|
logger = logging.getLogger("main")
|
||||||
|
|
||||||
|
from amarillo.app.utils.utils import copy_static_files
|
||||||
|
#this has to run before app.configuration is imported, otherwise we get validation error for config because the config file is not copied yet
|
||||||
|
copy_static_files(["conf", "static", "templates", "logging.conf", "config"])
|
||||||
|
|
||||||
import amarillo.plugins
|
import amarillo.plugins
|
||||||
from amarillo.app.configuration import configure_services, configure_admin_token
|
from amarillo.app.configuration import configure_services, configure_admin_token
|
||||||
from amarillo.app.routers import carpool, agency, agencyconf, region
|
from amarillo.app.routers import carpool, agency, agencyconf, region
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from amarillo.app.views import home
|
from amarillo.app.views import home
|
||||||
|
|
||||||
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
|
|
||||||
logger = logging.getLogger("main")
|
|
||||||
|
|
||||||
# https://pydantic-docs.helpmanual.io/usage/settings/
|
# https://pydantic-docs.helpmanual.io/usage/settings/
|
||||||
# from amarillo.app.views import home
|
# from amarillo.app.views import home
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,15 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
import logging
|
||||||
|
|
||||||
from datetime import datetime, date, timedelta
|
from datetime import datetime, date, timedelta
|
||||||
from pyproj import Geod
|
from pyproj import Geod
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def assert_folder_exists(foldername):
|
def assert_folder_exists(foldername):
|
||||||
if not os.path.isdir(foldername):
|
if not os.path.isdir(foldername):
|
||||||
os.makedirs(foldername)
|
os.makedirs(foldername)
|
||||||
|
|
@ -37,4 +44,27 @@ def geodesic_distance_in_m(coord1, coord2):
|
||||||
geod = Geod(ellps="WGS84")
|
geod = Geod(ellps="WGS84")
|
||||||
lons = [coord1[0], coord2[0]]
|
lons = [coord1[0], coord2[0]]
|
||||||
lats = [coord1[1], coord2[1]]
|
lats = [coord1[1], coord2[1]]
|
||||||
return geod.line_lengths(lons, lats)[0]
|
return geod.line_lengths(lons, lats)[0]
|
||||||
|
|
||||||
|
|
||||||
|
def copy_static_files(files_and_dirs_to_copy):
|
||||||
|
amarillo_dir = Path(__file__).parents[2]
|
||||||
|
source_dir = os.path.join(amarillo_dir, "static")
|
||||||
|
|
||||||
|
destination_dir = os.getcwd()
|
||||||
|
|
||||||
|
for item in files_and_dirs_to_copy:
|
||||||
|
source_path = os.path.join(source_dir, item)
|
||||||
|
destination_path = os.path.join(destination_dir, item)
|
||||||
|
|
||||||
|
if os.path.exists(destination_path):
|
||||||
|
# logger.info(f"{item} already exists")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if os.path.isfile(source_path):
|
||||||
|
shutil.copy2(source_path, destination_path)
|
||||||
|
logger.info(f"Copied {item} to {destination_path}")
|
||||||
|
|
||||||
|
if os.path.isdir(source_path):
|
||||||
|
shutil.copytree(source_path, destination_path)
|
||||||
|
logger.info(f"Copied directory {item} and its contents to {destination_path}")
|
||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "amarillo-core"
|
name = "amarillo-core"
|
||||||
version = "0.0.7"
|
version = "0.0.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastapi[all]==0.104.0",
|
"fastapi[all]==0.104.0",
|
||||||
"geopandas==0.14",
|
"geopandas==0.14",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue