Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -305,6 +305,8 @@ def summarize(inp,history,data=None):
|
|
305 |
|
306 |
|
307 |
def find_rss():
|
|
|
|
|
308 |
lod=""
|
309 |
out_box=[]
|
310 |
yield [],[(None,"loading sources")]
|
@@ -330,10 +332,15 @@ def find_rss():
|
|
330 |
lod = xmltodict.parse(r.content)
|
331 |
except Exception as e:
|
332 |
lod=f'{rss_url} ::ERROR:: {e}'
|
|
|
|
|
333 |
except Exception as e:
|
334 |
lod=f'{rss_url} ::ERROR:: {e}'
|
|
|
|
|
335 |
else:
|
336 |
lod = f'{rss_url} ::ERROR::COULD NOT CONNECT:: {r.status_code}'
|
|
|
337 |
pass
|
338 |
try:
|
339 |
print(lod['rss']['channel']['item'][0].keys())
|
@@ -351,6 +358,7 @@ def find_rss():
|
|
351 |
r_description = 'No Description provided'
|
352 |
lods = {"title":r_title, "description":r_description,"link":r_link}
|
353 |
except Exception as e:
|
|
|
354 |
print(e)
|
355 |
pass
|
356 |
#lods = {"title":"ERROR", "description":{e},"link":"ERROR"}
|
@@ -364,15 +372,9 @@ def find_rss():
|
|
364 |
out_box.append(lod)
|
365 |
|
366 |
except Exception as e:
|
367 |
-
|
368 |
-
#print(f'{ea["source"]}')
|
369 |
-
#print(f'{ea["link"]}')
|
370 |
-
#lod = f'{rss_url} ::ERROR:: {e}'
|
371 |
-
|
372 |
print(f'Exception::{e}')
|
373 |
print(f'Exception::{ea.keys()}')
|
374 |
-
|
375 |
-
#out_box.append(lod)
|
376 |
|
377 |
#user_repo=save_data.split('datasets/',1)[1].split('/raw',1)[0]
|
378 |
timestamp=str(datetime.datetime.now())
|
@@ -390,7 +392,7 @@ def find_rss():
|
|
390 |
token=token_self,
|
391 |
repo_type="dataset",
|
392 |
)
|
393 |
-
yield out_box,[(None,f'Source is current as of:\n{timestamp} UTC\n\nThe current Date and Time is:\n{timestamp} UTC')]
|
394 |
|
395 |
|
396 |
def load_data(rss_url=None):
|
@@ -449,9 +451,10 @@ with gr.Blocks() as app:
|
|
449 |
keyw = gr.Button("Use Keyword [Experimental]")
|
450 |
with gr.Row():
|
451 |
out_json = gr.JSON()
|
452 |
-
|
|
|
453 |
keyw.click(get_records,[inst,out_json],[inst,cb])
|
454 |
load_btn.click(load_data,rss_custom,[out_json,cb])
|
455 |
-
u_btn.click(find_rss,None,[out_json,cb])
|
456 |
sub_btn.click(summarize,[inst,cb,out_json],[inst,cb])
|
457 |
app.queue(default_concurrency_limit=20).launch()
|
|
|
305 |
|
306 |
|
307 |
def find_rss():
|
308 |
+
error_box=[]
|
309 |
+
error_box_schema={"Name":"","Error":"","Keys":"","Other":""}
|
310 |
lod=""
|
311 |
out_box=[]
|
312 |
yield [],[(None,"loading sources")]
|
|
|
332 |
lod = xmltodict.parse(r.content)
|
333 |
except Exception as e:
|
334 |
lod=f'{rss_url} ::ERROR:: {e}'
|
335 |
+
error_box.append({"Name":rss_url,"Error":e,"Error Code":1})
|
336 |
+
|
337 |
except Exception as e:
|
338 |
lod=f'{rss_url} ::ERROR:: {e}'
|
339 |
+
error_box.append({"Name":rss_url,"Error":e,"Error Code":2})
|
340 |
+
|
341 |
else:
|
342 |
lod = f'{rss_url} ::ERROR::COULD NOT CONNECT:: {r.status_code}'
|
343 |
+
error_box.append({"Name":rss_url,"Error":f'Status Code:{r.status_code}',"Error Code":3})
|
344 |
pass
|
345 |
try:
|
346 |
print(lod['rss']['channel']['item'][0].keys())
|
|
|
358 |
r_description = 'No Description provided'
|
359 |
lods = {"title":r_title, "description":r_description,"link":r_link}
|
360 |
except Exception as e:
|
361 |
+
error_box.append({"Name":rss_url,"Error":e,"Error Code":4})
|
362 |
print(e)
|
363 |
pass
|
364 |
#lods = {"title":"ERROR", "description":{e},"link":"ERROR"}
|
|
|
372 |
out_box.append(lod)
|
373 |
|
374 |
except Exception as e:
|
375 |
+
error_box.append({"Name":rss_url,"Error":e,"Error Code":5})
|
|
|
|
|
|
|
|
|
376 |
print(f'Exception::{e}')
|
377 |
print(f'Exception::{ea.keys()}')
|
|
|
|
|
378 |
|
379 |
#user_repo=save_data.split('datasets/',1)[1].split('/raw',1)[0]
|
380 |
timestamp=str(datetime.datetime.now())
|
|
|
392 |
token=token_self,
|
393 |
repo_type="dataset",
|
394 |
)
|
395 |
+
yield out_box,[(None,f'Source is current as of:\n{timestamp} UTC\n\nThe current Date and Time is:\n{timestamp} UTC')],error_box
|
396 |
|
397 |
|
398 |
def load_data(rss_url=None):
|
|
|
451 |
keyw = gr.Button("Use Keyword [Experimental]")
|
452 |
with gr.Row():
|
453 |
out_json = gr.JSON()
|
454 |
+
error_box=gr.JSON()
|
455 |
+
fil = gr.Textbox()
|
456 |
keyw.click(get_records,[inst,out_json],[inst,cb])
|
457 |
load_btn.click(load_data,rss_custom,[out_json,cb])
|
458 |
+
u_btn.click(find_rss,None,[out_json,cb,error_box])
|
459 |
sub_btn.click(summarize,[inst,cb,out_json],[inst,cb])
|
460 |
app.queue(default_concurrency_limit=20).launch()
|