[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Provide a nicer error when sqlite3 is unavailable



commit 4bfe05dc045d4d0f3e17bec730a1e279ef35a8e2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Oct 30 13:53:19 2017 -0700

    Provide a nicer error when sqlite3 is unavailable
    
    Oops! Turns out this isn't available by default on FreeBSD or Gentoo. Providing
    a nicer notice, encouraging folks to contact us so we can provide per-platform
    suggestions for how to get it.
---
 nyx/__init__.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/nyx/__init__.py b/nyx/__init__.py
index ee81f51..11cdf33 100644
--- a/nyx/__init__.py
+++ b/nyx/__init__.py
@@ -46,7 +46,6 @@ import contextlib
 import distutils.spawn
 import os
 import platform
-import sqlite3
 import sys
 import threading
 import time
@@ -60,6 +59,29 @@ import stem.util.log
 import stem.util.system
 import stem.util.tor_tools
 
+SQLITE_UNAVAILABLE = """\
+Python's sqlite3 module is unavailable. Unfortunatley some platforms
+don't bundle this with the interpreter. Please let us know at...
+
+  https://trac.torproject.org/projects/tor/wiki/doc/nyx/bugs
+"""
+
+SQLITE_UNAVAILABLE_FREEBSD = """\
+Python's sqlite3 module is unavailable. Please run...
+
+  sudo pkg install py27-sqlite3
+"""
+
+try:
+  import sqlite3
+except ImportError:
+  if stem.util.system.is_bsd():
+    print(SQLITE_UNAVAILABLE_FREEBSD)
+  else:
+    print(SQLITE_UNAVAILABLE)
+
+  sys.exit(1)
+
 __version__ = '1.4.6-dev'
 __release_date__ = 'April 28, 2011'
 __author__ = 'Damian Johnson'

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits