forked from madsailor/SMF-Extension
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add python based logging to extension.
Add suppport to get historical quotes from the Intrinio service
- Loading branch information
Showing
9 changed files
with
280 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"user":"intrinio-user-id", | ||
"password":"intrinio-password", | ||
"certifi":"/for/macOS/path/to/certifi/cacert.pem" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Python logging for LO extension | ||
# Copyright (C) 2017 Dave Hocker as TheAgency (AtHomeX10@gmail.com) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# See the LICENSE file for more details. | ||
# | ||
|
||
import logging | ||
import logging.handlers | ||
import os | ||
|
||
|
||
######################################################################## | ||
# Enable logging for the extension | ||
def EnableLogging(): | ||
# Default overrides | ||
logformat = '%(asctime)s, %(module)s, %(levelname)s, %(message)s' | ||
logdateformat = '%Y-%m-%d %H:%M:%S' | ||
|
||
# Logging level override | ||
loglevel = logging.DEBUG | ||
# loglevel = logging.INFO | ||
# loglevel = logging.WARNING | ||
# loglevel = logging.ERROR | ||
|
||
logger = logging.getLogger("smf-extension") | ||
logger.setLevel(loglevel) | ||
|
||
formatter = logging.Formatter(logformat, datefmt=logdateformat) | ||
|
||
# Log to a file | ||
# Make logfile location OS specific | ||
if os.name == "posix": | ||
# Linux or OS X | ||
file_path = "{0}/libreoffice/intrinio/".format(os.environ["HOME"]) | ||
elif os.name == "nt": | ||
# Windows | ||
file_path = "{0}\\libreoffice\\intrinio\\".format(os.environ["HOMEPATH"]) | ||
logfile = file_path + "smf-extension.log" | ||
|
||
fh = logging.handlers.TimedRotatingFileHandler(logfile, when='midnight', backupCount=3) | ||
fh.setLevel(loglevel) | ||
fh.setFormatter(formatter) | ||
logger.addHandler(fh) | ||
logger.debug("Logging to file: %s", logfile) | ||
|
||
def getAppLogger(): | ||
""" | ||
Return an instance of the default logger for this app. | ||
:return: logger instance | ||
""" | ||
return logging.getLogger("smf-extension") | ||
|
||
# Controlled logging shutdown | ||
def Shutdown(): | ||
getAppLogger().debug("Logging shutdown") | ||
logging.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
The SMF Extension enables you to create spreadsheets with stock market data pulled directly from the web. | ||
Currently supported sources include Yahoo Finance, Google Finance, Morningstar, and ADVFN. | ||
Currently supported sources include Yahoo Finance, Google Finance, Intrinio, Morningstar, and ADVFN. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.