@@ -85,17 +85,32 @@ def __init__(
85
85
except ImportError :
86
86
self ._alarm = None
87
87
self ._debug = debug
88
+ if url and self .network is None :
89
+ raise RuntimeError ("network must not be None to get data from a url" )
88
90
self .url = url
91
+ if headers and self .network is None :
92
+ raise RuntimeError ("network must not be None to send headers" )
89
93
self ._headers = headers
94
+ if json_path and self .network is None :
95
+ raise RuntimeError ("network must not be None to use json_path" )
90
96
self ._json_path = None
91
97
self .json_path = json_path
92
98
99
+ if regexp_path and self .network is None :
100
+ raise RuntimeError ("network must not be None to use regexp_path" )
93
101
self ._regexp_path = regexp_path
102
+
103
+ if success_callback and self .network is None :
104
+ raise RuntimeError ("network must not be None to use success_callback" )
94
105
self ._success_callback = success_callback
95
106
96
107
# Add any JSON translators
108
+
97
109
if json_transform :
98
- self .network .add_json_transform (json_transform )
110
+ if self .network is not None :
111
+ self .network .add_json_transform (json_transform )
112
+ else :
113
+ raise RuntimeError ("network must not be None to use json_transform." )
99
114
100
115
def _load_font (self , font ):
101
116
"""
@@ -416,6 +431,9 @@ def fetch(self, refresh_url=None, timeout=10):
416
431
:param int timeout: The timeout period in seconds.
417
432
418
433
"""
434
+
435
+ if self .network is None :
436
+ raise RuntimeError ("network must not be None to use fetch()" )
419
437
if refresh_url :
420
438
self .url = refresh_url
421
439
values = []
@@ -459,6 +477,9 @@ def _fill_text_labels(self, values):
459
477
460
478
def get_local_time (self , location = None ):
461
479
"""Accessor function for get_local_time()"""
480
+ if self .network is None :
481
+ raise RuntimeError ("network must not be None to use get_local_time()" )
482
+
462
483
return self .network .get_local_time (location = location )
463
484
464
485
def push_to_io (self , feed_key , data , metadata = None , precision = None ):
@@ -470,6 +491,8 @@ def push_to_io(self, feed_key, data, metadata=None, precision=None):
470
491
:param int precision: Optional amount of precision points to send with floating point data
471
492
472
493
"""
494
+ if self .network is None :
495
+ raise RuntimeError ("network must not be None to use push_to_io()" )
473
496
474
497
self .network .push_to_io (feed_key , data , metadata = metadata , precision = precision )
475
498
@@ -479,6 +502,8 @@ def get_io_data(self, feed_key):
479
502
:param str feed_key: Name of feed key to receive data from.
480
503
481
504
"""
505
+ if self .network is None :
506
+ raise RuntimeError ("network must not be None to use get_io_data()" )
482
507
483
508
return self .network .get_io_data (feed_key )
484
509
@@ -489,6 +514,9 @@ def get_io_feed(self, feed_key, detailed=False):
489
514
:param bool detailed: Whether to return additional detailed information
490
515
491
516
"""
517
+ if self .network is None :
518
+ raise RuntimeError ("network must not be None to use get_io_feed()" )
519
+
492
520
return self .network .get_io_feed (feed_key , detailed )
493
521
494
522
def get_io_group (self , group_key ):
@@ -497,6 +525,8 @@ def get_io_group(self, group_key):
497
525
:param str group_key: Name of group key to match.
498
526
499
527
"""
528
+ if self .network is None :
529
+ raise RuntimeError ("network must not be None to use get_io_group()" )
500
530
return self .network .get_io_group (group_key )
501
531
502
532
@property
@@ -509,6 +539,9 @@ def json_path(self):
509
539
510
540
@json_path .setter
511
541
def json_path (self , value ):
542
+ if value is not None and self .network is None :
543
+ raise RuntimeError ("network must not be None to use json_path." )
544
+
512
545
if value :
513
546
if isinstance (value [0 ], (list , tuple )):
514
547
self ._json_path = value
0 commit comments