Updated config file
Added new fields for limiting requests
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import sys
|
|
||||||
import io
|
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
import log21
|
import log21
|
||||||
import simplenote
|
import simplenote
|
||||||
@@ -183,6 +183,12 @@ def export_to_onenote(simplenotes, onenote_mgr, chosen_notebook=None, chosen_sec
|
|||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
|
config = onenote_mgr.config
|
||||||
|
interval = config.interval
|
||||||
|
limit = config.limit
|
||||||
|
total_notes_added = 0
|
||||||
|
bundle_notes_added = 0
|
||||||
|
|
||||||
for note in onenote_notes["value"]:
|
for note in onenote_notes["value"]:
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
@@ -204,6 +210,18 @@ def export_to_onenote(simplenotes, onenote_mgr, chosen_notebook=None, chosen_sec
|
|||||||
cred.password = sn['password']
|
cred.password = sn['password']
|
||||||
delete_note(cred, note)
|
delete_note(cred, note)
|
||||||
|
|
||||||
|
if bundle_notes_added == limit:
|
||||||
|
if interval > 300:
|
||||||
|
time.sleep(300)
|
||||||
|
else:
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
bundle_notes_added = 0
|
||||||
|
else:
|
||||||
|
bundle_notes_added += 1
|
||||||
|
|
||||||
|
total_notes_added += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -271,19 +289,7 @@ def main():
|
|||||||
14. [X] Delete the Simplenote note
|
14. [X] Delete the Simplenote note
|
||||||
"""
|
"""
|
||||||
|
|
||||||
token = Models.ResponseToken()
|
config.token_init()
|
||||||
|
|
||||||
if config.mode == "token input":
|
|
||||||
print("Enter token: ")
|
|
||||||
token_input = input()
|
|
||||||
token.access_token = token_input
|
|
||||||
config.token = token.access_token
|
|
||||||
elif config.mode == "token":
|
|
||||||
token.access_token = config.token
|
|
||||||
else:
|
|
||||||
token = onenote_mgr.fetch_token()
|
|
||||||
|
|
||||||
config.token = token.access_token
|
|
||||||
|
|
||||||
onenote_mgr = OneNoteManager.OneNoteManager(config=config)
|
onenote_mgr = OneNoteManager.OneNoteManager(config=config)
|
||||||
|
|
||||||
@@ -292,8 +298,8 @@ def main():
|
|||||||
export_to_onenote(notes, onenote_mgr, chosen_notebook=chosen_notebook, chosen_section=chosen_section)
|
export_to_onenote(notes, onenote_mgr, chosen_notebook=chosen_notebook, chosen_section=chosen_section)
|
||||||
|
|
||||||
|
|
||||||
logger = log21.get_logger('My Logger', level_names={21: 'SpecialInfo', log21.WARNING: ' ! ', log21.ERROR: '!!!'})
|
# logger = log21.get_logger('My Logger', level_names={21: 'SpecialInfo', log21.WARNING: ' ! ', log21.ERROR: '!!!'})
|
||||||
logger.log(21, 'Here', '%s', 'GO!', args=('we',))
|
# logger.log(21, 'Here', '%s', 'GO!', args=('we',))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
# from OneNoteManager import OneNoteManager
|
||||||
|
import OneNoteManager
|
||||||
|
|
||||||
|
|
||||||
class SimpleNote(object):
|
class SimpleNote(object):
|
||||||
def __init__(self, title=None, content=None):
|
def __init__(self, title=None, content=None):
|
||||||
self.title = title
|
self.title = title
|
||||||
@@ -59,17 +63,35 @@ class OneNote(object):
|
|||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
def __init__(self, token=None, secret=None, app_id=None, mode=None, scopes=None, authority_url=None, base_url=None, vendors=None) -> None:
|
def __init__(self, token=None, secret=None, app_id=None, mode=None, scopes=None, authority_url=None, limit=None, interval=None, base_url=None, vendors=None) -> None:
|
||||||
# def __init__(self, token=None, secret=None, app_id=None, mode=None, scopes=None, authority_url=None, base_url=None) -> None:
|
|
||||||
self.token = token
|
self.token = token
|
||||||
self.secret = secret
|
self.secret = secret
|
||||||
self.app_id = app_id
|
self.app_id = app_id
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.scopes = scopes
|
self.scopes = scopes
|
||||||
self.authority_url = authority_url
|
self.authority_url = authority_url
|
||||||
|
self.limit = limit
|
||||||
|
self.interval = interval
|
||||||
self.base_url = base_url
|
self.base_url = base_url
|
||||||
self.vendors = vendors
|
self.vendors = vendors
|
||||||
|
|
||||||
|
|
||||||
|
def token_init(self):
|
||||||
|
token = ResponseToken()
|
||||||
|
|
||||||
|
if self.mode == "token input":
|
||||||
|
print("Enter token: ")
|
||||||
|
token_input = input()
|
||||||
|
token.access_token = token_input
|
||||||
|
self.token = token.access_token
|
||||||
|
elif self.mode == "token":
|
||||||
|
token.access_token = self.token
|
||||||
|
else:
|
||||||
|
onenote_mgr = OneNoteManager(self)
|
||||||
|
token = onenote_mgr.fetch_token()
|
||||||
|
|
||||||
|
self.token = token.access_token
|
||||||
|
|
||||||
class Vendor(object):
|
class Vendor(object):
|
||||||
def __init__(self, username=None, password=None, target_notebook=None, target_section=None) -> None:
|
def __init__(self, username=None, password=None, target_notebook=None, target_section=None) -> None:
|
||||||
self.username = username
|
self.username = username
|
||||||
|
|||||||
+7
-2
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import webbrowser
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import webbrowser
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import msal
|
import msal
|
||||||
@@ -14,6 +15,7 @@ class OneNoteManager(object):
|
|||||||
self.token = token
|
self.token = token
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
if self.config != None:
|
||||||
self.initialize_onenote(self.config)
|
self.initialize_onenote(self.config)
|
||||||
|
|
||||||
def initialize_onenote(self, config):
|
def initialize_onenote(self, config):
|
||||||
@@ -132,8 +134,11 @@ class OneNoteManager(object):
|
|||||||
print('User code: %s' % (user_code))
|
print('User code: %s' % (user_code))
|
||||||
print("Enter code in browser to continue (Has been entered into clipboard)\n")
|
print("Enter code in browser to continue (Has been entered into clipboard)\n")
|
||||||
|
|
||||||
|
if os.name == "nt":
|
||||||
useless_cat_call = subprocess.run(["clip.exe"], stdout=subprocess.PIPE, text=True, input=user_code)
|
useless_cat_call = subprocess.run(["clip.exe"], stdout=subprocess.PIPE, text=True, input=user_code)
|
||||||
|
elif os.name == "posix":
|
||||||
|
useless_cat_call = subprocess.run(["clip.exe"], stdout=subprocess.PIPE, text=True, input=user_code)
|
||||||
|
|
||||||
|
|
||||||
app_code = flow['message']
|
app_code = flow['message']
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
"scopes": ["Create", "Read"],
|
"scopes": ["Create", "Read"],
|
||||||
"authority_url": "https://some-link.com",
|
"authority_url": "https://some-link.com",
|
||||||
"base_url": "https://some-other-link.com",
|
"base_url": "https://some-other-link.com",
|
||||||
|
"limit": 100,
|
||||||
|
"interval": 300,
|
||||||
"vendors": {
|
"vendors": {
|
||||||
"simplenote": {
|
"simplenote": {
|
||||||
"username": "me",
|
"username": "me",
|
||||||
|
|||||||
Reference in New Issue
Block a user