Skip to content

Commit ece5575

Browse files
authored
Merge pull request #5 from aviaryan/v2
V2
2 parents 106656c + 87d94f8 commit ece5575

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
VSCode Notebook :memo:
33
</h1>
44

5-
**v1.0**
5+
**v2.0**
66

77
VSCode Notebook is an attempt to use VSCode as a complete note taking application.
88
This is a VSCode port of the popular [SublimeNotebook](https://github.com/aviaryan/SublimeNotebook) project.
@@ -28,7 +28,7 @@ The result is this project, a wrapper/idea that converts my text editor, VSCode,
2828

2929
* Fast Search across all notes
3030
* Hierarchical organization and display of notes
31-
* Password based encryption for notes
31+
* Password based encryption for notes (thanks to [pyAES](https://github.com/ricmoo/pyaes))
3232
* Cloud sync (Dropbox, Google Drive, Box, etc)
3333
* Periodic git backup (to Github, Gitlab, your own private git server, etc)
3434
* Markdown based markup and code syntax highlighting

notebook.code-workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// release settings
1717
// uncommented in the release zip
1818
// "vscode_notebook/*.py": true,
19+
// "**/vscode_notebook/pyaes": true,
1920
},
2021
"search.useIgnoreFiles": false
2122
// ^ can be removed in production

vscode_notebook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
SETTINGS_PATH = 'vscode_notebook/settings.json'
2-
VERSION = 1.0
2+
VERSION = 2.0

vscode_notebook/cryptlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from getpass import getpass
66
from .settings import Settings
77
from .message import print_err
8-
from .pyaes import aes, AESModeOfOperationCTR
8+
from .pyaes import AESModeOfOperationCTR
99

1010

1111
EXTRA_STR = 'ENCo0D#DT{xTCh$cKe>'

vscode_notebook/settings.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import os
33
import time
4+
from traceback import print_exc
45
from subprocess import check_output, STDOUT
56
from vscode_notebook import SETTINGS_PATH, VERSION
67
from .message import print_err, print_info
@@ -103,13 +104,28 @@ def do_git_push(self):
103104
print_err('notebookbackup remote not found')
104105
return False
105106
# push to remote
106-
print_info('Pushing to remote')
107107
commit_msg = "auto backup " + str(mins)
108-
out = check_output("git add -A && git commit -m \"{}\" && git push notebookbackup master".format(commit_msg),
109-
stderr=STDOUT, shell=True).decode()
110-
print_info('GIT LOG:\n\n' + out)
108+
# push only if changes
109+
out = check_output("git status -s", stderr=STDOUT, shell=True).decode()
110+
if not out:
111+
print_info('No changes detected, hence skipping git backup')
112+
return
113+
# save last push min in advance
114+
old_mins = self.json['last_git_push']
111115
self.json['last_git_push'] = mins
112116
self.save_settings()
117+
# actual push
118+
try:
119+
print_info('Pushing to remote')
120+
out = check_output("git add -A && git commit -m \"{}\" && git push notebookbackup master".format(commit_msg),
121+
stderr=STDOUT, shell=True).decode()
122+
print_info('GIT LOG:\n\n' + out)
123+
except Exception:
124+
# revert back
125+
print_exc()
126+
print_err('git push did not happen')
127+
self.json['last_git_push'] = old_mins
128+
self.save_settings()
113129

114130
@staticmethod
115131
def _find_in_array(item, arr):

vscode_notebook/vscode_notebook.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_first_time_key():
1818

1919
def main():
2020
"""
21-
Executes Sublime Notebook
21+
Executes Notebook
2222
"""
2323
if not os.path.exists(SETTINGS_PATH):
2424
# new case
@@ -42,7 +42,7 @@ def main():
4242
else:
4343
# get settings
4444
sts = Settings()
45-
# check SublimeNotebook settings version
45+
# check Notebook settings version
4646
check = sts.upgrade_settings()
4747
if check:
4848
print_info('settings.json upgraded to current version')
@@ -82,7 +82,7 @@ def main():
8282
if sts.is_git_setup():
8383
sts.do_git_push()
8484
else:
85-
# disable sublime notebook
85+
# disable notebook
8686
# exit as-is
8787
print_info('Notes have been left decrypted')
8888
pass

0 commit comments

Comments
 (0)