Revision 2151708b
Added by David Sorber over 7 years ago
| software/hbkcd/hbkcd/daemon.py | ||
|---|---|---|
|
from hbkcd.config import *
|
||
|
from hbkcd.command_server import StoppableHTTPServer, CommandHandler
|
||
|
from hbkcd.queue import ENCODE_QUEUE
|
||
|
from hbkcd.utils import *
|
||
|
|
||
|
# These should probably be protected...
|
||
|
RELAY_EMAIL = 'dsorber.phalanx@gmail.com'
|
||
| ... | ... | |
|
status = ''
|
||
|
if hbk_proc.returncode == 0:
|
||
|
status = 'COMPLETED SUCCESSFULLY'
|
||
|
item.final_size = os.stat(item.output_file).st_size
|
||
|
fmt_str = 'Encode of {:s} completed in {:s} (queued for: {:s})'
|
||
|
logging.info(fmt_str.format(item.path, elapsed_str, queued_str))
|
||
|
else:
|
||
| ... | ... | |
|
# If configured send encode complete email
|
||
|
if ENABLE_ENCODE_COMPLETE_EMAILS:
|
||
|
subject = 'hbkcd Encode Complete'
|
||
|
msg = '{:s}\n\nEncoded: {:s}\nOutput: {:s}\nDuration: {:s}\n'\
|
||
|
'Queued time: {:s}\nEncode log: {:s}\n'
|
||
|
msg = '{:s}\n\nEncoded: {:s}\nInitial Size: {:s}\n\n'\
|
||
|
'Output: {:s}\nFinal Size: {:s} ({:.2f}%)\n\n'\
|
||
|
'Duration: {:s}\nQueued time: {:s}\nEncode log: {:s}\n'
|
||
|
|
||
|
ratio = (item.final_size / (item.initial_size * 1.0))
|
||
|
send_email(subject, msg.format(status, item.path,
|
||
|
item.output_file, elapsed_str,
|
||
|
queued_str, log_path))
|
||
|
pp_filesize(item.initial_size),
|
||
|
item.output_file,
|
||
|
pp_filesize(item.final_size),
|
||
|
ratio, elapsed_str, queued_str,
|
||
|
log_path))
|
||
|
logging.debug('Sent encode complete email')
|
||
|
|
||
|
# Remove the item from the queue
|
||
| software/hbkcd/hbkcd/queue.py | ||
|---|---|---|
|
self.path = path
|
||
|
self.filename = os.path.basename(path)
|
||
|
self.output_file = output_file
|
||
|
self.initial_size = os.stat(path).st_size
|
||
|
self.final_size = 0
|
||
|
self.position = None
|
||
|
self.in_progress = False
|
||
|
self.status = 'queued'
|
||
| ... | ... | |
|
def get_dict_rep(self):
|
||
|
return {'position': self.position,
|
||
|
'path': self.path,
|
||
|
'initial_size': self.initial_size,
|
||
|
'output_file': self.output_file,
|
||
|
'in_progress': self.in_progress,
|
||
|
'status': self.status,
|
||
| software/hbkcd/setup.py | ||
|---|---|---|
|
|
||
|
setup(
|
||
|
name = 'hbkcd',
|
||
|
version = '0.3.0',
|
||
|
version = '0.4.0',
|
||
|
description = 'HandBrake Control Daemon',
|
||
|
packages = find_packages(),
|
||
|
python_requires = '>=3.6.0',
|
||
Add inital and final file size tracking for inclusion in encode complete
email. Version 0.4.0.