I have a python script that I am running from the command line that does three things
1.) Kills all Processing programs currently running
2.) Runs a new Processing program
3.) Shut downs Raspberry Pi
When running this command from the command line, it works flawlessly. Yet, when calling this Python script using crontab, only the 1st and 3rd processes run correctly. What I want to know is why the 2nd command (running a new Processing program) works when I run the Python script from the command line, but not from a crontab?
Here is my Python script
import os # Use operating system
import subprocess # Use subprocess calls
from time import sleep # Use sleep
from subprocess import call
os.system('sudo killall java')
sleep(5)
child = subprocess.Popen('sudo processing-java --sketch=/home/pi/Desktop/LaserCannonProcessing/LCshutdown --run', shell=True) #
sleep(15)
call("sudo poweroff", shell = True)
and here is my crontab
50 20 * * * sudo /usr/bin/python3 /home/pi/Desktop/Shutdown.py
Does anyone know why crontab can not successfully run the command to run a processing program? If so, is there any way I can fix this and make crontab run that line? Thanks
I have a python script that I am running from the command line that does three things
1.) Kills all Processing programs currently running
2.) Runs a new Processing program
3.) Shut downs Raspberry Pi
When running this command from the command line, it works flawlessly. Yet, when calling this Python script using crontab, only the 1st and 3rd processes run correctly. What I want to know is why the 2nd command (running a new Processing program) works when I run the Python script from the command line, but not from a crontab?
Here is my Python script
import os # Use operating system
import subprocess # Use subprocess calls
from time import sleep # Use sleep
from subprocess import call
os.system('sudo killall java')
sleep(5)
child = subprocess.Popen('sudo processing-java --sketch=/home/pi/Desktop/LaserCannonProcessing/LCshutdown --run', shell=True) #
sleep(15)
call("sudo poweroff", shell = True)
and here is my crontab
50 20 * * * sudo /usr/bin/python3 /home/pi/Desktop/Shutdown.py
Does anyone know why crontab can not successfully run the command to run a processing program? If so, is there any way I can fix this and make crontab run that line? Thanks
Я делаю учебник по Processing.js, который можно найти здесь: http://processingjs.org/articles/jsQuickStart.html
Когда я загружаю свой документ в браузер, я получаю две ошибки:
uncaught exception: called Processing constructor without passing canvas element reference or id.
И,
Access to restricted URI denied
xhr.send(null)
Что касается первой ошибки, я передаю идентификатор элемента холста следующим образом:
var canvas = document.getElementById('canvas1');
Я также проверил и убедился, что элемент холста в HTML имеет canvas1
Я бы.
Я не уверен, что пошло не так со второй ошибкой.
Пожалуйста, помогите мне понять, что я делаю не так.
Это мой код:
function sketchProc(processing) {
processing.draw = function() {
var centerX = processing.width / 2;
var centerY = processing.height / 2;
var maxArmLength = Math.min(centerX, centerY);
function drawArm(position, lengthScale, weight) {
processing.strokeWeight(weight);
processing.line(centerX, centerY,
centerX + Math.sin(position * 2 * Math.PI) * lengthScale * maxArmLength,
centerY - Math.cos(position * 2 * Math.PI) * lengthScale * maxArmLength);
}
processing.background(224);
var now = new Date();
var hoursPosition = (now.getHours() % 12 + now.getMinutes() / 60) / 12;
drawArm(hoursPosition, 0.5, 5);
}
}
var canvas = document.getElementById('canvas1');
var processingInstance = new Processing(canvas, sketchProc);
Я делаю учебник по Processing.js, который можно найти здесь: http://processingjs.org/articles/jsQuickStart.html
Когда я загружаю свой документ в браузер, я получаю две ошибки:
uncaught exception: called Processing constructor without passing canvas element reference or id.
А также
Access to restricted URI denied
xhr.send(null)
Что касается первой ошибки, я передаю идентификатор элемента canvas следующим образом:
var canvas = document.getElementById('canvas1');
Я также проверил и убедился, что элемент canvas в HTML имеет идентификатор canvas1
.
Я не уверен, что пошло не так со второй ошибкой.
Пожалуйста, помогите мне понять, что я делаю неправильно.
Это мой код:
function sketchProc(processing) {
processing.draw = function() {
var centerX = processing.width / 2;
var centerY = processing.height / 2;
var maxArmLength = Math.min(centerX, centerY);function drawArm(position, lengthScale, weight) {
processing.strokeWeight(weight);
processing.line(centerX, centerY,
centerX + Math.sin(position * 2 * Math.PI) * lengthScale * maxArmLength,
centerY - Math.cos(position * 2 * Math.PI) * lengthScale * maxArmLength);
}processing.background(224);
var now = new Date();
var hoursPosition = (now.getHours() % 12 + now.getMinutes() / 60) / 12;
drawArm(hoursPosition, 0.5, 5);
}
}var canvas = document.getElementById('canvas1');
var processingInstance = new Processing(canvas, sketchProc);