Revision 284 trunk/swipe/tooltron.py
| tooltron.py (revision 284) | ||
|---|---|---|
| 39 | 39 |
|
| 40 | 40 |
import sys |
| 41 | 41 |
import MySQLdb |
| 42 |
import getpass |
|
| 42 |
import base64 |
|
| 43 | 43 |
import datetime |
| 44 | 44 |
from datetime import date |
| 45 | 45 |
from time import * |
| 46 | 46 |
sys.path.append('../common')
|
| 47 | 47 |
import common |
| 48 | 48 |
|
| 49 |
keypadTimeout = 12 #in seconds |
|
| 50 |
|
|
| 51 | 49 |
#this table maps which keypad button to press for each tool. This |
| 52 | 50 |
#list should probably be printed next to the swipe box |
| 53 | 51 |
tools = {
|
| 54 |
'Bandsaw':[], |
|
| 55 |
'DrillPress':['3','8'], |
|
| 56 |
'Mill':['4'], |
|
| 52 |
'Bandsaw':['3','4'], |
|
| 53 |
'DrillPress':['1','2'], |
|
| 54 |
'Mill':['5'], |
|
| 57 | 55 |
'Lathe':[], |
| 58 | 56 |
#HACK: since the saw isn't used I use it for testing random boards |
| 59 | 57 |
'ChopMiterSaw':['1','2','5','6','7','9'] |
| ... | ... | |
| 64 | 62 |
#boards were swapped out. The tool ID number should be printed on the |
| 65 | 63 |
#tool board, but needs to be hand coded into the toolbox code |
| 66 | 64 |
ids = {
|
| 67 |
'1':11, |
|
| 68 |
'2':12, |
|
| 69 |
'3':13, |
|
| 70 |
'4':14, |
|
| 71 |
'5':15, |
|
| 72 |
'6':16, |
|
| 73 |
'7':17, |
|
| 74 |
'8':18, |
|
| 75 |
'9':19, |
|
| 76 |
'0':13 |
|
| 65 |
'1':13, |
|
| 66 |
'2':18, |
|
| 67 |
'3':11, |
|
| 68 |
'4':17, |
|
| 69 |
'5':14, |
|
| 70 |
'6':10, |
|
| 71 |
'7':10, |
|
| 72 |
'8':10, |
|
| 73 |
'9':10, |
|
| 74 |
'0':10 |
|
| 77 | 75 |
} |
| 78 | 76 |
|
| 79 | 77 |
try: |
| ... | ... | |
| 124 | 122 |
print "usage: tooltron.py /path/to/bus/device" |
| 125 | 123 |
else: |
| 126 | 124 |
|
| 127 |
pw = getpass.getpass("mysql password: ")
|
|
| 125 |
# read password |
|
| 126 |
try: |
|
| 127 |
passfile = open('pass', 'r')
|
|
| 128 | 128 |
|
| 129 |
except IOError as e: |
|
| 130 |
print "\========================================" |
|
| 131 |
print "File 'pass' could not be opened!" |
|
| 132 |
print e |
|
| 133 |
print "This file is required for MySQL authentication" |
|
| 134 |
print "\========================================" |
|
| 135 |
exit(-1) |
|
| 136 |
|
|
| 137 |
pw = base64.b64decode(passfile.read()) |
|
| 138 |
|
|
| 129 | 139 |
cursor = None |
| 130 | 140 |
qry1 = "SELECT tools_6 FROM civicrm_value_roboclub_info_2 WHERE card_number_1 = " |
| 131 | 141 |
|
Also available in: Unified diff