forked from LiberTEM/LiberTEM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
59 lines (45 loc) · 1.19 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import subprocess
import pathlib
import shutil
import click
import logging
logger = logging.getLogger(pathlib.Path(__file__).name)
logging.basicConfig(level=logging.INFO)
@click.group()
def cli():
pass
@cli.command(name="build")
def build_client():
# build the js client
cwd = os.path.dirname(__file__)
cwd_client = os.path.join(cwd, 'client')
logger.info(
"building js client",
)
npm = shutil.which('npm')
for command in [[npm, 'install'],
[npm, 'run-script', 'build']]:
logger.info(' '.join(command))
subprocess.check_call(command, cwd=cwd_client)
_copy_client()
def _copy_client():
# copy the js client
cwd = pathlib.Path(__file__).absolute().parent
cwd_client = cwd / 'client'
client = cwd / 'src' / 'libertem' / 'web' / 'client'
logger.info(
"preparing output directory: %s" % client,
)
if client.exists():
shutil.rmtree(client)
build = cwd_client / "dist"
logger.info(
f"copying client: {build} -> {client}",
)
shutil.copytree(build, client)
@cli.command(name="copy")
def copy_client():
_copy_client()
if __name__ == '__main__':
cli()