chg: Bump minimal version of poetry, bump deps, fix pyproject

pull/96/head
Raphaël Vinot 2020-10-03 21:19:43 +02:00
parent be2cd18d2b
commit c0ec0d7a50
11 changed files with 487 additions and 423 deletions

View File

@ -88,13 +88,13 @@ git clone https://github.com/Lookyloo/lookyloo.git
cd lookyloo
poetry install
echo LOOKYLOO_HOME="'`pwd`'" > .env
poetry run update.py
poetry run update
```
# Run the app
```bash
poetry run start.py
poetry run start
```
# Run the app in production

View File

@ -29,6 +29,10 @@ class AsyncScraper(AbstractManager):
unset_running('async_scrape')
if __name__ == '__main__':
def main():
m = AsyncScraper()
m.run(sleep_in_sec=1)
if __name__ == '__main__':
main()

View File

@ -9,7 +9,8 @@ from lookyloo.lookyloo import Lookyloo, Indexing
logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s',
level=logging.INFO, datefmt='%I:%M:%S')
if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser(description='Rebuild the redis cache.')
parser.add_argument('--rebuild_pickles', default=False, action='store_true', help='Delete and rebuild the pickles. Count 20s/pickle, it can take a very long time.')
args = parser.parse_args()
@ -39,3 +40,7 @@ if __name__ == '__main__':
if index:
indexing.index_cookies_capture(tree)
indexing.index_body_hashes_capture(tree)
if __name__ == '__main__':
main()

View File

@ -67,7 +67,7 @@ def stop_all():
shutdown_indexing()
if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser(description='Manage backend DBs.')
parser.add_argument("--start", action='store_true', default=False, help="Start all")
parser.add_argument("--stop", action='store_true', default=False, help="Stop all")
@ -80,3 +80,7 @@ if __name__ == '__main__':
stop_all()
if not args.stop and args.status:
check_all()
if __name__ == '__main__':
main()

View File

@ -5,7 +5,8 @@ from lookyloo.helpers import is_running, get_socket_path
import time
from redis import StrictRedis
if __name__ == '__main__':
def main():
r = StrictRedis(unix_socket_path=get_socket_path('cache'), db=1)
r.set('shutdown', 1)
time.sleep(5)
@ -15,3 +16,7 @@ if __name__ == '__main__':
break
print(running)
time.sleep(5)
if __name__ == '__main__':
main()

View File

@ -4,10 +4,15 @@
from subprocess import Popen
from lookyloo.helpers import get_homedir
if __name__ == '__main__':
def main():
# Just fail if the env isn't set.
get_homedir()
p = Popen(['run_backend.py', '--start'])
p = Popen(['run_backend', '--start'])
p.wait()
Popen(['async_scrape.py'])
Popen(['start_website.py'])
Popen(['async_scrape'])
Popen(['start_website'])
if __name__ == '__main__':
main()

View File

@ -8,7 +8,7 @@ from lookyloo.helpers import get_homedir, shutdown_requested, set_running, unset
from redis import StrictRedis
if __name__ == '__main__':
def main():
r = StrictRedis(unix_socket_path=get_socket_path('cache'))
r.delete('cache_loaded')
website_dir = get_homedir() / 'website'
@ -37,3 +37,7 @@ if __name__ == '__main__':
except Exception:
pass
unset_running('website')
if __name__ == '__main__':
main()

View File

@ -5,10 +5,15 @@ from subprocess import Popen
from lookyloo.helpers import get_homedir, get_socket_path
from redis import Redis
if __name__ == '__main__':
def main():
get_homedir()
p = Popen(['shutdown.py'])
p = Popen(['shutdown'])
p.wait()
r = Redis(unix_socket_path=get_socket_path('cache'), db=1)
r.delete('shutdown')
Popen(['run_backend.py', '--stop'])
Popen(['run_backend', '--stop'])
if __name__ == '__main__':
main()

View File

@ -32,11 +32,28 @@ def run_command(command):
sys.exit()
if __name__ == '__main__':
def check_poetry_version():
args = shlex.split("poetry self -V")
homedir = get_homedir()
process = subprocess.run(args, cwd=homedir, capture_output=True)
poetry_version_str = process.stdout.decode()
version = poetry_version_str.split()[2]
version_details = tuple(int(i) for i in version.split('.'))
if version_details < (1, 1, 0):
print('Lookyloo requires poetry >= 1.1.0, please update.')
print('If you installed with "pip install --user poetry", run "pip install --user -U poetry"')
print('If you installed via the recommended method, use "poetry self update"')
print('More details: https://github.com/python-poetry/poetry#updating-poetry')
sys.exit()
def main():
parser = argparse.ArgumentParser(description='Pull latest release, update dependencies, update and validate the config files, update 3rd deps for the website.')
parser.add_argument('--yes', default=False, action='store_true', help='Run all commands without asking.')
args = parser.parse_args()
check_poetry_version()
print('* Update repository.')
keep_going(args.yes)
run_command('git pull')
@ -56,3 +73,7 @@ if __name__ == '__main__':
print('* Update third party dependencies for the website.')
keep_going(args.yes)
run_command('tools/3rdparty.py')
if __name__ == '__main__':
main()

805
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,21 +20,21 @@ classifiers = [
]
[tool.poetry.scripts]
start_website = "bin/start_website.py"
start = "bin/start.py"
run_backend = "bin/run_backend.py"
async_scrape = "bin/async_scrape.py"
shutdown = "bin/shutdown.py"
stop = "bin/stop.py"
rebuild_caches = "bin/rebuild_caches.py"
update = "bin/update.py"
start_website = "bin.start_website:main"
start = "bin.start:main"
run_backend = "bin.run_backend:main"
async_scrape = "bin.async_scrape:main"
shutdown = "bin.shutdown:main"
stop = "bin.stop:main"
rebuild_caches = "bin.rebuild_caches:main"
update = "bin.update:main"
[tool.poetry.dependencies]
python = "^3.7"
requests = "^2.22.0"
flask = "^1.1.1"
gunicorn = {version = "^20.0.4"}
gunicorn = "^20.0.4"
cchardet = "^2.1.5"
redis = "^3.3.11"
beautifulsoup4 = "^4.9.2"
@ -55,5 +55,5 @@ mypy = "^0.782"
ipython = "^7.13.0"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry_core>=1.1.0"]
build-backend = "poetry.core.masonry.api"