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