27
27
# noinspection PyAttributeOutsideInit
28
28
class Nse :
29
29
version : str = '5.2'
30
- beta : Tuple [bool , int ] = (True , 14 )
30
+ beta : Tuple [bool , int ] = (True , 15 )
31
31
32
32
def __init__ (self , window : Tk ) -> None :
33
33
self .intervals : List [int ] = [1 , 2 , 3 , 5 , 10 , 15 ]
@@ -50,6 +50,8 @@ def __init__(self, window: Tk) -> None:
50
50
"Python-NSE-Option-Chain-Analyzer/master/nse_logo.png"
51
51
self .url_icon_ico : str = "https://raw.githubusercontent.com/VarunS2002/" \
52
52
"Python-NSE-Option-Chain-Analyzer/master/nse_logo.ico"
53
+ self .url_update : str = "https://api.github.com/repos/VarunS2002/" \
54
+ "Python-NSE-Option-Chain-Analyzer/releases/latest"
53
55
self .headers : Dict [str , str ] = {
54
56
'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, '
55
57
'like Gecko) Chrome/80.0.3987.149 Safari/537.36' ,
@@ -159,10 +161,17 @@ def get_icon(self) -> None:
159
161
return
160
162
161
163
def check_for_updates (self , auto : bool = True ) -> None :
162
- release_data : requests .Response = requests .get (
163
- "https://api.github.com/repos/VarunS2002/Python-NSE-Option-Chain-Analyzer/releases/latest" ,
164
- headers = self .headers , timeout = 5 )
165
- latest_version : str = release_data .json ()['tag_name' ]
164
+ try :
165
+ release_data : requests .Response = requests .get (self .url_update , headers = self .headers , timeout = 5 )
166
+ latest_version : str = release_data .json ()['tag_name' ]
167
+ float (latest_version )
168
+ except Exception as err :
169
+ print (err , sys .exc_info ()[0 ], "21" )
170
+ if not auto :
171
+ self .info .attributes ('-topmost' , False )
172
+ messagebox .showerror (title = "Error" , message = "Failed to check for updates." )
173
+ self .info .attributes ('-topmost' , True )
174
+ return
166
175
167
176
if float (latest_version ) > float (Nse .version ):
168
177
self .info .attributes ('-topmost' , False ) if not auto else None
0 commit comments