Merge pull request #37 from th3r00t/development

Merge 0.5.0 to stable branch
This commit is contained in:
th3r00t
2020-05-11 22:56:21 -04:00
committed by GitHub
273 changed files with 864 additions and 472 deletions

View File

@@ -1,84 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [enforcement@pyshelf.com](mailto:enforcement@pyshelf.com). All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of actions.
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the project community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

3
.gitignore vendored
View File

@@ -129,3 +129,6 @@ create_db.sql
uwsgi.ini
installer.log
pyshelf_nginx.conf
tags
TAGS
config.json

6
.tern-config vendored Normal file
View File

@@ -0,0 +1,6 @@
{
“plugins”:
{
“node”: {}
}
}

0
LICENSE vendored Normal file → Executable file
View File

80
README.md vendored Normal file → Executable file
View File

@@ -1,20 +1,22 @@
# pyShelf 0.4.1
# pyShelf 0.5.0
<p align="center"><b>Terminal based ebook server. Open source & Lightweight.</b></p>
<p align="center">Having used Calibre for hosting my eBook collection in the past, I found myself frustrated having to install X on my server, or manage my library externally, Thus I have decided to spin up my own.</p>
<p align="center"><a href="https://pyshelf.com">https://pyshelf.com</a></p>
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D51ALZH)
![pyShelf 0.5.0 Collection 1](https://github.com/th3r00t/pyShelf/raw/development/preview_050.png)
![pyShelf 0.5.0 Collection 2](https://github.com/th3r00t/pyShelf/raw/development/preview_1_050.png)
Having used Calibre for hosting my eBook collection in the past, I found myself frustrated having to install X on my server, or manage my library externally, Thus I have decided to spin up my own.
### Join the discussion: Discord [https://discord.gg/H9TbNJS](https://discord.gg/H9TbNJS) | IRC freenode.net @ #pyshelf
<p align="center"><b>Discord [https://discord.gg/H9TbNJS](https://discord.gg/H9TbNJS) | IRC freenode.net @ #pyshelf</b></p>
## Current Features
* Custom Installer
* Custom Installer -- pre-req installs work on Arch Based Distros Only
* Recursive Scanning
* Fast database access
* Django based frontend
* Basic seaching via a SearchVector of author, title, & file_name fields.
* Ebook Downloading
* Collections
## Currently Supported Formats
* epub
@@ -25,22 +27,39 @@ Having used Calibre for hosting my eBook collection in the past, I found myself
## Further Installation & Support Information
* [SUPPORT.md](https://github.com/th3r00t/pyShelf/blob/development/.github/SUPPORT.md)
## 0.4.1 Patch Notes.
### Filename detection
Now using os.path.splitext to ensure proper formating of downloaded files
## 0.5.0 Patch Notes.
## 0.4.0 Patch Notes.
### The Installer Initiative
### Pre-req Dependencies
* gcc -- This will be installed by the new pre-installer script if its binary is not detected at /usr/bin/gcc
Users on distros other then Arch should install gcc via their systems package manager prior to
running the installer.
* Python3
* pip
### New Features
* Collections
We are now categorizing your ebooks into collections based on the folder
structure used to store them. Any folder after the root book folder is now
considered as a collection.
#### books/forgotten realms/ -> Forgotten Realms Collection.
#### books/Dune/Prelude To Dune -> Dune, & Preluse To Dune Collections.
All work this time around was centered on creating an installer simple and inclusive enough to hopefully enable all
users to simply set it and forget it. I have debugged as much as I can with my setup. I am performing some simple file finding to determine which system installer is present, and setting it as the installer used by pyShelf.
In addition to the work on the collection system, a good deal of time was spent
on the installer, and the concept of having an installer in the first place.
This setup has been tested and is working flawlessly on arch based distros, and i have done what I can for debian, and centos based distros, If you do encounter installer issues please let me know if it isnt finding the system installer, or possibly isnt passing command line arguments to your installer.
I mainly wanted to make this project for Network Administrators, and other home
enthusiasts whom I assume will know how to setup a Django app, and a
Postgres server. Beyond that theres nothing the user has to do to make the
system work...
Also it should be noted that I am determining the presence of your postgresql, and nginx servers based on whether or not the
process is listed in the process list.
The installer will only run correctly on arch based distros. This could be
easily rectified to include other package managers, Members of the community
are welcome to dig into the installer source and patch in support
for other package managers.
At this time I would suggest stopping both your postgresql and nginx servers should you already have them and allowing the installer to do its work generating custom configurations and putting the nginx config files in place (/etc/nginx/sites-available, and symlinked to /etc/nginx/sites-enabled/) None of your existing configurations will be overwritten.
There is some support for detection of the aptitude package manager
installation already present in the source now, however it is not complete and
should not be relied upon to be present in future releases unless completed by
a member of the community,
## Development
@@ -59,15 +78,24 @@ All configuration is now handled by the installer.
Running via the Django test server might be possible, albeit not recomended.
## In Progress
### In Progress
* Organizational tools.
* Docker image for those who need it.
* Improved cover image storage, and acquisition.
#### Organizational tools.
- [x] Automated Collections
- [ ] Manual Collections
- [ ] Books Removal
- [ ] Access Restrictions
- [ ] Metadata Manipulation
- [ ] Others?
#### Improved cover image storage, and acquisition.
#### OPDS Support
#### Support for other formats
- [ ] .mobi
- [ ] .pdf
- [ ] .cbz
- [ ] .zip (Zipped book folders, is this a new idea? (Consider storing your library folders zipped and retrieving a book on demand))
## Future Goals
* Support for other book formats (Currently only supporting EPUBS)
* Terminal Backend for catalogue maintenance
* Calculate page count from total characters
### Future Goals
#### Terminal Backend for catalogue maintenance
#### Calculate page count from total characters
* (Thanks to @Fireblend for the idea) https://github.com/th3r00t/pyShelf/issues/3
* Reader for easy integration with your catalogue

2
config.json vendored Normal file → Executable file
View File

@@ -1 +1 @@
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.4.1", "BOOKPATH": "", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "hostname": "localhost", "webport": "8000", "wsgiport": "8001"}
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.5.0", "BOOKPATH": "", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "hostname": "localhost", "webport": "8000", "wsgiport": "8001"}

0
data/.track_this_folder vendored Normal file → Executable file
View File

0
docs/html/annotated.html vendored Normal file → Executable file
View File

0
docs/html/bc_s.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

0
docs/html/bdwn.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

0
docs/html/classes.html vendored Normal file → Executable file
View File

0
docs/html/closed.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 132 B

View File

View File

View File

View File

Before

Width:  |  Height:  |  Size: 853 B

After

Width:  |  Height:  |  Size: 853 B

View File

View File

View File

Before

Width:  |  Height:  |  Size: 966 B

After

Width:  |  Height:  |  Size: 966 B

View File

View File

View File

View File

View File

View File

0
docs/html/d8/dfe/classsrc_1_1backend_1_1lib_1_1config_1_1Config.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

View File

View File

View File

View File

Before

Width:  |  Height:  |  Size: 962 B

After

Width:  |  Height:  |  Size: 962 B

View File

View File

0
docs/html/dir_1c7294442ce83d360610449d04c9d7fc.html vendored Normal file → Executable file
View File

0
docs/html/dir_3f615ade772d23cefe5e20dcb18424a2.html vendored Normal file → Executable file
View File

0
docs/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html vendored Normal file → Executable file
View File

0
docs/html/dir_9020577e2da81c4cf5a5554c26431f94.html vendored Normal file → Executable file
View File

0
docs/html/doc.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 746 B

1
docs/html/doxygen.css vendored Normal file → Executable file
View File

@@ -1768,4 +1768,3 @@ tt, code, kbd, samp
u {
text-decoration: underline;
}

0
docs/html/doxygen.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

0
docs/html/dynsections.js vendored Normal file → Executable file
View File

0
docs/html/files.html vendored Normal file → Executable file
View File

0
docs/html/folderclosed.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 616 B

After

Width:  |  Height:  |  Size: 616 B

0
docs/html/folderopen.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 597 B

After

Width:  |  Height:  |  Size: 597 B

0
docs/html/functions.html vendored Normal file → Executable file
View File

0
docs/html/functions_func.html vendored Normal file → Executable file
View File

0
docs/html/hierarchy.html vendored Normal file → Executable file
View File

0
docs/html/index.hhc vendored Normal file → Executable file
View File

0
docs/html/index.hhk vendored Normal file → Executable file
View File

0
docs/html/index.hhp vendored Normal file → Executable file
View File

0
docs/html/index.html vendored Normal file → Executable file
View File

0
docs/html/jquery.js vendored Normal file → Executable file
View File

0
docs/html/menu.js vendored Normal file → Executable file
View File

0
docs/html/menudata.js vendored Normal file → Executable file
View File

0
docs/html/nav_f.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

0
docs/html/nav_g.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 95 B

After

Width:  |  Height:  |  Size: 95 B

0
docs/html/nav_h.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 98 B

After

Width:  |  Height:  |  Size: 98 B

0
docs/html/open.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

0
docs/html/splitbar.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 314 B

After

Width:  |  Height:  |  Size: 314 B

0
docs/html/sync_off.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 853 B

After

Width:  |  Height:  |  Size: 853 B

0
docs/html/sync_on.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 845 B

After

Width:  |  Height:  |  Size: 845 B

0
docs/html/tab_a.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 142 B

0
docs/html/tab_b.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

0
docs/html/tab_h.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

0
docs/html/tab_s.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 184 B

0
docs/html/tabs.css vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_api_hooks_DuckDuckGo.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_config_Config.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_display_TerminalDisplay.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_library_Catalogue.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_pyShelf_BookDisplay.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_pyShelf_InitFiles.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_lib_storage_Storage.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_tests_config_test_TestConfig.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_tests_library_test_TestCatalogue.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_tests_library_test_Test_Catalogue.3 vendored Normal file → Executable file
View File

0
docs/man/man3/src_backend_tests_library_test_Test_Config.3 vendored Normal file → Executable file
View File

0
docs/warn.log vendored Normal file → Executable file
View File

0
doxygen.conf vendored Normal file → Executable file
View File

2
importBooks vendored
View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!python
import pathlib
import sys

2
install.sh vendored
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
eval python3 preinstall
eval "pip install -r requirements.txt"
eval python3 installer

77
installer vendored Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!python
import json
import os
import pathlib
@@ -136,6 +136,9 @@ class SystemInstaller:
if os.path.isdir(_dirs[1]):
ln_string = str(_dirs[0] + outfile + " " + _dirs[1] + outfile)
os.system("sudo ln -s %s" % ln_string)
""" TODO check for sites-enabled, create it if it doesnt exist,
then symlink the config """
except Exception as e:
pass
return True
@@ -152,7 +155,7 @@ class SystemInstaller:
wsgiport = r["answer"]
nginx_conf_str = """
# pyshelf_nginx.conf
upstream django {server unix://%s/pyshelf_wsgi.sock;}
upstream django {server unix:///tmp/pyshelf_wsgi.sock;}
server {
listen %s;
server_name %s;
@@ -166,7 +169,6 @@ class SystemInstaller:
location / {uwsgi_pass django; include %s/uwsgi_params;}
}
""" % (
root,
port,
hostname,
root,
@@ -194,11 +196,10 @@ class SystemInstaller:
master=True
pidfile=/tmp/pyShelf.pid
vacuum=True
socket=%s/pyshelf_wsgi.sock
socket=/tmp/pyshelf_wsgi.sock
chmod-socket=666
""" % (
root,
root
)
with open(_fp, "w") as write_file:
write_file.write(wsgi_conf_str)
@@ -223,19 +224,18 @@ install_answers = TerminalDisplay().installer()
for key in install_answers:
config[key["name"]] = key["answer"]
# config["USER"] = os.environ["USER"]
config["USER"] = 'pyshelf'
config["USER"] = "pyshelf"
# Write configuration
Configuration().write_file(config)
# Start checking for our list of required services
service_list = ["postgres", "nginx", "httpd", "test"]
service_list = ["postgres", "nginx", "httpd"]
req = RequiredServices().check_ps(service_list)
# Does user have either nginx || apache?
if RequiredServices().web_server_found(req) is False:
web_prompt = [
{
"message": " You must have either apache or nginx\n would you like us to try and install nginx now? > ",
"message": " You must have either apache or nginx\n would you like \
us to try and install nginx now? Enter for default 'no' > ",
"options": "nginx",
"name": "NGINX",
"answer": None,
@@ -274,7 +274,8 @@ if RequiredServices().web_server_found(req) is False:
if RequiredServices().db_server_found(req) is False:
db_prompt = [
{
"message": " You must have PostgreSQL\n would you like us to try and install it now? > ",
"message": " You must have PostgreSQL\n would you like us to try \
and install it now? Enter for default 'no' > ",
"options": "postgres",
"name": "postgresql",
"answer": None,
@@ -300,23 +301,28 @@ if RequiredServices().db_server_found(req) is False:
)
install_status = os.system(cmd)
for r in install_answers:
if r["name"] == "PASSWORD": sql_pass = r["answer"]
if r["name"] == "PASSWORD":
sql_pass = r["answer"]
# sql_user = config["USER"]
sql_user = "pyshelf"
db_name = "pyshelf"
psql_cmd = """
CREATE DATABASE %s;
CREATE USER %s WITH PASSWORD \'%s\';
GRANT ALL PRIVILEGES ON DATABASE %s TO %s;
""" % (db_name, sql_user, sql_pass, db_name, sql_user)
_sql_file = "create_db.sql"
psql_cmd = (
"CREATE DATABASE %s; CREATE USER %s WITH PASSWORD '%s'; \
GRANT ALL PRIVILEGES ON DATABASE %s TO %s;"
% (db_name, sql_user, sql_pass, db_name, sql_user)
)
_sql_file = "/tmp/create_db.sql"
with open(_sql_file, "w") as sql_file_open:
sql_file_open.write(psql_cmd)
sql_file_open.close()
os.system(
"sudo -u postgres initdb --locale=en_US.UTF-8 -E UTF8 \
-D /var/lib/postgres/data"
)
os.system("sudo systemctl start postgresql")
os.system("sudo -u postgres initdb --locale=en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data")
os.system("sudo -u postgres psql -f %s" % _sql_file)
# os.system("sudo -u postgres psql -c \'%s\'"%psql_cmd)
messages = messages + [
"PostgreSQL installed and started",
"To enable autostart you must run",
@@ -324,7 +330,24 @@ if RequiredServices().db_server_found(req) is False:
"\n",
"Database cluster initialized at /var/lib/postgres",
"pyShelf database and user created",
psql_cmd
psql_cmd,
]
else:
psql_cmd = (
"CREATE DATABASE %s; CREATE USER %s WITH PASSWORD '%s'; \
GRANT ALL PRIVILEGES ON DATABASE %s TO %s;"
% (db_name, sql_user, sql_pass, db_name, sql_user)
)
_sql_file = "/tmp/create_db.sql"
with open(_sql_file, "w") as sql_file_open:
sql_file_open.write(psql_cmd)
sql_file_open.close()
os.system("sudo systemctl start postgresql")
os.system("sudo -u postgres psql -f %s" % _sql_file)
# os.system("sudo -u postgres psql -c \'%s\'"%psql_cmd)
messages = messages + [
"pyShelf database and user created",
psql_cmd,
]
# Post install configurations
@@ -342,11 +365,19 @@ except Exception as e:
try:
copy_config = sysinstall.copy_config()
if copy_config:
messages = messages + ["pyShelf site config copied to sites-available, and symlinked to sites-enabled"]
messages = messages + [
"pyShelf site config copied to sites-available, and symlinked to sites-enabled"
]
except Exception as e:
messages = messages + ["nginx site config not copied", "A nginx config for your install has been created \"pyshelf_nginx.conf\""]
messages = messages + [
"nginx site config not copied",
'A nginx config for your install has been created "pyshelf_nginx.conf"',
]
sysinstall.make_wsgi_config(install_answers)
messages = messages + ["You should now import your books by running importBooks", "You can then start the interface with uwsgi --ini uwsgi.ini"]
messages = messages + [
"You should now import your books by running importBooks",
"You can then start the interface with uwsgi --ini uwsgi.ini",
]
# Display end screen
sysinstall.log()

13
makeCollections vendored Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/python
import pathlib
import sys
from src.backend.lib.storage import Storage
from src.backend.pyShelf_MakeCollections import MakeCollections
PRG_PATH = pathlib.Path.cwd()
LIB_PATH = pathlib.Path.joinpath(PRG_PATH, "src", "backend", "lib")
sys.path.insert(0, PRG_PATH)
print("\n")
MakeCollections(PRG_PATH)

33
preinstall vendored Executable file
View File

@@ -0,0 +1,33 @@
#!python
import os
from subprocess import run
class RequiredPackages:
def __init__(self, bins):
self.required = bins
self.to_be_installed = []
self.locate()
def locate(self):
for bin in self.required:
if os.path.isfile(bin[1]):
continue
else:
self.to_be_installed.append(bin[0])
return self.to_be_installed
# Package List
package_list = [["gcc", "/usr/bin/gcc"]]
packages, required_packages = "", RequiredPackages(package_list)
for package in required_packages.to_be_installed:
packages = packages + package + " "
try:
ret = run(["sudo", "pacman", "-S", packages[0:-1]])
print(ret)
except Exception as e:
ret = run(["pacman", "-S", packages[0:-1]])
print(ret)

BIN
preview_050.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
preview_1_050.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

0
pyproject.toml vendored Normal file → Executable file
View File

1
requirements.txt vendored Normal file → Executable file
View File

@@ -12,7 +12,6 @@ pre-commit
isort
django
toml
uwsgi
django-debug-toolbar
psycopg2-binary
prompt_toolkit

0
src/__init__.py Normal file → Executable file
View File

0
src/backend/empty_bookshelf.sql vendored Normal file → Executable file
View File

3
src/backend/lib/display.py Normal file → Executable file
View File

@@ -11,7 +11,10 @@ class TerminalDisplay:
self.term = True
self.w, self.y = os.get_terminal_size()[0], os.get_terminal_size()[1]
self.home = os.environ["HOME"]
try:
self.user = os.environ["USER"]
except KeyError:
self.user = None
self.version = "0.4.0"
self.slogan = "The Installer Initiative"
self.green = "\033[1;32m"

View File

@@ -1,12 +1,7 @@
#!/usr/bin/python
import sqlite3
import re
import psycopg2
from psycopg2 import Error
from .config import Config
# db_pointer = Config().catalogue_db
class Storage:
@@ -31,7 +26,6 @@ class Storage:
try:
self.cursor.execute(_q)
except Exception as e:
breakpoint()
if e.pgcode == "42501":
_q = """ALTER TABLE public.books OWNER to pyshelf;"""
self.close()
@@ -102,3 +96,39 @@ class Storage:
"""
self.db.close()
return True
def make_collections(self):
_title_regx = re.compile(r"^[0-9][0-9]*|-|\ \B")
_q = "SELECT id,file_name FROM books"
self.cursor.execute(_q)
_set = self.cursor.fetchall()
for book in _set:
path = self.config.book_path + "/"
_collections = []
_pathing = book[1].split(path)[1].split("/")
_pathing.pop(0)
_pathing.pop(-1)
for _p in _pathing:
_s = _p.replace("'", "")
_x = re.sub(_title_regx, "", _s)
_s = _x.strip()
_q_x = """
SELECT id FROM collections where collection='%s'\
AND book_id_id=%s
""" % (
_s,
book[0],
)
try:
self.cursor.execute(_q_x)
if len(self.cursor.fetchall()) < 1:
self.cursor.execute(
"""INSERT INTO collections\
(collection, book_id_id) VALUES ('%s',%s)"""
% (_s, book[0])
)
except Exception as e:
print(e)
_collections.append(_p)
self.db.commit()
self.close()

View File

@@ -0,0 +1,23 @@
#!/usr/bin/python
import os
import sys
import time
from .lib.config import Config
from .lib.library import Catalogue
from .lib.pyShelf import InitFiles
from .lib.storage import Storage
sys.path.append(os.path.abspath("."))
def MakeCollections(root):
_t1 = time.time()
config = Config(root) # Get configuration settings
# InitFiles(config.file_array) # Initialize file system
_storage = Storage(config)
_storage.make_collections()
_t2 = time.time()
scan_time = round(_t2 - _t1)
print("Collections Made.")
print("Time %s seconds" % scan_time)

View File

@@ -19,7 +19,6 @@ def execute_scan(root):
_t1 = time.time()
config = Config(root) # Get configuration settings
InitFiles(config.file_array) # Initialize file system
Storage(config).check_ownership()
catalogue = Catalogue(config) # Open the Catalogue
catalogue.import_books()

View File

@@ -33,8 +33,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = "@(9b9jslgg41u1u=mr)-2*-n2x0vef0zsy39*z@sz18&tvow18"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = TEMPLATE_DEBUG = True
if DEBUG is True:
from pudb.remote import set_trace
ALLOWED_HOSTS = CONFIG.allowed_hosts

Some files were not shown because too many files have changed in this diff Show More