22
22
23
23
import wikipedia
24
24
import requests
25
- import logging
26
25
import time
27
26
import re
28
27
import urllib .request
@@ -47,16 +46,16 @@ def tell_me_about(cls, voice_transcript, skill):
47
46
only_text_pattern = '([a-zA-Z]+)'
48
47
for tag in tags :
49
48
reg_ex = re .search (tag + ' ' + only_text_pattern , voice_transcript )
50
- try :
51
- if reg_ex :
52
- topic = reg_ex . group ( 1 )
49
+ if reg_ex :
50
+ topic = reg_ex . group ( 1 )
51
+ try :
53
52
response = cls ._decoded_wiki_response (topic )
54
53
cls .response (response )
55
- except Exception as e :
56
- logging . error ( "Error with the execution of skill with message {0}" .format (e ))
57
- cls .response (" I can't find what you want, and I will open a new tab in browser" )
58
- time .sleep (1 )
59
- cls ._search_on_google (topic )
54
+ except Exception as e :
55
+ cls . console ( error_log = "Error with the execution of skill with message {0}" .format (e ))
56
+ cls .response (" I can't find what you want, and I will open a new tab in browser" )
57
+ time .sleep (1 )
58
+ cls ._search_on_google (topic )
60
59
61
60
@classmethod
62
61
def open_in_youtube (cls , voice_transcript , skill ):
@@ -65,6 +64,7 @@ def open_in_youtube(cls, voice_transcript, skill):
65
64
:param voice_transcript: string (e.g 'about google')
66
65
:param skill: dict (e.g
67
66
"""
67
+
68
68
tags = cls .extract_tags (voice_transcript , skill ['tags' ])
69
69
for tag in tags :
70
70
reg_ex = re .search (tag + ' ([a-zA-Z]+)' , voice_transcript )
@@ -79,7 +79,7 @@ def open_in_youtube(cls, voice_transcript, skill):
79
79
video = 'https://www.youtube.com' + vids [0 ]['href' ]
80
80
subprocess .Popen (["python" , "-m" , "webbrowser" , "-t" , video ], stdout = subprocess .PIPE , shell = False )
81
81
except Exception as e :
82
- logging . error ( "Error with the execution of skill with message {0}" .format (e ))
82
+ cls . console ( error_log = "Error with the execution of skill with message {0}" .format (e ))
83
83
cls .response ("I can't find what do you want in Youtube.." )
84
84
85
85
@classmethod
@@ -115,7 +115,7 @@ def open_website_in_browser(cls, voice_transcript, skill):
115
115
webbrowser .open_new_tab (url )
116
116
cls .response ('I opened the {0}' .format (domain ))
117
117
except Exception as e :
118
- logging . error ( "Error with the execution of skill with message {0}" .format (e ))
118
+ cls . console ( error_log = "Error with the execution of skill with message {0}" .format (e ))
119
119
cls .response ("I can't find this domain.." )
120
120
121
121
@classmethod
@@ -133,7 +133,7 @@ def tell_me_today_news(cls, **kwargs):
133
133
response += data .decode ()
134
134
cls .response (response )
135
135
except Exception as e :
136
- logging . error ( "Error with the execution of skill with message {0}" .format (e ))
136
+ cls . console ( error_log = "Error with the execution of skill with message {0}" .format (e ))
137
137
cls .response ("I can't find about daily news.." )
138
138
139
139
@classmethod
@@ -171,6 +171,6 @@ def _search_on_google(cls, term):
171
171
try :
172
172
webbrowser .open_new_tab (url )
173
173
except Exception as e :
174
- logging . error ( "Error with the execution of skill with message {0}" .format (e ))
174
+ cls . console ( error_log = "Error with the execution of skill with message {0}" .format (e ))
175
175
cls .response ("Sorry I faced an issue with google search" )
176
176
0 commit comments