-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
51 lines (45 loc) · 1.76 KB
/
Copy pathapp.py
File metadata and controls
51 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from instapy_cli import client
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import time
from post import Post
from setup_ import POST_DAYS, POST_LIST, PASSWORD, USERNAME, POST_HOUR
import os
import json
from eventhandler import MyHandler
from datetime import datetime
import tkinter as tk
from alert_window import AlertWindow
path = 'C:/Users/abhin/OneDrive/Desktop/posts'
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
try:
POST_LIST.initialize_me()
except Exception as e:
print('no json')
for post in POST_LIST.posts:
todays_date = datetime.today()
if post.description == "":
root = tk.Tk()
app = AlertWindow(root, post.image)
root.mainloop()
post.description = app.new_description
with open('posts.json', 'w') as json_file:
json.dump(POST_LIST.serialize(), json_file)
if todays_date.day == post.post_date.day:
if todays_date.hour == POST_HOUR:
# should post a photo
if not post.has_been_posted:
with client(USERNAME, PASSWORD) as cli:
cli.upload("production_ready_posts/" + post.image, post.description)
post.has_been_posted = True
with open('posts.json', 'w') as json_file:
json.dump(POST_LIST.serialize(), json_file)
time.sleep(60)
except KeyboardInterrupt:
observer.stop()
observer.join()