Skip to content

Commit 91b67d9

Browse files
Update main.py to coding standard from pylint
1 parent b9fb6cc commit 91b67d9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

main.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
zones, with proxying enabled or disabled. The tool runs checks and updates every
1212
5 minutes and includes redundancy for IP checking services.
1313
"""
14+
# pylint: disable=line-too-long
1415

1516
import time
1617
import socket
@@ -67,8 +68,8 @@ def create_logger(level=logging.INFO):
6768
LOGGER = create_logger()
6869

6970

70-
# Get current DNS record for the specified domain
7171
def get_dns_record(zone_id, domain_name):
72+
""" Get current DNS record for the specified domain """
7273
LOGGER.info("Fetching record for '%s' in zone '%s'.", domain_name, zone_id)
7374

7475
headers = {
@@ -94,8 +95,8 @@ def get_dns_record(zone_id, domain_name):
9495
return None
9596

9697

97-
# Update the DNS record
9898
def update_dns_record(record, content):
99+
""" Update the DNS record """
99100
headers = {
100101
'Authorization': 'Bearer ' + CF_API_TOKEN,
101102
'Content-Type': 'application/json',
@@ -118,8 +119,8 @@ def update_dns_record(record, content):
118119
LOGGER.error("Failed to update DNS record: %s", response.json())
119120

120121

121-
# Loads static wishlist of domains in json format along with their metadata
122122
def read_zones_from_file(json_file_path, zone_id):
123+
""" Loads static wishlist of domains in json format along with their metadata """
123124
with open(json_file_path, 'r', encoding="utf-8") as file:
124125
data = json.load(file)
125126

@@ -137,8 +138,8 @@ def read_zones_from_file(json_file_path, zone_id):
137138
return zones
138139

139140

140-
# Fetches all DNS records that were loaded from file
141141
def get_dns_records_by_name(zones):
142+
""" Fetches all DNS records that were loaded from file """
142143
records = []
143144

144145
LOGGER.info("Trying to fetch records for %s zones.", len(zones))
@@ -173,14 +174,14 @@ def get_dns_records_by_comment(zone_id, comment_key):
173174
return records
174175
LOGGER.warning("Request was successful but no valid domains were found: %s", response.json())
175176
return []
176-
177+
177178
LOGGER.error("Failed to get dns_records with comment key: %s", response.json())
178179

179180
return []
180181

181182

182-
# Get public IP address from the list of IP checking services
183183
def get_public_ip():
184+
""" Get public IP address from the list of IP checking services """
184185
for service in IP_CHECK_SERVICES:
185186
try:
186187
response = requests.get(service, timeout=5)
@@ -191,8 +192,8 @@ def get_public_ip():
191192
return None
192193

193194

194-
# Check if there is an active internet connection
195195
def is_connected():
196+
""" Check if there is an active internet connection """
196197
try:
197198
host = socket.gethostbyname("www.cloudflare.com")
198199
socket.create_connection((host, 80), 2)
@@ -201,8 +202,8 @@ def is_connected():
201202
LOGGER.error("Socket error: %s", exc)
202203
return False
203204

204-
# Function to run the check and update process
205205
def check_and_update_dns():
206+
""" Function to run the check and update process """
206207
LOGGER.info("Run triggered by schedule.")
207208

208209
if not is_connected():

0 commit comments

Comments
 (0)