Finally remove Desktop symlink code; several compatibility fixes

git-svn-id: svn://svn.berlios.de/gpodder/trunk@433 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2007-09-25 20:06:48 +00:00
parent d303f6ae3b
commit e2db68e087
5 changed files with 24 additions and 39 deletions

View File

@ -1,3 +1,17 @@
Tue, 25 Sep 2007 22:02:19 +0200 <thp@perli.net>
Finally remove Desktop symlink code; several compatibility fixes
* src/gpodder/download.py: Prevent divide-by-zero errors when
calculating download speed
* src/gpodder/gui.py: Prevent divide-by-zero errors when calculating
percentage done in code for moving the downloaded items folder
* src/gpodder/libgpodder.py: Remove the "Symlink on Desktop" code,
because it's not GUI-accessible anymore and we didn't use it anyway
* src/gpodder/opml.py: Better local filename detection by using
os.path.exists() instead of .startswith('/'); this is also good for
cross-platform compatibility where parts don't usually start with a
forward slash (i.e. Win32)
Mon, 24 Sep 2007 00:09:44 +0200 <thp@perli.net>
Channel list selection bug fixes

View File

@ -109,7 +109,10 @@ class DownloadThread(threading.Thread):
now = time.time()
if self.start_time > 0:
passed = now - self.start_time
speed = (count*blockSize)/passed
if passed > 0:
speed = (count*blockSize)/passed
else:
speed = 0
else:
self.start_time = now
passed = now - self.start_time

View File

@ -1469,7 +1469,10 @@ class gPodderProperties(GladeWidget):
while not event.isSet():
new_download_dir_size = util.calculate_size( new_download_dir)
fract = (1.00*new_download_dir_size) / (1.00*download_dir_size)
if download_dir_size > 0:
fract = (1.00*new_download_dir_size) / (1.00*download_dir_size)
else:
fract = 0.0
if fract < 0.99:
myprogressbar.set_text( _('%s of %s') % ( util.format_filesize( new_download_dir_size, 'MB'), download_dir_size_string, ))
else:

View File

@ -58,12 +58,6 @@ from os import unlink
from os import listdir
from glob import glob
# for the desktop symlink stuff:
from os import symlink
from os import stat
from stat import S_ISLNK
from stat import ST_MODE
from libplayers import dotdesktop_command
from types import ListType
@ -240,24 +234,11 @@ class gPodderLibClass( object):
if self.__download_dir and self.__download_dir != new_downloaddir:
log( 'Moving downloads from %s to %s', self.__download_dir, new_downloaddir)
try:
# Save state of Symlink on Desktop
generate_symlink = False
if self.getDesktopSymlink():
log( 'Desktop symlink exists before move.')
generate_symlink = True
# Fix error when moving over disk boundaries
if isdir( new_downloaddir) and not listdir( new_downloaddir):
rmdir( new_downloaddir)
shutil.move( self.__download_dir, new_downloaddir)
if generate_symlink:
# Re-generate Symlink on Desktop
log( 'Will re-generate desktop symlink to %s.', new_downloaddir)
self.removeDesktopSymlink()
self.__download_dir = new_downloaddir
self.createDesktopSymlink()
except:
log( 'Error while moving %s to %s.', self.__download_dir, new_downloaddir)
return
@ -408,23 +389,6 @@ class gPodderLibClass( object):
return ( False, command_line[0] )
return ( True, command_line[0] )
def getDesktopSymlink( self):
symlink_path = expanduser( "~/Desktop/%s" % self.desktop_link)
try:
return lexists( symlink_path)
except:
return exists( symlink_path)
def createDesktopSymlink( self):
if not self.getDesktopSymlink():
downloads_path = expanduser( "~/Desktop/")
util.make_directory( downloads_path)
symlink( self.downloaddir, "%s%s" % (downloads_path, self.desktop_link))
def removeDesktopSymlink( self):
if self.getDesktopSymlink():
unlink( expanduser( "~/Desktop/%s" % self.desktop_link))
def image_download_thread( self, url, callback_pixbuf = None, callback_status = None, callback_finished = None, cover_file = None):
if callback_status != None:
gobject.idle_add( callback_status, _('Downloading channel cover...'))

View File

@ -44,6 +44,7 @@ import xml.sax.saxutils
import urllib
import urllib2
import os.path
import datetime
import gpodder
@ -72,7 +73,7 @@ class Importer(object):
"""
self.items = []
try:
if url.startswith('/'):
if os.path.exists( url):
# assume local filename
doc = xml.dom.minidom.parse( url)
else: