This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib3 | |
def check_internet_conn(): | |
http = urllib3.PoolManager(timeout=3.0) | |
r = http.request('GET', 'google.com', preload_content=False) | |
code = r.status | |
r.release_conn() | |
if code == 200: | |
return True | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create a spinning cursor or progress bar in terminal can be useful | |
for some scripts. | |
1. Use '\r' to move cursor back to the line beginning. Or use '\b' | |
to erase the last character. | |
2. The standard out of Python is buffered, which means it will | |
collect some data written to standard out before it actually | |
writes to the terminal. | |
The code snippet |