commit
dc19cabf25
2 changed files with 34 additions and 1 deletions
|
@ -10,11 +10,18 @@ username = admin
|
||||||
password = eventman
|
password = eventman
|
||||||
ca =
|
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]
|
[event]
|
||||||
id = 1492099112_2612922-3896-9zwsccuvguz91jtw9y6lwvkud11ba7wt
|
id = 1492099112_2612922-3896-9zwsccuvguz91jtw9y6lwvkud11ba7wt
|
||||||
field = order_nr
|
field = order_nr
|
||||||
limit_field = 9
|
limit_field = 9
|
||||||
|
|
||||||
|
# the 'actions' section key: value pairs are used in the PUT method.
|
||||||
[actions]
|
[actions]
|
||||||
attended = True
|
attended = True
|
||||||
checked_in_by = ${eventman:username}
|
checked_in_by = ${eventman:username}
|
||||||
|
checkin_datetime = %NOW%
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,12 @@ import os
|
||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
import serial
|
import serial
|
||||||
import urllib
|
import urllib
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
|
import datetime
|
||||||
import requests
|
import requests
|
||||||
import configparser
|
import configparser
|
||||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||||
|
@ -49,6 +51,8 @@ def convert_obj(obj):
|
||||||
return True
|
return True
|
||||||
elif obj_l in ['false', 'off', 'no']:
|
elif obj_l in ['false', 'off', 'no']:
|
||||||
return False
|
return False
|
||||||
|
elif obj == '%NOW%':
|
||||||
|
return datetime.datetime.utcnow()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +67,23 @@ def convert(seq):
|
||||||
return convert_obj(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():
|
class Connector():
|
||||||
def __init__(self, cfg):
|
def __init__(self, cfg):
|
||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
|
@ -119,6 +140,7 @@ class Connector():
|
||||||
|
|
||||||
def scan(port):
|
def scan(port):
|
||||||
retry = 1
|
retry = 1
|
||||||
|
logger.info('trying to connect to %s, please wait...' % port)
|
||||||
while True:
|
while True:
|
||||||
logger.debug('waiting for connection on port %s...' % port)
|
logger.debug('waiting for connection on port %s...' % port)
|
||||||
try:
|
try:
|
||||||
|
@ -133,7 +155,11 @@ def scan(port):
|
||||||
logger.info('connected to %s' % port)
|
logger.info('connected to %s' % port)
|
||||||
ser_io = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1), newline='\r', line_buffering=True)
|
ser_io = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1), newline='\r', line_buffering=True)
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
line = ser_io.readline().strip()
|
line = ser_io.readline().strip()
|
||||||
|
except serial.serialutil.SerialException as ex:
|
||||||
|
logger.error('disconnected: %s' % ex)
|
||||||
|
sys.exit(3)
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
yield line
|
yield line
|
||||||
|
|
Loading…
Reference in a new issue