def SubmitWeight(workOrderNumber, weight, testingMode): """submit weight to web api""" # make some fake apiResult data if we're testing if (testingMode): result = ApiResponse(200, "everything is awesome!") return result try: h = httplib2.Http('.cache') url = 'http://incomtek3-test/api/partWeights/records/scale/' + workOrderNumber + "/" + weight response, content = h.request(url, "POST", headers={'content-length':'0'} ) responseStatus = response.status data = content.decode("utf-8") # convert byte to string result = ApiResponse(responseStatus, data) return result except Exception as e: import LcdStuff as lcd lcd.setText(e.args[0]) import LedConfig as leds leds.blinkNoGoLeds() finally: pass
def SubmitWeight(workOrderNumber, weight, testingMode): """submit weight to web api""" # make some fake apiResult data if we're testing if (testingMode): pass #result = ApiResponse(200, "everything is awesome!") #return result try: h = httplib2.Http('.cache') url = 'http://incomtek3/api/partWeights/records/scale/' + workOrderNumber + "/" + weight response, content = h.request(url, "POST", headers={'content-length': '0'}) responseStatus = response.status data = content.decode("utf-8") # convert byte to string result = ApiResponse(responseStatus, data) return result except Exception as e: import LcdStuff as lcd # lcd.setText(e.args[0]) lcd.setText("There was an error sending the weight") import LedConfig as leds leds.blinkNoGoLeds() finally: pass
def alert(msg1, msg2 = "", msg3 = ""): lcd.setText(msg1, msg2, msg3, pressAckMsg) leds.blinkNoGoLeds() lcd.setText(readyText)
if (jsonData['model']['weightLimitExceeded']): alert("Exceeds weight limit", "Part must be sent", "to quarantine") continue sc = jsonData['model']['comtekStockCode'] lcd.setText("Weight submitted for", "stock code:", "", sc) leds.goLed.turnOn() time.sleep(10) leds.goLed.turnOff() else: # failed to properly read data if(pw.hasData): lcd.setText(pw.msg) leds.blinkNoGoLeds(); lcd.setText(readyText) leds.statusLed.turnOn() time.sleep(0.1) except KeyboardInterrupt: GeneralSetup.exitPiScale("") except Exception as e: lcd.setText(e.args[0]) leds.blinkNoGoLeds() finally: pass
def alert(msg1, msg2="", msg3=""): lcd.setText(msg1, msg2, msg3, pressAckMsg) leds.blinkNoGoLeds() lcd.setText(readyText)
alert("Exceeds weight limit", "Part must be sent", "to quarantine") continue sc = jsonData['model']['comtekStockCode'] lcd.setText("Weight submitted for", "stock code:", "", sc) leds.goLed.turnOn() time.sleep(10) leds.goLed.turnOff() else: # failed to properly read data if (pw.hasData): lcd.setText(pw.msg) leds.blinkNoGoLeds() lcd.setText(readyText) leds.statusLed.turnOn() time.sleep(0.1) except KeyboardInterrupt: GeneralSetup.exitPiScale("") except Exception as e: lcd.setText(e.args[0]) leds.blinkNoGoLeds() finally: pass