Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.
/ whitelist Public archive

Commit 67fbf57

Browse files
authored
Merge pull request #164 from mwoolweaver/master
remove error prone total_changes function introduced in #158
2 parents 520566d + 95374ae commit 67fbf57

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

scripts/uninstall.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,19 @@ def restart_pihole(docker):
154154
sqliteConnection = sqlite3.connect(gravity_db_location)
155155
cursor = sqliteConnection.cursor()
156156
print('[i] Successfully Connected to Gravity database')
157-
total_domains = cursor.execute(
158-
" SELECT * FROM domainlist WHERE type = 0 AND comment LIKE '%qjz9zk%' ")
159-
print("[i] There are a total of {} domains in your whitelist which are added by my script" .format(
160-
len(total_domains.fetchall())))
157+
total_domains = cursor.execute(" SELECT * FROM domainlist WHERE type = 0 AND comment LIKE '%qjz9zk%' ")
158+
159+
totalDomains = len(total_domains.fetchall())
160+
print("[i] There are a total of {} domains in your whitelist which are added by my script" .format(totalDomains))
161161
print('[i] Removing domains in the Gravity database')
162-
cursor.execute(
163-
" DELETE FROM domainlist WHERE type = 0 AND comment LIKE '%qjz9zk%' ")
162+
cursor.execute (" DELETE FROM domainlist WHERE type = 0 AND comment LIKE '%qjz9zk%' ")
164163

165164
sqliteConnection.commit()
166165

167-
# total_changes is returning 2x the actual value. ¯\_(ツ)_/¯
168-
# if I made a mistake, please create a PR
169-
numberOfDomains = sqliteConnection.total_changes
170-
if numberOfDomains > 1:
171-
numberOfDomains = numberOfDomains // 2
172-
print("[i] {} domains are removed" .format(numberOfDomains))
173-
remaining_domains = cursor.execute(
174-
" SELECT * FROM domainlist WHERE type = 0 OR type = 2 ")
175-
print("[i] There are a total of {} domains remaining in your whitelist" .format(
176-
len(remaining_domains.fetchall())))
166+
# we only removed domains we added so use total_domains
167+
print("[i] {} domains are removed" .format(totalDomains))
168+
remaining_domains = cursor.execute(" SELECT * FROM domainlist WHERE type = 0 OR type = 2 ")
169+
print("[i] There are a total of {} domains remaining in your exact whitelist" .format(len(remaining_domains.fetchall())))
177170

178171
cursor.close()
179172

scripts/whitelist.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,16 @@ def restart_pihole(docker):
166166

167167
sqliteConnection.commit()
168168

169-
# total_changes is returning 2x the actual value. ¯\_(ツ)_/¯
170-
# if I made a mistake, please create a PR
171-
numberOfDomains = sqliteConnection.total_changes
172-
if numberOfDomains > 1:
173-
numberOfDomains = numberOfDomains // 2
174-
# print(f'[i] {numberOfDomains} domains are added to whitelist out of {len(whitelist_remote)}')
175-
print("[i] {} domains are added to whitelist out of {}" .format(
176-
numberOfDomains, len(whitelist_remote)))
177-
total_domains = cursor.execute(
178-
" SELECT * FROM domainlist WHERE type = 0 OR type = 2 ")
179-
# print(f'[i] There are a total of {len(total_domains.fetchall())} domains in your whitelist')
180-
print("[i] There are a total of {} domains in your whitelist" .format(
181-
len(total_domains.fetchall())))
169+
# find only the domains we added
170+
number_domains = cursor.execute(" SELECT * FROM domainlist WHERE type = 0 AND comment LIKE '%qjz9zk%' ")
171+
172+
numberDomains = len(number_domains.fetchall())
173+
174+
#print(f'[i] {numberOfDomains} domains are added to whitelist out of {len(whitelist_remote)}')
175+
print("[i] {} domains are added to whitelist out of {}" .format(numberDomains, len(whitelist_remote)))
176+
total_domains = cursor.execute(" SELECT * FROM domainlist WHERE type = 0 OR type = 2 ")
177+
#print(f'[i] There are a total of {len(total_domains.fetchall())} domains in your whitelist')
178+
print("[i] There are a total of {} domains in your whitelist" .format(len(total_domains.fetchall())))
182179
cursor.close()
183180

184181
except sqlite3.Error as error:

0 commit comments

Comments
 (0)