* fix: get rid of "exception sinks", pheww except actionsapi
* various exception fixes
This commit is contained in:
@@ -124,7 +124,7 @@ def doman(*sourceFiles):
|
||||
pageName, pageDirectory = source[:source.rindex('.')], \
|
||||
source[source.rindex('.')+1:]
|
||||
except ValueError:
|
||||
ctx.ui.error(_('\n!!! ActionsAPI [doman]: Wrong man page file: %s') % (source))
|
||||
ctx.ui.warning(_('ActionsAPI [doman]: Wrong man page file: %s') % (source))
|
||||
|
||||
makedirs(manDIR + '/man%s' % pageDirectory)
|
||||
system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
||||
@@ -162,7 +162,7 @@ def rename(sourceFile, destinationFile):
|
||||
try:
|
||||
os.rename(get.installDIR() + sourceFile, get.installDIR() + baseDir + "/" + destinationFile)
|
||||
except OSError:
|
||||
ctx.ui.error(_('\n!!! ActionsAPI [rename]: No such file or directory: %s') % (sourceFile))
|
||||
ctx.ui.warning(_('ActionsAPI [rename]: No such file or directory: %s') % (sourceFile))
|
||||
|
||||
def dosed(sourceFiles, findPattern, replacePattern = ''):
|
||||
'''replaces patterns in sourceFiles'''
|
||||
@@ -196,7 +196,7 @@ def dosym(sourceFile, destinationFile):
|
||||
try:
|
||||
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
||||
except OSError:
|
||||
ctx.ui.error(_('\n!!! ActionsAPI [dosym]: File exists: %s') % (sourceFile))
|
||||
ctx.ui.warning(_('ActionsAPI [dosym]: File exists: %s') % (sourceFile))
|
||||
|
||||
def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||
'''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
|
||||
|
||||
+1
-11
@@ -84,20 +84,10 @@ def install(packages):
|
||||
else:
|
||||
return install_pkg_names(packages)
|
||||
|
||||
#FIXME: As Gurer warns, something's fishy with this exception proc.
|
||||
except InstallError, e:
|
||||
# FIXME: This is a workaround for __str__ conversion used in
|
||||
# Python exceptions
|
||||
ctx.ui.error(e.args[0])
|
||||
|
||||
except packagedb.Error, e:
|
||||
# FIXME: same workaround...
|
||||
ctx.ui.error("PackageDBError: (%s)" % e.args[0])
|
||||
ctx.ui.error(_("Package is not installable."))
|
||||
raise e
|
||||
|
||||
#except Exception, e:
|
||||
# print e
|
||||
# ctx.ui.error("Error: %s" % e)
|
||||
|
||||
def install_pkg_files(package_URIs):
|
||||
"""install a number of pisi package files"""
|
||||
|
||||
+4
-1
@@ -26,6 +26,9 @@ import pisi.context as ctx
|
||||
from pisi.configfile import ConfigurationFile
|
||||
from pisi.util import join_path as join
|
||||
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
class Config(object):
|
||||
"""Config Singleton"""
|
||||
|
||||
@@ -52,7 +55,7 @@ class Config(object):
|
||||
dir = self.values.general.destinationdirectory
|
||||
import os.path
|
||||
if not os.path.exists(dir):
|
||||
raise Exception, _('Destination directory %s does not exist') % dir
|
||||
raise Error, _('Destination directory %s does not exist') % dir
|
||||
return dir
|
||||
|
||||
def lib_dir(self):
|
||||
|
||||
+4
-2
@@ -42,7 +42,9 @@ import gettext
|
||||
__trans = gettext.translation('pisi', fallback=True)
|
||||
_ = __trans.ugettext
|
||||
|
||||
class ConfigException(Exception):
|
||||
import pisi
|
||||
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
class GeneralDefaults:
|
||||
@@ -84,7 +86,7 @@ class ConfigurationSection(object):
|
||||
self.defaults = DirsDefaults
|
||||
else:
|
||||
e = _("No section by name '%s'") % section
|
||||
raise ConfigException, e
|
||||
raise Error, e
|
||||
|
||||
self.section = section
|
||||
|
||||
|
||||
+8
-8
@@ -32,7 +32,7 @@ import pisi.context as ctx
|
||||
from pisi.uri import URI
|
||||
|
||||
|
||||
class FetchError(pisi.Error):
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
|
||||
@@ -128,19 +128,19 @@ class Fetcher:
|
||||
def fetchRemoteFile (self, archiveFile):
|
||||
from httplib import HTTPException
|
||||
|
||||
uri = self.url.uri
|
||||
try:
|
||||
fileObj = urllib2.urlopen(self.formatRequest\
|
||||
(urllib2.Request(self.url.uri)))
|
||||
fileObj = urllib2.urlopen(self.formatRequest(urllib2.Request(uri)))
|
||||
headers = fileObj.info()
|
||||
|
||||
except ValueError, e:
|
||||
self.err('%s' % (e, ))
|
||||
self.err('Cannot fetch %s; value error: %s' % (uri, e))
|
||||
except IOError, e:
|
||||
self.err('%s' % (e, ))
|
||||
self.err('Cannot fetch %s; %s' % (uri, e))
|
||||
except OSError, e:
|
||||
self.err('%s' % (e, ))
|
||||
self.err('Cannot fetch %s; %s' % (uri, e))
|
||||
except HTTPException, e:
|
||||
self.err(('(%s): %s') % (e.__class__.__name__, e))
|
||||
self.err(('Cannot fetch %s; (%s): %s') % (uri, e.__class__.__name__, e))
|
||||
|
||||
try:
|
||||
totalsize = int(headers['Content-Length'])
|
||||
@@ -158,5 +158,5 @@ class Fetcher:
|
||||
return request
|
||||
|
||||
def err (self, error):
|
||||
raise FetchError(error)
|
||||
raise Error(error)
|
||||
|
||||
|
||||
+2
-2
@@ -322,7 +322,7 @@ def sha1_file(filename):
|
||||
m.update(line)
|
||||
return m.hexdigest()
|
||||
except IOError:
|
||||
return "0"
|
||||
raise FileError(_("Cannot calculate SHA1 hash of %s") % filename)
|
||||
|
||||
def sha1_data(data):
|
||||
"""calculate sha1 hash of given data"""
|
||||
@@ -331,7 +331,7 @@ def sha1_data(data):
|
||||
m.update(data)
|
||||
return m.hexdigest()
|
||||
except:
|
||||
return "0"
|
||||
raise Error(_("Cannot calculate SHA1 hash of given data"))
|
||||
|
||||
def uncompress(patchFile, compressType="gz", targetDir=None):
|
||||
"""uncompresses a file and returns the path of the uncompressed
|
||||
|
||||
Reference in New Issue
Block a user