"""
The most basic (working) CherryPy 3.1 Windows service possible.
Requires Mark Hammond's pywin32 package.
"""

import win32serviceutil
import win32service

import cherrypy
import os
from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20'
controller_serial = 11111111
client = RFIDClient(ip_address, controller_serial)


class RootServer:
    @cherrypy.expose
    def index(self, apiKey=None, action=None, badge=None):
        if (apiKey == "secret"):
            if badge:
                badge = ten_digit_to_comma_format(int(badge))
                if (action == "remove"):
                    try:
                        client.remove_user(badge)
                        return "User Removed Successfully"
                    except:
                        return "Failed To Remove User"
                elif (action == "add"):
                    try:
예제 #2
0
from rfid import RFIDClient

ip_address = '192.168.1.20'
controller_serial = 123106461
client = RFIDClient(ip_address, controller_serial)

client.open_door(1)
예제 #3
0
from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20'
controller_serial = 123106461
client = RFIDClient(ip_address, controller_serial)

badge = ten_digit_to_comma_format(
    11111111)  # badge number needs to be in "comma format"

client.add_user(badge, [1])  # add badge to door 1
client.add_user(badge, [1, 2])  # add badge to door 1 and 2
client.add_user(badge, [1, 2, 3])  # add badge to door 1, 2, and 3
client.add_user(badge, [1, 2, 3, 4])  # add badge to door 1, 2, 3, and 4
예제 #4
0
from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20'
controller_serial = 123106461
client = RFIDClient(ip_address, controller_serial)

badge = ten_digit_to_comma_format(
    11111111)  # badge number needs to be in "comma format"

client.remove_user(badge)
from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20'
controller_serial = 123106461
client = RFIDClient(ip_address, controller_serial)

badge = ten_digit_to_comma_format(11111111) # badge number needs to be in "comma format"

client.add_user(badge, [1]) # add badge to door 1
client.add_user(badge, [1, 2]) # add badge to door 1 and 2
client.add_user(badge, [1, 2, 3]) # add badge to door 1, 2, and 3
client.add_user(badge, [1, 2, 3, 4]) # add badge to door 1, 2, 3, and 4
from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20'
controller_serial = 123106461
client = RFIDClient(ip_address, controller_serial)

badge = ten_digit_to_comma_format(11111111) # badge number needs to be in "comma format"

client.remove_user(badge)