2023-01-04 02:41:07 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2023-01-08 15:43:27 +01:00
|
|
|
import shutil, os
|
2023-01-04 02:41:07 +01:00
|
|
|
|
|
|
|
infix = ': Treating channel '
|
|
|
|
path = 'channels/'
|
|
|
|
|
|
|
|
threads = {}
|
|
|
|
|
|
|
|
with open('nohup.out') as f:
|
|
|
|
lines = f.read().splitlines()
|
|
|
|
for line in lines:
|
|
|
|
if infix in line:
|
|
|
|
#print(line)
|
|
|
|
threadId = line.split(': ')[1]
|
|
|
|
channelId = line.split(infix)[1].split(' (')[0]
|
2023-02-19 02:04:28 +01:00
|
|
|
if threadId.isdigit() and channelId.startswith('UC') and len(channelId) == 24:
|
|
|
|
threads[threadId] = channelId
|
2023-01-04 02:41:07 +01:00
|
|
|
for threadId in threads:
|
|
|
|
channelId = threads[threadId]
|
|
|
|
print(threadId, channelId)
|
2023-01-08 15:43:27 +01:00
|
|
|
# There are three cases:
|
|
|
|
# - `channelId`/ exists
|
|
|
|
# - `channelId`/ and `channelId`.zip exist
|
|
|
|
# - `channelId`.zip exists
|
|
|
|
# To manage every case, we need to use two `try`/`except`.
|
2023-01-04 03:10:28 +01:00
|
|
|
try:
|
|
|
|
shutil.rmtree(path + channelId)
|
2023-01-08 15:43:27 +01:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
2023-01-04 03:10:28 +01:00
|
|
|
os.remove(path + channelId + ".zip")
|
|
|
|
except:
|
|
|
|
pass
|