diff --git a/README.markdown b/README.markdown index 99611b9..0d7f2c7 100644 --- a/README.markdown +++ b/README.markdown @@ -2,7 +2,7 @@ VSCode Notebook :memo: -**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. @@ -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 diff --git a/notebook.code-workspace b/notebook.code-workspace index eaa01a0..16c37fd 100644 --- a/notebook.code-workspace +++ b/notebook.code-workspace @@ -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 diff --git a/vscode_notebook/__init__.py b/vscode_notebook/__init__.py index 50d9486..ac9d577 100644 --- a/vscode_notebook/__init__.py +++ b/vscode_notebook/__init__.py @@ -1,2 +1,2 @@ SETTINGS_PATH = 'vscode_notebook/settings.json' -VERSION = 1.0 +VERSION = 2.0 diff --git a/vscode_notebook/cryptlib.py b/vscode_notebook/cryptlib.py index 4e2cdef..aac5d2d 100644 --- a/vscode_notebook/cryptlib.py +++ b/vscode_notebook/cryptlib.py @@ -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>' diff --git a/vscode_notebook/settings.py b/vscode_notebook/settings.py index d5c701d..772e9eb 100644 --- a/vscode_notebook/settings.py +++ b/vscode_notebook/settings.py @@ -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 @@ -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): diff --git a/vscode_notebook/vscode_notebook.py b/vscode_notebook/vscode_notebook.py index a1f6dab..2e40839 100755 --- a/vscode_notebook/vscode_notebook.py +++ b/vscode_notebook/vscode_notebook.py @@ -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 @@ -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') @@ -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