Move SetupCockpit to its own repo
This commit is contained in:
parent
96599a50e9
commit
9d5ce283f6
13 changed files with 0 additions and 254 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,2 @@
|
|||
*.pyc
|
||||
__pycache__
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
"""This file is read every hour to signal a break should be made in working."""
|
||||
|
||||
from playsound import playsound
|
||||
|
||||
playsound("gong.wav")
|
|
@ -1,2 +0,0 @@
|
|||
# PersonnalScripts
|
||||
Various personnal scripts to automate stuff
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
"""Script for changing timelines of out-of-sync subtitles."""
|
||||
|
||||
import argparse
|
||||
from typing import List, Tuple
|
||||
|
||||
|
||||
def main():
|
||||
"""Create a new file with update timeline, given the offset in seconds."""
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('file', help='file containing the subtitles to update')
|
||||
parser.add_argument(
|
||||
'offset', help='number of seconds to update the file with'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
file = args.file
|
||||
offset = int(args.offset)
|
||||
|
||||
output: List[str] = []
|
||||
|
||||
with open(file, 'r') as subtitles:
|
||||
for line in subtitles.readlines():
|
||||
if '-->' in line:
|
||||
start: str = line.split(' --> ')[0]
|
||||
new_start: str = get_new_timeline(start, offset)
|
||||
|
||||
end: str = line.split(' --> ')[1]
|
||||
new_end: str = get_new_timeline(end, offset)
|
||||
|
||||
new_line: str = "{} --> {}".format(new_start, new_end)
|
||||
output.append(new_line)
|
||||
|
||||
else:
|
||||
output.append(line)
|
||||
|
||||
new_file = "UPDATED.{}".format(file)
|
||||
|
||||
with open(new_file, 'w') as newfile:
|
||||
newfile.write(''.join(output))
|
||||
|
||||
|
||||
def convert_time_to_total_seconds(hrs: int, mns: int, scs: int) -> int:
|
||||
"""Take hours, minutes, seconds, Return total seconds."""
|
||||
|
||||
minutes: int = hrs * 60 + mns
|
||||
seconds: int = minutes * 60 + scs
|
||||
|
||||
return seconds
|
||||
|
||||
|
||||
def convert_time_to_h_m_s(seconds: int) -> Tuple[int, int, int]:
|
||||
"""Take total seconds, Return hours, minutes, seconds."""
|
||||
|
||||
minutes: int = seconds // 60
|
||||
hours = minutes // 60
|
||||
minutes %= 60
|
||||
seconds %= 60
|
||||
|
||||
return hours, minutes, seconds
|
||||
|
||||
|
||||
def get_new_timeline(string: str, offset: int) -> str:
|
||||
"""Convert timeline."""
|
||||
|
||||
hours: str = string.split(':')[0]
|
||||
minutes: str = string.split(':')[1]
|
||||
seconds: str = string.split(':')[2].split(',')[0]
|
||||
milliseconds: str = string.split(',')[1]
|
||||
|
||||
temp_seconds = convert_time_to_total_seconds(
|
||||
int(hours), int(minutes), int(seconds)
|
||||
)
|
||||
temp_seconds += offset
|
||||
new_hours, new_minutes, new_seconds = convert_time_to_h_m_s(temp_seconds)
|
||||
new_h = "{0:02d}".format(new_hours)
|
||||
new_m = "{0:02d}".format(new_minutes)
|
||||
new_s = "{0:02d}".format(new_seconds)
|
||||
|
||||
new_string: str = "{}:{}:{},{}".format(
|
||||
new_h,
|
||||
new_m,
|
||||
new_s,
|
||||
milliseconds
|
||||
)
|
||||
|
||||
return new_string
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,117 +0,0 @@
|
|||
"""Tests for the subltitles script."""
|
||||
|
||||
import unittest
|
||||
import prog
|
||||
|
||||
class TestScript(unittest.TestCase):
|
||||
"""Test all the elements in the script."""
|
||||
|
||||
def test_convert_time_to_total_seconds(self):
|
||||
"""Take hours, minutes, seconds, Return total seconds."""
|
||||
|
||||
seconds = prog.convert_time_to_total_seconds(1, 43, 33)
|
||||
self.assertEqual(seconds, 6213)
|
||||
|
||||
seconds = prog.convert_time_to_total_seconds(2, 0, 0)
|
||||
self.assertEqual(seconds, 7200)
|
||||
|
||||
seconds = prog.convert_time_to_total_seconds(2, 59, 59)
|
||||
self.assertEqual(seconds, 10799)
|
||||
|
||||
def test_convert_time_to_h_m_s(self):
|
||||
"""Take total seconds, Return hours, minutes, seconds."""
|
||||
|
||||
hours, minutes, seconds = prog.convert_time_to_h_m_s(6213)
|
||||
self.assertEqual((hours, minutes, seconds), (1, 43, 33))
|
||||
hours, minutes, seconds = prog.convert_time_to_h_m_s(7200)
|
||||
self.assertEqual((hours, minutes, seconds), (2, 0, 0))
|
||||
hours, minutes, seconds = prog.convert_time_to_h_m_s(10799)
|
||||
self.assertEqual((hours, minutes, seconds), (2, 59, 59))
|
||||
|
||||
def test_offset(self):
|
||||
"""Combine the conversions with an offset in between."""
|
||||
|
||||
offset: int = -18
|
||||
hours: int = 0
|
||||
minutes: int = 0
|
||||
seconds: int = 36
|
||||
|
||||
temp_seconds: int = prog.convert_time_to_total_seconds(
|
||||
hours, minutes, seconds
|
||||
)
|
||||
|
||||
temp_seconds += offset
|
||||
|
||||
new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s(
|
||||
temp_seconds
|
||||
)
|
||||
|
||||
self.assertEqual((new_hours, new_minutes, new_seconds), (0, 0, 18))
|
||||
|
||||
offset: int = -20
|
||||
hours: int = 0
|
||||
minutes: int = 4
|
||||
seconds: int = 5
|
||||
|
||||
temp_seconds: int = prog.convert_time_to_total_seconds(
|
||||
hours, minutes, seconds
|
||||
)
|
||||
|
||||
temp_seconds += offset
|
||||
|
||||
new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s(
|
||||
temp_seconds
|
||||
)
|
||||
|
||||
self.assertEqual((new_hours, new_minutes, new_seconds), (0, 3, 45))
|
||||
|
||||
offset: int = 73
|
||||
hours: int = 2
|
||||
minutes: int = 52
|
||||
seconds: int = 50
|
||||
|
||||
temp_seconds: int = prog.convert_time_to_total_seconds(
|
||||
hours, minutes, seconds
|
||||
)
|
||||
|
||||
temp_seconds += offset
|
||||
|
||||
new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s(
|
||||
temp_seconds
|
||||
)
|
||||
|
||||
self.assertEqual((new_hours, new_minutes, new_seconds), (2, 54, 3))
|
||||
|
||||
offset: int = 73
|
||||
hours: int = 2
|
||||
minutes: int = 59
|
||||
seconds: int = 49
|
||||
|
||||
temp_seconds: int = prog.convert_time_to_total_seconds(
|
||||
hours, minutes, seconds
|
||||
)
|
||||
|
||||
temp_seconds += offset
|
||||
|
||||
new_hours, new_minutes, new_seconds = prog.convert_time_to_h_m_s(
|
||||
temp_seconds
|
||||
)
|
||||
|
||||
self.assertEqual((new_hours, new_minutes, new_seconds), (3, 1, 2))
|
||||
|
||||
def test_get_timeline(self):
|
||||
"""Correct string is outputted"""
|
||||
|
||||
original_timeline: str = "00:04:05,080"
|
||||
new_timeline: str = prog.get_new_timeline(original_timeline, -18)
|
||||
self.assertNotEqual(original_timeline, new_timeline)
|
||||
self.assertEqual(new_timeline, "00:03:47,080")
|
||||
|
||||
original_timeline: str = "00:04:06,373"
|
||||
new_timeline: str = prog.get_new_timeline(original_timeline, -29)
|
||||
self.assertNotEqual(original_timeline, new_timeline)
|
||||
self.assertEqual(new_timeline, "00:03:37,373")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -1,35 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will return the following set of system information:
|
||||
|
||||
# - Hostname information:
|
||||
echo -e "\e[31;43m***** HOSTNAME INFORMATION *****\e[0m"
|
||||
hostnamectl
|
||||
echo ""
|
||||
|
||||
# - File system disk space usage:
|
||||
echo -e "\e[31;43m***** FILE SYSTEM DISK SPACE USAGE *****\e[0m"
|
||||
df -h
|
||||
echo ""
|
||||
|
||||
# - Free and used memory in the system:
|
||||
echo -e "\e[31;43m***** FREE AND USED MEMORY *****\e[0m"
|
||||
free
|
||||
echo ""
|
||||
|
||||
# - System uptime and load:
|
||||
echo -e "\e[31;43m***** SYSTEM UPTIME AND LOAD *****\e[0m"
|
||||
uptime
|
||||
echo ""
|
||||
|
||||
# - Logged-in users:
|
||||
echo -e "\e[31;43m***** CURRENTLY LOGGED-IN USERS *****\e[0m"
|
||||
who
|
||||
echo ""
|
||||
|
||||
# - Top 5 processes as far as memory usage is concerned
|
||||
echo -e "\e[31;43m***** TOP 5 MEMORY-CONSUMING PROCESSES *****\e[0m"
|
||||
ps -eo %mem,%cpu,comm --sort=-%mem | head -n 6
|
||||
echo ""
|
||||
echo -e "\e[1;32mDone.\e[0m"
|
||||
|
Loading…
Add table
Reference in a new issue