Revision 146
logging with user names
trunk/swipe/tooltron.py | ||
---|---|---|
130 | 130 |
|
131 | 131 |
def logMessage(str): |
132 | 132 |
flog.write(strftime("%Y.%m.%d %H:%M:%S ") + str + "\n") |
133 |
flog.flush() |
|
133 | 134 |
|
134 | 135 |
logMessage("----- SERVER STARTED -----") |
135 | 136 |
|
... | ... | |
283 | 284 |
|
284 | 285 |
print "user has access to:", acl |
285 | 286 |
|
286 |
user = "user"
|
|
287 |
user = "" |
|
287 | 288 |
|
289 |
#query for name |
|
290 |
qry2 = "SELECT civicrm_contact.display_name \ |
|
291 |
FROM civicrm_value_roboclub_info_2 \ |
|
292 |
INNER JOIN (civicrm_contact) \ |
|
293 |
ON civicrm_value_roboclub_info_2.entity_id = civicrm_contact.id \ |
|
294 |
WHERE civicrm_value_roboclub_info_2.card_number_1 = " + id.group(1) + ";" |
|
295 |
|
|
296 |
cursor.execute(qry2) |
|
297 |
result = cursor.fetchall() |
|
298 |
|
|
299 |
if len(result) > 0: |
|
300 |
user += result[0][0] |
|
301 |
|
|
302 |
qry2 = "SELECT civicrm_email.email \ |
|
303 |
FROM civicrm_value_roboclub_info_2 \ |
|
304 |
INNER JOIN (civicrm_email) \ |
|
305 |
ON civicrm_email.contact_id = civicrm_value_roboclub_info_2.entity_id \ |
|
306 |
WHERE civicrm_value_roboclub_info_2.card_number_1 = " + id.group(1) + ";" |
|
307 |
|
|
308 |
cursor.execute(qry2) |
|
309 |
result = cursor.fetchall() |
|
310 |
|
|
311 |
if len(result) > 0: |
|
312 |
user += " ("+result[0][0]+")" |
|
313 |
|
|
314 |
if user == "": |
|
315 |
user = str(id.group(1)) |
|
316 |
|
|
317 |
print user |
|
318 |
|
|
288 | 319 |
startTime = time.time(); |
289 | 320 |
resp = "" |
290 | 321 |
while resp=="": |
... | ... | |
312 | 343 |
keypad.write(TT_ACK) |
313 | 344 |
sendTool(resp) |
314 | 345 |
print "ACCESS GRANTED" |
315 |
logMessage(user+" accessed tool "+toolNameLong)
|
|
346 |
logMessage(user+" ACCESSED tool "+toolNameLong)
|
|
316 | 347 |
if checkAck(resp): |
317 | 348 |
print "ACK" |
318 | 349 |
toolFails[toolName] = 0 |
... | ... | |
320 | 351 |
print "NO ACK!!!!" |
321 | 352 |
logMessage("tool "+toolNameLong+" did not ACK") |
322 | 353 |
toolFails[toolName] += 1 |
323 |
if toolFails > MAX_TOOL_FAILS: |
|
354 |
if toolFails[toolName] > MAX_TOOL_FAILS:
|
|
324 | 355 |
#TODO: send email |
325 | 356 |
logMessage("WARNING: tool "+toolNameLong+ |
326 | 357 |
" has failed to ACK "+ |
... | ... | |
329 | 360 |
else: |
330 | 361 |
keypad.write(TT_NACK) |
331 | 362 |
print "ACCESS DENIED!!" |
332 |
logMessage(user + " denied on tool "+toolNameLong)
|
|
363 |
logMessage(user + " DENIED on tool "+toolNameLong)
|
|
333 | 364 |
|
334 | 365 |
clear_id() |
335 | 366 |
|
Also available in: Unified diff