Example #1
0
def beam_prev_sendungen(list_preview_sendungen):
    """transfer items to php script"""
    # urllib noetig
    # config
    anzahl_sendungen = int(db.ac_config_1[2])
    #anzahl_sendungen = 5
    url = db.ac_config_1[3]

    # Assoziatives Array / Dictionary / Hashmap
    # fuer datenuebertragung append: data_upload['px']='peix''
    data_upload = {
        'pa': 'hinein',
        'pc': db.ac_config_1[4],
        'pd': db.ac_config_1[5]
    }

    z = 0
    for item in list_preview_sendungen:
        c_time = str(item[2])
        c_autor = (lib_cm.replace_uchar_with_html(item[14]) + " " +
                   lib_cm.replace_uchar_with_html(item[15]))
        c_title = lib_cm.replace_uchar_with_html(item[11])

        data_upload['px' + str(z + 1)] = c_time
        data_upload['py' + str(z + 1)] = c_autor
        data_upload['pz' + str(z + 1)] = c_title
        z += 1
        if z == anzahl_sendungen:
            break

    # anzahel der uebergebenen sendungen
    data_upload['pb'] = str(anzahl_sendungen)
    lib_cm.message_write_to_console(ac, data_upload)

    # urlencode kann fehler werfen,
    # wenn sonderzeichen nicht encodet werden können
    try:
        data_upload_encoded = urllib.urlencode(data_upload)
    except Exception, e:
        log_message = u"urlencode Error: %s" % str(e)
        db.write_log_to_db(ac, log_message, "x")
        log_message = u"urlencode Error Data " + c_autor + " " + c_title
        db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console")
        log_message = u"Uebertragung auf Web-Server abgebrochen "
        db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console")
        return None
Example #2
0
def beam_prev_sendungen(list_preview_sendungen):
    """transfer items to php script"""
    # urllib noetig
    # config
    anzahl_sendungen = int(db.ac_config_1[2])
    #anzahl_sendungen = 5
    url = db.ac_config_1[3]

    # Assoziatives Array / Dictionary / Hashmap
    # fuer datenuebertragung append: data_upload['px']='peix''
    data_upload = {'pa': 'hinein',
        'pc': db.ac_config_1[4],
        'pd': db.ac_config_1[5]}

    z = 0
    for item in list_preview_sendungen:
        c_time = str(item[2])
        c_autor = (lib_cm.replace_uchar_with_html(item[14]) + " "
                + lib_cm.replace_uchar_with_html(item[15]))
        c_title = lib_cm.replace_uchar_with_html(item[11])

        data_upload['px' + str(z + 1)] = c_time
        data_upload['py' + str(z + 1)] = c_autor
        data_upload['pz' + str(z + 1)] = c_title
        z += 1
        if z == anzahl_sendungen:
            break

    # anzahel der uebergebenen sendungen
    data_upload['pb'] = str(anzahl_sendungen)
    lib_cm.message_write_to_console(ac, data_upload)

    # urlencode kann fehler werfen,
    # wenn sonderzeichen nicht encodet werden können
    try:
        data_upload_encoded = urllib.urlencode(data_upload)
    except Exception, e:
        log_message = u"urlencode Error: %s" % str(e)
        db.write_log_to_db(ac, log_message, "x")
        log_message = u"urlencode Error Data " + c_autor + " " + c_title
        db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console")
        log_message = u"Uebertragung auf Web-Server abgebrochen "
        db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console")
        return None
Example #3
0
def upload_data_prepare():
    """prepare pload-data for webserver """
    # Bei I-Netfehler upload aussetzen
    if ac.app_counter_error > 3:
        db.write_log_to_db_a(ac, ac.app_errorslist[5], "x",
            "write_also_to_console")
        ac.app_counter_error = 0
        return

    c_autor = lib_cm.replace_uchar_with_html(ac.log_author)
    c_title = lib_cm.replace_uchar_with_html(ac.log_title)
    data_upload = {'pa': 'hinein',
        'pb': ac.log_start,
        'pc': ac.log_start,
        'pd': c_autor,
        'pe': c_title,
        'pf': db.ac_config_1[6],
        'pg': db.ac_config_1[7]}

    # urlencode kann fehler werfen,
    # wenn sonderzeichen nicht encodet werden können
    try:
        data_upload_encoded = urllib.urlencode(data_upload)
    except Exception, e:
        log_message = "urlencode Error: %s" % str(e)
        db.write_log_to_db(ac, log_message, "x")
        log_message = "urlencode Error Data " + c_autor + " " + c_title
        db.write_log_to_db(ac, log_message, "x")
        data_upload = {'pa': 'hinein',
            'pb': ac.log_start,
            'pc': ac.log_start,
            'pd': db.ac_config_1[3],
            'pe': db.ac_config_1[4],
            'pf': db.ac_config_1[6],
            'pg': db.ac_config_1[7]}

        # use this only for debugging!!
        #lib_cm.message_write_to_console(ac, u"data_upload"
        #                    + c_autor.encode('utf-8', 'ignore') + " "
        #                    + c_title.encode('utf-8', 'ignore'))
        data_upload_encoded = urllib.urlencode(data_upload)