예제 #1
0
def tps(data):
    kd_thread = str(uuid.uuid4())
    raw_thread = colection_raw_thread(kd_thread, data["kode_kelurahan"])
    raw_tps = colection_raw_tps()
    kpu_tps = data_kpu()
    kawal_tps = data_kawal()
    data_kpu_tps = kpu_tps.get_data([
        data["kode_provinsi"], data["kode_kabkota"], data["kode_kec"],
        data["kode_kelurahan"]
    ])
    err_msg = kpu_tps.err_msg
    data_kawal_tps = kawal_tps.get_data(data["kode_kelurahan"])
    hsl_olah = olah_data_kawal_tps(data_kawal_tps["data_kawal"])
    err_msg += kawal_tps.err_msg
    if err_msg == '':
        tmp_data = {
            "kode": str(data['kode_kelurahan']),
            "kode_provinsi": str(data["kode_provinsi"]),
            "kode_kabkota": str(data["kode_kabkota"]),
            "kode_kec": str(data["kode_kec"]),
            "data_kpu": data_kpu_tps["data_kpu"],
            "data_kawal": hsl_olah
        }
        raw_tps.mycol.update_one({"kode": str(data['kode_kelurahan'])},
                                 {"$set": tmp_data},
                                 upsert=True)
        # raw_tps.mycol.insert_one(tmp_data)
    else:
        raw_thread.set_error_msg(err_msg)
    raw_thread.stop()
예제 #2
0
def kel(data):
    kd_thread = str(uuid.uuid4())
    raw_thread = colection_raw_thread(kd_thread, data["kode_kec"])
    raw_kelurahan = colection_raw_kel()
    kpu_kel = data_kpu()
    kawal_kel = data_kawal()
    data_kpu_kel = kpu_kel.get_data(
        [data["kode_provinsi"], data["kode_kabkota"], data["kode_kec"]])
    err_msg = kpu_kel.err_msg
    data_kawal_kel = kawal_kel.get_data(data["kode_kec"])
    err_msg += kawal_kel.err_msg
    if (err_msg == ""):
        tmp_data = {
            "kode": str(data['kode_kec']),
            "kode_provinsi": str(data["kode_provinsi"]),
            "kode_kabkota": str(data["kode_kabkota"]),
            "data_kpu": data_kpu_kel["data_kpu"],
            "data_kawal": data_kawal_kel["data_kawal"]
        }
        raw_kelurahan.mycol.update_one({"kode": str(data['kode_kec'])},
                                       {"$set": tmp_data},
                                       upsert=True)
        # raw_kelurahan.mycol.insert_one(tmp_data)
    else:
        raw_thread.set_error_msg(err_msg)
    raw_thread.stop()
예제 #3
0
def detail_tps_org(data):
    kd_thread = str(uuid.uuid4())
    raw_thread = colection_raw_thread(kd_thread, data["kode_tps"])
    raw_detail_tps = colection_raw_detail_tps()
    kpu_detail_tps = data_kpu()
    data_kpu_detail_tps = kpu_detail_tps.get_data([
        data["kode_provinsi"], data["kode_kabkota"], data["kode_kec"],
        data["kode_kelurahan"], data['kode_tps']
    ])
    err_msg = kpu_detail_tps.err_msg
    if err_msg == '':
        data_kpu_detail_tps["data_kpu"]["json_wilayah"] = data["json_wilayah"]
        tmp_data = {
            "kode": str(data['kode_tps']),
            "kode_provinsi": str(data["kode_provinsi"]),
            "kode_kabkota": str(data["kode_kabkota"]),
            "kode_kec": str(data["kode_kec"]),
            "kode_kelurahan": str(data["kode_kelurahan"]),
            "data_kpu": data_kpu_detail_tps["data_kpu"]
        }
        raw_detail_tps.mycol.update_one({"kode": str(data['kode_tps'])},
                                        {"$set": tmp_data},
                                        upsert=True)
        # raw_detail_tps.mycol.insert_one(tmp_data)
    else:
        raw_thread.set_error_msg(err_msg)
    raw_thread.stop()
예제 #4
0
def kawal_tps(data):
    kd_thread = str(uuid.uuid4())
    raw_thread = colection_raw_thread(kd_thread, data["kode_tps"])
    raw_detail_tps = colection_raw_detail_tps()
    tmp_data = {"data_kawal": data["data_kawal"]}
    raw_detail_tps.mycol.update_one({"kode": str(data['kode_tps'])},
                                    {"$set": tmp_data})
    raw_thread.stop()
예제 #5
0
     },
     'backup': {
         'kerjakan': 0,
         'isimport': 1,
         'isexport': 0,
         'table': {
             'raw_provinsi': 1,
             'raw_kabkota': 1,
             'raw_kec': 1,
             'raw_kel': 1,
             'raw_tps': 0,
             'raw_detail_tps': 0
         }
     }
 }
 raw_thread = colection_raw_thread("", "")
 raw_data = get_raw()
 if menu["provinsi"]['kerjakan'] == 1:
     print("Baca Data Provinsi")
     raw_data.get_raw_provinsi()
     time.sleep(10)
 if menu["kabkota"]['kerjakan'] == 1:
     print("Baca Data Kabkota")
     raw_data.get_raw_kabkota()
     time.sleep(10)
 if menu["kec"]['kerjakan'] == 1:
     print("Baca Data Kecamatan")
     raw_data.get_raw_kec(menu["kec"]['hps_log'], menu["kec"]['isupdate'])
     jml = raw_thread.jml_error()
     if jml > 0:
         print("Baca Ulang Data Kecamatan")
예제 #6
0
 def hapus_log():
     raw_proses = colection_raw_proses("", "")
     raw_proses.delete_all()
     raw_thread = colection_raw_thread("", "")
     raw_thread.delete_all()