Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 839 Bytes

os.md

File metadata and controls

42 lines (30 loc) · 839 Bytes

os.py

Operating system utilities for checking the runtime environment.

  • Sudo: Determine if the current process is running with sudo.
  • Internet connection: Test for an internet connection.

Example Usage

Check for sudo privileges.

python

if is_sudo():
    print("Running with sudo privileges.")
else:
    print("Running without sudo privileges.")

Check for a live internet connection.

python

if internet():
    print("An internet connection is available.")
else:
    print("No internet connection or DNS is blocked.")

Specify a host and port to check for specific services.

python

# Check for a local web server
if internet(host='localhost', port=8000):
    print("Local web server is accessible.")
else:
    print("Local web server is not accessible.")