Esempio n. 1
0
def endjob(filename, msgid, cat, status, path, bytes, fail_msg, stages, script, script_output, script_ret, test=None):
    """ Send end-of-job email """

    # Translate the stage names
    tr = sabnzbd.api.Ttemplate
    if not status and fail_msg:
        xstages = {tr('stage-fail'): (fail_msg,)}
    else:
        xstages = {}

    for stage in stages:
        lines = []
        for line in stages[stage]:
            if '\n' in line or '<br/>' in line:
                lines.extend(line.replace('<br/>', '\n').split('\n'))
            else:
                lines.append(line)
        xstages[tr('stage-'+stage.lower())] = lines

    parm = {}
    parm['status'] = status
    parm['name'] = filename
    parm['path'] = path
    parm['msgid'] = str(msgid)
    parm['stages'] = xstages
    parm['script'] = script
    parm['script_output'] = script_output
    parm['script_ret'] = script_ret
    parm['cat'] = cat
    parm['size'] = "%sB" % to_units(bytes)
    parm['end_time'] = time.strftime(time_format('%Y-%m-%d %H:%M:%S'), time.localtime(time.time()))

    return send_with_template('email', parm, test)
Esempio n. 2
0
def endjob(filename, msgid, cat, status, path, bytes, stages, script,
           script_output, script_ret):
    """ Send end-of-job email """

    # Translate the stage names
    tr = sabnzbd.api.Ttemplate
    xstages = {}
    for stage in stages:
        lines = []
        for line in stages[stage]:
            if '\n' in line or '<br/>' in line:
                lines.extend(line.replace('<br/>', '\n').split('\n'))
            else:
                lines.append(line)
        xstages[tr('stage-' + stage.lower())] = lines

    parm = {}
    parm['status'] = status
    parm['name'] = filename
    parm['path'] = path
    parm['msgid'] = str(msgid)
    parm['stages'] = xstages
    parm['script'] = script
    parm['script_output'] = script_output
    parm['script_ret'] = script_ret
    parm['cat'] = cat
    parm['size'] = "%sB" % to_units(bytes)
    parm['end_time'] = time.strftime(time_format('%Y-%m-%d %H:%M:%S'),
                                     time.localtime(time.time()))

    return send_with_template('email', parm)
Esempio n. 3
0
def endjob(filename,
           cat,
           status,
           path,
           bytes,
           fail_msg,
           stages,
           script,
           script_output,
           script_ret,
           test=None):
    """ Send end-of-job email """
    # Is it allowed?
    if not check_cat('misc', cat, keyword='email') and not test:
        return None

    # Translate the stage names
    tr = sabnzbd.api.Ttemplate
    if not status and fail_msg:
        xstages = {tr('stage-fail'): (fail_msg, )}
    else:
        xstages = {}

    for stage in stages:
        lines = []
        for line in stages[stage]:
            if '\n' in line or '<br/>' in line:
                lines.extend(line.replace('<br/>', '\n').split('\n'))
            else:
                lines.append(line)
        xstages[tr('stage-' + stage.lower())] = lines

    parm = {}
    parm['status'] = status
    parm['name'] = filename
    parm['path'] = path
    parm['msgid'] = ''
    parm['stages'] = xstages
    parm['script'] = script
    parm['script_output'] = script_output
    parm['script_ret'] = script_ret
    parm['cat'] = cat
    parm['size'] = "%sB" % to_units(bytes)
    parm['end_time'] = time.strftime(time_format('%Y-%m-%d %H:%M:%S'),
                                     time.localtime(
                                         time.time())).decode(codepage)

    return send_with_template('email', parm, test)
Esempio n. 4
0
def endjob(filename,
           cat,
           status,
           path,
           bytes_downloaded,
           fail_msg,
           stages,
           script,
           script_output,
           script_ret,
           test=None):
    """ Send end-of-job email """
    # Is it allowed?
    if not check_cat("misc", cat, keyword="email") and not test:
        return None

    # Translate the stage names
    tr = sabnzbd.api.Ttemplate
    if not status and fail_msg:
        xstages = {tr("stage-fail"): (fail_msg, )}
    else:
        xstages = {}

    for stage in stages:
        lines = []
        for line in stages[stage]:
            if "\n" in line or "<br/>" in line:
                lines.extend(line.replace("<br/>", "\n").split("\n"))
            else:
                lines.append(line)
        xstages[tr("stage-" + stage.lower())] = lines

    parm = {}
    parm["status"] = status
    parm["name"] = filename
    parm["path"] = path
    parm["msgid"] = ""
    parm["stages"] = xstages
    parm["script"] = script
    parm["script_output"] = script_output
    parm["script_ret"] = script_ret
    parm["cat"] = cat
    parm["size"] = "%sB" % to_units(bytes_downloaded)
    parm["end_time"] = time.strftime(time_format("%Y-%m-%d %H:%M:%S"),
                                     time.localtime(time.time()))

    return send_with_template("email", parm, test)
Esempio n. 5
0
def endjob(filename, msgid, cat, status, path, bytes, stages, script, script_output, script_ret):
    """ Send end-of-job email """

    # Translate the stage names
    xstages = {}
    for stage in stages:
        xstages[Tx('stage-'+stage.lower())] = stages[stage]

    parm = {}
    parm['status'] = status
    parm['name'] = filename
    parm['path'] = path
    parm['msgid'] = str(msgid)
    parm['stages'] = xstages
    parm['script'] = script
    parm['script_output'] = script_output
    parm['script_ret'] = script_ret
    parm['cat'] = cat
    parm['size'] = "%sB" % to_units(bytes)
    parm['end_time'] = time.strftime(time_format('%Y-%m-%d %H:%M:%S'), time.localtime(time.time()))

    return send_with_template('email', parm)
Esempio n. 6
0
def endjob(filename, msgid, cat, status, path, bytes, stages, script,
           script_output, script_ret):
    """ Send end-of-job email """

    # Translate the stage names
    xstages = {}
    for stage in stages:
        xstages[Tx('stage-' + stage.lower())] = stages[stage]

    parm = {}
    parm['status'] = status
    parm['name'] = filename
    parm['path'] = path
    parm['msgid'] = str(msgid)
    parm['stages'] = xstages
    parm['script'] = script
    parm['script_output'] = script_output
    parm['script_ret'] = script_ret
    parm['cat'] = cat
    parm['size'] = "%sB" % to_units(bytes)
    parm['end_time'] = time.strftime(time_format('%Y-%m-%d %H:%M:%S'),
                                     time.localtime(time.time()))

    return send_with_template('email', parm)
Esempio n. 7
0
 def test_timeformatampm(self):
     misc.HAVE_AMPM = True
     assert "%I:%M:%S %p" == misc.time_format("%H:%M:%S")
     assert "%I:%M %p" == misc.time_format("%H:%M")
Esempio n. 8
0
 def test_timeformat24h(self):
     assert "%H:%M:%S" == misc.time_format("%H:%M:%S")
     assert "%H:%M" == misc.time_format("%H:%M")