summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-11-24 22:15:54 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-11-24 22:15:54 +0200
commit5c83245e807b713a6724c4fcaf0b4cde302e88ce (patch)
tree6c67f1f329825977c6cc227dc1191c3f5571d6b8
parentd4ae7ee22933c2fc2679e688c3caeb11409f5ba2 (diff)
py3k fixes in preparation of py3k support in mutagen.
-rwxr-xr-xvalosoitin/Valosoitin.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/valosoitin/Valosoitin.py b/valosoitin/Valosoitin.py
index 9898329..3951e26 100755
--- a/valosoitin/Valosoitin.py
+++ b/valosoitin/Valosoitin.py
@@ -27,8 +27,14 @@ import urllib
27import argparse 27import argparse
28import datetime 28import datetime
29import cgi 29import cgi
30import ConfigParser 30try:
31import cPickle 31 import ConfigParser
32except ImportError:
33 from configparser import ConfigParser
34try:
35 import cPickle
36except ImportError:
37 import pickle as cPickle
32 38
33import random 39import random
34random.seed() 40random.seed()
@@ -41,7 +47,10 @@ import logging
41logging.basicConfig(level=logging.DEBUG) 47logging.basicConfig(level=logging.DEBUG)
42 48
43import gettext 49import gettext
44gettext.install("valosoitin", unicode=True) 50try:
51 gettext.install("valosoitin", unicode=True)
52except TypeError:
53 gettext.install("valosoitin")
45 54
46import mutagen 55import mutagen
47import mutagen.mp3 56import mutagen.mp3
@@ -95,7 +104,7 @@ conf = ConfigParser.SafeConfigParser()
95conf_dir = os.path.expanduser(os.path.join("~", ".config", "valosoitin")) 104conf_dir = os.path.expanduser(os.path.join("~", ".config", "valosoitin"))
96conf_path = os.path.join(conf_dir, "valosoitin.conf") 105conf_path = os.path.join(conf_dir, "valosoitin.conf")
97if not os.path.exists(conf_dir): 106if not os.path.exists(conf_dir):
98 os.mkdir(conf_dir, 0700) 107 os.mkdir(conf_dir, 0x700)
99if not os.path.exists(os.path.join(conf_path)): 108if not os.path.exists(os.path.join(conf_path)):
100 conf.add_section("Settings") 109 conf.add_section("Settings")
101 conf.set("Settings", "audio_backend", "gstreamer") 110 conf.set("Settings", "audio_backend", "gstreamer")
@@ -350,8 +359,10 @@ class Valosoitin(object):
350 elif mimetype == "audio/flac": 359 elif mimetype == "audio/flac":
351 try: 360 try:
352 m = mutagen.flac.FLAC(f) 361 m = mutagen.flac.FLAC(f)
353 except mutagen.flac.FLACNoHeaderError, mutagen.flac.FLACVorbisError: 362 except mutagen.flac.FLACNoHeaderError:
354 logging.info("Invalid header in FLAC file.") 363 logging.info("Invalid header in FLAC file.")
364 except mutagen.flac.FLACVorbisError:
365 logging.info("Invalid header in FLAC vorbis file.")
355 elif mimetype == "audio/opus": 366 elif mimetype == "audio/opus":
356 try: 367 try:
357 m = mutagen.oggopus.OggOpus(f) 368 m = mutagen.oggopus.OggOpus(f)