commit
dc19cabf25
2 changed files with 34 additions and 1 deletions
|
@ -10,11 +10,18 @@ username = admin
|
|||
password = eventman
|
||||
ca =
|
||||
|
||||
# in the 'event' section you have to specify the ID of the event,
|
||||
# the name of the field used to search for tickets and - optionally -
|
||||
# the number of chars in the field value that will be considered
|
||||
# for the match (limit_field)
|
||||
[event]
|
||||
id = 1492099112_2612922-3896-9zwsccuvguz91jtw9y6lwvkud11ba7wt
|
||||
field = order_nr
|
||||
limit_field = 9
|
||||
|
||||
# the 'actions' section key: value pairs are used in the PUT method.
|
||||
[actions]
|
||||
attended = True
|
||||
checked_in_by = ${eventman:username}
|
||||
checkin_datetime = %NOW%
|
||||
|
||||
|
|
|
@ -22,10 +22,12 @@ import os
|
|||
import io
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import serial
|
||||
import urllib
|
||||
import logging
|
||||
import argparse
|
||||
import datetime
|
||||
import requests
|
||||
import configparser
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
@ -49,6 +51,8 @@ def convert_obj(obj):
|
|||
return True
|
||||
elif obj_l in ['false', 'off', 'no']:
|
||||
return False
|
||||
elif obj == '%NOW%':
|
||||
return datetime.datetime.utcnow()
|
||||
return obj
|
||||
|
||||
|
||||
|
@ -63,6 +67,23 @@ def convert(seq):
|
|||
return convert_obj(seq)
|
||||
|
||||
|
||||
class ImprovedEncoder(json.JSONEncoder):
|
||||
"""Enhance the default JSON encoder to serialize datetime instances."""
|
||||
def default(self, o):
|
||||
if isinstance(o, (datetime.datetime, datetime.date,
|
||||
datetime.time, datetime.timedelta)):
|
||||
try:
|
||||
return str(o)
|
||||
except Exception as e:
|
||||
pass
|
||||
elif isinstance(o, set):
|
||||
return list(o)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
||||
# Inject our class as the default encoder.
|
||||
json._default_encoder = ImprovedEncoder()
|
||||
|
||||
|
||||
class Connector():
|
||||
def __init__(self, cfg):
|
||||
self.cfg = cfg
|
||||
|
@ -119,6 +140,7 @@ class Connector():
|
|||
|
||||
def scan(port):
|
||||
retry = 1
|
||||
logger.info('trying to connect to %s, please wait...' % port)
|
||||
while True:
|
||||
logger.debug('waiting for connection on port %s...' % port)
|
||||
try:
|
||||
|
@ -133,7 +155,11 @@ def scan(port):
|
|||
logger.info('connected to %s' % port)
|
||||
ser_io = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1), newline='\r', line_buffering=True)
|
||||
while True:
|
||||
line = ser_io.readline().strip()
|
||||
try:
|
||||
line = ser_io.readline().strip()
|
||||
except serial.serialutil.SerialException as ex:
|
||||
logger.error('disconnected: %s' % ex)
|
||||
sys.exit(3)
|
||||
if not line:
|
||||
continue
|
||||
yield line
|
||||
|
|
Loading…
Reference in a new issue