Import sys and modify exit invocation to be able to create single file executable of iottb
This commit is contained in:
parent
78c155208e
commit
c6c8cfb223
BIN
code/iottb
Executable file
BIN
code/iottb
Executable file
Binary file not shown.
@ -10,23 +10,23 @@ poetry install --editable
|
||||
# or with pip
|
||||
pip install -e .
|
||||
```
|
||||
Currently this is the recommended method.
|
||||
Currently, this is the recommended method.
|
||||
Alternatively install with pip into any activated environment:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
It is possible to make a single executable for you machine wich you can just put in your path using pyinstaller.
|
||||
It is possible to make a single executable for you machine which you can just put in your path using pyinstaller.
|
||||
1. Install pyinstaller
|
||||
```bash
|
||||
pip install pyinstaller
|
||||
```
|
||||
2. Make the executable
|
||||
```bash
|
||||
pyinstaller --onefile iottb/main.py
|
||||
pyinstaller --onefile --name iottb --distpath ~/opt iottb/main.py
|
||||
```
|
||||
To be able to run it as `iottb` rename it to `iottb` and put it somewhere on your PATH.
|
||||
Currently this method has bugs, since some python standard library names do not seem to be compiled into the executable.
|
||||
to be able to run it as `iottb` if `~/opt' is a directory on your PATH.
|
||||
A executable which should be able to run on linux is included in the repo.
|
||||
## Basic Invocation
|
||||
|
||||
## Configuration
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
import click
|
||||
from pathlib import Path
|
||||
@ -165,7 +166,7 @@ def add_device(device, db, guided):
|
||||
click.echo(
|
||||
f'To initialize the testbed in the default location run "iottb init-db"')
|
||||
click.echo('Exiting...')
|
||||
exit()
|
||||
sys.exit()
|
||||
# Ensure a device name was passed as argument
|
||||
if device == "":
|
||||
click.echo("Device name cannot be an empty string. Exiting...", lvl='w')
|
||||
@ -181,19 +182,18 @@ def add_device(device, db, guided):
|
||||
logger.warning(f'Device directory {device_dir} already exists.')
|
||||
click.echo(f'Device {device} already exists in the database.')
|
||||
click.echo('Exiting...')
|
||||
exit()
|
||||
sys.exit()
|
||||
try:
|
||||
device_dir.mkdir()
|
||||
except OSError as e:
|
||||
logger.error(f'Error trying to create device {e}')
|
||||
click.echo('Exiting...')
|
||||
exit()
|
||||
sys.exit()
|
||||
|
||||
# Step 4: Save metadata into device_dir
|
||||
metadata_path = device_dir / definitions.DEVICE_METADATA_FILE_NAME
|
||||
with metadata_path.open('w') as metadata_file:
|
||||
json.dump(device_metadata.__dict__, metadata_file, indent=4)
|
||||
click.echo(f'Successfully added device {device} to database')
|
||||
logger.debug(f'Added device {device} to database {
|
||||
database}. Full path of metadata {metadata_path}')
|
||||
logger.debug(f'Added device {device} to database {database}. Full path of metadata {metadata_path}')
|
||||
logger.info(f'Metadata for {device} {device_metadata.print_attributes()}')
|
||||
|
||||
@ -3,6 +3,7 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@ -280,7 +281,7 @@ def sniff(ctx, device, interface, print_pacno, ff, count, monitor_mode, print_ll
|
||||
click.prompt('Create metadata anyway?')
|
||||
else:
|
||||
click.echo('Aborting capture...')
|
||||
exit()
|
||||
sys.exit()
|
||||
end_time = datetime.now().strftime("%H:%M:%S")
|
||||
end = time()
|
||||
delta = end - start
|
||||
|
||||
@ -30,7 +30,7 @@ def init_db(ctx, dest, name, update_default):
|
||||
click.echo(f'A database {name} already exists.')
|
||||
logger.debug(f'DB {name} exists in {dest}')
|
||||
click.echo(f'Exiting...')
|
||||
exit()
|
||||
sys.exit()
|
||||
logger.debug(f'DB name {name} registered but does not exist.')
|
||||
if not dest:
|
||||
logger.info('No dest set, choosing default destination.')
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import click
|
||||
from pathlib import Path
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user