blob: e50027ffbb78caaf41f219df7431fd17b4ba1c3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import os
import shutil
import subprocess
import tempfile
import time
import library.command
def run(book_library, browser_cmd):
tmp_dir = tempfile.mkdtemp()
directory = os.path.dirname(os.path.realpath(__file__))
shutil.copytree(f'{directory}/public', tmp_dir, dirs_exist_ok=True)
with open(f'{tmp_dir}/books.js', 'w') as f:
json = library.command.get(book_library)
f.write(f'const bookLibrary = {json}')
browser_cmd = f'{browser_cmd} {tmp_dir}/index.html'
subprocess.run(browser_cmd.split(' '))
|