Move mopidy.exceptions.SettingError to mopidy.SettingsError

This commit is contained in:
Stein Magnus Jodal 2010-03-08 20:34:57 +01:00
parent 1619ecbd56
commit b1ece22032
3 changed files with 10 additions and 12 deletions

View File

@ -1,5 +1,4 @@
from mopidy.exceptions import SettingError
from mopidy import settings as original_settings
from mopidy import settings as raw_settings
def get_version():
return u'0.1.dev'
@ -7,13 +6,16 @@ def get_version():
def get_mpd_protocol_version():
return u'0.16.0'
class SettingsError(Exception):
pass
class Settings(object):
def __getattr__(self, attr):
if not hasattr(original_settings, attr):
raise SettingError(u'Setting "%s" is not set.' % attr)
value = getattr(original_settings, attr)
if not hasattr(raw_settings, attr):
raise SettingsError(u'Setting "%s" is not set.' % attr)
value = getattr(raw_settings, attr)
if type(value) != bool and not value:
raise SettingError(u'Setting "%s" is empty.' % attr)
raise SettingsError(u'Setting "%s" is empty.' % attr)
return value
settings = Settings()

View File

@ -6,8 +6,7 @@ import sys
sys.path.insert(0,
os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
from mopidy import settings
from mopidy.exceptions import SettingError
from mopidy import settings, SettingsError
from mopidy.mpd.server import MpdServer
logger = logging.getLogger('mopidy')
@ -44,5 +43,5 @@ if __name__ == '__main__':
main()
except KeyboardInterrupt:
sys.exit('\nInterrupted by user')
except SettingError, e:
except SettingsError, e:
sys.exit('%s' % e)

View File

@ -1,6 +1,3 @@
class SettingError(Exception):
pass
class MpdAckError(Exception):
pass