2006-12-14 14:08:08 +00:00
|
|
|
#!/usr/bin/python
|
2007-06-11 13:09:24 +01:00
|
|
|
"""
|
|
|
|
Scyther : An automatic verifier for security protocols.
|
|
|
|
Copyright (C) 2007 Cas Cremers
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
"""
|
|
|
|
|
2006-12-14 14:08:08 +00:00
|
|
|
#
|
|
|
|
# Scyther interface error classes
|
|
|
|
#
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Error(Exception):
|
|
|
|
"""Base class for exceptions in this module."""
|
|
|
|
pass
|
|
|
|
|
2007-01-27 21:42:16 +00:00
|
|
|
class ScytherError(Error):
|
|
|
|
"""Exception raised for errors generated by the backend
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
errorlist -- list of error lines are retrieved from the
|
|
|
|
backend
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, errorlist):
|
|
|
|
self.errorlist = errorlist
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
s = "Scyther backend reported the following errors:\n"
|
|
|
|
s = s + "\n".join(self.errorlist)
|
|
|
|
return s
|
|
|
|
|
2006-12-14 14:08:08 +00:00
|
|
|
class InputError(Error):
|
|
|
|
"""Exception raised for errors in the input.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
expression -- input expression in which the error occurred
|
|
|
|
message -- explanation of the error
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, expression, message):
|
|
|
|
self.expression = expression
|
|
|
|
self.message = message
|
|
|
|
|
|
|
|
class BinaryError(Error):
|
|
|
|
"""Raised when the Scyther executable is not found.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
file -- file location at which we should have been able to find it.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, file):
|
|
|
|
self.file = file
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Could not find Scyther executable at '%s'" % (self.file)
|
|
|
|
|
|
|
|
|
2006-12-14 19:46:36 +00:00
|
|
|
class NoBinaryError(Error):
|
|
|
|
"""Raised when the Scyther executable is not defined.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
None.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Scyther class attribute 'program' was not defined."
|
|
|
|
|
|
|
|
|
2006-12-14 14:08:08 +00:00
|
|
|
class UnknownPlatformError(Error):
|
|
|
|
"""Raised when the platform is not supported yet.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
platform -- string describing the platform.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, platform):
|
|
|
|
self.platform = platform
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "The %s platform is currently unsupported." % self.platform
|
2006-12-14 19:46:36 +00:00
|
|
|
|
2007-01-27 12:53:19 +00:00
|
|
|
class StringListError(Error):
|
|
|
|
"""Raised when the a string should be a list of strings or a string
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
obj -- object that did not fit
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, obj):
|
|
|
|
self.obj = obj
|
|
|
|
|
|
|
|
def __str__(self):
|
2007-05-18 13:06:29 +01:00
|
|
|
return "Got '%s', which is type '%s' instead of a (list of) string." % (self.obj, type(self.obj))
|
2006-12-14 19:46:36 +00:00
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 et list lcs=tab\:>-:
|