Skip to content

Commit

Permalink
tagging and cleanup for 0.9 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
sccolbert committed Jun 27, 2010
1 parent 19386a3 commit 54ef344
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 814 deletions.
4 changes: 2 additions & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ README.txt
setup.py
./bin/pymazon
./pymazon/__init__.py
./pymazon/cmd/__init__.py
./pymazon/cmd/ui.py
./pymazon/core/__init__.py
./pymazon/core/decryptor.py
./pymazon/core/downloader.py
Expand All @@ -14,8 +16,6 @@ setup.py
./pymazon/core/settings.py
./pymazon/core/tree_model.py
./pymazon/gtk/__init__.py
./pymazon/gtk/gtkgui.py
./pymazon/gtk/tester.py
./pymazon/gtk/tree_model.py
./pymazon/gtk/ui.py
./pymazon/qt/__init__.py
Expand Down
11 changes: 5 additions & 6 deletions bin/pymazon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import sys
#for dev only
sys.path.append('/home/brucewayne/development/pymazon/hg')

from pymazon.core.options import parse_options
from pymazon.core.settings import settings
Expand All @@ -33,7 +31,7 @@ logger = PymazonLogger('main')
def main():
entry, amzs = parse_options()
if entry == 'cmd':
if not amzs:
if not amzs:
raise ValueError('No .amz files specified.')
from pymazon.cmd.ui import main
main(amzs)
Expand All @@ -42,7 +40,7 @@ def main():
from pymazon.qt.ui import main
main(amzs)
except ImportError, e:
print e
logger.error(e)
msg = ('Unable to import PyQt4. You can still use Pymazon '
'via the commmand line with the -c switch. '
'Type `pymazon --help` for more info.')
Expand All @@ -51,7 +49,8 @@ def main():
try:
from pymazon.gtk.ui import main
main(amzs)
except ImportError:
except ImportError, e:
logger.error(e)
msg = ('Unable to import PyGtk. You can still use Pymazon '
'via the commmand line with the -c switch. '
'Type `pymazon --help` for more info.')
Expand Down
7 changes: 3 additions & 4 deletions pymazon/cmd/ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -19,12 +19,11 @@
import os
import sys

from pymazon.core.downloader import Downloader
from pymazon.core.item_model import Track
from pymazon.core.tree_model import TreeModel
from pymazon.core.parser import AmzParser
from pymazon.core.downloader import Downloader
from pymazon.core.settings import settings

from pymazon.core.tree_model import TreeModel


pymazon_splash = """
Expand Down
5 changes: 3 additions & 2 deletions pymazon/core/decryptor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -16,9 +16,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

import sys
import base64
from cStringIO import StringIO
import sys

try:
from Crypto.Cipher import DES
Expand All @@ -30,6 +30,7 @@

from pymazon.util.log_util import PymazonLogger


logger = PymazonLogger('decryptor')


Expand Down
11 changes: 6 additions & 5 deletions pymazon/core/downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -16,16 +16,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

import urllib2
import threading
from cStringIO import StringIO
from collections import deque
from cStringIO import StringIO
import threading
import urllib2

from pymazon.core.item_model import Downloadable
from pymazon.core.tree_model import TreeModel
from pymazon.core.settings import settings
from pymazon.core.tree_model import TreeModel
from pymazon.util.log_util import PymazonLogger


logger = PymazonLogger('downloader')


Expand Down
8 changes: 4 additions & 4 deletions pymazon/core/item_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(self, url=None):
super(Downloadable, self).__init__()
self.url = url

def _safe_save_name(self, fname):
def _safe_save_name(self, fname):
# ensure we don't overwrite any files
i = 1
nfname = fname
Expand Down Expand Up @@ -121,9 +121,9 @@ def save(self, data):
sn = template.safe_substitute(artist=self.album.artist,
title=self.title,
tracknum=self.number,
album=self.album.title)
album=self.album.title)

save_path = os.path.join(settings.save_dir, sn + '.' + self.extension)
save_path = os.path.join(settings.save_dir, sn + '.' + self.extension)
super(Track, self).save(save_path, data)

def __unicode__(self):
Expand Down
4 changes: 1 addition & 3 deletions pymazon/core/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -17,7 +17,6 @@
"""

import os

from optparse import OptionParser

from pymazon.core.settings import settings
Expand Down Expand Up @@ -87,7 +86,6 @@ def parse_options():
'downloader. i.e. the number of simultaneous '
'downloads. When using the command line interfaces, '
'the number of threads is always 1.')


options, args = parser.parse_args()

Expand Down
4 changes: 2 additions & 2 deletions pymazon/core/parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -20,7 +20,7 @@
from xml.parsers import expat

from pymazon.core.decryptor import AmzDecryptor
from pymazon.core.item_model import Album, Track, OtherMedia
from pymazon.core.item_model import Album, OtherMedia, Track


class ParseException(Exception):
Expand Down
30 changes: 24 additions & 6 deletions pymazon/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -16,10 +16,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

from ConfigParser import ConfigParser, NoOptionError, NoSectionError
import os
import sys
import warnings
from ConfigParser import ConfigParser, NoOptionError, NoSectionError


def pymazon_showwarning(message, category, *args):
print 'Warning:'
Expand Down Expand Up @@ -49,10 +50,24 @@ def _get_pymazon_dir():
'access is granted. Then, restart Pymazon.' % pymazon_dir)
sys.exit(0)


def _get_default_toolkit():
# try qt first, then gtk, if neither, use qt
try:
import PyQt4
toolkit = 'qt4'
except ImportError:
try:
import pygtk
toolkit = 'gtk'
except ImportError:
toolkit = 'qt4'
return toolkit


#-------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Program-wide settings Class
#-------------------------------------------------------------------------------
#------------------------------------------------------------------------------

class PymazonSettingsError(Exception):
pass
Expand All @@ -65,7 +80,7 @@ def __init__(self):
self._config_file = os.path.join(self._pymazon_dir, 'pymazonrc')
self._save_dir = os.environ.get('XDG_MUSIC_DIR', os.getcwd())
self._name_template = '${tracknum} - ${title}'
self._toolkit = 'qt4'
self._toolkit = None # will be figured out in read/write_config_file
self._num_threads = 1
self._read_config_file()

Expand All @@ -86,7 +101,7 @@ def _get_name_template(self):
return self._name_template

def _set_name_template(self, value):
template_string = str(value)
template_string = str(value).lstrip(os.path.sep)
self._name_template = template_string

name_template = property(_get_name_template, _set_name_template)
Expand Down Expand Up @@ -117,6 +132,9 @@ def _set_num_threads(self, val):
num_threads = property(_get_num_threads, _set_num_threads)

def write_config_file(self):
# don't do unnecessary imports if the user already has a config file.
if self._toolkit is None:
self._toolkit = _get_default_toolkit()
cp = '''\
[config]
save_dir = %s
Expand Down
2 changes: 1 addition & 1 deletion pymazon/core/tree_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Pymazon - A Python based downloader for the Amazon.com MP3 store
Copyright (c) 2009 Steven C. Colbert
Copyright (c) 2010 Steven C. Colbert
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand Down
Loading

0 comments on commit 54ef344

Please sign in to comment.