General code cleanup
This commit is contained in:
parent
2e6c398cd1
commit
24c4ae781b
0
audiotrim.sh
Executable file → Normal file
0
audiotrim.sh
Executable file → Normal file
37
ddusb.py
Executable file → Normal file
37
ddusb.py
Executable file → Normal file
@ -2,36 +2,37 @@
|
|||||||
"""Write an ISO image to a usb drive using dd."""
|
"""Write an ISO image to a usb drive using dd."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import configparser
|
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# TODO add a config file for blacklisting certain devices e.g. /dev/sda
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-b", "--bs",
|
||||||
|
default=512,
|
||||||
|
help="block size",
|
||||||
|
metavar="bs")
|
||||||
|
parser.add_argument("input_file", help="input file to write")
|
||||||
|
parser.add_argument("output_file", help="output block device")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
block_size = args.bs
|
||||||
parser.add_argument("-b", "--bs", default=512, help="block size", metavar="bs")
|
input_file = args.input_file
|
||||||
parser.add_argument("input_file", help="input file to write")
|
block_device = args.output_file
|
||||||
parser.add_argument("output_file", help="output block device")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
block_size = args.bs
|
if not pathlib.Path(block_device).is_block_device():
|
||||||
input_file = args.input_file
|
|
||||||
block_device = args.output_file
|
|
||||||
|
|
||||||
if not pathlib.Path(block_device).is_block_device():
|
|
||||||
print(f"Error: {block_device} is not a block device")
|
print(f"Error: {block_device} is not a block device")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
print(f"Input file: {input_file}")
|
print(f"Input file: {input_file}")
|
||||||
print(f"Block device: {block_device}")
|
print(f"Block device: {block_device}")
|
||||||
print(f"Block size: {block_size}")
|
print(f"Block size: {block_size}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(["dd", f"if={input_file}",
|
subprocess.run(["dd", f"if={input_file}",
|
||||||
f"of={block_device}",
|
f"of={block_device}",
|
||||||
f"bs={block_size}",
|
f"bs={block_size}",
|
||||||
"status=progress"], check=True)
|
"status=progress"], check=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
exit(1)
|
exit(1)
|
||||||
else:
|
else:
|
||||||
subprocess.run(['sync'])
|
subprocess.run(['sync'])
|
||||||
|
11
drivetemp.py
Executable file → Normal file
11
drivetemp.py
Executable file → Normal file
@ -13,7 +13,11 @@ import argparse
|
|||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
# ========== Constants ==========
|
||||||
|
DUMP_CMD = ['skdump', '--temperature']
|
||||||
|
|
||||||
|
|
||||||
|
# ========== Functions ==========
|
||||||
def verify_device_node(query):
|
def verify_device_node(query):
|
||||||
"""Check if query is a device node.
|
"""Check if query is a device node.
|
||||||
:param query: input that refers to a device
|
:param query: input that refers to a device
|
||||||
@ -31,11 +35,10 @@ def retrieve_smart_temp(device_node):
|
|||||||
:returns: output of skdump in mKelvin
|
:returns: output of skdump in mKelvin
|
||||||
:rtype: float
|
:rtype: float
|
||||||
"""
|
"""
|
||||||
dump_cmd = subprocess.run(['sudo', 'skdump', '--temperature',
|
temp = subprocess.run(DUMP_CMD + device_node,
|
||||||
device_node],
|
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True)
|
text=True).stdout
|
||||||
return float(dump_cmd.stdout)
|
return float(temp)
|
||||||
|
|
||||||
|
|
||||||
def convert_to_celsius(mkel_temp):
|
def convert_to_celsius(mkel_temp):
|
||||||
|
4
fless.sh
Executable file → Normal file
4
fless.sh
Executable file → Normal file
@ -4,7 +4,7 @@
|
|||||||
# - fd (soft)
|
# - fd (soft)
|
||||||
# - fzf
|
# - fzf
|
||||||
|
|
||||||
_help() {
|
help() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Usage: fless [-h|--help] [-b|--boot] [-d|--dir directory] [-e|--etc]
|
Usage: fless [-h|--help] [-b|--boot] [-d|--dir directory] [-e|--etc]
|
||||||
Options:
|
Options:
|
||||||
@ -58,7 +58,7 @@ while true; do
|
|||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
'-h'|'--help')
|
'-h'|'--help')
|
||||||
printHelp
|
help
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user