Repository: learningequality/kolibri

Issue:
apt-cache not found error in other linux distribution
<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior
Installed Kolibri 0.13.2 Using sudo pip install kolibri.
It succesfully installed. But when i run kolibri start, It shows the following error.
FileNotFoundError: [Errno 2] No such file or directory: 'apt-cache'

…

### Expected behavior
I am running Clear Linux OS which is not apt-cache based. So Can you please guide me what should i do rectify this error?

…

### User-facing consequences
Not everyone is going to use Ubuntu based distros. I also tested this on Manjaro systems. They also throw the same errors. So Please Kindly fix this issue, Or Guide me on how to fix this issue.-->

…

### Errors and logs


```
WARNING:root:No C Extensions available for this platform.

Traceback (most recent call last):
  File "/usr/bin/kolibri", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/kolibri/dist/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/kolibri/dist/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/kolibri/dist/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.8/site-packages/kolibri/utils/cli.py", line 235, in invoke
    check_debian_user(ctx.params.get("no_input"))
  File "/usr/lib/python3.8/site-packages/kolibri/utils/debian_check.py", line 25, in check_debian_user
    install_type = installation_type()
  File "/usr/lib/python3.8/site-packages/kolibri/utils/server.py", line 518, in installation_type
    install_type = is_debian_package()
  File "/usr/lib/python3.8/site-packages/kolibri/utils/server.py", line 488, in is_debian_package
    check_output(["apt-cache", "show", "kolibri"])
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'apt-cache'

```

…

### Steps to reproduce
Running kolibri from command line on any non debian based distro.

…

### Context
 * Kolibri version - 0.13.2
 * Operating system - Clearlinux

…



Discussion:
Hello  @nemoece this is the first report we have from a Clearlinux user, thanks for letting us now this problem. It has an easy fix that will be applied to future releases of Kolibri.
In the meantime, you can edit the file 
/usr/lib/python3.8/site-packages/kolibri/utils/server.py
and right after these lines:
```
    def is_debian_package():
        # find out if this is from the debian package
```
add another line:
`        return "whl"`
Be careful with the spaces, the spaces before return should be the same that before # in the previous line. I.E. it should look like:
```
    def is_debian_package():
        # find out if this is from the debian package
        return "whl"
        install_type = "dpkg"
```


Resolving patch:
diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -27,6 +27,11 @@
     # This module can't work on this OS
     psutil = None
 
+try:
+    FileNotFoundError
+except NameError:
+    FileNotFoundError = IOError
+
 logger = logging.getLogger(__name__)
 
 # Status codes for kolibri
@@ -489,7 +494,10 @@ def is_debian_package():
             apt_repo = str(check_output(["apt-cache", "madison", "kolibri"]))
             if apt_repo:
                 install_type = "apt"
-        except CalledProcessError:  # kolibri package not installed!
+        except (
+            CalledProcessError,
+            FileNotFoundError,
+        ):  # kolibri package not installed!
             install_type = "whl"
         return install_type
 


Test patch: