Checks if command is recognized on machine. Used to determine installations of 'less' pager.
(command)
| 19 | return s |
| 20 | |
| 21 | def is_command_valid(command): |
| 22 | """ |
| 23 | Checks if command is recognized on machine. Used to determine installations |
| 24 | of 'less' pager. |
| 25 | """ |
| 26 | if not command: |
| 27 | return False |
| 28 | |
| 29 | try: |
| 30 | # call command silentyly |
| 31 | with open(devnull, 'wb') as no_out: |
| 32 | subprocess.call(command, stdout=no_out, stderr=no_out) |
| 33 | except OSError: |
| 34 | return False |
| 35 | else: |
| 36 | return True |
no outgoing calls