mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 13:19:58 -05:00
Creating new /api/archive/upload which accepts a file from the SingleFile browser extension and converts it to an Archive.
This commit is contained in:
parent
01338e4d89
commit
531ec3d65e
62 changed files with 1000 additions and 562 deletions
|
|
@ -74,7 +74,7 @@ class KiwixZimDownloader(Downloader):
|
|||
zim_directory = lib.get_zim_directory()
|
||||
zim_directory.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
output_path = await self.download_file(download.id, download.url, zim_directory)
|
||||
output_path = await self.download_file(download, download.url, zim_directory)
|
||||
|
||||
# Notify the maintainer if outdated Zim files are lying around.
|
||||
lib.flag_outdated_zim_files()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from modules.zim.errors import UnknownZim, UnknownZimSubscription
|
|||
from modules.zim.kiwix import KIWIX_CATALOG
|
||||
from modules.zim.models import Zim, Zims, TagZimEntry, ZimSubscription
|
||||
from wrolpi import flags
|
||||
from wrolpi.cmd import run_command
|
||||
from wrolpi.common import register_modeler, logger, extract_html_text, extract_headlines, get_media_directory, walk, \
|
||||
register_refresh_cleanup, background_task, get_wrolpi_config, unique_by_predicate
|
||||
from wrolpi.db import get_db_session, optional_session, get_db_curs
|
||||
|
|
@ -471,13 +472,12 @@ async def check_zim(path: pathlib.Path) -> int:
|
|||
|
||||
@warning: Only performs the checksum check!
|
||||
"""
|
||||
cmd = f'zimcheck -C {path.absolute()}'
|
||||
proc = await asyncio.create_subprocess_shell(cmd)
|
||||
stdout, stderr = await proc.communicate()
|
||||
logger.debug(f'zimcheck returned {proc.returncode}')
|
||||
if proc.returncode != 0 and stderr:
|
||||
logger.debug(stderr)
|
||||
return proc.returncode
|
||||
cmd = ['zimcheck', '-C', path.absolute()]
|
||||
result = await run_command(cmd)
|
||||
logger.debug(f'zimcheck returned {result.return_code}')
|
||||
if result.return_code != 0 and result.stderr:
|
||||
logger.debug(result.stderr)
|
||||
return result.return_code
|
||||
|
||||
|
||||
ZIM_NAME_PARSER = re.compile(r'(.+?)_(\d{4}-\d{2}).zim')
|
||||
|
|
@ -566,10 +566,9 @@ async def restart_kiwix():
|
|||
|
||||
logger.info('Restarting Kiwix serve')
|
||||
|
||||
cmd = f'sudo /usr/bin/systemctl restart wrolpi-kiwix.service'
|
||||
proc = await asyncio.create_subprocess_shell(cmd)
|
||||
stdout, stderr = await proc.communicate()
|
||||
logger.debug(f'systemctl returned {proc.returncode}')
|
||||
if proc.returncode != 0 and stderr:
|
||||
logger.debug(stderr)
|
||||
return proc.returncode
|
||||
cmd = ('sudo', '/usr/bin/systemctl', 'restart' 'wrolpi-kiwix.service')
|
||||
result = await run_command(cmd)
|
||||
logger.debug(f'systemctl returned {result.return_code}')
|
||||
if result.return_code != 0 and result.stderr:
|
||||
logger.debug(result.stderr)
|
||||
return result.return_code
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from wrolpi.common import DownloadFileInfo, get_wrolpi_config
|
|||
from wrolpi.downloader import Download, import_downloads_config, save_downloads_config
|
||||
from wrolpi.files import lib as files_lib
|
||||
from wrolpi.files.models import FileGroup
|
||||
from wrolpi.test.common import skip_circleci
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -182,6 +183,7 @@ def test_zim_all_entries(test_session, test_zim):
|
|||
assert len(entries) == 12
|
||||
|
||||
|
||||
@skip_circleci
|
||||
@pytest.mark.asyncio
|
||||
async def test_zim_download(test_session, kiwix_download_zim, test_directory, test_zim_bytes, flags_lock,
|
||||
await_switches):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue