Update app.py
Browse files
app.py
CHANGED
@@ -16,22 +16,33 @@ def run_script_periodically(interval):
|
|
16 |
|
17 |
while True:
|
18 |
|
19 |
-
|
20 |
|
21 |
-
#
|
22 |
-
subprocess.run(["python", "update_embeddings.py"]) # Use "python3" if needed
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# Function to greet the user
|
30 |
def greet(name):
|
31 |
return "Hello " + name + "!!"
|
32 |
|
33 |
# Specify the interval (in seconds)
|
34 |
-
interval_seconds = 60*60*24*
|
35 |
|
36 |
# Create a thread to run the script periodically
|
37 |
script_thread = threading.Thread(target=run_script_periodically, args=(interval_seconds,))
|
|
|
16 |
|
17 |
while True:
|
18 |
|
19 |
+
current_day = datetime.now().weekday() # Monday is 0, Sunday is 6
|
20 |
|
21 |
+
if current_day == 0: # Check if today is Monday
|
|
|
22 |
|
23 |
+
log_message("Starting Updation")
|
24 |
+
|
25 |
+
# Run run.py as a subprocess
|
26 |
+
subprocess.run(["python", "update_embeddings.py"]) # Use "python3" if needed
|
27 |
+
|
28 |
+
log_message("Finished Updation")
|
29 |
+
|
30 |
+
# Wait for the specified interval before running again
|
31 |
+
time.sleep(interval)
|
32 |
|
33 |
+
else:
|
34 |
+
|
35 |
+
print("Today is not Monday, lets check again in a day.")
|
36 |
+
|
37 |
+
# Wait until the next day
|
38 |
+
time.sleep(60 * 60 * 24) # Check again in 24 hours
|
39 |
|
40 |
# Function to greet the user
|
41 |
def greet(name):
|
42 |
return "Hello " + name + "!!"
|
43 |
|
44 |
# Specify the interval (in seconds)
|
45 |
+
interval_seconds = 60*60*24*1 # Run run.py every day
|
46 |
|
47 |
# Create a thread to run the script periodically
|
48 |
script_thread = threading.Thread(target=run_script_periodically, args=(interval_seconds,))
|