Replace all double quotes strings with single quoted strings.
This commit is contained in:
@@ -9,12 +9,12 @@ def set_device_ip_address(ip_addr: str, file_path: Path):
|
||||
assert file_path.is_file()
|
||||
with file_path.open('r') as f:
|
||||
data = json.load(f)
|
||||
current_ip = data["device_ip_address"]
|
||||
current_ip = data['device_ip_address']
|
||||
if current_ip is not None:
|
||||
print(f"Device IP Address is set to {current_ip}")
|
||||
response = input(f"Do you want to change the recorded IP address to {ip_addr}? [Y/N] ")
|
||||
if response.upper() == "N":
|
||||
print("Aborting change to device IP address")
|
||||
print(f'Device IP Address is set to {current_ip}')
|
||||
response = input(f'Do you want to change the recorded IP address to {ip_addr}? [Y/N] ')
|
||||
if response.upper() == 'N':
|
||||
print('Aborting change to device IP address')
|
||||
return ReturnCodes.ABORTED
|
||||
with file_path.open('w') as f:
|
||||
json.dump(data, f)
|
||||
@@ -26,12 +26,12 @@ def set_device_mac_address(mac_addr: str, file_path: Path):
|
||||
assert file_path.is_file()
|
||||
with file_path.open('r') as f:
|
||||
data = json.load(f)
|
||||
current_mac = data["device_mac_address"]
|
||||
current_mac = data['device_mac_address']
|
||||
if current_mac is not None:
|
||||
print(f"Device MAC Address is set to {current_mac}")
|
||||
response = input(f"Do you want to change the recorded MAC address to {mac_addr}? [Y/N] ")
|
||||
if response.upper() == "N":
|
||||
print("Aborting change to device MAC address")
|
||||
print(f'Device MAC Address is set to {current_mac}')
|
||||
response = input(f'Do you want to change the recorded MAC address to {mac_addr}? [Y/N] ')
|
||||
if response.upper() == 'N':
|
||||
print('Aborting change to device MAC address')
|
||||
return ReturnCodes.ABORTED
|
||||
with file_path.open('w') as f:
|
||||
json.dump(data, f)
|
||||
|
||||
@@ -16,29 +16,29 @@ def get_capture_date_folder(device_root: Path):
|
||||
try:
|
||||
today_folder.mkdir()
|
||||
except FileExistsError:
|
||||
print(f"Folder {today_folder} already exists")
|
||||
print(f'Folder {today_folder} already exists')
|
||||
return today_folder
|
||||
raise FileNotFoundError(f"Given path {device_root} is not a device root directory")
|
||||
raise FileNotFoundError(f'Given path {device_root} is not a device root directory')
|
||||
|
||||
|
||||
def get_capture_src_folder(device_folder: Path):
|
||||
assert device_folder.is_dir(), f"Given path {device_folder} is not a folder"
|
||||
assert device_folder.is_dir(), f'Given path {device_folder} is not a folder'
|
||||
today_iso = get_iso_date()
|
||||
max_sequence_number = 1
|
||||
for d in device_folder.iterdir():
|
||||
if d.is_dir() and d.name.startswith(f'{today_iso}_capture_'):
|
||||
name = d.name
|
||||
num = int(name.split("_")[2])
|
||||
num = int(name.split('_')[2])
|
||||
max_sequence_number = max(max_sequence_number, num)
|
||||
|
||||
next_sequence_number = max_sequence_number + 1
|
||||
return device_folder.joinpath(f"{today_iso}_capture_{next_sequence_number:03}")
|
||||
return device_folder.joinpath(f'{today_iso}_capture_{next_sequence_number:03}')
|
||||
|
||||
|
||||
def make_capture_src_folder(capture_src_folder: Path):
|
||||
try:
|
||||
capture_src_folder.mkdir()
|
||||
except FileExistsError:
|
||||
print(f"Folder {capture_src_folder} already exists")
|
||||
print(f'Folder {capture_src_folder} already exists')
|
||||
finally:
|
||||
return capture_src_folder
|
||||
|
||||
@@ -5,25 +5,25 @@ from typing import Optional
|
||||
|
||||
|
||||
def check_installed() -> bool:
|
||||
"""Check if tcpdump is installed and available on the system path."""
|
||||
'''Check if tcpdump is installed and available on the system path.'''
|
||||
return shutil.which('tcpdump') is not None
|
||||
|
||||
|
||||
def ensure_installed():
|
||||
"""Ensure that tcpdump is installed, raise an error if not."""
|
||||
'''Ensure that tcpdump is installed, raise an error if not.'''
|
||||
if not check_installed():
|
||||
raise RuntimeError("tcpdump is not installed. Please install it to continue.")
|
||||
raise RuntimeError('tcpdump is not installed. Please install it to continue.')
|
||||
|
||||
|
||||
def list_interfaces() -> str:
|
||||
"""List available network interfaces using tcpdump."""
|
||||
'''List available network interfaces using tcpdump.'''
|
||||
ensure_installed()
|
||||
try:
|
||||
result = subprocess.run(['tcpdump', '--list-interfaces'], capture_output=True, text=True, check=True)
|
||||
return result.stdout
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Failed to list interfaces: {e}")
|
||||
return ""
|
||||
print(f'Failed to list interfaces: {e}')
|
||||
return ''
|
||||
|
||||
|
||||
def is_valid_ipv4(ip: str) -> bool:
|
||||
|
||||
@@ -13,6 +13,6 @@ def subfolder_exists(parent: Path, child: str):
|
||||
|
||||
|
||||
def generate_unique_string_with_prefix(prefix: str):
|
||||
return prefix + "_" + str(uuid.uuid4())
|
||||
return prefix + '_' + str(uuid.uuid4())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user