Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Added common logging, settings, translations and jsonRPC boilerplate #6

Merged
merged 6 commits into from
Jan 22, 2017

Conversation

razzeee
Copy link
Member

@razzeee razzeee commented Jan 18, 2017

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

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3c0a0692288186d9a30fdcbd3cf034afd5874a3a on common-boilerplate into 761f4d7 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

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.

This comment was marked as spam.

import simplejson as json

# read settings
__addon__ = xbmcaddon.Addon('<%= props.scriptid %>')

This comment was marked as spam.

# 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.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

<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.

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.

import time
import xbmc


kodiLogging.config()
logger = logging.getLogger(__name__)

This comment was marked as spam.

@phate89
Copy link
Contributor

phate89 commented Jan 18, 2017

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..

@MartijnKaijser
Copy link
Member

MartijnKaijser commented Jan 18, 2017

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.
Also most of this stuff is quite pointless as it's nearly duplication of what is already provided by the api

@razzeee
Copy link
Member Author

razzeee commented Jan 19, 2017

@MartijnKaijser
while that would be the best approach, that won't help us know or with already released versions

@coveralls
Copy link

coveralls commented Jan 19, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 805ec12 on common-boilerplate into 761f4d7 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 83c38e5 on common-boilerplate into 761f4d7 on master.

@coveralls
Copy link

coveralls commented Jan 20, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 89c0a60 on common-boilerplate into 761f4d7 on master.

<% } %>

# read settings
ADDON = xbmcaddon.Addon('<%= props.scriptid %>')

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 289e740 on common-boilerplate into 761f4d7 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 289e740 on common-boilerplate into 761f4d7 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling a0479fd on common-boilerplate into 761f4d7 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling a0479fd on common-boilerplate into 761f4d7 on master.

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.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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.

data = json.dumps(params)
request = xbmc.executeJSONRPC(data)

try:

This comment was marked as spam.

@coveralls
Copy link

coveralls commented Jan 22, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 0657782 on common-boilerplate into 761f4d7 on master.

@razzeee razzeee merged commit 3f4fb25 into master Jan 22, 2017
@razzeee razzeee deleted the common-boilerplate branch January 22, 2017 18:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants