Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Python3 into Master #389

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

python ?= python2.7
python ?= python3
user ?= $(shell whoami)

all: pulseaudio_dlna.egg-info
Expand Down
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,21 @@ is loaded.
These are the requirements _pulseaudio-dlna_ acutally needs to run. These dependencies
will get installed if you install it via the PPA.

- python2.7
- python-pip
- python-setuptools
- python-dbus
- python-docopt
- python-requests
- python-setproctitle
- python-gi
- python-protobuf
- python-notify2
- python-psutil
- python-concurrent.futures
- python-chardet
- python-netifaces
- python-pyroute2 | python-netaddr
- python-lxml
- python-zeroconf
- python3
- python3-pip
- python3-setuptools
- python3-dbus
- python3-docopt
- python3-requests
- python3-setproctitle
- python3-gi
- python3-notify2
- python3-psutil
- python3-chardet
- python3-netifaces
- python3-pyroute2 | python3-netaddr
- python3-lxml
- python3-pychromecast
- vorbis-tools
- sox
- lame
Expand All @@ -278,7 +276,7 @@ will get installed if you install it via the PPA.

You can install all the dependencies in Ubuntu via:

sudo apt-get install python2.7 python-pip python-setuptools python-dbus python-docopt python-requests python-setproctitle python-gi python-protobuf python-notify2 python-psutil python-concurrent.futures python-chardet python-netifaces python-pyroute2 python-netaddr python-lxml python-zeroconf vorbis-tools sox lame flac faac opus-tools
sudo apt-get install python3 python3-pip python3-setuptools python3-dbus python3-docopt python3-requests python3-setproctitle python3-gi python3-notify2 python3-psutil python3-chardet python3-netifaces python3-pyroute2 python3-netaddr python3-lxml python3-pychromecast vorbis-tools sox lame flac faac opus-tools

### PulseAudio DBus module ###

Expand Down Expand Up @@ -314,7 +312,7 @@ So all Ubuntu versions prior to _14.10 Utopic_ need to install:

All Ubuntu versions above install:

sudo apt-get install virtualenv python-dev
sudo apt-get install virtualenv python3-dev

#### Installing & starting ####

Expand Down
2 changes: 1 addition & 1 deletion man/pulseaudio-dlna.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.2.
.TH PULSEAUDIO-DLNA "1" "April 2016" "pulseaudio-dlna 0.5.2" "User Commands"
.TH PULSEAUDIO-DLNA "1" "April 2016" "pulseaudio-dlna 0.6.0" "User Commands"
.SH NAME
pulseaudio-dlna \- Stream audio to DLNA devices and Chromecasts
.SH DESCRIPTION
Expand Down
8 changes: 3 additions & 5 deletions pulseaudio_dlna/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,12 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

import os
import pkg_resources

import utils.git
from .utils import git

try:
version = pkg_resources.get_distribution(__package__).version
Expand All @@ -30,7 +28,7 @@
if os.environ.get('USE_PKG_VERSION', None) == '1':
branch, rev = None, None
else:
branch, rev = utils.git.get_head_version()
branch, rev = git.get_head_version()

__version__ = '{version}{rev}'.format(
version=version,
Expand Down
6 changes: 2 additions & 4 deletions pulseaudio_dlna/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand Down Expand Up @@ -115,9 +115,6 @@

'''


from __future__ import unicode_literals

import sys
import os
import docopt
Expand Down Expand Up @@ -170,5 +167,6 @@ def acquire_lock():
except socket.error:
return False


if __name__ == "__main__":
sys.exit(main())
14 changes: 5 additions & 9 deletions pulseaudio_dlna/application.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

import multiprocessing
import signal
import setproctitle
Expand All @@ -33,7 +31,6 @@
import pulseaudio_dlna.plugins.dlna.ssdp.listener
import pulseaudio_dlna.plugins.dlna.ssdp.discover
import pulseaudio_dlna.plugins.chromecast
import pulseaudio_dlna.plugins.chromecast.mdns
import pulseaudio_dlna.encoders
import pulseaudio_dlna.covermodes
import pulseaudio_dlna.streamserver
Expand All @@ -47,7 +44,6 @@

class Application(object):

ENCODING = 'utf-8'
DEVICE_CONFIG_PATHS = [
os.path.expanduser('~/.local/share/pulseaudio-dlna'),
'/etc/pulseaudio-dlna',
Expand Down Expand Up @@ -213,7 +209,7 @@ def run(self, options):
logger.info(' {}'.format(encoder))

logger.info('Codec settings:')
for identifier, _type in pulseaudio_dlna.codecs.CODECS.iteritems():
for identifier, _type in pulseaudio_dlna.codecs.CODECS.items():
codec = _type()
logger.info(' {}'.format(codec))

Expand Down Expand Up @@ -331,9 +327,9 @@ def obj_to_dict(obj):
continue
try:
with open(config_file, 'w') as h:
h.write(json_text.encode(self.ENCODING))
h.write(json_text)
logger.info('Found the following devices:')
for device in holder.devices.values():
for device in list(holder.devices.values()):
logger.info('{name} ({flavour})'.format(
name=device.name, flavour=device.flavour))
for codec in device.codecs:
Expand All @@ -356,7 +352,7 @@ def read_device_config(self):
if os.path.isfile(config_file) and \
os.access(config_file, os.R_OK):
with open(config_file, 'r') as h:
json_text = h.read().decode(self.ENCODING)
json_text = h.read()
logger.debug('Device configuration:\n{}'.format(json_text))
json_text = json_text.replace('\n', '')
try:
Expand Down
11 changes: 5 additions & 6 deletions pulseaudio_dlna/codecs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

import functools
import logging
import re
Expand Down Expand Up @@ -67,7 +65,7 @@ def set_backend(backend):
def set_codecs(identifiers):
step = 3
priority = (len(CODECS) + 1) * step
for identifier, _type in CODECS.iteritems():
for identifier, _type in CODECS.items():
_type.ENABLED = False
_type.PRIORITY = 0
for identifier in identifiers:
Expand All @@ -81,7 +79,7 @@ def set_codecs(identifiers):

def enabled_codecs():
codecs = []
for identifier, _type in CODECS.iteritems():
for identifier, _type in CODECS.items():
if _type.ENABLED:
codecs.append(_type())
return codecs
Expand Down Expand Up @@ -168,7 +166,7 @@ def __str__(self, detailed=False):
def to_json(self):
attributes = ['priority', 'suffix', 'mime_type']
d = {
k: v for k, v in self.__dict__.iteritems()
k: v for k, v in iter(self.__dict__.items())
if k not in attributes
}
d['mime_type'] = self.specific_mime_type
Expand Down Expand Up @@ -363,4 +361,5 @@ def load_codecs():
CODECS[_type.IDENTIFIER] = _type
return None


load_codecs()
11 changes: 5 additions & 6 deletions pulseaudio_dlna/covermodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

import sys
import inspect
import socket
Expand Down Expand Up @@ -82,7 +80,7 @@ class DefaultCoverMode(BaseCoverMode):
def thumb(self):
try:
return self.bridge.device.get_image_url('default.png')
except:
except Exception:
return None


Expand Down Expand Up @@ -111,7 +109,7 @@ def thumb(self):
try:
return self.bridge.device.get_image_url(
'distribution-{}.png'.format(dist_icon))
except:
except Exception:
return None


Expand All @@ -124,7 +122,7 @@ def thumb(self):
try:
return self.bridge.device.get_sys_icon_url(
self.bridge.sink.primary_application_name)
except:
except Exception:
return None


Expand All @@ -136,4 +134,5 @@ def load_modes():
MODES[_type.IDENTIFIER] = _type
return None


load_modes()
7 changes: 4 additions & 3 deletions pulseaudio_dlna/daemon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from gi.repository import GObject

import dbus
Expand Down Expand Up @@ -250,6 +248,9 @@ def __eq__(self, other):
def __gt__(self, other):
return self.pid > other.pid

def __hash__(self):
return self.pid


class PulseAudioFinder(object):
@staticmethod
Expand Down
22 changes: 9 additions & 13 deletions pulseaudio_dlna/encoders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

import distutils.spawn
import inspect
import sys
Expand Down Expand Up @@ -66,10 +64,7 @@ def _find_executable(path):
# The distutils module uses python's ascii default encoding and is
# therefore not capable of handling unicode properly when it contains
# non-ascii characters.
encoding = 'utf-8'
result = distutils.spawn.find_executable(path.encode(encoding))
if result is not None and type(result) is str:
result = result.decode(encoding)
result = distutils.spawn.find_executable(path)
return result


Expand Down Expand Up @@ -113,7 +108,7 @@ def supported_bit_rates(self):
def __str__(self):
return '<{} available="{}">'.format(
self.__class__.__name__,
unicode(self.available),
str(self.available),
)


Expand All @@ -139,8 +134,8 @@ def supported_bit_rates(self):
def __str__(self):
return '<{} available="{}" bit-rate="{}">'.format(
self.__class__.__name__,
unicode(self.available),
unicode(self.bit_rate),
str(self.available),
str(self.bit_rate),
)


Expand All @@ -165,9 +160,9 @@ def channels(self, value):
def __str__(self):
return '<{} available="{}" sample-rate="{}" channels="{}">'.format(
self.__class__.__name__,
unicode(self.available),
unicode(self.sample_rate),
unicode(self.channels),
str(self.available),
str(self.sample_rate),
str(self.channels),
)


Expand All @@ -194,4 +189,5 @@ def load_encoders():
ENCODERS.append(_type)
return None


load_encoders()
4 changes: 1 addition & 3 deletions pulseaudio_dlna/encoders/avconv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# This file is part of pulseaudio-dlna.

Expand All @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with pulseaudio-dlna. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

import logging

from pulseaudio_dlna.encoders.ffmpeg import (
Expand Down
Loading