tea4Cups prehook sketch没有运行某些库

时间:2018-04-02 13:20:14

标签: python raspbian cups

我正在使用带有CUPS打印系统的tea4cups后端。

我正在编写一个prehook,我在其中运行一个python脚本,通过GPIO /中继打开打印机,并设置一个cron任务,在设置的时间后将其关闭。

我已经将我的问题缩小到了我已经确定我不能使用某些python库的程度。即,crontablogging

每当我在python脚本中导入这些库时,tea4cups prehook都无法成功退出。工作状态显示:

completed at
Mon 02 Apr 2018 12:59:44 UTC 
"Tea4CUPS v3.12_official (PID 22795) : Prehook prehook_new on printer Brother_HL_5470DW_Tea4Cups didn't exit successfully."

请记住,当我从终端手动运行脚本时,我的脚本运行完美。只是当我将这些库导入脚本时,tea4cups无法运行它。

这是python脚本:

#!/usr/bin/python

import RPi.GPIO as GPIO
import Adafruit_DHT
from sys import argv, exit
import crontab
import logging

# Initialize temperature sensor
sensor = Adafruit_DHT.DHT22

# Pin definitions
DHTPin = 17
printPin = 27
heatPin = 22

# Pin Setup
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(heatPin, GPIO.OUT)
GPIO.setup(printPin, GPIO.OUT)

GPIO.output(heatPin, GPIO.HIGH)

# Initialize variables
temperature = 0

# Main Program
print("final")

以下是我提到这个prehook的tea4cups.conf文件:

prehook_new : python /home/pi/printserver/debug

以下是python脚本的权限:

enter image description here

有人可以帮助我,我该怎么办?

1 个答案:

答案 0 :(得分:0)

首先,我将使用python程序的完整路径。使用which python来获取它。

第二,我怀疑打印行会混淆tea4CUPS(但是我没有阅读所有tea4CUPS的代码。如果查看其源代码,您会发现调用了stdioRedirSystem方法来调用您的程序。

第三,我建议您在tea4cups的配置文件(/etc/cups/tea4cups.conf)中启用调试模式,然后查看cups错误文件(/var/log/cups/error.log)。