-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
63 lines (50 loc) · 1.92 KB
/
test.py
File metadata and controls
63 lines (50 loc) · 1.92 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
# # ! 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")
p = subprocess.Popen(
"git add -A", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# print("Commiting all the things")
p1 = subprocess.Popen(
f"git commit -m '{datetime.now()}'", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p1.stdout.readlines()[2:]:
print(line.decode("utf-8"))
# print("Pushing all the things")
p2 = subprocess.Popen(
"git push origin master", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
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}'")