Parcourir la source

Import BugFix for DEBUG-Mode

spike_filter
Dirk Alders il y a 4 ans
Parent
révision
5ffef8254a
3 fichiers modifiés avec 30 ajouts et 7 suppressions
  1. 15
    0
      .gitignore
  2. 8
    3
      bmp.py
  3. 7
    4
      dht.py

+ 15
- 0
.gitignore Voir le fichier

@@ -114,3 +114,18 @@ dmypy.json
114 114
 # Pyre type checker
115 115
 .pyre/
116 116
 
117
+# ---> Linux
118
+*~
119
+
120
+# temporary files which can be created if a process still has a handle open of a deleted file
121
+.fuse_hidden*
122
+
123
+# KDE directory preferences
124
+.directory
125
+
126
+# Linux trash folder which might appear on any partition or disk
127
+.Trash-*
128
+
129
+# .nfs files are created when an open file is removed but is still being accessed
130
+.nfs*
131
+

+ 8
- 3
bmp.py Voir le fichier

@@ -1,8 +1,13 @@
1 1
 import time
2 2
 
3
-from . import logger, background_task, DEBUG
4
-if not DEBUG:
5
-	import smbus
3
+from . import logger, background_task
4
+try:
5
+    import smbus
6
+except ImportError:
7
+    logger.warning("Could not import smbus. DEBUG set to True.")
8
+    DEBUG = True
9
+else:
10
+    from . import DEBUG
6 11
 
7 12
 
8 13
 class bmp_180(background_task):

+ 7
- 4
dht.py Voir le fichier

@@ -1,10 +1,13 @@
1 1
 import time
2 2
 
3
-from . import logger, background_task, DEBUG
4
-
5
-if not DEBUG:
3
+from . import logger, background_task
4
+try:
6 5
     import adafruit_dht
7
-
6
+except ImportError:
7
+    logger.warning("Could not import adafruit_dht. DEBUG set to True")
8
+    DEBUG = True
9
+else:
10
+    from . import DEBUG
8 11
 
9 12
 class dht_22(background_task):
10 13
     RUN_SLEEP_TIME = 2.0

Chargement…
Annuler
Enregistrer