Skip to content

Commit 270f13d

Browse files
committed
Ported to Python 3
WILL NOT WORK COMPLETELY, YET
1 parent d5dfb0e commit 270f13d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+219
-277
lines changed

addon.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.service.kodi.callbacks" name="Kodi Callbacks" version="1.0.0" provider-name="KenV99">
2+
<addon id="script.service.kodi.callbacks"
3+
name="Kodi Callbacks"
4+
version="1.1.0"
5+
provider-name="KenV99">
36
<requires>
4-
<import addon="xbmc.python" version="2.20.0"/>
7+
<import addon="xbmc.python" version="3.0.0"/>
58
<import addon="script.module.requests" version="2.3.0"/>
9+
<import addon="script.module.web-pdb" />
610
</requires>
711
<extension point="xbmc.service" library="default.py" start="startup">
812
</extension>

default.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def start():
106106
settings.getSettings()
107107
kl = KodiLogger()
108108
if settings.general['elevate_loglevel'] is True:
109-
kl.setLogLevel(xbmc.LOGNOTICE)
109+
kl.setLogLevel(xbmc.LOGINFO)
110110
else:
111111
kl.setLogLevel(xbmc.LOGDEBUG)
112112
log = kl.log
@@ -134,8 +134,8 @@ def start():
134134

135135

136136
def main():
137-
msg = _(u'$$$ [kodi.callbacks] - Staring kodi.callbacks ver: %s (%s:build %s) python: %s').encode('utf-8') % (str(_addonversion_), branch, build, sys.version)
138-
xbmc.log(msg=msg, level=xbmc.LOGNOTICE)
137+
msg = _(u'$$$ [kodi.callbacks] - Staring kodi.callbacks ver: %s (%s:build %s) python: %s') % (str(_addonversion_), branch, build, sys.version)
138+
xbmc.log(msg=msg, level=xbmc.LOGINFO)
139139
if branch != 'master':
140140
xbmcaddon.Addon().setSetting('installed branch', branch)
141141
start()
@@ -154,7 +154,7 @@ def main():
154154
if __name__ == '__main__':
155155

156156
if testTasks:
157-
KodiLogger.setLogLevel(KodiLogger.LOGNOTICE)
157+
KodiLogger.setLogLevel(KodiLogger.LOGINFO)
158158
startdebugger()
159159
from resources.lib.tests.testTasks import testTasks
160160

resources/lib/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
19+
1920
import os
2021
import pkgutil
2122
import sys
2223

23-
import tasks
24+
from resources.lib import tasks
2425
from resources.lib.kodilogging import KodiLogger
2526
from resources.lib.taskABC import AbstractTask
2627
from resources.lib.utils.kodipathtools import translatepath, setPathExecuteRW, setPathRW

resources/lib/dialogtb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def show_textbox(title, msg):
6363
_cwd_ = xbmc.translatePath(_addon_.getAddonInfo('path'))
6464
msgbox = MessageDialog(u"DialogTextBox.xml", _cwd_, u"Default")
6565
xt = type(msg)
66-
if xt is str or xt is unicode:
66+
if xt is str:
6767
wmsg = u'\n'.join(textwrap.wrap(msg, 62))
6868
elif xt is list:
6969
tmsg = []
@@ -80,4 +80,3 @@ def show_textbox(title, msg):
8080
msgbox.set_text(title, wmsg)
8181
msgbox.doModal()
8282
del msg
83-

resources/lib/kodilogging.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import xbmc
2020
import threading
2121

22-
def log(loglevel=xbmc.LOGNOTICE, msg=''):
22+
def log(loglevel=xbmc.LOGINFO, msg=''):
2323
if isinstance(msg, str):
2424
msg = msg.decode("utf-8")
2525
message = u"$$$ [%s] - %s" % ('kodi.callbacks', msg)
@@ -40,7 +40,7 @@ class KodiLogger(object):
4040
kodirunning = True
4141

4242
def __new__(cls):
43-
if xbmc.getFreeMem() == long():
43+
if xbmc.getFreeMem() == int():
4444
KodiLogger.kodirunning = False
4545
if KodiLogger._instance is None:
4646
with KodiLogger._lock:
@@ -59,10 +59,9 @@ def setLogLevel(arg):
5959
def log(loglevel=None, msg=''):
6060
if loglevel is None:
6161
loglevel = KodiLogger.selfloglevel
62-
if isinstance(msg, str):
63-
msg = msg.decode("utf-8")
62+
msg = str(msg)
6463
if KodiLogger.kodirunning:
6564
message = u"$$$ [%s] - %s" % (u'kodi.callbacks', msg)
66-
xbmc.log(msg=message.encode("utf-8", 'replace'), level=loglevel)
65+
xbmc.log(msg=message, level=loglevel)
6766
else:
68-
print msg
67+
print(msg)

resources/lib/kodisettings/generate_xml.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def createTasks():
7070
tasks = []
7171
last_id = None
7272
taskcontrols = []
73-
for i in xrange(1, 11):
73+
for i in range(1, 11):
7474
tasks.append('Task %i' % i)
7575
prefix = "T%s" % str(i)
7676
curTaskType = '%s.type' % prefix
@@ -105,7 +105,7 @@ def createTasks():
105105
try:
106106
option = varset['option']
107107
except KeyError:
108-
conditionals = struct.Conditional(struct.Conditional.OP_EQUAL, unicode(key), curTaskType)
108+
conditionals = struct.Conditional(struct.Conditional.OP_EQUAL, str(key), curTaskType)
109109
if varset['type'] == 'sfile':
110110
labelbrowse = u'%s - browse' % varset['label']
111111
labeledit = u'%s - edit' % varset['label']
@@ -128,7 +128,7 @@ def createTasks():
128128
default=varset['default'],
129129
visible=conditionals))
130130
else:
131-
conditionals = struct.Conditional(struct.Conditional.OP_EQUAL, unicode(key), curTaskType)
131+
conditionals = struct.Conditional(struct.Conditional.OP_EQUAL, str(key), curTaskType)
132132
if varset['type'] == 'sfile':
133133
labelbrowse = '%s - browse' % varset['label']
134134
labeledit = '%s - edit' % varset['label']
@@ -163,7 +163,7 @@ def createEvents(tasks):
163163
eventcontrols = []
164164

165165
last_id = None
166-
for i in xrange(1, 11):
166+
for i in range(1, 11):
167167
prefix = 'E%s' % str(i)
168168
curEvtType = '%s.type' % prefix
169169
action_evt = 'RunScript(script.service.kodi.callbacks, lselector, id=%s.type, heading=%s, lvalues=%s)' % (
@@ -250,7 +250,7 @@ def createEvents(tasks):
250250
lines.append(vs[x+1:])
251251
for line in lines:
252252
eventcontrols.append(struct.Lsep(label=line, visible=conditionals))
253-
conditionals = struct.Conditional(struct.Conditional.OP_NOT_EQUAL, unicode(glsid('None')), curEvtType)
253+
conditionals = struct.Conditional(struct.Conditional.OP_NOT_EQUAL, str(glsid('None')), curEvtType)
254254
eventcontrols.append(
255255
struct.Text('%s.userargs' % prefix, 'Var subbed arg string', default='', visible=conditionals))
256256
eventcontrols.append(struct.Action('%s.test' % prefix, 'Test Command (click OK to save changes first)',

0 commit comments

Comments
 (0)