diff --git a/.travis.yml b/.travis.yml index 2ac2879..714e171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,18 @@ language: python -python: - - "2.7" + +matrix: + include: + - python: 3.7 + os: linux + compiler: gcc + virtualenv: system_site_packages: true # command to prepare the system to install prerequisites or dependencies before_install: - sudo apt-get install -qq python-setuptools - - sudo apt-get install -qq python-pip python-dev libshout3-dev python-liblo python-mutagen python-pycurl liblo-dev libshout3-dev librtmp-dev python-yaml libcurl4-openssl-dev python-mutagen + - sudo apt-get install -qq python-pip python-dev libshout3-dev python-liblo python-mutagen python-pycurl liblo-dev libshout3-dev librtmp-dev python-yaml libcurl4-openssl-dev python-mutagen libmariadbclient-dev # command to run tests script: diff --git a/README.rst b/README.rst index 080566a..ccde926 100644 --- a/README.rst +++ b/README.rst @@ -98,7 +98,7 @@ an install inside Gygwin should work well. To install it, say on Debian, do:: - sudo apt-get install python-pip python-dev python-liblo \ + sudo apt-get install python3-pip python3-dev cython3 python-liblo \ python-mutagen python-pycurl python-yaml \ libshout3-dev librtmp-dev liblo-dev \ libcurl4-openssl-dev libmariadbclient-dev diff --git a/deefuzzer/__init__.py b/deefuzzer/__init__.py index b27f3b4..f82e626 100644 --- a/deefuzzer/__init__.py +++ b/deefuzzer/__init__.py @@ -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.4' +__version__ = '0.8.0' diff --git a/deefuzzer/core.py b/deefuzzer/core.py index a43617e..2b87a88 100644 --- a/deefuzzer/core.py +++ b/deefuzzer/core.py @@ -5,43 +5,30 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + + 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 +45,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 +54,11 @@ def __init__(self, conf_file): 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 +67,8 @@ def __init__(self, conf_file): 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 +101,7 @@ def __init__(self, conf_file): # 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 +191,7 @@ def create_station(self, folder, options): 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 +248,7 @@ def add_station(self, this_station): return def run(self): - q = Queue.Queue(1) + q = queue.Queue(1) ns = 0 p = Producer(q) p.start() @@ -317,12 +306,12 @@ def run(self): 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) diff --git a/deefuzzer/player.py b/deefuzzer/player.py index ac7fe06..adbed42 100644 --- a/deefuzzer/player.py +++ b/deefuzzer/player.py @@ -5,38 +5,23 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin - -from relay import * +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + + +from .relay import * import time @@ -80,7 +65,7 @@ def file_read_fast(self): 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 +107,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 +122,7 @@ def read_callback(self, size): except: while True: try: - self.relay = urllib.urlopen(self.__relayparam) + self.relay = urllib.request.urlopen(self.__relayparam) chunk = self.relay.read(size) break except: diff --git a/deefuzzer/recorder.py b/deefuzzer/recorder.py index 4ddb312..187e06c 100644 --- a/deefuzzer/recorder.py +++ b/deefuzzer/recorder.py @@ -5,36 +5,22 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + + import os diff --git a/deefuzzer/relay.py b/deefuzzer/relay.py index b3d7c9a..ab96384 100644 --- a/deefuzzer/relay.py +++ b/deefuzzer/relay.py @@ -5,40 +5,25 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. +# This file is part of deefuzzer -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". +# 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, either version 3 of the License, or +# (at your option) any later version. -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin from threading import Thread -import Queue -import urllib +import queue +import urllib.request, urllib.parse, urllib.error class Relay(Thread): @@ -47,7 +32,7 @@ def __init__(self, sub_buffer_size, queue_size): 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 +40,7 @@ def set_url(self, url): def open(self): try: - self.stream = urllib.urlopen(self.url) + self.stream = urllib.request.urlopen(self.url) self.isopen = True except: self.isopen = False diff --git a/deefuzzer/station.py b/deefuzzer/station.py index d31838d..37ce72f 100644 --- a/deefuzzer/station.py +++ b/deefuzzer/station.py @@ -5,36 +5,21 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + import os import sys @@ -43,18 +28,18 @@ 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 +441,7 @@ def get_playlist(self): 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 +486,7 @@ def get_playlist(self): 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 +599,7 @@ def media_to_objs(self, media_list): 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 +633,7 @@ def update_feeds(self, media_list, rss_file, sub_title): media_description = '' media_description_item = '' - 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 +734,8 @@ def get_songmeta(self, mediaobj): song = mediaobj.get_song(True) except: pass - + + # print(title, artist, song) return title, artist, song def get_currentsongmeta(self): @@ -832,7 +818,7 @@ def ping_server(self): 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 +842,7 @@ def icecastloop_nextmedia(self): self.set_read_mode() return True - except Exception, e: + except Exception as e: self._err('icecastloop_nextmedia: Error: ' + str(e)) return False @@ -879,9 +865,9 @@ def icecastloop_metadata(self): 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 diff --git a/deefuzzer/streamer.py b/deefuzzer/streamer.py index 54fb5ca..6977735 100644 --- a/deefuzzer/streamer.py +++ b/deefuzzer/streamer.py @@ -5,36 +5,21 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + from threading import Thread diff --git a/deefuzzer/tools/PyRSS2Gen.py b/deefuzzer/tools/PyRSS2Gen.py index 56b249a..17c090b 100644 --- a/deefuzzer/tools/PyRSS2Gen.py +++ b/deefuzzer/tools/PyRSS2Gen.py @@ -24,10 +24,10 @@ def write_xml(self, outfile, encoding="iso-8859-1"): 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 @@ def to_xml(self, encoding="iso-8859-1"): 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 @@ def publish(self, handler): _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 @@ def publish(self, handler): _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) diff --git a/deefuzzer/tools/__init__.py b/deefuzzer/tools/__init__.py index 276c198..0ccf127 100644 --- a/deefuzzer/tools/__init__.py +++ b/deefuzzer/tools/__init__.py @@ -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 * diff --git a/deefuzzer/tools/get_access_token.py b/deefuzzer/tools/get_access_token.py index 6801019..0158a22 100644 --- a/deefuzzer/tools/get_access_token.py +++ b/deefuzzer/tools/get_access_token.py @@ -19,7 +19,7 @@ # 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_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('') diff --git a/deefuzzer/tools/mediabase.py b/deefuzzer/tools/mediabase.py index ee74697..9fca41f 100644 --- a/deefuzzer/tools/mediabase.py +++ b/deefuzzer/tools/mediabase.py @@ -80,7 +80,7 @@ def get_file_metadata(self, clear_cache=False): 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 @@ def get_metadata_value(self, key, clean=False, clear_cache=False): 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""" diff --git a/deefuzzer/tools/mp3.py b/deefuzzer/tools/mp3.py index bc14cd6..47ea9ce 100644 --- a/deefuzzer/tools/mp3.py +++ b/deefuzzer/tools/mp3.py @@ -42,7 +42,7 @@ 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 @@ def write_tags(self): 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() ''' diff --git a/deefuzzer/tools/ogg.py b/deefuzzer/tools/ogg.py index 8f9adea..e0dc15f 100644 --- a/deefuzzer/tools/ogg.py +++ b/deefuzzer/tools/ogg.py @@ -40,7 +40,7 @@ import string import datetime from mutagen.oggvorbis import OggVorbis -from utils import * +from .utils import * class Ogg(MediaBase): @@ -102,7 +102,7 @@ def decode(self): 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 @@ def get_args(self, options=None): 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: diff --git a/deefuzzer/tools/osc.py b/deefuzzer/tools/osc.py index b4bb72a..29a627e 100644 --- a/deefuzzer/tools/osc.py +++ b/deefuzzer/tools/osc.py @@ -5,36 +5,21 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + from threading import Thread @@ -47,8 +32,8 @@ def __init__(self, port): 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) diff --git a/deefuzzer/tools/streamer.py b/deefuzzer/tools/streamer.py index bc95923..4267502 100644 --- a/deefuzzer/tools/streamer.py +++ b/deefuzzer/tools/streamer.py @@ -5,36 +5,21 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + from threading import Thread diff --git a/deefuzzer/tools/twitt.py b/deefuzzer/tools/twitt.py index d487dd1..7475061 100644 --- a/deefuzzer/tools/twitt.py +++ b/deefuzzer/tools/twitt.py @@ -5,36 +5,21 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + # Twitter DeeFuzzer keys DEEFUZZER_CONSUMER_KEY = 'ozs9cPS2ci6eYQzzMSTb4g' diff --git a/deefuzzer/tools/utils.py b/deefuzzer/tools/utils.py index fb70538..7b74f07 100644 --- a/deefuzzer/tools/utils.py +++ b/deefuzzer/tools/utils.py @@ -16,6 +16,7 @@ import mimetypes from itertools import chain from deefuzzer.tools import * +import xmltodict mimetypes.add_type('application/x-yaml', '.yaml') @@ -71,12 +72,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 @@ -90,20 +91,12 @@ def get_conf_dict(file): confile = open(file, 'r') data = confile.read() confile.close() - return xmltodict(data, 'utf-8') + return xmltodict.parse(data) 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: diff --git a/deefuzzer/tools/webm.py b/deefuzzer/tools/webm.py index f39eff0..85ab2d6 100644 --- a/deefuzzer/tools/webm.py +++ b/deefuzzer/tools/webm.py @@ -39,7 +39,7 @@ import os import string import datetime -from utils import * +from .utils import * class WebM(MediaBase): diff --git a/deefuzzer/tools/xmltodict2.py b/deefuzzer/tools/xmltodict2.py index bf0ea46..2a59523 100644 --- a/deefuzzer/tools/xmltodict2.py +++ b/deefuzzer/tools/xmltodict2.py @@ -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("<", "<") if "code" in dct: - if len(dct["code"].keys()): + if len(list(dct["code"].keys())): ret += "%s%s%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%s" % ("\t" * (level + 1), eol) if "properties" in dct: - if len(dct["properties"].keys()): + if len(list(dct["properties"].keys())): ret += "%s%s%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" % (itmTab, propItm, itmVal, propItm, eol) ret += "%s%s" % (currTab, prop, eol) diff --git a/requirements.txt b/requirements.txt index 897fb90..4e6fc20 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,10 @@ setuptools --e . \ No newline at end of file +python-shout==0.2.6 +python-twitter==3.5 +mutagen==1.43.0 +pyliblo==0.10.0 +pycurl==7.43.0.2 +pyyaml==3.13 +mysqlclient==1.4.6 +xmltodict==0.12.0 +-e . diff --git a/scripts/deefuzzer b/scripts/deefuzzer index 3c9c6ef..e728514 100755 --- a/scripts/deefuzzer +++ b/scripts/deefuzzer @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys diff --git a/scripts/dev/xml2yaml.py b/scripts/dev/xml2yaml.py index bcc0174..0f60341 100755 --- a/scripts/dev/xml2yaml.py +++ b/scripts/dev/xml2yaml.py @@ -5,36 +5,21 @@ # -# This software is a computer program whose purpose is to stream audio -# and video data through icecast2 servers. - -# This software is governed by the CeCILL license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". - -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. - -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. - -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -# Author: Guillaume Pellerin +# This file is part of deefuzzer + +# 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, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + import sys diff --git a/scripts/osc/osc_jingles_start.py b/scripts/osc/osc_jingles_start.py index 6e5177c..b15c8d6 100644 --- a/scripts/osc/osc_jingles_start.py +++ b/scripts/osc/osc_jingles_start.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_jingles_stop.py b/scripts/osc/osc_jingles_stop.py index 84e3044..7e2f4f5 100644 --- a/scripts/osc/osc_jingles_stop.py +++ b/scripts/osc/osc_jingles_stop.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_player_fast.py b/scripts/osc/osc_player_fast.py index fedf9db..0262c5f 100644 --- a/scripts/osc/osc_player_fast.py +++ b/scripts/osc/osc_player_fast.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_player_next.py b/scripts/osc/osc_player_next.py index ef0e30f..8de7678 100644 --- a/scripts/osc/osc_player_next.py +++ b/scripts/osc/osc_player_next.py @@ -7,7 +7,7 @@ # 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 diff --git a/scripts/osc/osc_player_slow.py b/scripts/osc/osc_player_slow.py index a5761bd..1dff54f 100644 --- a/scripts/osc/osc_player_slow.py +++ b/scripts/osc/osc_player_slow.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_record_start.py b/scripts/osc/osc_record_start.py index d0b5fe5..4472367 100644 --- a/scripts/osc/osc_record_start.py +++ b/scripts/osc/osc_record_start.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_record_stop.py b/scripts/osc/osc_record_stop.py index 0bfa651..25bd3dc 100644 --- a/scripts/osc/osc_record_stop.py +++ b/scripts/osc/osc_record_stop.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_relay_start.py b/scripts/osc/osc_relay_start.py index 19c06a1..0e1919e 100644 --- a/scripts/osc/osc_relay_start.py +++ b/scripts/osc/osc_relay_start.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_relay_stop.py b/scripts/osc/osc_relay_stop.py index d54af34..83584b2 100644 --- a/scripts/osc/osc_relay_stop.py +++ b/scripts/osc/osc_relay_stop.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_twitter_start.py b/scripts/osc/osc_twitter_start.py index b10d0cc..6e39d2e 100644 --- a/scripts/osc/osc_twitter_start.py +++ b/scripts/osc/osc_twitter_start.py @@ -7,8 +7,8 @@ # 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 diff --git a/scripts/osc/osc_twitter_stop.py b/scripts/osc/osc_twitter_stop.py index 1a33947..9f5eda1 100644 --- a/scripts/osc/osc_twitter_stop.py +++ b/scripts/osc/osc_twitter_stop.py @@ -7,8 +7,8 @@ # 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 diff --git a/setup.py b/setup.py index 7f5337e..a77a123 100644 --- a/setup.py +++ b/setup.py @@ -6,8 +6,8 @@ from setuptools import setup, find_packages CLASSIFIERS = [ - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Multimedia :: Sound/Audio', 'Topic :: Multimedia :: Sound/Audio :: Players', @@ -21,16 +21,18 @@ long_description=open('README.rst').read(), author="Guillaume Pellerin", author_email="yomguy@parisson.com", - version='0.7.4', + version='0.8.0', install_requires=[ 'setuptools', + 'wheel', 'python-shout==0.2.6', - 'python-twitter', - 'mutagen', - 'pyliblo', - 'pycurl', - 'pyyaml', - 'mysqlclient', + 'python-twitter==3.5', + 'mutagen==1.43.0', + 'pyliblo==0.10.0', + 'pycurl==7.43.0.2', + 'pyyaml==3.13', + 'mysqlclient==1.4.6', + 'xmltodict==0.12.0', ], platforms=['OS Independent'], license='GPL v3', @@ -39,5 +41,5 @@ packages=find_packages(), include_package_data=True, zip_safe=False, - python_requires='<=2.7.16', + python_requires='>=3', )
%s: %s