From 68aa0ccec62f5ad77af456608a8af73b3e289c61 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Fri, 16 Jan 2009 00:03:59 -0800 Subject: [PATCH] reverse the urljoin patch... turns out urljoin doesn't work exactly like os.path.join.. it'll dirname the base and then add the component... not very useful as paths and files cannot be told apart.. urljoin is only useful for relative browsing, not for my use.. [git-p4: depot-paths = "//depot/": change = 1278] --- FSStorage.py | 3 +-- ZipStorage.py | 4 +--- dvd.py | 5 ++--- mpegtsmod.py | 3 +-- pymeds.py | 5 +---- shoutcast.py | 7 +++---- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/FSStorage.py b/FSStorage.py index 7915714..6d2225d 100644 --- a/FSStorage.py +++ b/FSStorage.py @@ -12,7 +12,6 @@ import itertools import os import sets import stat -import urlparse from DIDLLite import Container, StorageFolder, Item, VideoItem, AudioItem, TextItem, ImageItem, Resource, ResourceList from twisted.web import resource, server, static @@ -199,7 +198,7 @@ class FSItem(FSObject, Item): kwargs['content'] = DynamicTrans(self.FSpath, static.File(self.FSpath, mimetype)) Item.__init__(self, *args, **kwargs) - self.url = urlparse.urljoin(self.cd.urlbase, self.id) + self.url = '%s/%s' % (self.cd.urlbase, self.id) self.mimetype = mimetype self.checkUpdate() diff --git a/ZipStorage.py b/ZipStorage.py index 413b47b..649268a 100644 --- a/ZipStorage.py +++ b/ZipStorage.py @@ -8,8 +8,6 @@ import itertools import os.path import sets import time -import urlparse - import iterzipfile zipfile = iterzipfile import itertarfile @@ -172,7 +170,7 @@ class ZipFile(ZipItem, Item): kwargs['content'] = ZipResource(self.zf, self.name, self.mimetype) Item.__init__(self, *args, **kwargs) - self.url = urlparse.urljoin(self.cd.urlbase, self.id) + self.url = '%s/%s' % (self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype) self.res.size = self.zi.file_size diff --git a/dvd.py b/dvd.py index e176e4f..ffe9e0d 100644 --- a/dvd.py +++ b/dvd.py @@ -10,7 +10,6 @@ default_audio_lang = 'en' import itertools import os import sets -import urlparse import sys sys.path.append('mpegts') @@ -115,7 +114,7 @@ class DVDChapter(VideoItem): p = audio.pos: audiofilter(i, 0x80 + p)) VideoItem.__init__(self, *args, **kwargs) - self.url = urlparse.urljoin(self.cd.urlbase, self.id) + self.url = '%s/%s' % (self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:video/mpeg:*') #self.res.size = self.chapter.size @@ -133,7 +132,7 @@ class DVDTitle(StorageFolder): p = audio.pos: audiofilter(itertools.chain(*dt), 0x80 + p)) StorageFolder.__init__(self, *args, **kwargs) - self.url = urlparse.urljoin(self.cd.urlbase, self.id) + self.url = '%s/%s' % (self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:video/mpeg:*') # mapping from path to objectID diff --git a/mpegtsmod.py b/mpegtsmod.py index e65380f..7d07688 100644 --- a/mpegtsmod.py +++ b/mpegtsmod.py @@ -13,7 +13,6 @@ import itertools import os import sets import struct -import urlparse import sys mpegtspath = 'mpegts' @@ -294,7 +293,7 @@ class MPEGTS(FSObject, VideoItem): VideoItem.__init__(self, *args, **kwargs) FSObject.__init__(self, path) - self.url = urlparse.urljoin(self.cd.urlbase, self.id) + self.url = '%s/%s' % (self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:video/mpeg:*') def doUpdate(self): diff --git a/pymeds.py b/pymeds.py index f0cd132..e100213 100755 --- a/pymeds.py +++ b/pymeds.py @@ -124,10 +124,7 @@ def makeService(config): if uuid is None: uuid = generateuuid() - # XXX - may cause troubles if people aren't using urljoin, add a / to - # the first empty string arg to troubleshoot - urlbase = urlparse.urlunparse(('http', '%s:%s' % (listenAddr, - listenPort), '', '', '', '')) + urlbase = 'http://%s:%d/' % (listenAddr, listenPort) # Create SOAP server and content server from twisted.web import server, resource, static diff --git a/shoutcast.py b/shoutcast.py index 7d87d91..81c097d 100644 --- a/shoutcast.py +++ b/shoutcast.py @@ -15,7 +15,6 @@ import ConfigParser import StringIO import os.path import random -import urlparse import traceback @@ -285,11 +284,11 @@ class ShoutStation(AudioItem): kwargs['content'] = ShoutProxy(self.station['PLS_URL'], self.station['MimeType'].encode('ascii')) AudioItem.__init__(self, *args, **kwargs) - self.url = urlparse.urljoin(self.cd.urlbase, self.id) + self.url = '%s/%s' % (self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:%s:*' % \ self.station['MimeType'].encode('ascii')) - #self.res = Resource(urlparse.urljoin(self.url, 'pcm'), - # 'http-get:*:%s:*' % 'audio/x-wav') + #self.res = Resource(self.url + '/pcm', 'http-get:*:%s:*' % \ + # 'audio/x-wav') self.bitrate = self.station['Bitrate'] * 128 # 1024k / 8bit class ShoutGenre(MusicGenre):