mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
start on installer script
This commit is contained in:
@@ -22,8 +22,6 @@ class Config:
|
||||
self.VERSION = _data["VERSION"]
|
||||
self.TITLE = self.TITLE + " ver " + self.VERSION
|
||||
self.book_shelf = _data["BOOKSHELF"]
|
||||
# self.catalogue_db = "data/catalogue.db"
|
||||
# self.catalogue_db = str(root) + "/" + _data["DATABASE"]
|
||||
self.catalogue_db = _data["DATABASE"]
|
||||
self.user = _data["USER"]
|
||||
self.password = _data["PASSWORD"]
|
||||
@@ -31,7 +29,6 @@ class Config:
|
||||
self.db_port = _data["DB_PORT"]
|
||||
self.file_array = [
|
||||
self.book_shelf,
|
||||
# self.catalogue_db,
|
||||
]
|
||||
self.root = root
|
||||
self.auto_scan = True
|
||||
|
||||
68
src/backend/lib/display.py
Normal file
68
src/backend/lib/display.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pprint import pprint
|
||||
|
||||
from prompt_toolkit import prompt as prm
|
||||
|
||||
|
||||
class TerminalDisplay:
|
||||
def __init__(self):
|
||||
self.term = True
|
||||
self.w, self.y = os.get_terminal_size()[0], os.get_terminal_size()[1]
|
||||
|
||||
def screen(self):
|
||||
return self.term
|
||||
|
||||
def installer(self):
|
||||
questions = [
|
||||
{
|
||||
"message": "Input the absolute path to your ebooks\nEg. /home/{user}/Books > ",
|
||||
"options": "",
|
||||
"name": "BOOKPATH",
|
||||
"answer": "",
|
||||
},
|
||||
{
|
||||
"message": "Input your PostgreSQL server ip\nEg. localhost > ",
|
||||
"options": "localhost",
|
||||
"name": "DB_HOST",
|
||||
"answer": "",
|
||||
},
|
||||
{
|
||||
"message": "Input your PostgreSQL server port\nEg. 5432 > ",
|
||||
"options": "5432",
|
||||
"name": "DB_PORT",
|
||||
"answer": "",
|
||||
},
|
||||
{
|
||||
"message": "Input your PostgreSQL user name\nEg. pyshelf > ",
|
||||
"options": "pyshelf",
|
||||
"name": "USER",
|
||||
"answer": "",
|
||||
},
|
||||
{
|
||||
"message": "Input your PostgreSQL password\neg. pyshelf > ",
|
||||
"options": "pyshelf",
|
||||
"name": "PASSWORD",
|
||||
"answer": "",
|
||||
},
|
||||
]
|
||||
answers = self.prompt(questions)
|
||||
pprint(answers)
|
||||
|
||||
@staticmethod
|
||||
def clear():
|
||||
os.system("cls" if os.name == "nt" else "clear")
|
||||
|
||||
def prompt(self, questions):
|
||||
self.clear()
|
||||
answers = questions
|
||||
for answer in answers:
|
||||
self.h_rule()
|
||||
answer["answer"] = prm(answer["message"])
|
||||
self.clear()
|
||||
return answers
|
||||
|
||||
def h_rule(self):
|
||||
print("\u2501" * self.w)
|
||||
Reference in New Issue
Block a user