mirror of
https://github.com/seemoo-lab/opendrop.git
synced 2026-09-16 16:16:12 -04:00
Use f-strings everywhere else
This commit is contained in:
@@ -26,6 +26,6 @@ __version__ = "0.12.2"
|
|||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
dyld_path = os.environ.get("DYLD_LIBRARY_PATH", "") # save old path
|
dyld_path = os.environ.get("DYLD_LIBRARY_PATH", "") # save old path
|
||||||
archive_path = "/usr/local/opt/libarchive/lib"
|
archive_path = "/usr/local/opt/libarchive/lib"
|
||||||
os.environ["DYLD_LIBRARY_PATH"] = "{}:{}".format(dyld_path, archive_path)
|
os.environ["DYLD_LIBRARY_PATH"] = f"{dyld_path}:{archive_path}"
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
+2
-2
@@ -97,7 +97,7 @@ class AirDropClient:
|
|||||||
logger.debug(f"Send {url} request")
|
logger.debug(f"Send {url} request")
|
||||||
|
|
||||||
AirDropUtil.write_debug(
|
AirDropUtil.write_debug(
|
||||||
self.config, body, "send_{}_request.plist".format(url.lower().strip("/"))
|
self.config, body, f"send_{url.lower().strip('/')}_request.plist"
|
||||||
)
|
)
|
||||||
|
|
||||||
_headers = self._get_headers()
|
_headers = self._get_headers()
|
||||||
@@ -119,7 +119,7 @@ class AirDropClient:
|
|||||||
AirDropUtil.write_debug(
|
AirDropUtil.write_debug(
|
||||||
self.config,
|
self.config,
|
||||||
response_bytes,
|
response_bytes,
|
||||||
"send_{}_response.plist".format(url.lower().strip("/")),
|
f"send_{url.lower().strip('/')}_response.plist",
|
||||||
)
|
)
|
||||||
|
|
||||||
if http_resp.status != 200:
|
if http_resp.status != 200:
|
||||||
|
|||||||
+3
-5
@@ -81,9 +81,7 @@ class AirDropConfig:
|
|||||||
self.port = server_port
|
self.port = server_port
|
||||||
|
|
||||||
if service_id is None:
|
if service_id is None:
|
||||||
service_id = "{0:0{1}x}".format(
|
service_id = f"{random.randint(0, 0xFFFFFFFFFFFF):012x}" # random 6-byte string in base16
|
||||||
random.randint(0, 0xFFFFFFFFFFFF), 12
|
|
||||||
) # random 6-byte string in base16
|
|
||||||
self.service_id = service_id
|
self.service_id = service_id
|
||||||
|
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
@@ -109,7 +107,7 @@ class AirDropConfig:
|
|||||||
self.root_ca_file = resource_filename("opendrop", "certs/apple_root_ca.pem")
|
self.root_ca_file = resource_filename("opendrop", "certs/apple_root_ca.pem")
|
||||||
if not os.path.exists(self.root_ca_file):
|
if not os.path.exists(self.root_ca_file):
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
"Need Apple root CA certificate: {}".format(self.root_ca_file)
|
f"Need Apple root CA certificate: {self.root_ca_file}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.key_dir = os.path.join(self.airdrop_dir, "keys")
|
self.key_dir = os.path.join(self.airdrop_dir, "keys")
|
||||||
@@ -148,7 +146,7 @@ class AirDropConfig:
|
|||||||
"-out",
|
"-out",
|
||||||
"certificate.pem",
|
"certificate.pem",
|
||||||
"-subj",
|
"-subj",
|
||||||
"/CN={}".format(self.computer_name),
|
f"/CN={self.computer_name}",
|
||||||
],
|
],
|
||||||
cwd=self.key_dir,
|
cwd=self.key_dir,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
|||||||
+2
-5
@@ -54,14 +54,11 @@ class AirDropServer:
|
|||||||
if self.ip_addr is None:
|
if self.ip_addr is None:
|
||||||
if self.config.interface == "awdl0":
|
if self.config.interface == "awdl0":
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Interface {} does not have an IPv6 address. "
|
f"Interface {self.config.interface} does not have an IPv6 address. Make sure that `owl` is running."
|
||||||
"Make sure that `owl` is running.".format(self.config.interface)
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Interface {} does not have an IPv6 address".format(
|
f"Interface {self.config.interface} does not have an IPv6 address"
|
||||||
self.config.interface
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.Handler = AirDropServerHandler
|
self.Handler = AirDropServerHandler
|
||||||
|
|||||||
Reference in New Issue
Block a user