import os import util class TPException(Exception): def __str__(self): return "%s: %s" % (self.__class__.__name__, Exception.__str__(self)) class InvalidReference (TPException): pass class AccessDenied (TPException): pass class UnavailableResource (TPException): pass class IncompleteSubject (TPException): def __init__(self): pass class NoSuchDomain (TPException): pass class NoSuchMethod (TPException): pass class InspectorNotFound (TPException): pass class UnavailableInspector (TPException): pass class SkinNotFound (TPException): pass class MissingDependency (TPException): pass class InternalError (TPException): pass class InterfaceViolation (TPException): pass def check_file_dependency(dname, fname, msg): fpath = os.path.join(dname, fname) if not os.path.exists(fpath): raise MissingDependency(msg) def check_installed_application(name, msg=''): if os.system('type %s > /dev/null 2> /dev/null' % name) != 0: raise MissingDependency(msg)