-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
126 lines (106 loc) · 3.69 KB
/
test.py
File metadata and controls
126 lines (106 loc) · 3.69 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# # ! TODO: Add Highligthing shit
import json
import os
import platform
import subprocess
import time
from collections import deque
from datetime import datetime
from glob import glob
# import cson
home = os.path.expanduser("~")
def sync(
location=os.path.join(home, 'Boostnote')
):
os.chdir(location)
p = subprocess.Popen(
"git status", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# print(p.stdout.readlines()[1].strip())
if p.stdout.readlines()[1].decode("utf=8").strip() == 'nothing to commit, working tree clean':
os.system("git push origin master")
else:
print("Adding all the things")
os.system("git add -A")
# print("Commiting all the things")
os.system("git commit -m '.'")
# print("Pushing all the things")
os.system("git push origin master")
retval = p.wait()
def boostnote_exists(location=os.path.join(home, 'Boostnote')):
if os.path.isdir(BOOSTNOTE_PATH):
return 1
else:
# ! YAML Config
return 0
# raise NotADirectoryError("BoostNode Base Directory doesn't exist. Either make sure BoostNote is installed or add PATH to it in syncboostnote.yaml")\
def boostnote_notes_exist(location=os.path.join(home, 'notes')):
if os.path.isdir(BOOSTNOTE_NOTES_PATH):
return 1
else:
# ! YAML Config
raise NotADirectoryError(
f"No NOTES were found in the {BOOSTNOTE_NOTES_PATH} directory")
def git_update(message='nothing'):
os.system('git add -A')
os.system(f"git commit -m '{message}'")
def timely_check(config):
time_check = config['TIME']
frequency = config['FREQUENCY']
if frequency == 'onchange':
raise NotImplementedError('This THING is not implemented currently')
else:
if datetime.now().hour == time_check:
print("ITS HIGH NOON")
else:
if datetime.now().hour > time_check:
time.sleep(
(datetime.now().hour - time_check) * 360
)
elif datetime.now().hour < time_check:
time.sleep(
(datetime.now().hour - time_check + 24) * 360
)
# time.sleep(2)
print("Has the time come yet?")
def time_check(frequency, thyme, config):
'''
Waits for the time and performs:
1. If user mentions time, then sleep time will be time + frequency
2. If user mention time, then sleep time will be 1200 hrs + frequency
'''
thyme = 12
while(1):
if frequency == 'onchange':
while(1):
if not get_changes():
# Wait
print(f'Waiting for {"2 seconds"}')
time.sleep(2)
# time, slep(10 * 60 * 60)
else:
# change occured
print("Calling update_changes")
update_changes()
print("Calling ultimate")
ultimate(config)
if datetime.now().hour == thyme:
# check updates
print(gay)
pass
else:
print('shit', datetime.now())
if frequency == 'hourly':
time.sleep(1 * 360 / 100)
elif frequency == 'daily':
time.sleep(24 * 360 / 100)
elif frequency == 'weekly':
time.sleep(24 * 7 * 360 / 100)
# time_check('onchange', '14',
# {
# "BOOSTNOTE_PATH": os.path.join(home, 'Boostnote'),
# "SHIELDS": True,
# "SHIELDS_TYPE": "for-the-badge",
# "FREQUENCY": "hourly",
# "TIME": 11
# }
# )