]> git.parisson.com Git - deefuzzer.git/commitdiff
Add Python 3 compatibility, fix various encoding options, need DEBUG
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 30 Dec 2019 01:48:35 +0000 (02:48 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 30 Dec 2019 01:48:35 +0000 (02:48 +0100)
27 files changed:
deefuzzer/__init__.py
deefuzzer/core.py
deefuzzer/player.py
deefuzzer/relay.py
deefuzzer/station.py
deefuzzer/tools/PyRSS2Gen.py
deefuzzer/tools/__init__.py
deefuzzer/tools/get_access_token.py
deefuzzer/tools/mediabase.py
deefuzzer/tools/mp3.py
deefuzzer/tools/ogg.py
deefuzzer/tools/osc.py
deefuzzer/tools/utils.py
deefuzzer/tools/webm.py
deefuzzer/tools/xmltodict2.py
scripts/deefuzzer
scripts/osc/osc_jingles_start.py
scripts/osc/osc_jingles_stop.py
scripts/osc/osc_player_fast.py
scripts/osc/osc_player_next.py
scripts/osc/osc_player_slow.py
scripts/osc/osc_record_start.py
scripts/osc/osc_record_stop.py
scripts/osc/osc_relay_start.py
scripts/osc/osc_relay_stop.py
scripts/osc/osc_twitter_start.py
scripts/osc/osc_twitter_stop.py

index c15a1c93e1bebd8e0cdf01d2587df7be3d820048..f1545c98137c77717a5aa61e355db5873ad9fa08 100644 (file)
@@ -1,5 +1,5 @@
-from core import *
-from station import *
-from tools import *
+from .core import *
+from .station import *
+from .tools import *
 
 __version__ = '0.7.3'
index a43617ede3620b27e6bcaa887d4eb1074b206316..a57ed671fb037a6d4298ccfe9e49fcad72bf052f 100644 (file)
 
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
+
 import os
 import shout
-import Queue
+import queue
 import datetime
 import mimetypes
 import hashlib
+import platform
 from threading import Thread
 from deefuzzer.station import *
 from deefuzzer.tools import *
@@ -58,7 +60,7 @@ class DeeFuzzer(Thread):
     station_settings = []
     station_instances = {}
     watch_folder = {}
-    log_queue = Queue.Queue()
+    log_queue = queue.Queue()
     main_loop = False
     ignore_errors = False
     max_retry = 0
@@ -67,9 +69,11 @@ class DeeFuzzer(Thread):
         Thread.__init__(self)
         self.conf_file = conf_file
         self.conf = get_conf_dict(self.conf_file)
-
-        if 'deefuzzer' not in self.conf:
-            return
+        
+        print(self.conf)
+        
+        if 'deefuzzer' not in self.conf :
+            raise('This is not a standard deefuzzer config file')
 
         # Get the log setting first (if possible)
         log_file = str(self.conf['deefuzzer'].pop('log', ''))
@@ -78,9 +82,8 @@ class DeeFuzzer(Thread):
             os.makedirs(self.log_dir)
         self.logger = QueueLogger(log_file, self.log_queue)
         self.logger.start()
-        #print(self.conf)
 
-        for key in self.conf['deefuzzer'].keys():
+        for key in list(self.conf['deefuzzer'].keys()):
             if key == 'm3u':
                 self.m3u = str(self.conf['deefuzzer'][key])
 
@@ -113,6 +116,7 @@ class DeeFuzzer(Thread):
 
         # Set the deefuzzer logger
         self._info('Starting DeeFuzzer')
+        self._info('Using Python version %s' % platform.python_version())
         self._info('Using libshout version %s' % shout.version())
         self._info('Number of stations : ' + str(len(self.station_settings)))
 
@@ -202,7 +206,7 @@ class DeeFuzzer(Thread):
             return
         self._info('Creating station for folder ' + folder)
         d = dict(path=folder, name=name)
-        for i in options.keys():
+        for i in list(options.keys()):
             if 'folder' not in i:
                 s[i] = replace_all(options[i], d)
         if 'media' not in s:
@@ -259,7 +263,7 @@ class DeeFuzzer(Thread):
             return
 
     def run(self):
-        q = Queue.Queue(1)
+        q = queue.Queue(1)
         ns = 0
         p = Producer(q)
         p.start()
@@ -317,12 +321,12 @@ class DeeFuzzer(Thread):
                             if 'short_name' in self.station_settings[i]['infos']:
                                 name = self.station_settings[i]['infos']['short_name']
                                 y = 1
-                                while name in self.station_instances.keys():
+                                while name in list(self.station_instances.keys()):
                                     y += 1
                                     name = self.station_settings[i]['infos']['short_name'] + " " + str(y)
 
                         self.station_settings[i]['station_name'] = name
-                        namehash = hashlib.md5(name).hexdigest()
+                        namehash = hashlib.md5(str(name).encode('utf-8')).hexdigest()
                         self.station_settings[i]['station_statusfile'] = os.sep.join([self.log_dir, namehash])
 
                     new_station = Station(self.station_settings[i], q, self.log_queue, self.m3u)
index ac7fe06799a272d17653099eb6a9b865d9e9ea9c..3945b85ca10ee4d4aa39eb3c6c932268d3b785d2 100644 (file)
@@ -36,7 +36,7 @@
 
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
-from relay import *
+from .relay import *
 import time
 
 
@@ -80,7 +80,7 @@ class Player:
     def file_read_slow(self):
         """Read a bigger part of the media and stream the little parts
          of the data through a generator"""
-        m = open(self.media, 'r')
+        m = open(self.media, 'rb')
         while True:
             self.main_chunk = m.read(self.main_buffer_size)
             if not self.main_chunk:
@@ -122,7 +122,7 @@ class URLReader:
 
     def __init__(self, relay):
         self.__relayparam = relay
-        self.relay = urllib.urlopen(self.__relayparam)
+        self.relay = urllib.request.urlopen(self.__relayparam)
         self.rec_mode = 0
 
     def set_recorder(self, recorder, mode=1):
@@ -137,7 +137,7 @@ class URLReader:
         except:
             while True:
                 try:
-                    self.relay = urllib.urlopen(self.__relayparam)
+                    self.relay = urllib.request.urlopen(self.__relayparam)
                     chunk = self.relay.read(size)
                     break
                 except:
index b3d7c9a6da9ca1b921fdcf781918e23e1a28e443..2a91b0cc796f3afc3d6f56f462281632cfb97a09 100644 (file)
@@ -37,8 +37,8 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from threading import Thread
-import Queue
-import urllib
+import queue
+import urllib.request, urllib.parse, urllib.error
 
 
 class Relay(Thread):
@@ -47,7 +47,7 @@ class Relay(Thread):
         Thread.__init__(self)
         self.sub_buffer_size = sub_buffer_size
         self.queue_size = queue_size
-        self.queue = Queue.Queue(self.queue_size)
+        self.queue = queue.Queue(self.queue_size)
         self.stream = None
 
     def set_url(self, url):
@@ -55,7 +55,7 @@ class Relay(Thread):
 
     def open(self):
         try:
-            self.stream = urllib.urlopen(self.url)
+            self.stream = urllib.request.urlopen(self.url)
             self.isopen = True
         except:
             self.isopen = False
index d31838d72ad60c01f7ecca269bb3b9b752c96e97..614973cefb4d0d2e544df4e897fc65bfe462e316 100644 (file)
@@ -43,18 +43,18 @@ import datetime
 import string
 import random
 import shout
-import urllib
+import urllib.request, urllib.parse, urllib.error
 import mimetypes
 import json
 import hashlib
 import MySQLdb as mdb
 
 from threading import Thread
-from player import *
-from recorder import *
-from relay import *
-from streamer import *
-from tools import *
+from .player import *
+from .recorder import *
+from .relay import *
+from .streamer import *
+from .tools import *
 
 
 class Station(Thread):
@@ -456,7 +456,7 @@ class Station(Thread):
                     for row in rows:
                         file_list.append(row[0])
 
-                except mdb.Error, e:
+                except mdb.Error as e:
                     self._err('Could not get playlist from MySQLdb, Error %d: %s' % (e.args[0], e.args[1]))
 
                 finally:
@@ -501,7 +501,7 @@ class Station(Thread):
         return file_list
 
     def get_array_hash(self, s):
-        return hashlib.md5(str(s)).hexdigest()
+        return hashlib.md5(str(s).encode('utf-8')).hexdigest()
 
     def get_jingles(self):
         file_list = []
@@ -614,7 +614,7 @@ class Station(Thread):
                     file_meta = Ogg(media)
                 elif file_ext.lower() == 'webm' or mimetypes.guess_type(media)[0] == 'video/webm':
                     file_meta = WebM(media)
-            except Exception, e:
+            except Exception as e:
                 self._err('Could not get specific media type class for %s' % (media))
                 self._err('Error: %s' % (str(e)))
                 pass
@@ -648,7 +648,7 @@ class Station(Thread):
             media_description = '<table>'
             media_description_item = '<tr><td>%s:   </td><td><b>%s</b></td></tr>'
 
-            for key in media.metadata.keys():
+            for key in list(media.metadata.keys()):
                 if media.metadata[key] != '':
                     if key == 'filepath' and not self.feeds_showfilepath:
                         continue
@@ -749,7 +749,8 @@ class Station(Thread):
             song = mediaobj.get_song(True)
         except:
             pass
-
+        
+        print(title, artist, song)
         return title, artist, song
 
     def get_currentsongmeta(self):
@@ -832,7 +833,7 @@ class Station(Thread):
 
         while not self.server_ping:
             try:
-                server = urllib.urlopen(self.server_url)
+                server = urllib.request.urlopen(self.server_url)
                 self.server_ping = True
                 self._info('Channel available.')
             except:
@@ -856,7 +857,7 @@ class Station(Thread):
                 self.set_read_mode()
 
             return True
-        except Exception, e:
+        except Exception as e:
             self._err('icecastloop_nextmedia: Error: ' + str(e))
         return False
 
@@ -879,9 +880,9 @@ class Station(Thread):
         try:
             self.update_twitter_current()
             if self.song:
-                self.channel.set_metadata({'song': self.song, 'charset': 'utf-8'})
+                self.channel.set_metadata({'song': str(self.song), 'charset': 'utf-8'})
             return True
-        except Exception, e:
+        except Exception as e:
             self._err('icecastloop_metadata: Error: ' + str(e))
         return False
 
index 56b249a5097c3244ccf44b68ee006c2ef3ab6994..17c090be103dfc16e7e218cd35770b052d074ffb 100644 (file)
@@ -24,10 +24,10 @@ class WriteXmlMixin:
 
     def to_xml(self, encoding="iso-8859-1"):
         try:
-            import cStringIO as StringIO
+            import io as StringIO
         except ImportError:
-            import StringIO
-        f = StringIO.StringIO()
+            import io
+        f = io.StringIO()
         self.write_xml(f, encoding)
         return f.getvalue()
 
@@ -35,7 +35,7 @@ class WriteXmlMixin:
 def _element(handler, name, obj, d=None):
     if not d:
         d = {}
-    if isinstance(obj, basestring) or obj is None:
+    if isinstance(obj, str) or obj is None:
         # special-case handling to make the API easier
         # to use for the common case.
         handler.startElement(name, d)
@@ -377,7 +377,7 @@ class RSS2(WriteXmlMixin):
         _opt_element(handler, "lastBuildDate", lastBuildDate)
 
         for category in self.categories:
-            if isinstance(category, basestring):
+            if isinstance(category, str):
                 category = Category(category)
             category.publish(handler)
 
@@ -459,7 +459,7 @@ class RSSItem(WriteXmlMixin):
         _opt_element(handler, "author", self.author)
 
         for category in self.categories:
-            if isinstance(category, basestring):
+            if isinstance(category, str):
                 category = Category(category)
             category.publish(handler)
 
index 276c19803c3f4cb1b058fb25624b0a1727c1355c..0ccf1273257b945413e3418bd0aec7956464af62 100644 (file)
@@ -1,11 +1,11 @@
 # -*- coding: utf-8 -*-
-from xmltodict import *
-from PyRSS2Gen import *
-from mediabase import *
-from mp3 import *
-from ogg import *
-from webm import *
-from logger import *
-from osc import *
-from twitt import *
-from utils import *
+from .xmltodict import *
+from .PyRSS2Gen import *
+from .mediabase import *
+from .mp3 import *
+from .ogg import *
+from .webm import *
+from .logger import *
+from .osc import *
+from .twitt import *
+from .utils import *
index 6801019f8022272ee180595de69214a74a24cfe3..0158a229e9d3c25c9111e3450ebe1c2e5577d4a1 100644 (file)
@@ -19,7 +19,7 @@ import sys
 
 # parse_qsl moved to urlparse module in v2.6
 try:
-    from urlparse import parse_qsl
+    from urllib.parse import parse_qsl
 except:
     from cgi import parse_qsl
 
@@ -34,56 +34,56 @@ consumer_key = 'ozs9cPS2ci6eYQzzMSTb4g'
 consumer_secret = '1kNEffHgGSXO2gMNTr8HRum5s2ofx3VQnJyfd0es'
 
 if consumer_key is None or consumer_secret is None:
-    print 'You need to edit this script and provide values for the'
-    print 'consumer_key and also consumer_secret.'
-    print ''
-    print 'The values you need come from Twitter - you need to register'
-    print 'as a developer your "application".  This is needed only until'
-    print 'Twitter finishes the idea they have of a way to allow open-source'
-    print 'based libraries to have a token that can be used to generate a'
-    print 'one-time use key that will allow the library to make the request'
-    print 'on your behalf.'
-    print ''
+    print('You need to edit this script and provide values for the')
+    print('consumer_key and also consumer_secret.')
+    print('')
+    print('The values you need come from Twitter - you need to register')
+    print('as a developer your "application".  This is needed only until')
+    print('Twitter finishes the idea they have of a way to allow open-source')
+    print('based libraries to have a token that can be used to generate a')
+    print('one-time use key that will allow the library to make the request')
+    print('on your behalf.')
+    print('')
     sys.exit(1)
 
 signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1()
 oauth_consumer = oauth.Consumer(key=consumer_key, secret=consumer_secret)
 oauth_client = oauth.Client(oauth_consumer)
 
-print 'Requesting temp token from Twitter'
+print('Requesting temp token from Twitter')
 
 resp, content = oauth_client.request(REQUEST_TOKEN_URL, 'GET')
 
 if resp['status'] != '200':
-    print 'Invalid respond from Twitter requesting temp token: %s' % resp['status']
+    print('Invalid respond from Twitter requesting temp token: %s' % resp['status'])
 else:
     request_token = dict(parse_qsl(content))
 
-    print ''
-    print 'Please visit this Twitter page and retrieve the pincode to be used'
-    print 'in the next step to obtaining an Authentication Token:'
-    print ''
-    print '%s?oauth_token=%s' % (AUTHORIZATION_URL, request_token['oauth_token'])
-    print ''
+    print('')
+    print('Please visit this Twitter page and retrieve the pincode to be used')
+    print('in the next step to obtaining an Authentication Token:')
+    print('')
+    print('%s?oauth_token=%s' % (AUTHORIZATION_URL, request_token['oauth_token']))
+    print('')
 
-    pincode = raw_input('Pincode? ')
+    pincode = input('Pincode? ')
 
     token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
     token.set_verifier(pincode)
 
-    print ''
-    print 'Generating and signing request for an access token'
-    print ''
+    print('')
+    print('Generating and signing request for an access token')
+    print('')
 
     oauth_client = oauth.Client(oauth_consumer, token)
     resp, content = oauth_client.request(ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % pincode)
     access_token = dict(parse_qsl(content))
 
     if resp['status'] != '200':
-        print 'The request for a Token did not succeed: %s' % resp['status']
-        print access_token
+        print('The request for a Token did not succeed: %s' % resp['status'])
+        print(access_token)
     else:
-        print 'Your Twitter Access Token key: %s' % access_token['oauth_token']
-        print '          Access Token secret: %s' % access_token['oauth_token_secret']
-        print ''
+        print('Your Twitter Access Token key: %s' % access_token['oauth_token'])
+        print('          Access Token secret: %s' % access_token['oauth_token_secret'])
+        print('')
 
index ee74697dc87bd3dea5a5b1274e8b4f8e78d17b46..9fca41f904d6aaf9a73ad6cb4803a10c0d66c327 100644 (file)
@@ -80,7 +80,7 @@ class MediaBase(object):
     def read_file_metadata(self):
         """Reads the metadata for the media, filtered by the tagdata dictionary for this media type"""
         self.metadata = {}
-        for key in self.tagdata.keys():
+        for key in list(self.tagdata.keys()):
             self.metadata[key] = ''
             try:
                 self.metadata[key] = self.sourceobj[key][0]
@@ -107,7 +107,7 @@ class MediaBase(object):
             r = "";
         if clean:
             r = r.replace('_',' ').strip()
-        return r.encode('utf-8')
+        return r
 
     def get_title(self):
         """Returns the cleaned title for this media"""
index bc14cd61d6fb7c86730d8fd4084da5ffc4b29a86..47ea9ce15705a3f46c86d49db4d792051f3c634d 100644 (file)
@@ -42,7 +42,7 @@ import datetime
 from mutagen.easyid3 import EasyID3
 from mutagen.mp3 import MP3, MPEGInfo
 from mutagen import id3
-from utils import *
+from .utils import *
 
 EasyID3.valid_keys["comment"] = "COMM::'XXX'"
 EasyID3.valid_keys["copyright"] = "TCOP::'XXX'"
@@ -95,7 +95,7 @@ class Mp3(MediaBase):
             respect of mutagen classes and methods"""
 
         self.sourceobj.add_tags()
-        self.sourceobj.tags['TIT2'] = id3.TIT2(encoding=2, text=u'text')
+        self.sourceobj.tags['TIT2'] = id3.TIT2(encoding=2, text='text')
         self.sourceobj.save()
 
         '''
index 8f9adea371354d0d1bd433297bebd011e4b235ff..e0dc15fd994217458882d88c1c4b0fb0bcfa79f0 100644 (file)
@@ -40,7 +40,7 @@ import os
 import string
 import datetime
 from mutagen.oggvorbis import OggVorbis
-from utils import *
+from .utils import *
 
 
 class Ogg(MediaBase):
@@ -102,7 +102,7 @@ class Ogg(MediaBase):
 
     def write_tags(self):
         # self.ogg.add_tags()
-        for tag in self.metadata.keys():
+        for tag in list(self.metadata.keys()):
             self.sourceobj[tag] = str(self.metadata[tag])
         self.sourceobj.save()
 
@@ -122,7 +122,7 @@ class Ogg(MediaBase):
         else:
             args.append('-Q -b ' + self.bitrate_default)
 
-        for tag in self.metadata.keys():
+        for tag in list(self.metadata.keys()):
             value = clean_word(self.metadata[tag])
             args.append('-c %s="%s"' % (tag, value))
             if tag in self.tagdata:
index b4bb72a79d2bfa192cb2ae1e79cde9dfa5bb416b..41cc1bc5d7852691fad0068b004f8b1c12c40460 100644 (file)
@@ -47,8 +47,8 @@ class OSCController(Thread):
         self.port = port
         try:
             self.server = liblo.Server(self.port)
-        except liblo.ServerError, err:
-            print str(err)
+        except liblo.ServerError as err:
+            print(str(err))
 
     def add_method(self, path, type, method):
         self.server.add_method(path, type, method)
index fb70538e7916c28a6a59f8a79f2beb36e60021fd..3a1b78363df6fd40873055130d37546e226c3401 100644 (file)
@@ -71,12 +71,12 @@ def replace_all(option, repl):
         return r
     elif isinstance(option, dict):
         r = {}
-        for key in option.keys():
+        for key in list(option.keys()):
             r[key] = replace_all(option[key], repl)
         return r
     elif isinstance(option, str):
         r = option
-        for key in repl.keys():
+        for key in list(repl.keys()):
             r = r.replace('[' + key + ']', repl[key])
         return r
     return option
@@ -94,16 +94,8 @@ def get_conf_dict(file):
 
     elif 'yaml' in mime_type or 'yml' in mime_type:
         import yaml
-
-        def custom_str_constructor(loader, node):
-            return loader.construct_scalar(node).encode('utf-8')
-
-        yaml.add_constructor(u'tag:yaml.org,2002:str', custom_str_constructor)
         confile = open(file, 'r')
-        data = confile.read()
-        confile.close()
-        for c in yaml.load_all(data):
-            conf = c
+        conf = yaml.safe_load(confile)
         return conf
 
     elif 'json' in mime_type:
index f39eff07b4460c8776e5788663fbe60de8bfdb2d..85ab2d6a441683a4fdca5af9e935dcdae9cfbf7e 100644 (file)
@@ -39,7 +39,7 @@
 import os
 import string
 import datetime
-from utils import *
+from .utils import *
 
 
 class WebM(MediaBase):
index bf0ea4683fb04f3591736c373f7260d3bf502dca..2a59523d1f25dc40dbe0e7c2e6d27c30898d8fed 100644 (file)
@@ -173,7 +173,7 @@ def xmltodict(xml, attsToSkip=None, addCodeFile=False):
         # argument was a file
         try:
             ret = parser.ParseFromFile(xml)
-        except expat.ExpatError, e:
+        except expat.ExpatError as e:
             errmsg = _("The XML in '%s' is not well-formed and cannot be parsed: %s") % (xml, e)
     else:
         # argument must have been raw xml:
@@ -186,7 +186,7 @@ def xmltodict(xml, attsToSkip=None, addCodeFile=False):
             except expat.ExpatError:
                 errmsg = _("An invalid XML string was encountered")
     if errmsg:
-        raise dabo.dException.XmlException, errmsg
+        raise dabo.dException.XmlException(errmsg)
     if addCodeFile and isPath:
         # Get the associated code file, if any
         codePth = "%s-code.py" % os.path.splitext(xml)[0]
@@ -194,8 +194,8 @@ def xmltodict(xml, attsToSkip=None, addCodeFile=False):
             try:
                 codeDict = desUtil.parseCodeFile(open(codePth).read())
                 desUtil.addCodeToClassDict(ret, codeDict)
-            except StandardError, e:
-                print "Failed to parse code file:", e
+            except Exception as e:
+                print("Failed to parse code file:", e)
     return ret
 
 
@@ -203,10 +203,10 @@ def escQuote(val, noEscape=False, noQuote=False):
     """Add surrounding quotes to the string, and escape
     any illegal XML characters.
     """
-    if not isinstance(val, basestring):
+    if not isinstance(val, str):
         val = str(val)
-    if not isinstance(val, unicode):
-        val = unicode(val, default_encoding)
+    if not isinstance(val, str):
+        val = str(val, default_encoding)
     if noQuote:
         qt = ''
     else:
@@ -246,7 +246,7 @@ def dicttoxml(dct, level=0, header=None, linesep=None):
     ret = ""
 
     if "attributes" in dct:
-        for key, val in dct["attributes"].items():
+        for key, val in list(dct["attributes"].items()):
             # Some keys are already handled.
             noEscape = key in ("sizerInfo",)
             val = escQuote(val, noEscape)
@@ -262,10 +262,10 @@ def dicttoxml(dct, level=0, header=None, linesep=None):
             ret += "%s" % dct["cdata"].replace("<", "&lt;")
 
         if "code" in dct:
-            if len(dct["code"].keys()):
+            if len(list(dct["code"].keys())):
                 ret += "%s%s<code>%s" % (eol, "\t" * (level + 1), eol)
                 methodTab = "\t" * (level + 2)
-                for mthd, cd in dct["code"].items():
+                for mthd, cd in list(dct["code"].items()):
                     # Convert \n's in the code to eol:
                     cd = eol.join(cd.splitlines())
 
@@ -281,12 +281,12 @@ def dicttoxml(dct, level=0, header=None, linesep=None):
                 ret += "%s</code>%s" % ("\t" * (level + 1), eol)
 
         if "properties" in dct:
-            if len(dct["properties"].keys()):
+            if len(list(dct["properties"].keys())):
                 ret += "%s%s<properties>%s" % (eol, "\t" * (level + 1), eol)
                 currTab = "\t" * (level + 2)
-                for prop, val in dct["properties"].items():
+                for prop, val in list(dct["properties"].items()):
                     ret += "%s<%s>%s" % (currTab, prop, eol)
-                    for propItm, itmVal in val.items():
+                    for propItm, itmVal in list(val.items()):
                         itmTab = "\t" * (level + 3)
                         ret += "%s<%s>%s</%s>%s" % (itmTab, propItm, itmVal, propItm, eol)
                     ret += "%s</%s>%s" % (currTab, prop, eol)
index 3c9c6ef5643d6e97427bc59b9e8cdd046d379e09..e7285141e53eeed29c2e326c2952bd23a6df9e86 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import os
 import sys
index 6e5177c28e2fcdca74baffa1155a272c8deb6de7..b15c8d61e128b477ecf6a7b25c21c4d15c012a7c 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index 84e30447c22c10f03b47ea2be4c4e73fdbe67580..7e2f4f5377e1abdd6731e1815696b89ab0ffede7 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index fedf9db3aa3a47911780100d5253df532d055d83..0262c5f5b90929088497c58c1abfd0bd760c17ee 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index ef0e30f37b297df0b3d70d403ce6fcb8852cd5ba..8de767800b9387b2ab761c14d03d0c5ea4eebabb 100644 (file)
@@ -7,7 +7,7 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
+except liblo.AddressError as err:
     sys.exit(err)
 
 # send message "/foo/message1" with int, float and string arguments
index a5761bd5faac026a541ab920ba1a46f179237edf..1dff54f3d725de9298151ecb4a16a88182f4efbd 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index d0b5fe5f293020bea0fa66fa1a1604d7abc8f8c0..447236711809397ae6ca6b4d7ecbb7c358dbf427 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index 0bfa651d8e82b40d7227858aff64ae30c64d933a..25bd3dc77417894c38b1fa9941e0eeee8397d97b 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index 19c06a1b1a60d3b82fd2eb4960d0cabdfd093a40..0e1919ed1e72e3d8ade1082256961541f52fc532 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index d54af348e439f17370de9f0e286f1b2b9ba252c1..83584b2c16e3365e99ade304736a5202f1369b93 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index b10d0ccd010726c516113e1277d83e7b1a23d892..6e39d2e78b6f057ec8cf1ed128d3e995c34dc469 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments
index 1a339476dd5edecca811f0ca43232e4126189afc..9f5eda16f3432f4023e85cc034f662aecd39af1d 100644 (file)
@@ -7,8 +7,8 @@ import sys
 # send all messages to port 1234 on the local machine
 try:
     target = liblo.Address(1234)
-except liblo.AddressError, err:
-    print str(err)
+except liblo.AddressError as err:
+    print(str(err))
     sys.exit()
 
 # send message "/foo/message1" with int, float and string arguments