|
You are here |
techtldr.com | ||
| | | | |
nabeelvalley.co.za
|
|
| | | | | How to work with modules and handle the 'ModuleNotFoundError: No module named ...' error | |
| | | | |
willhaley.com
|
|
| | | | | See here an example of a custom Linux mount script, written in Python, that can be used to mount disks with /etc/fstab. The mount script is installed at /usr/bin/mount.my-command and is executable. #!/usr/bin/env python3 import sys import subprocess device = sys.argv[1] mount_point = sys.argv[2] options = sys.argv[4] # Any customization could be done here to the `mount` command that is run. mount_command = ['mount', '-o', options, device, mount_point] output = subprocess.run( mount_command, capture_output=True ) if output.returncode != 0: print("error mounting") print(output.stderr.decode('UTF-8')) sys.exit(output.returncode) See here how the custom script can then be used in /etc/fstab like any "normal" mount. | |
| | | | |
www.paepper.com
|
|
| | | | | When you are prototyping and developing small scripts that you keep running, it might be annoying that they quit when an error occurs. If you want very basic robustness against these crashes, you can at least use a bash script to automatically restart your script on error. The tool to use here is called until and makes this a breeze. Let's use a dumb example Python script called test.py: import time while True: print('Looping') time.sleep(5) raise Exception('Exception in loop') It is in a loop and crashes every 5 seconds, so we can verify that our restart procedure works as expected. | |
| | | | |
caitlinsanswersforhumanitiesclass.wordpress.com
|
|
| | | This is the excerpt for your very first post. | ||