Kicks off a subprocess to send the 'Query' to HowDoI Prints the result, which in this program will route to a gooeyGUI window :param Query: text english question to ask the HowDoI web engine :return: nothing
(Query, num_answers, full_text)
| 80 | |
| 81 | |
| 82 | def QueryHowDoI(Query, num_answers, full_text): |
| 83 | ''' |
| 84 | Kicks off a subprocess to send the 'Query' to HowDoI |
| 85 | Prints the result, which in this program will route to a gooeyGUI window |
| 86 | :param Query: text english question to ask the HowDoI web engine |
| 87 | :return: nothing |
| 88 | ''' |
| 89 | full_text_option = ' -a' if full_text else '' |
| 90 | t = subprocess.Popen(HOW_DO_I_COMMAND + ' \"' + Query + '\" -n ' + |
| 91 | str(num_answers)+full_text_option, stdout=subprocess.PIPE) |
| 92 | (output, err) = t.communicate() |
| 93 | print('{:^88}'.format(Query.rstrip())) |
| 94 | print('_'*60) |
| 95 | print(output.decode("utf-8")) |
| 96 | exit_code = t.wait() |
| 97 | |
| 98 | |
| 99 | if __name__ == '__main__': |