mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Removed final django dependency.
This commit is contained in:
24
docker/docker-compose.yml
vendored
Normal file
24
docker/docker-compose.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: "postgres"
|
||||
restart: always
|
||||
environment:
|
||||
- "POSTGRES_PASSWORD=pyshelf"
|
||||
- "POSTGRES_USER=pyshelf"
|
||||
- "POSTGRES_DB=pyshelf"
|
||||
volumes:
|
||||
- "db_data:/var/lib/postgresql/data/"
|
||||
pyshelf:
|
||||
image: "pyshelf/pyshelf"
|
||||
restart: always
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "1337:1337"
|
||||
volumes:
|
||||
- "${LOCAL_BOOK_DIR}:/books"
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
db_data:
|
||||
42
src/backend/lib/pyShelf.py
vendored
42
src/backend/lib/pyShelf.py
vendored
@@ -2,26 +2,16 @@
|
||||
import asyncio
|
||||
import os
|
||||
import time
|
||||
import datetime
|
||||
import websockets
|
||||
|
||||
from .config import Config
|
||||
from .library import Catalogue
|
||||
from .storage import Storage
|
||||
from django.conf import settings
|
||||
import psycopg2
|
||||
from django.contrib.auth.hashers import make_password
|
||||
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.Argon2PasswordHasher',
|
||||
]
|
||||
|
||||
|
||||
class InitFiles:
|
||||
"""First run file creation operations"""
|
||||
|
||||
def __init__(self, file_array):
|
||||
for _pointer in file_array:
|
||||
time.sleep(1)
|
||||
@@ -58,17 +48,15 @@ class Server:
|
||||
async def initialize_server(self):
|
||||
self.config.logger.info("INITIALIZE")
|
||||
self.serve = await websockets.serve(self.socketio, self.host[0], self.host[1])
|
||||
await asyncio.sleep(.1)
|
||||
await asyncio.sleep(0.1)
|
||||
self.config.logger.info("Server Initialization Complete")
|
||||
|
||||
async def runImport(self):
|
||||
_start_time = time.time()
|
||||
InitFiles(self.config.file_array)
|
||||
_storage = Storage(self.config)
|
||||
_storage.check_ownership()
|
||||
Catalogue(self.config).import_books()
|
||||
_storage.make_collections()
|
||||
_total_time = round(time.time() - _start_time)
|
||||
|
||||
async def socketio(self, websocket, path):
|
||||
self.config.logger.info("Listener Starting")
|
||||
@@ -97,29 +85,3 @@ class Server:
|
||||
self.loop.set_debug(True)
|
||||
await websockets.serve(self.socketio, self.host[0], self.host[1])
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
||||
class Admin:
|
||||
|
||||
def __init__(self, root):
|
||||
self.config = Config(root)
|
||||
self.db = Storage(self.config)
|
||||
settings.configure()
|
||||
|
||||
def createsuperuser(self):
|
||||
self.db.cursor.execute("SELECT * FROM interface_user")
|
||||
_user_list = self.db.cursor.fetchall()
|
||||
if len(_user_list) > 0:
|
||||
return False
|
||||
else:
|
||||
today = datetime.date.today()
|
||||
date = psycopg2.Date(today.year, today.month, today.day)
|
||||
self.db.cursor.execute(
|
||||
'INSERT INTO interface_user (username, password, is_staff, is_active, is_superuser, '
|
||||
'date_joined, first_name, last_name, ulvl, email ) '
|
||||
'VALUES( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
|
||||
("pyshelf", make_password("pyshelf"), True, True, True, date, "pyshelf", "default", 1,
|
||||
"change_or@delete.me"))
|
||||
self.db.commit()
|
||||
self.db.close()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user