Skip to content
Merged

V2 #5

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VSCode Notebook :memo:
</h1>

**v1.0**
**v2.0**

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

* Fast Search across all notes
* Hierarchical organization and display of notes
* Password based encryption for notes
* Password based encryption for notes (thanks to [pyAES](https://github.com/ricmoo/pyaes))
* Cloud sync (Dropbox, Google Drive, Box, etc)
* Periodic git backup (to Github, Gitlab, your own private git server, etc)
* Markdown based markup and code syntax highlighting
Expand Down
1 change: 1 addition & 0 deletions notebook.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// release settings
// uncommented in the release zip
// "vscode_notebook/*.py": true,
// "**/vscode_notebook/pyaes": true,
},
"search.useIgnoreFiles": false
// ^ can be removed in production
Expand Down
2 changes: 1 addition & 1 deletion vscode_notebook/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SETTINGS_PATH = 'vscode_notebook/settings.json'
VERSION = 1.0
VERSION = 2.0
2 changes: 1 addition & 1 deletion vscode_notebook/cryptlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from getpass import getpass
from .settings import Settings
from .message import print_err
from .pyaes import aes, AESModeOfOperationCTR
from .pyaes import AESModeOfOperationCTR


EXTRA_STR = 'ENCo0D#DT{xTCh$cKe>'
Expand Down
24 changes: 20 additions & 4 deletions vscode_notebook/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import time
from traceback import print_exc
from subprocess import check_output, STDOUT
from vscode_notebook import SETTINGS_PATH, VERSION
from .message import print_err, print_info
Expand Down Expand Up @@ -103,13 +104,28 @@ def do_git_push(self):
print_err('notebookbackup remote not found')
return False
# push to remote
print_info('Pushing to remote')
commit_msg = "auto backup " + str(mins)
out = check_output("git add -A && git commit -m \"{}\" && git push notebookbackup master".format(commit_msg),
stderr=STDOUT, shell=True).decode()
print_info('GIT LOG:\n\n' + out)
# push only if changes
out = check_output("git status -s", stderr=STDOUT, shell=True).decode()
if not out:
print_info('No changes detected, hence skipping git backup')
return
# save last push min in advance
old_mins = self.json['last_git_push']
self.json['last_git_push'] = mins
self.save_settings()
# actual push
try:
print_info('Pushing to remote')
out = check_output("git add -A && git commit -m \"{}\" && git push notebookbackup master".format(commit_msg),
stderr=STDOUT, shell=True).decode()
print_info('GIT LOG:\n\n' + out)
except Exception:
# revert back
print_exc()
print_err('git push did not happen')
self.json['last_git_push'] = old_mins
self.save_settings()

@staticmethod
def _find_in_array(item, arr):
Expand Down
6 changes: 3 additions & 3 deletions vscode_notebook/vscode_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_first_time_key():

def main():
"""
Executes Sublime Notebook
Executes Notebook
"""
if not os.path.exists(SETTINGS_PATH):
# new case
Expand All @@ -42,7 +42,7 @@ def main():
else:
# get settings
sts = Settings()
# check SublimeNotebook settings version
# check Notebook settings version
check = sts.upgrade_settings()
if check:
print_info('settings.json upgraded to current version')
Expand Down Expand Up @@ -82,7 +82,7 @@ def main():
if sts.is_git_setup():
sts.do_git_push()
else:
# disable sublime notebook
# disable notebook
# exit as-is
print_info('Notes have been left decrypted')
pass