Esempio n. 1
0
    def clearLog(self):
        if self.koneksifinger:
            print 'Menghapus Log Di Fingerprint'
            if self.checkMac:
                dataLog = None
                while dataLog is None:
                    dataLog = parsingFromFinger(
                        getDataFinger.getAttLog(self.tujuan, self.alamat, 0,
                                                'All').get())
                jumlahDataLog = len(dataLog)
                print 'Jumlah Data Log %s' % jumlahDataLog

                self.cursor.execute(SQL_SYNTAX['CHECKATTENDACE'],
                                    (macFinger, ))
                fetch = self.cursor.fetchone()
                jumlahLogLocal = fetch[0]
                print 'Jumlah Data Log Local %s' % jumlahLogLocal

                if (jumlahLogLocal & jumlahDataLog) >= 100000:
                    print 'Menghapus Log di LocalHost'
                    lcd_.printLCD('Menghapus Log', 'Fingerprint').lcd_status()
                    parsingFromFinger(
                        getDataFinger.clearData(self.tujuan, self.alamat, 0,
                                                3).get())
                    time.sleep(10)
                    if clear is None:
                        lcd_.printLCD('Clear Log',
                                      'Successfully!').lcd_status()
Esempio n. 2
0
def checkAlamat():
    for alamat in listAlamat:
        if check_connection.onCheck(alamat, listAlamat[alamat],
                                    5).checkAlamat():
            listAlamat[alamat] = listAlamat[alamat].replace("http://", "")
            useAlamat[alamat] = listAlamat[alamat]
            print 'Alamat %s Valid' % alamat
        else:
            lcd_.printLCD('Alamat %s' % alamat, 'Tidak Valid').lcd_status()
            print 'Alamat %s Tidak Valid' % alamat
    print useAlamat
Esempio n. 3
0
 def checkMac(self):
     global macFinger
     print 'Check Mac %s is Already Registered' % macFinger
     self.cursor.execute(SQL_SYNTAX['FINDMAC'], (macFinger, ))
     macLocal = self.cursor.fetchone()
     print 'Mac %s Terdaftar' % macLocal
     if macLocal is None:
         lcd_.printLCD('Alat Fingerprint', 'Tidak Terdaftar').lcd_status()
         return False
     else:
         return True
Esempio n. 4
0
def resetall(usealamat):
    if Server.load('Trigger',None) is 4:
        for alamat in usealamat:
            cetak.printLCD ('Reset Semua Data','').lcd_status()
            JUMLAHPEGAWAIFINGER = Finger.jumlahpegawai(alamat, usealamat[alamat])
            JUMLAHDATAABSENSI   = len(Finger.ambildataabsensi(alamat, usealamat[alamat]))
            if JUMLAHDATAABSENSI or JUMLAHPEGAWAIFINGER != 0:
                Finger.hapusabsensi(alamat, usealamat[alamat])
                Finger.hapussemua(alamat, usealamat[alamat])
                FungsiLocal.hapussemua()
                cetak.printLCD ('Reseting %s' % alamat,'').lcd_status()
                time.sleep(30)
Esempio n. 5
0
def clone():
    SRC = '/home/pi/finger'
    CMD = {
        'REMOVESOURCE': 'sudo rm -rf %s',
        'CLONETOSOURCE':
        'sudo git clone https://github.com/Nat4Lia/finger.git %s',
        'COPYTOETC': 'sudo cp -R /home/pi/finger /etc/',
        'REBOOT': 'sudo reboot'
    }
    cnx = mysql.connector.connect(**config)
    cursor = cnx.cursor(buffered=True)
    if check_connection.internet.check():
        trigger = [None, False]
        while not trigger[1]:
            time.sleep(30)
            trigger = loadJSON(requestGET(URL['TRIGGER']))
        print 'Trigger %s' % trigger[0][0]['status']
        if trigger[0][0]['status'] is 3:
            getVersion = [None, False]
            while not getVersion[1]:
                getVersion = loadJSON(requestGET(URL['CEKVERSI']))
            print getVersion
            versionSer = getVersion[0]['version']
            print 'Versi server %s' % versionSer
            cursor.execute(SQL_SYNTAX['CHECKVERSION'])
            fetch = cursor.fetchone()
            versionLoc = fetch[0]
            print 'versi local %s' % versionLoc
            if versionLoc != versionSer:
                if os.path.isdir(SRC):
                    print os.path.isdir(SRC)
                    run(CMD['REMOVESOURCE'] % SRC, shell=True)
                    run(CMD['CLONETOSOURCE'] % SRC, shell=True)
                    run(CMD['COPYTOETC'], shell=True)
                    cursor.execute(SQL_SYNTAX['UPDATEVERSION'], (versionSer, ))
                    cnx.commit()
                else:
                    os.path.isdir(SRC)
                    run(CMD['CLONETOSOURCE'] % SRC, shell=True)
                    run(CMD['COPYTOETC'], shell=True)
                    cursor.execute(SQL_SYNTAX['ADDVERSION'], (versionSer, ))
                    cnx.commit()
                print 'Updating to Version %s' % versionSer
                lcd_.printLCD('Updating to',
                              'Version %s' % versionSer).lcd_status()
                time.sleep(5)
                run(CMD['REBOOT'], shell=True)
Esempio n. 6
0
def clone():
    SRC = '/home/pi/finger'
    CMD = {
            'REMOVESOURCE'  : 'sudo rm -rf %s',
            'CLONETOSOURCE' : 'sudo git clone https://github.com/Nat4Lia/finger.git %s',
            'COPYTOETC'     : 'sudo cp -R /home/pi/finger /etc/',
            'REBOOT'        : 'sudo reboot'
    }

    if Server.load('Trigger',None) is 3 :
        version = Server.load('Update',None)
        if FungsiLocal.cekversion(version) :
            cetak.printLCD ('Updating...','').lcd_status()
            if os.path.isdir(SRC) :
                run(CMD['REMOVESOURCE'] % SRC,shell=True)
                run(CMD['CLONETOSOURCE'] % SRC,shell=True)
                run(CMD['COPYTOETC'], shell=True)
                FungsiLocal.updateversion(version)
            else :
                run(CMD['CLONETOSOURCE'] % SRC,shell=True)
                run(CMD['COPYTOETC'], shell=True)
                FungsiLocal.tambahversion(version)
            cetak.printLCD('Update ke versi','%s' % version).lcd_status()
            time.sleep(5)
            cetak.printLCD('Restarting Raspberry','...').lcd_status()
            run(CMD['REBOOT'], shell=True)
Esempio n. 7
0
def requestGET(URL):
    try:
        r = requests.get(URL, timeout=5)
        return r
    except requests.exceptions.RequestException as err:
        print err
        lcd_.printLCD('Request Exception', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.Timeout as err:
        print err
        lcd_.printLCD('Timeout', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.ConnectionError as err:
        print err
        lcd_.printLCD('Connection Error', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.HTTPError as err:
        print err
        lcd_.printLCD('HTTP error', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.ConnectTimeout as err:
        print err
        lcd_.printLCD('Timeout', 'Trying To Connect').lcd_status()
        return None
Esempio n. 8
0
def requestPOST(URL, header, payload):
    try:
        r = requests.post(URL, headers=header, json=payload)
        return r
    except requests.exceptions.RequestException as err:
        print err
        lcd_.printLCD('Request Exception', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.Timeout as err:
        print err
        lcd_.printLCD('Timeout', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.ConnectionError as err:
        print err
        lcd_.printLCD('Connection Error', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.HTTPError as err:
        print err
        lcd_.printLCD('HTTP error', 'Trying To Connect').lcd_status()
        return None
    except requests.exceptions.ConnectTimeout as err:
        print err
        lcd_.printLCD('Timeout', 'Trying To Connect').lcd_status()
        return None
Esempio n. 9
0
    def kirimstatus(self):
        cetak.printLCD('Mengirim Status','Data Raspberry').lcd_status()
        tujuan  = self.tujuan
        alamat  = self.alamat
        mac     = Finger.ambilmacaddress(tujuan, alamat)
        pegawaifinger = Finger.semuadatapegawai(tujuan, alamat)
        

        ip                  = alamat.replace(':80','')
        versi               = FungsiLocal.ambilversion()
        jumlahmac           = FungsiLocal.cekjumlahmac()
        jumlahpegawaifinger = 0
        jumlahadminfinger   = 0
        for pegawai in pegawaifinger:
            if str(pegawai[4].text) == str(0):
                jumlahpegawaifinger+=1
            elif str(pegawai[4].text) == str(14):
                jumlahadminfinger+=1
        jumlahabsensifinger = len(Finger.ambildataabsensi(tujuan, alamat))
        jumlahpegawailocal  = FungsiLocal.cekjumlahpegawai(mac)
        jumlahadminlocal    = FungsiLocal.cekjumlahadmin(mac)
        jumlahabsensilocal  = FungsiLocal.cekjumlahabsensi(mac)
        instansiid          = instansi_id.ID_INSTANSI

        encryptText     = str(ip) + str(versi) + str(jumlahmac) + str(jumlahpegawaifinger) + str(jumlahadminfinger) + str(jumlahabsensifinger) + str(jumlahpegawailocal) + str(jumlahadminlocal) + str(jumlahabsensilocal) + str(instansiid)
        encryption      = encrypt(encryptText)
        headers = {'Content-Type' : 'application/json', 'Accept' : 'application/json'}
        payload = {
                     'ip'                  : ip,
                     'versi'               : versi,
                     'jumlahmac'           : jumlahmac,
                     'jumlahpegawaifinger' : jumlahpegawaifinger,
                     'jumlahadminfinger'   : jumlahadminfinger,
                     'jumlahabsensifinger' : jumlahabsensifinger,
                     'jumlahpegawailocal'  : jumlahpegawailocal,
                     'jumlahadminlocal'    : jumlahadminlocal,
                     'jumlahabsensilocal'  : jumlahabsensilocal,
                     'instansi_id'         : instansiid,
                     'token'               : encryption
                    }
        if Server.POST('LOGRASPBERRY', headers, payload):
            cetak.printLCD('Berhasil Mengirim','Status Raspberry').lcd_status()
        else:
            cetak.printLCD('Gagal Mengirim','Status Raspberry').lcd_status()

# clearlog(tujuan, '10.10.10.10:80', '00:17:61:11:72:24')
# manajemenuser('Finger A', '10.10.10.10:80')
# normalizepegawai('Finger A', '10.10.10.10:80','00:17:61:11:72:24')
# daftarmac()
# Proses(tujuan, alamat).manajemenadmin()
Esempio n. 10
0
    def clearlog(self):
        tujuan  = self.tujuan
        alamat  = self.alamat
        mac     = Finger.ambilmacaddress(tujuan, alamat)

        if FungsiLocal.macterdaftar(mac) :
            #Jika Mac Terdaftar
            JUMLAHABSENSIFINGER     = len(Finger.ambildataabsensi(tujuan, alamat))
            JUMLAHABSENSILOCAL      = FungsiLocal.cekjumlahabsensi(mac)
            if (JUMLAHABSENSIFINGER and JUMLAHABSENSILOCAL) >=50000:
                cetak.printLCD('Menghapus data','absensi lama').lcd_status()
                Finger.hapusabsensi(tujuan, alamat)
                FungsiLocal.hapusdataabsensi(mac)
        else:
            cetak.printLCD('Mac Fingerprint','Tidak Terdaftar').lcd_status()
            time.sleep(3)
            cetak.printLCD('Hubungi Kominfo','Untuk Mendaftarkan').lcd_status()
            time.sleep(3)
Esempio n. 11
0
    def setUser(self):
        if self.koneksifinger & self.koneksiinternet:
            print 'Manajemen User Fingerprint'
            trigger = [None, False]
            while not trigger[1]:
                time.sleep(30)
                trigger = loadJSON(requestGET(URL['TRIGGER']))
            print 'Trigger %s' % trigger[0][0]['status']
            if trigger[0][0]['status'] is 1:
                lcd_.printLCD('Config User', 'Fingerprint').lcd_status()
                print 'Cek Jumlah Pegawai di Tabel dengan Mac %s ' % macFinger
                self.cursor.execute(SQL_SYNTAX['CHECKPEGAWAI'], (macFinger, ))
                fetch = self.cursor.fetchone()
                jumlahPegLoc = fetch[0]
                print 'Jumlah Pegawai Di LocalHost %s' % jumlahPegLoc

                listPegawai = [None, False]
                while not listPegawai[1]:
                    listPegawai = loadJSON(requestGET(URL['CEKPEGAWAI']))
                jumlahPegSer = len(listPegawai[0])
                print 'Jumlah Pegawai di Server %s' % jumlahPegSer

                totalNewPeg = 0

                selisih = jumlahPegSer - jumlahPegLoc
                print 'Selisih %s' % selisih

                if selisih > 0:
                    lcd_.printLCD('Ditemukan %s' % selisih,
                                  'Baru').lcd_status()
                    for pegawai in range(0, jumlahPegSer):
                        ID = listPegawai[0][pegawai]['id']
                        NAMA = listPegawai[0][pegawai]['nama'].replace(
                            "'", " ")
                        self.cursor.execute(SQL_SYNTAX['FINDPEGAWAI'], (
                            ID,
                            macFinger,
                        ))
                        cekPegLoc = self.cursor.fetchone()
                        print 'Cek Pegawai %s di LocalHost' % ID
                        if cekPegLoc is None:
                            # hapusUser = None
                            # while hapusUser is None:
                            hapusUser = parsingFromFinger(
                                getDataFinger.delUser(self.tujuan, self.alamat,
                                                      0, ID).delete())
                            print 'Menghapus User %s' % (ID)
                            fingerPegawai = [None, False]
                            while not fingerPegawai[1]:
                                time.sleep(0.7)
                                lcd_.printLCD('Mengambil Data',
                                              'Fingerprint').lcd_status()
                                print 'Mencoba Mengambil Data Finger %s ' % NAMA
                                fingerPegawai = loadJSON(
                                    requestGET(URL['AMBILFINGER'] % ID))
                            else:
                                setUser = None
                                while setUser is None:
                                    setUser = parsingFromFinger(
                                        getDataFinger.setUserInfo(
                                            self.tujuan, self.alamat, 0, NAMA,
                                            ID).get())
                                print '%s Mendaftarkan ID : %s, Nama : %s ke fingerprint' % (
                                    setUser[0][1].text, ID, NAMA)
                                lcd_.printLCD('Mendaftarkan Ke',
                                              'Fingerprint').lcd_status()
                                status = [None, None]
                                if setUser[0][1].text == 'Successfully!':
                                    for fingerID in range(0, 2):
                                        pegawai_id = fingerPegawai[0][
                                            fingerID]['pegawai_id']
                                        size = fingerPegawai[0][fingerID][
                                            'size']
                                        valid = fingerPegawai[0][fingerID][
                                            'valid']
                                        finger_template = fingerPegawai[0][
                                            fingerID]['templatefinger']
                                        statusSetTemplate = None
                                        while statusSetTemplate is None:
                                            statusSetTemplate = parsingFromFinger(
                                                getDataFinger.setUserTemplate(
                                                    self.tujuan, self.alamat,
                                                    0, pegawai_id, fingerID,
                                                    size, valid,
                                                    finger_template).get())
                                        status[fingerID] = statusSetTemplate[
                                            0][1].text
                                if (status[0]
                                        and status[1]) == 'Successfully!':
                                    self.cursor.execute(
                                        SQL_SYNTAX['ADDPEGAWAI'], (
                                            ID,
                                            NAMA,
                                            macFinger,
                                        ))
                                    self.cnx.commit()
                                    totalNewPeg += 1
                                    print 'Sukses menambahkan template finger %s' % NAMA
                                    lcd_.printLCD(
                                        'Update', '%s Pegawai Baru' %
                                        totalNewPeg).lcd_status()
                                else:
                                    headers = {
                                        'Content-Type': 'application/json',
                                        'Accept': 'application/json'
                                    }
                                    payload = {'user_id': ID, 'nama': NAMA}
                                    time.sleep(3)
                                    if requestPOST(URL['ERRORUSER'], headers,
                                                   payload).status_code is 200:
                                        lcd_.printLCD('User %s' % ID,
                                                      'Error').lcd_status()
                                        print 'User %s Tidak Terdaftar' % ID
                else:
                    lcd_.printLCD('Tidak Ada Update',
                                  'Pegawai Baru').lcd_status()

            elif trigger[0][0]['status'] is 2:
                print 'Cek Jumlah Pegawai Di LocalHost'
                self.cursor.execute(SQL_SYNTAX['FINDALLPEGAWAI'],
                                    (macFinger, ))
                fetch = self.cursor.fetchall()
                jumlahPegLoc = len(fetch)
                print 'Jumlah Pegawai Di LocalHost %s' % jumlahPegLoc

                for pegawai in range(0, jumlahPegLoc):
                    idPegLoc = fetch[pegawai][0]
                    cekPegawai = False
                    while not cekPegawai:
                        time.sleep(1.3)
                        cekPegawai = loadJSON(
                            requestGET(URL['CEKIDPEGAWAI'] % idPegLoc))
                        print 'Cek ID Pegawai %s Di API' % idPegLoc
                    if not cekPegawai[0]:
                        hapusTemplate = None
                        hapusUser = None
                        while hapusTemplate is None:
                            hapusTemplate = parsingFromFinger(
                                getDataFinger.deleteTemplate(
                                    self.tujuan, self.alamat, 0,
                                    idPegLoc).delete())
                        print '%s Menghapus Template User %s' % (
                            hapusTemplate[0][1].text, idPegLoc)
                        while hapusUser is None:
                            hapusUser = parsingFromFinger(
                                getDataFinger.delUser(self.tujuan, self.alamat,
                                                      0, idPegLoc).delete())
                        print '%s Menghapus User %s' % (hapusUser[0][1].text,
                                                        idPegLoc)
                        self.cursor.execute(SQL_SYNTAX['DELETEPEGAWAI'], (
                            idPegLoc,
                            macFinger,
                        ))
                        self.cnx.commit()
                        lcd_.printLCD('Pegawai %s' % idPegLoc,
                                      'Dihapus').lcd_status()
Esempio n. 12
0
    def setAdmin(self):
        if self.koneksifinger & self.koneksiinternet:
            print 'Manajemen Admin Fingerprint'
            trigger = [None, False]
            while not trigger[1]:
                time.sleep(30)
                trigger = loadJSON(requestGET(URL['TRIGGER']))
            print 'Trigger %s' % trigger[0][0]['status']
            if trigger[0][0]['status'] is 1:
                print 'Cek Jumlah Admin di Tabel dengan Mac %s ' % macFinger
                self.cursor.execute(SQL_SYNTAX['CHECKADMIN'], (macFinger, ))
                fetch = self.cursor.fetchone()
                jumlahAdmLoc = fetch[0]
                print 'Jumlah Admin Di LocalHost %s' % jumlahAdmLoc

                listAdmin = [None, False]
                while not listAdmin[1]:
                    listAdmin = loadJSON(requestGET(URL['CEKADMIN']))
                jumlahAdmSer = len(listAdmin[0])
                print 'Jumlah Admin Di Server %s' % jumlahAdmSer

                selisih = jumlahAdmSer - jumlahAdmLoc
                print 'Selisih %s' % selisih

                if selisih > 0:
                    lcd_.printLCD('Menambahkan Admin',
                                  'Fingerprint').lcd_status()
                    for admin in range(0, jumlahAdmSer):
                        ID = listAdmin[0][admin]['id']
                        print 'ID %s Akan Dijadikan Admin' % ID
                        self.cursor.execute(SQL_SYNTAX['FINDADMIN'], (
                            ID,
                            macFinger,
                        ))
                        isiAdmin = self.cursor.fetchone()
                        self.cursor.execute(SQL_SYNTAX['FINDPEGAWAI'], (
                            ID,
                            macFinger,
                        ))
                        isiPegawai = self.cursor.fetchone()
                        print isiAdmin, isiPegawai[0]

                        if ((ID == isiPegawai[0]) & (isiAdmin is None)):
                            print 'Mengubah Pegawai %s Menjadi Admin' % ID
                            hapusTemplate = None
                            hapusUser = None
                            while hapusTemplate is None:
                                hapusTemplate = parsingFromFinger(
                                    getDataFinger.deleteTemplate(
                                        self.tujuan, self.alamat, 0,
                                        ID).delete())
                            print '%s Menghapus Template User %s' % (
                                hapusTemplate[0][1].text, ID)
                            while hapusUser is None:
                                hapusUser = parsingFromFinger(
                                    getDataFinger.delUser(
                                        self.tujuan, self.alamat, 0,
                                        ID).delete())
                            print '%s Menghapus User %s' % (
                                hapusUser[0][1].text, ID)
                            NAMA = listAdmin[0][admin]['nama'].replace(
                                "'", " ")
                            fingerPegawai = [None, False]
                            while not fingerPegawai[1]:
                                time.sleep(3.3)
                                print 'Mencoba Mengambil Data Finger Admin %s ' % NAMA
                                fingerPegawai = loadJSON(
                                    requestGET(URL['AMBILFINGER'] % ID))
                            else:
                                setUser = None
                                while setUser is None:
                                    setUser = parsingFromFinger(
                                        getDataFinger.setAdminUser(
                                            self.tujuan, self.alamat, 0, NAMA,
                                            ID).get())
                                print '%s Mendaftarkan ID : %s, Nama : %s ke fingerprint sebagai Admin' % (
                                    setUser[0][1].text, ID, NAMA)
                                status = ['', '']
                                if setUser[0][1].text == 'Successfully!':
                                    for fingerID in range(0, 2):
                                        pegawai_id = fingerPegawai[0][
                                            fingerID]['pegawai_id']
                                        size = fingerPegawai[0][fingerID][
                                            'size']
                                        valid = fingerPegawai[0][fingerID][
                                            'valid']
                                        finger_template = fingerPegawai[0][
                                            fingerID]['templatefinger']
                                        statusSetTemplate = None
                                        while statusSetTemplate is None:
                                            statusSetTemplate = parsingFromFinger(
                                                getDataFinger.setUserTemplate(
                                                    self.tujuan, self.alamat,
                                                    0, pegawai_id, fingerID,
                                                    size, valid,
                                                    finger_template).get())
                                        status[fingerID] = statusSetTemplate[
                                            0][1].text
                                        print 'Template %s Added' % status[
                                            fingerID]
                                if (status[0]
                                        and status[1]) == 'Successfully!':
                                    self.cursor.execute(
                                        SQL_SYNTAX['ADDADMIN'], (
                                            ID,
                                            NAMA,
                                            macFinger,
                                        ))
                                    self.cnx.commit()
                                    lcd_.printLCD('Sukses Menambahkan',
                                                  'Admin').lcd_status()
                elif selisih == 0:
                    print 'Cek ID Admin di Tabel dengan Mac %s ' % macFinger
                    self.cursor.execute(SQL_SYNTAX['FINDALLADMIN'],
                                        (macFinger, ))
                    fetch = self.cursor.fetchall()

                    for cekID in range(0, jumlahAdmLoc):
                        ID = fetch[cekID][0]
                        print 'Cek ID %s di API Cek Admin' % ID
                        cekAdmin = [None, False]
                        while not cekAdmin[1]:
                            time.sleep(1.3)
                            cekAdmin = loadJSON(
                                requestGET(URL['CEKIDADMIN'] % ID))
                        if not cekAdmin[0]:
                            lcd_.printLCD('Menghapus Admin',
                                          'Fingerprint').lcd_status()
                            print 'ID %s tidak terdaftar sebagai Admin' % ID
                            cekPegawai = [None, False]
                            while not cekPegawai[1]:
                                time.sleep(1.3)
                                cekPegawai = loadJSON(
                                    requestGET(URL['CEKIDADMIN'] % ID))
                            ID = cekPegawai[0][0]['pegawai_id']
                            NAMA = cekPegawai[0][0]['nama'].replace("'", " ")
                            print 'Mengubah %s menjadi User' % NAMA
                            fingerPegawai = [None, False]
                            while not fingerPegawai[1]:
                                lcd_.printLCD('Mengambil Data',
                                              'Fingerprint').lcd_status()
                                print 'Mencoba Mengambil Data Finger %s ' % NAMA
                                time.sleep(3.3)
                                fingerPegawai = loadJSON(
                                    requestGET(URL['AMBILFINGER'] % ID))
                            else:
                                hapusTemplate = None
                                hapusUser = None
                                while hapusTemplate is None:
                                    hapusTemplate = parsingFromFinger(
                                        getDataFinger.deleteTemplate(
                                            self.tujuan, self.alamat, 0,
                                            ID).delete())
                                print '%s Menghapus Template User %s' % (
                                    hapusTemplate[0][1].text, ID)
                                while hapusUser is None:
                                    hapusUser = parsingFromFinger(
                                        getDataFinger.delUser(
                                            self.tujuan, self.alamat, 0,
                                            ID).delete())
                                print '%s Menghapus User %s' % (
                                    hapusUser[0][1].text, ID)
                                setUser = None
                                while setUser is None:
                                    setUser = parsingFromFinger(
                                        getDataFinger.setUserInfo(
                                            self.tujuan, self.alamat, 0, NAMA,
                                            ID).get())
                                print '%s Mendaftarkan ID : %s, Nama : %s ke fingerprint' % (
                                    setUser[0][1].text, ID, NAMA)
                                status = [None, None]
                                if setUser[0][1].text == 'Successfully!':
                                    for fingerID in range(0, 2):
                                        pegawai_id = fingerPegawai[0][
                                            fingerID]['pegawai_id']
                                        size = fingerPegawai[0][fingerID][
                                            'size']
                                        valid = fingerPegawai[0][fingerID][
                                            'valid']
                                        finger_template = fingerPegawai[0][
                                            fingerID]['templatefinger']
                                        statusSetTemplate = None
                                        while statusSetTemplate is None:
                                            statusSetTemplate = parsingFromFinger(
                                                getDataFinger.setUserTemplate(
                                                    self.tujuan, self.alamat,
                                                    0, pegawai_id, fingerID,
                                                    size, valid,
                                                    finger_template).get())
                                        status[fingerID] = statusSetTemplate[
                                            0][1].text
                                if (status[0]
                                        and status[1]) == 'Successfully!':
                                    lcd_.printLCD('Sukses Menghapus',
                                                  'Admin').lcd_status()
Esempio n. 13
0
    def sendLogToServer(self):
        global macFinger
        if self.koneksifinger & self.koneksiinternet:
            print 'Mengambil Data Log Dari Fingerprint'
            lcd_.printLCD('Mengambil Data', 'Absensi Fingerprint').lcd_status()
            dataLog = None
            jumlahDataLog = 0
            print 'Status Check Mac %s' % self.checkMac
            if self.checkMac:
                while dataLog is None:
                    dataLog = parsingFromFinger(
                        getDataFinger.getAttLog(self.tujuan, self.alamat, 0,
                                                'All').get())
                jumlahDataLog = len(dataLog)
                print 'Jumlah Data Log %s' % jumlahDataLog

                self.cursor.execute(SQL_SYNTAX['CHECKATTENDACE'],
                                    (macFinger, ))
                fetch = self.cursor.fetchone()
                jumlahLogLocal = fetch[0]
                print 'Jumlah Data Log Local %s' % jumlahLogLocal

                selisih = jumlahDataLog - jumlahLogLocal
                print 'Selisih Data Log %s' % selisih
                totalUpload = 0
                if selisih > 0:
                    lcd_.printLCD('Ditemukan',
                                  '%s Data Record' % selisih).lcd_status()
                    for data in range(jumlahLogLocal, jumlahDataLog):
                        ID_INSTANSI = instansi_id.ID_INSTANSI
                        PIN = dataLog[data][0].text
                        MAC = macFinger
                        tanggal, jam = dataLog[data][1].text.split(' ')
                        s_verified = dataLog[data][2].text
                        s_status = dataLog[data][3].text

                        encryptText = str(jam) + str(tanggal) + str(PIN) + str(
                            ID_INSTANSI) + str(s_status)
                        encryption = encrypt(encryptText)
                        print 'Data Yang Dikirim '
                        print 'user id  : %s' % PIN
                        print 'status   : %s' % s_status
                        print 'instansi : %s' % ID_INSTANSI
                        print 'jam      : %s' % jam
                        print 'tanggal  : %s' % tanggal
                        print 'token    : %s' % encryption

                        headers = {
                            'Content-Type': 'application/json',
                            'Accept': 'application/json'
                        }
                        payload = {
                            'status': s_status,
                            'instansi': ID_INSTANSI,
                            'jam': jam,
                            'tanggal': tanggal,
                            'user_id': PIN,
                            'token': encryption
                        }

                        if requestPOST(URL['ATTENDACE'], headers,
                                       payload).status_code is 200:
                            self.cursor.execute(SQL_SYNTAX['ADDATTENDANCE'], (
                                PIN,
                                MAC,
                            ))
                            totalUpload += 1
                            lcd_.printLCD('Uploading...', '%s Data' %
                                          totalUpload).lcd_status()
                            print 'Updating %s Data, ID = %s, Jam = %s' % (
                                totalUpload, PIN, jam)
                            print 'Upload Sukses'
                            if totalUpload == selisih:
                                self.cnx.commit()
                                lcd_.printLCD('Success Uploading', '%s Data' %
                                              totalUpload).lcd_status()
                                print 'Success Updating %s Data' % totalUpload
                else:
                    lcd_.printLCD('Tidak Ada Data',
                                  'Absensi Baru').lcd_status()
Esempio n. 14
0

def checkAlamat():
    for alamat in listAlamat:
        if check_connection.onCheck(alamat, listAlamat[alamat],
                                    5).checkAlamat():
            listAlamat[alamat] = listAlamat[alamat].replace("http://", "")
            useAlamat[alamat] = listAlamat[alamat]
            print 'Alamat %s Valid' % alamat
        else:
            lcd_.printLCD('Alamat %s' % alamat, 'Tidak Valid').lcd_status()
            print 'Alamat %s Tidak Valid' % alamat
    print useAlamat


lcd_.printLCD('Starting', '%c %c %c' % (32, 32, 32)).lcd_status()
time.sleep(3)
lcd_.printLCD('Starting', '%c %c %c' % (46, 32, 32)).lcd_status()
time.sleep(4)
lcd_.printLCD('Starting', '%c %c %c' % (46, 46, 32)).lcd_status()
time.sleep(5)
lcd_.printLCD('Starting', '%c %c %c' % (46, 46, 46)).lcd_status()

import check_connection
import getDataFinger
import database_
checkAlamat()
while True:
    database_.addMacToLocalHost()
    database_.clone()
    for alamat in useAlamat:
Esempio n. 15
0
    def manajemenuser(self):
        tujuan  = self.tujuan
        alamat  = self.alamat
        mac     = Finger.ambilmacaddress(tujuan, alamat)
        jumlahDihapus       = 0
        if FungsiLocal.macterdaftar(mac) :
            cetak.printLCD('Pengaturan Pegawai','Fingerprint').lcd_status()
            if Server.load('Trigger',None) is 1:
                APICEKPEGAWAI          = Server.load('Pegawai',instansi_id.ID_INSTANSI)
                LOCALHOSTCEKPEGAWAI     = FungsiLocal.carisemuapegawai(mac)
                normalizepegawai(LOCALHOSTCEKPEGAWAI, APICEKPEGAWAI, tujuan, alamat, mac)
                JUMLAHPEGAWAISERVER     = len(APICEKPEGAWAI)
                JUMLAHPEGAWAIFINGER     = Finger.jumlahpegawai(tujuan, alamat) - FungsiLocal.cekjumlahadmin(mac)
                JUMMLAHPEGAWAILOCAL     = FungsiLocal.cekjumlahpegawai(mac)
                SELISIHJUMLAHPEGAWAI    = JUMLAHPEGAWAISERVER - JUMMLAHPEGAWAILOCAL
                JumlahDaftarBaru        = 0
                if SELISIHJUMLAHPEGAWAI > 0: #Jika Terdapat Pegawai Baru Di Server
                    #MENGAMBIL DATA ARRAY API
                    cetak.printLCD('Menambahkan','Pegawai').lcd_status()
                    for PEGAWAI in range (0, JUMLAHPEGAWAISERVER):
                        #Mengambil ID dan NAMA pegawai
                        try:
                            ID =  APICEKPEGAWAI[PEGAWAI]['id']
                            NAMA = APICEKPEGAWAI[PEGAWAI]['nama'].replace("'"," ")
                        except ValueError as err:
                            pass
                        except TypeError as err:
                            pass
                        #Daftarkan Pegawai
                        try:
                            daftarkan   = daftarpegawai(tujuan, alamat, ID, NAMA, mac)
                        except IOError as err:
                            pass
                else:
                    pass

                if JumlahDaftarBaru == 0:
                    pass
                    cetak.printLCD('Tidak Ada','Pegawai Baru').lcd_status()
                else:
                    pass
                    cetak.printLCD('%s Pegawai Baru' % JumlahDaftarBaru,'Berhasil Ditambahkan').lcd_status()

            elif Server.load('Trigger',None) is 2:
                APIHAPUSPEGAWAI         = Server.load('HapusPegawai',None)
                JUMLAHPEGAWAIDIHAPUS    = len(APIHAPUSPEGAWAI)
                for PEGAWAI in range (0, JUMLAHPEGAWAIDIHAPUS) :
                    try:
                        ID      = APIHAPUSPEGAWAI[PEGAWAI]['pegawai_id']
                        hapuspegawai(tujuan,  alamat, ID, mac)
                        jumlahDihapus += 1
                    except ValueError as err:
                        pass
                    except TypeError as err:
                        pass

                cetak.printLCD('%s Pegawai' % JumlahDaftarBaru,'Berhasil Dihapus').lcd_status()


        else:
            cetak.printLCD('Mac Fingerprint','Tidak Terdaftar').lcd_status()
            time.sleep(3)
            cetak.printLCD('Hubungi Kominfo','Untuk Mendaftarkan').lcd_status()
            time.sleep(3)
Esempio n. 16
0
    def manajemenadmin(self):
        tujuan  = self.tujuan
        alamat  = self.alamat
        mac     = Finger.ambilmacaddress(tujuan, alamat)
        jumlahDihapus       = 0
        if FungsiLocal.macterdaftar(mac) :
            if Server.load('Trigger',None) is 1:
                APICEKADMIN             = Server.load('Admin',None)
                LOCALHOSTCEKADMIN       = FungsiLocal.carisemuaadmin(mac)
                normalizeadmin(LOCALHOSTCEKADMIN, APICEKADMIN, tujuan, alamat, mac)
                JUMLAHADMINSERVER       = len(APICEKADMIN)
                JUMLAHADMINFINGER       = Finger.jumlahpegawai(tujuan, alamat) - FungsiLocal.cekjumlahpegawai(mac)
                JUMMLAHADMINLOCAL       = FungsiLocal.cekjumlahadmin(mac)
                SELISIHJUMLAHADMIN      = JUMLAHADMINSERVER - JUMMLAHADMINLOCAL
                JumlahDaftarBaru        = 0
                if SELISIHJUMLAHADMIN > 0 : #Jika Terdapat ADMIN Baru Di Server
                    cetak.printLCD('Menambahkan','Admin').lcd_status()
                    #MENGAMBIL DATA ARRAY API
                    for ADMIN in range (0, JUMLAHADMINSERVER):
                        #Mengambil ID dan NAMA ADMIN
                        try:
                            ID =  APICEKADMIN[ADMIN]['id']
                            NAMA = APICEKADMIN[ADMIN]['nama'].replace("'"," ")
                        except ValueError as err:
                            pass
                        except TypeError as err:
                            pass
                        #Daftarkan ADMIN
                        try:
                            daftarkan   = daftaradmin(tujuan, alamat, ID, NAMA, mac)
                        except IOError as err:
                            pass
                else:
                    pass

                if JumlahDaftarBaru == 0:
                    pass
                    cetak.printLCD('Tidak Ada','Admin Baru').lcd_status()
                else:
                    pass
                    cetak.printLCD('%s Admin Baru' % JumlahDaftarBaru,'Berhasil Ditambahkan').lcd_status()

            elif Server.load('Trigger',None) is 2:
                APIHAPUSADMIN         = Server.load('Admin',None)
                JUMLAHADMINDIHAPUS    = len(APIHAPUSADMIN)
                for ADMIN in range (0, JUMLAHADMINDIHAPUS) :
                    try:
                        ID      = APIHAPUSADMIN[ADMIN]['pegawai_id']
                        hapusadmin(tujuan,  alamat, ID, mac)
                        jumlahDihapus += 1
                    except ValueError as err:
                        pass
                    except TypeError as err:
                        pass
                cetak.printLCD('%s Admin' % JumlahDaftarBaru,'Berhasil Dihapus').lcd_status()
        else:
            pass
            cetak.printLCD('Mac Fingerprint','Tidak Terdaftar').lcd_status()
            cetak.printLCD('Hubungi Kominfo','Untuk Mendaftarkan').lcd_status()
Esempio n. 17
0
 def check(self):
     while True:
         try:
             urllib2.urlopen(self.tujuan, timeout=self.waktuhabis)
             print 'PING   : OK !'
             return True
         except urllib2.URLError as err:
             lcd_.printLCD('URL', 'Error').lcd_status()
             lcd_.printLCD('Try to connect', self.teks).lcd_status()
             print 'Try to connect %s' % self.teks
         except socket.timeout as err:
             lcd_.printLCD('Socket', 'Timeout').lcd_status()
             lcd_.printLCD('Try to connect', self.teks).lcd_status()
             print 'Try to connect %s' % self.teks
         except socket.error as err:
             lcd_.printLCD('Socket', 'Error').lcd_status()
             lcd_.printLCD('Try to connect', self.teks).lcd_status()
             print 'Try to connect %s' % self.teks
Esempio n. 18
0
    def kirimdataabsensi(self):
        tujuan  = self.tujuan
        alamat  = self.alamat
        mac     = Finger.ambilmacaddress(tujuan, alamat)

        if FungsiLocal.macterdaftar(mac) :
            cetak.printLCD('Mengambil Data','Absensi').lcd_status()
            DATAABSENSI             = Finger.ambildataabsensi(tujuan, alamat)
            JUMLAHDATAABSENSI       = len(DATAABSENSI)
            JUMLAHDATAABSENSILOCAL  = FungsiLocal.cekjumlahabsensi(mac)
            SELISIHDATAABSENSI      = JUMLAHDATAABSENSI - JUMLAHDATAABSENSILOCAL
            TOTALSUKSESPOST         = 0
            TOTALGAGALPOST          = 0
            if SELISIHDATAABSENSI > 0:
                for DATA in range (JUMLAHDATAABSENSILOCAL, JUMLAHDATAABSENSI):
                    try:
                        IDINSTANSI      = instansi_id.ID_INSTANSI
                        USERPIN         = DATAABSENSI[DATA][0].text
                        TANGGAL, JAM    = DATAABSENSI[DATA][1].text.split(' ')
                        VERIFIKASI      = DATAABSENSI[DATA][2].text
                        STATUS          = DATAABSENSI[DATA][3].text
                        MACADDRESS      = mac

                        encryptText     = str(JAM) + str(TANGGAL) + str(USERPIN) + str(IDINSTANSI) + str(STATUS)
                        encryption      = encrypt(encryptText)

                        headers = {'Content-Type' : 'application/json', 'Accept' : 'application/json'}
                        payload = {'status' : STATUS, 'instansi' : IDINSTANSI, 'jam' : JAM, 'tanggal' : TANGGAL, 'user_id' : USERPIN, 'token' : encryption }

                        if Server.POST('KEHADIRAN', headers, payload):
                            FungsiLocal.inputdataabsensi(USERPIN, MACADDRESS)
                            TOTALSUKSESPOST +=1
                            cetak.printLCD('Total Absensi','Berhasil Dikirim %s' % TOTALSUKSESPOST).lcd_status()
                        else:
                            TOTALGAGALPOST +=1
                            cetak.printLCD('Total Absensi','Gagal Dikirim %s' % TOTALGAGALPOST).lcd_status()

                    except TypeError as err:
                        pass
                    except ValueError as err:
                        pass
                    except IndexError as err:
                        pass
            else:
                pass
                cetak.printLCD('Tidak Ada','Absensi Baru').lcd_status()
        else:
            pass
            cetak.printLCD('Mac Fingerprint','Tidak Terdaftar').lcd_status()
            time.sleep(3)
            cetak.printLCD('Hubungi Kominfo','Untuk Mendaftarkan').lcd_status()
            time.sleep(3)
Esempio n. 19
0
                'Finger D' : 'http://10.10.10.40:80',
                'Finger E' : 'http://10.10.10.50:80'
}

useAlamat = {}

def checkAlamat() :
    for alamat in listAlamat :
        if check_connection.onCheck(alamat, listAlamat[alamat], 5).checkAlamat() :
            listAlamat[alamat] = listAlamat[alamat].replace("http://","")
            useAlamat[alamat] = listAlamat[alamat]
        else :
            pass


lcd_.printLCD('Starting v2.3','%c %c %c' % (32, 32, 32)).lcd_status()
time.sleep(3)
lcd_.printLCD('Starting v2.3','%c %c %c' % (46, 32, 32)).lcd_status()
time.sleep(4)
lcd_.printLCD('Starting v2.3','%c %c %c' % (46, 46, 32)).lcd_status()
time.sleep(5)
lcd_.printLCD('Starting v2.3','%c %c %c' % (46, 46, 46)).lcd_status()


import check_connection
checkAlamat()
if len(useAlamat) is 0 :
    lcd_.printLCD ('Tidak Ada Fingerprint', 'Yang Terhubung').lcd_status()
    time.sleep(10)
    lcd_.printLCD ('Harap Hubungkan', 'Raspberry ke Fingerprint').lcd_status()
    time.sleep(10)