-
Notifications
You must be signed in to change notification settings - Fork 25
Added common logging, settings, translations and jsonRPC boilerplate #6
Conversation
Coverage remained the same at 100.0% when pulling 3c0a0692288186d9a30fdcbd3cf034afd5874a3a on common-boilerplate into 761f4d7 on master. |
1 similar comment
Coverage remained the same at 100.0% when pulling 3c0a0692288186d9a30fdcbd3cf034afd5874a3a on common-boilerplate into 761f4d7 on master. |
if sys.version_info >= (2, 7): | ||
import json as json | ||
else: | ||
import simplejson as json |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
import simplejson as json | ||
|
||
# read settings | ||
__addon__ = xbmcaddon.Addon('<%= props.scriptid %>') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
<import addon="xbmc.python" version="<%= props.kodiVersion %>"/><% if (props.type == 'Plugin') { -%><import addon="script.module.routing" version="0.2.0"/><% } -%> | ||
<import addon="xbmc.python" version="<%= props.kodiVersion %>"/> | ||
<%_ if (props.type == 'Plugin') { -%> <import addon="script.module.routing" version="0.2.0"/><% } %> | ||
<%_ if (props.type == 'Plugin' || props.type == 'Script' || props.type == 'Service') { -%> <import addon="script.module.simplejson" version="3.3.0"/><% } %> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
from xbmcgui import ListItem | ||
from xbmcplugin import addDirectoryItem, endOfDirectory | ||
|
||
|
||
logger = logging.getLogger(__name__) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
import time | ||
import xbmc | ||
|
||
|
||
kodiLogging.config() | ||
logger = logging.getLogger(__name__) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Isn't better instead of adding it to ask tamland to create a module and add that dependency? It seems a very good logging other projects could use.. |
Imo its plain stupid we even have to build a module around our Kodi python module to make it usable. That clearly shows it needs to get fixed and not build something around it. |
3c0a069
to
805ec12
Compare
@MartijnKaijser |
<% } %> | ||
|
||
# read settings | ||
ADDON = xbmcaddon.Addon('<%= props.scriptid %>') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
1 similar comment
1 similar comment
if getSettingAsBool('debug'): | ||
try: | ||
xbmc.log(self.format(record), levels[record.levelno]) | ||
except UnicodeEncodeError: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
logger = logging.getLogger(__name__) | ||
|
||
def notification(header, message, time=5000, icon=ADDON.getAddonInfo('icon')): | ||
xbmc.executebuiltin("XBMC.Notification(%s,%s,%i,%s)" % (header, message, time, icon)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
data = json.dumps(params) | ||
request = xbmc.executeJSONRPC(data) | ||
|
||
try: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This adds a bunch of boilerplate for plugins, services and scripts.
Only the service example will use something from this (logging).
This code is taken from my trakt script.
With the logging stuff taken from @tamland
Please review and let me know if there are things to improve @enen92 @phil65 @phate89