File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 2
2
""" xbar plugin
3
3
--Use Yahoo Finance data to monitor stock indices, currencies and cryptocurrencies """
4
4
5
+ import sys
5
6
import os
6
7
import logging
7
8
9
+ import requests .exceptions
8
10
from yahooquery import Ticker
9
11
10
12
@@ -29,7 +31,13 @@ def get_quotes(symbols):
29
31
""" Get quotes with yahooquery """
30
32
31
33
quotes = Ticker (symbols )
32
- data = quotes .price
34
+
35
+ try :
36
+ data = quotes .price
37
+ except requests .exceptions .ConnectionError :
38
+ log .warning ("Cannot get data" )
39
+ return None
40
+
33
41
for symbol in symbols :
34
42
if not isinstance (data [symbol ], dict ):
35
43
log .warning ("Quote not found for symbol: %s" , symbol )
@@ -102,6 +110,10 @@ def main():
102
110
unique_symbols = SYMBOLS_TICKER + list (set (SYMBOLS_DROPDOWN ) - set (SYMBOLS_TICKER ))
103
111
quotes = get_quotes (unique_symbols )
104
112
113
+ if quotes is None :
114
+ print ("⚠️ connection failed | color=gray" )
115
+ sys .exit (0 )
116
+
105
117
if len (SYMBOLS_TICKER ) == 0 :
106
118
print ("xbar" )
107
119
else :
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
# <xbar.title>YF Stock Ticker</xbar.title>
3
- # <xbar.version>v0.3 -beta</xbar.version>
3
+ # <xbar.version>v0.4 -beta</xbar.version>
4
4
# <xbar.author>Germain Masse</xbar.author>
5
5
# <xbar.author.github>gmasse</xbar.author.github>
6
6
# <xbar.desc>--Use Yahoo Finance data to monitor stock indices, currencies and cryptocurrencies</xbar.desc>
You can’t perform that action at this time.
0 commit comments