Add files that should have been added to previous commit.
This commit is contained in:
parent
b5e28c8d11
commit
ec5550f3d2
2 changed files with 34 additions and 4 deletions
|
@ -12,13 +12,14 @@ TODO
|
|||
"""
|
||||
|
||||
import argparse
|
||||
from blasta.config import Settings, Share
|
||||
from blasta.config import Cache, Settings, Share
|
||||
from blasta.http.instance import HttpInstance
|
||||
from blasta.database.sqlite import DatabaseSQLite
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from os.path import getsize, exists
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from typing import Optional
|
||||
|
@ -44,9 +45,35 @@ def main():
|
|||
http_instance = HttpInstance(accounts, sessions)
|
||||
return http_instance.app
|
||||
|
||||
app = main()
|
||||
|
||||
if __name__ == 'blasta.__main__':
|
||||
|
||||
directory = os.path.dirname(__file__)
|
||||
|
||||
# Copy data files
|
||||
directory_data = Share.get_directory()
|
||||
if not os.path.exists(directory_data):
|
||||
directory_assets = os.path.join(directory, 'assets')
|
||||
directory_assets_new = shutil.copytree(directory_assets, directory_data)
|
||||
print(f'Data directory {directory_assets_new} has been created and populated.')
|
||||
|
||||
# Copy settings files
|
||||
directory_settings = Settings.get_directory()
|
||||
if not os.path.exists(directory_settings):
|
||||
directory_configs = os.path.join(directory, 'configs')
|
||||
directory_settings_new = shutil.copytree(directory_configs, directory_settings)
|
||||
print(f'Settings directory {directory_settings_new} has been created and populated.')
|
||||
|
||||
# Create cache directories
|
||||
directory_cache = Cache.get_directory()
|
||||
if not os.path.exists(directory_cache):
|
||||
print(f'Creating a cache directory at {directory_cache}.')
|
||||
os.mkdir(directory_cache)
|
||||
for subdirectory in ('data', 'export', 'items'):
|
||||
subdirectory_cache = os.path.join(directory_cache, subdirectory)
|
||||
if not os.path.exists(subdirectory_cache):
|
||||
print(f'Creating a cache subdirectory at {subdirectory_cache}.')
|
||||
os.mkdir(subdirectory_cache)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='blasta',
|
||||
description='Blasta - A collaborative annotation system.',
|
||||
|
@ -57,7 +84,10 @@ if __name__ == 'blasta.__main__':
|
|||
parser.add_argument('-o', '--open', help='open an html browser', action='store_const', const=True, dest='open')
|
||||
args = parser.parse_args()
|
||||
port = int(args.port or 8000)
|
||||
|
||||
app = main()
|
||||
uvicorn.run(app, host='localhost', port=port)
|
||||
|
||||
if args.open:
|
||||
# TODO Check first time
|
||||
webbrowser.open('http://localhost:{}/help/about'.format(port))
|
||||
|
|
|
@ -61,4 +61,4 @@ blasta = "blasta.__main__:main"
|
|||
platforms = ["any"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"*" = ["*.toml"]
|
||||
"*" = ["*.atom", "*.css", "*.ico", "*.js", "*.sql", "*.svg", "*.toml", "*.xhtml", "*.xsl"]
|
||||
|
|
Loading…
Reference in a new issue