-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathColdTurkeyBlockerPro-Activator-Mac.py
More file actions
54 lines (40 loc) · 1.61 KB
/
ColdTurkeyBlockerPro-Activator-Mac.py
File metadata and controls
54 lines (40 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
''' **For Mac Only** '''
import json
import os
import sqlite3
DB_PATH = r"/Library/Application Support/Cold Turkey/data-app.db"
def activate():
try:
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
s = (c.execute("SELECT value FROM settings WHERE key = 'settings'")
.fetchone()[0])
data = json.loads(s)
if data["additional"]["proStatus"] != "pro":
print("Your version of Cold Turkey Blocker is not activated.")
data["additional"]["proStatus"] = "pro"
print("But now it is activated.\nJust check it.")
c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""",
(json.dumps(data),))
conn.commit()
else:
print("Looks like your copy of Cold Turkey Blocker is already activated.")
print("Deactivating it now.")
data["additional"]["proStatus"] = "free"
c.execute("""UPDATE settings set value = ? WHERE "key" = 'settings'""",
(json.dumps(data),))
conn.commit()
except sqlite3.Error as e:
print("Failed to activate", e)
finally:
if conn:
conn.close()
os.system(r'killall Cold Turkey Blocker')
def main():
if os.path.exists(DB_PATH):
print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
activate()
else:
print("Looks like Cold Turkey Blocker is not installed.\nIf it is installed then run it at least once.")
if __name__ == '__main__':
main()