Setup testing structure
This commit is contained in:
0
code/kydcap/subcommands/__init__.py
Normal file
0
code/kydcap/subcommands/__init__.py
Normal file
@@ -1,19 +1,20 @@
|
||||
import pathlib
|
||||
|
||||
from kydcap.config import DEVICE_METADATA_FILE
|
||||
from kydcap.models.device_metadata import DeviceMetadata
|
||||
from kydcap.models.device_metadata_model import DeviceMetadata
|
||||
|
||||
|
||||
def setup_init_root_dir_parser(subparsers):
|
||||
parser = subparsers.add_parser("init-device-root", aliases=["idr"])
|
||||
parser.add_argument("root_dir", type=pathlib.Path, default=pathlib.Path.cwd())
|
||||
parser.add_argument("--root_dir", type=pathlib.Path, default=pathlib.Path.cwd())
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument("--dynamic", action="store_false", help="enable guided setup")
|
||||
group.add_argument("-n", "--name", action="store", required=True, type=str, help="name of device")
|
||||
group.add_argument("--dynamic", action="store_true", help="enable guided setup", default=False)
|
||||
group.add_argument("-n", "--name", action="store", type=str, help="name of device")
|
||||
parser.set_defaults(func=handle_idr)
|
||||
|
||||
|
||||
def handle_idr(args):
|
||||
print("Entered kydcap initialize-device-root")
|
||||
root_dir = args.root_dir
|
||||
device_name = None
|
||||
if args.dynamic:
|
||||
|
||||
@@ -2,7 +2,7 @@ import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from kydcap.config import *
|
||||
from kydcap.models.device_metadata import DeviceMetadata
|
||||
from kydcap.models.device_metadata_model import DeviceMetadata
|
||||
|
||||
|
||||
def setup_sniff_parser(subparsers):
|
||||
@@ -85,7 +85,18 @@ def handle_sniff(args):
|
||||
pass
|
||||
print('Executing: ' + ' '.join(cmd))
|
||||
# TODO maybe dump this into file -> put into device metadata
|
||||
start_time = datetime.now().strftime('%H:%M:%S')
|
||||
subprocess.run(cmd)
|
||||
stop_time = datetime.now().strftime('%H:%M:%S')
|
||||
try:
|
||||
start_time = datetime.now().strftime('%H:%M:%S')
|
||||
subprocess.run(cmd)
|
||||
stop_time = datetime.now().strftime('%H:%M:%S')
|
||||
except KeyboardInterrupt:
|
||||
print("Received keyboard interrupt.")
|
||||
exit(ReturnCodes.ABORTED)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Failed to capture packet: {e}")
|
||||
exit(ReturnCodes.FAILURE)
|
||||
except Exception as e:
|
||||
print(f"Failed to capture packet: {e}")
|
||||
exit(ReturnCodes.FAILURE)
|
||||
|
||||
return ReturnCodes.SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user