Why I love tools

I find these tools to be incredibly useful in my coding journey. GitHub provides a smooth way to manage and share code, while Git helps me track changes and collaborate effectively. Visual Studio Code makes coding enjoyable with its user-friendly interface and helpful extensions. Docker simplifies testing and deploying applications, ensuring things work smoothly. These tools come together to make coding an exciting and efficient adventure.

Tools Check Automation

import subprocess

script="""
echo "Check if user is properly signed into git"

cd ~

declare -A settings=(["name"]="" ["email"]="")

echo -n "Enter your GitHub username: "
read settings["name"]

echo -n "Enter the email you use with GitHub: "
read settings["email"]

printf "\n"

for key in "${!settings[@]}"; do

  grep_config=`cat ~/.gitconfig | grep ${settings[$key]}`

  if [[ ! ${#check_username} > 0 ]]; then
    echo "Your git $key is not set to ${settings[$key]}!"
    echo "Running git config --global user.$key ${settings[$key]} to set your name"

    git config --global user.$key ${settings[$key]}
  fi

  echo "Your $key is set to ${settings[$key]}"

  printf "\n"
done

echo "Script complete"
"""

subprocess.run(script, shell=True, executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
---------------------------------------------------------------------------

KeyboardInterrupt                         Traceback (most recent call last)

Cell In[1], line 37
      1 import subprocess
      3 script="""
      4 echo "Check if user is properly signed into git"
      5 
   (...)
     34 echo "Script complete"
     35 """
---> 37 subprocess.run(script, shell=True, executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE)


File /usr/lib/python3.10/subprocess.py:505, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    503 with Popen(*popenargs, **kwargs) as process:
    504     try:
--> 505         stdout, stderr = process.communicate(input, timeout=timeout)
    506     except TimeoutExpired as exc:
    507         process.kill()


File /usr/lib/python3.10/subprocess.py:1154, in Popen.communicate(self, input, timeout)
   1151     endtime = None
   1153 try:
-> 1154     stdout, stderr = self._communicate(input, endtime, timeout)
   1155 except KeyboardInterrupt:
   1156     # https://bugs.python.org/issue25942
   1157     # See the detailed comment in .wait().
   1158     if timeout is not None:


File /usr/lib/python3.10/subprocess.py:2021, in Popen._communicate(self, input, endtime, orig_timeout)
   2014     self._check_timeout(endtime, orig_timeout,
   2015                         stdout, stderr,
   2016                         skip_check_and_raise=True)
   2017     raise RuntimeError(  # Impossible :)
   2018         '_check_timeout(..., skip_check_and_raise=True) '
   2019         'failed to raise TimeoutExpired.')
-> 2021 ready = selector.select(timeout)
   2022 self._check_timeout(endtime, orig_timeout, stdout, stderr)
   2024 # XXX Rewrite these to use non-blocking I/O on the file
   2025 # objects; they are no longer using C stdio!


File /usr/lib/python3.10/selectors.py:416, in _PollLikeSelector.select(self, timeout)
    414 ready = []
    415 try:
--> 416     fd_event_list = self._selector.poll(timeout)
    417 except InterruptedError:
    418     return ready


KeyboardInterrupt: