From 192f2f912f75b7304f09f2b255e24427eef800c1 Mon Sep 17 00:00:00 2001
From: tts2k <tranthaison2000@gmail.com>
Date: Sun, 7 Jan 2018 02:49:19 +0000
Subject: Add read permission


diff --git a/haiku_cnf.py b/haiku_cnf.py
index 7c68057..c7f51d9 100644
--- a/haiku_cnf.py
+++ b/haiku_cnf.py
@@ -17,7 +17,7 @@ def update_db():
     db['base-pkgs'] = json.dumps(read_basepkgs())
     if Popen(['which', 'haikuporter'],stdout=PIPE).communicate()[0]:
         home = os.path.expanduser('~')
-        with open("%s/config/settings/command-not-found/options.json" % home, "w") as options: 
+        with open("%s/config/settings/command-not-found/options.json" % home, "rw") as options: 
             d = json.load(options)
             d['haikuports'] = True
             # json.dump(d, options)
diff --git a/install_cnf.py b/install_cnf.py
index 1e1dd35..fc0051b 100644
--- a/install_cnf.py
+++ b/install_cnf.py
@@ -35,7 +35,6 @@ def main():
         options = open("%s/config/settings/command-not-found/options.json" % home, "w")
         options.write(default_options)
         options.close()
-    os.system("install -m 755 haiku_cnf.py /boot/system/non-packaged/bin/command_not_found.py")
 
 
 if __name__ == '__main__':
-- 
2.15.0


From b0ab9db5c1938def17e0785eb03fb709c060dbfe Mon Sep 17 00:00:00 2001
From: tts2k <tranthaison2000@gmail.com>
Date: Tue, 9 Jan 2018 12:27:13 +0000
Subject: write default option if not available


diff --git a/haiku_cnf.py b/haiku_cnf.py
index c7f51d9..d9e0644 100644
--- a/haiku_cnf.py
+++ b/haiku_cnf.py
@@ -1,6 +1,7 @@
 #!/bin/env python
 #GPL v3 (c) 2011, 2016-2017 Jack Laxson "jrabbit"
 import anydbm
+import commands
 import json
 import os
 import pprint
@@ -106,6 +107,26 @@ def our_help():
     --
     %(app)s reads options from ~/config/settings/command-not-found/options.json""" % {'app': sys.argv[0]}
 
+
+
+def write_default_opt():
+    default_options="""{
+"autocorrect": false, 
+"spellcheck": false,
+"haikuports": false
+}\n"""
+
+    home = commands.getoutput('finddir B_USER_SETTINGS_DIRECTORY')
+    if not os.path.exists("%s/command-not-found/options.json" % home):
+        try:
+            os.mkdir("%s/command-not-found/" % home)
+        except OSError:
+            # Folder exists
+            pass
+        options = open("%s/command-not-found/options.json" % home, "w")
+        options.write(default_options)
+        options.close()
+
 def cnf(command):
     logger.debug("Entered CNF: %s", command)
     db = get_db()
@@ -131,6 +152,7 @@ if __name__ == '__main__':
         sys.exit()
     logging.basicConfig(level=logging.DEBUG)
     command = sys.argv[1]
+    write_default_opt()
     options = get_options()
     if 'meta-setup' not in get_db():
         logger.debug("Running for first time")
-- 
2.15.0

