Update attendances module
Add services files directory configuration to application.properties
This commit is contained in:
@@ -10,10 +10,12 @@ import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.quartz.SchedulerException;
|
||||
import com.axelor.app.AppSettings;
|
||||
|
||||
public class FetchAttendanceJob implements Job {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(FetchCheckInOutJob.class);
|
||||
private final String pythonScriptDir = AppSettings.get().get("services.dir");
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException{
|
||||
@@ -22,9 +24,14 @@ public class FetchAttendanceJob implements Job {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pythonScriptDir == null || pythonScriptDir.isEmpty()) {
|
||||
log.error("Python script path is not configured in AppSettings.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Define the command to run the Python script with the correct path (V3)
|
||||
String[] args = {"python", "C:\\Users\\administrator\\Desktop\\Scrape\\main.py"};
|
||||
String[] args = {"python", pythonScriptDir + "\\Scrape\\main.py"};
|
||||
|
||||
// Execute the command
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
|
||||
@@ -14,10 +14,12 @@ import org.slf4j.LoggerFactory;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.time.LocalDate;
|
||||
import org.quartz.SchedulerException;
|
||||
import com.axelor.app.AppSettings;
|
||||
|
||||
public class FetchCheckInOutJob implements Job {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(FetchCheckInOutJob.class);
|
||||
private final String pythonScriptDir = AppSettings.get().get("services.dir");
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
@@ -26,6 +28,11 @@ public class FetchCheckInOutJob implements Job {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pythonScriptDir == null || pythonScriptDir.isEmpty()) {
|
||||
log.error("Python script path is not configured in AppSettings.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
@@ -35,11 +42,10 @@ public class FetchCheckInOutJob implements Job {
|
||||
.all()
|
||||
.filter("self.date_attendance = :today")
|
||||
.bind("today", today)
|
||||
.fetch()
|
||||
.size();
|
||||
.fetch().size();
|
||||
|
||||
// Define the command to run the Python script with the correct path (V3)
|
||||
String[] args = {"python", "C:\\Users\\administrator\\Desktop\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)};
|
||||
String[] args = {"python", pythonScriptDir + "\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)};
|
||||
|
||||
// Execute the command
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
|
||||
Reference in New Issue
Block a user