* forgot to add Exceptions
* webserver conf in a file
This commit is contained in:
parent
baafed8f38
commit
fccfba66d7
3 changed files with 91 additions and 0 deletions
71
pythonrewrite/bin2/CryptoBoxExceptions.py
Normal file
71
pythonrewrite/bin2/CryptoBoxExceptions.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
"""
|
||||
exceptions of the cryptobox package
|
||||
"""
|
||||
|
||||
|
||||
class CryptoBoxError(Exception):
|
||||
"""base class for exceptions of the cryptobox"""
|
||||
pass
|
||||
|
||||
|
||||
class CBConfigError(CryptoBoxError):
|
||||
"""any kind of error related to the configuration of a cryptobox"""
|
||||
pass
|
||||
|
||||
|
||||
class CBConfigUnavailableError(CBConfigError):
|
||||
"""config file/input was not available at all"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
self.source = source
|
||||
|
||||
def __str__(self):
|
||||
if self.source:
|
||||
return "failed to access the configuration of the cryptobox: %s" % self.source
|
||||
else:
|
||||
return "failed to access the configuration of the cryptobox"
|
||||
|
||||
|
||||
class CBConfigUndefinedError(CBConfigError):
|
||||
"""a specific configuration setting was not defined"""
|
||||
|
||||
def __init__(self, section, name=None):
|
||||
self.section = section
|
||||
self.name = name
|
||||
|
||||
def __str__(self):
|
||||
# is it a settings or a section?
|
||||
if self.name:
|
||||
# setting
|
||||
return "undefined configuration setting: [%s]->%s - please check your configuration file" % (self.section, self.name)
|
||||
else:
|
||||
# section
|
||||
return "undefined configuration section: [%s] - please check your configuration file" % (self.section, )
|
||||
|
||||
|
||||
|
||||
class CBConfigInvalidValueError(CBConfigError):
|
||||
"""a configuration setting was invalid somehow"""
|
||||
|
||||
def __init__(self, section, name, value, reason):
|
||||
self.section = section
|
||||
self.name = name
|
||||
self.value = value
|
||||
self.reason = reason
|
||||
|
||||
def __str__(self):
|
||||
return "invalid configuration setting [%s]->%s (%s): %s" % (self.section, self.name, self.value, self.reason)
|
||||
|
||||
|
||||
class CBEnvironmentError(CryptoBoxError):
|
||||
"""some part of the environment of the cryptobox is broken
|
||||
e.g. the wrong version of a required program
|
||||
"""
|
||||
|
||||
def __init__(self, desc):
|
||||
self.desc = desc
|
||||
|
||||
def __str__(self):
|
||||
return "misconfiguration detected: %s" % self.desc
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ class CryptoBoxWebserver:
|
|||
#perhaps put config handling into a seperate class in CryptoBox.py?
|
||||
# [l] why do we need to map the css manually? Shouldn't the whole
|
||||
# www-data path be accessible anyway?
|
||||
'''
|
||||
cherrypy.config.configMap.update(
|
||||
{
|
||||
"/cryptobox.css": {
|
||||
|
@ -26,8 +27,10 @@ class CryptoBoxWebserver:
|
|||
"staticFilter.file": os.path.abspath("../www-data/cryptobox.css" )
|
||||
}
|
||||
})
|
||||
'''
|
||||
|
||||
def start(self):
|
||||
cherrypy.config.update(file = "cryptoboxwebserver.conf")
|
||||
cherrypy.server.start()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
17
pythonrewrite/bin2/cryptoboxwebserver.conf
Normal file
17
pythonrewrite/bin2/cryptoboxwebserver.conf
Normal file
|
@ -0,0 +1,17 @@
|
|||
[global]
|
||||
server.socketPort = 8080
|
||||
#server.environment = "production"
|
||||
server.environment = "development"
|
||||
server.logToScreen = True
|
||||
server.threadPool = 1
|
||||
server.reverseDNS = False
|
||||
server.logFile = "cryptoboxwebserver.log"
|
||||
|
||||
[/favicon.ico]
|
||||
static_filter.on = True
|
||||
static_filter.file = "/var/www/cryptobox/favicon.ico"
|
||||
|
||||
[/cryptobox.css]
|
||||
static_filter.on = True
|
||||
static_filter.file = "/var/www/cryptobox/cryptobox.css"
|
||||
|
Loading…
Reference in a new issue