22import os
33import sys
44import cme
5- from getpass import getuser
65from logging import getLogger
76from cme .context import Context
87from cme .logger import CMEAdapter
@@ -24,9 +23,13 @@ def module_is_sane(self, module, module_path):
2423 self .logger .error ('{} missing the name variable' .format (module_path ))
2524 module_error = True
2625
26+ elif not hasattr (module , 'description' ):
27+ self .logger .error ('{} missing the description variable' .format (module_path ))
28+ module_error = True
29+
2730 elif not hasattr (module , 'options' ):
2831 self .logger .error ('{} missing the options function' .format (module_path ))
29- module_error = True
32+ module_error = True
3033
3134 elif not hasattr (module , 'on_login' ) and not (module , 'on_admin_login' ):
3235 self .logger .error ('{} missing the on_login/on_admin_login function(s)' .format (module_path ))
@@ -48,19 +51,19 @@ def get_modules(self):
4851
4952 modules_path = os .path .join (os .path .dirname (cme .__file__ ), 'modules' )
5053 for module in os .listdir (modules_path ):
51- if module [- 3 :] == '.py' :
54+ if module [- 3 :] == '.py' and module != 'example_module.py' :
5255 module_path = os .path .join (modules_path , module )
5356 m = self .load_module (os .path .join (modules_path , module ))
5457 if m :
55- modules [m .name ] = {'path' : module , 'description' : m .__doc__ , 'options' : m .options .__doc__ }
58+ modules [m .name ] = {'path' : module_path , 'description' : m .description , 'options' : m .options .__doc__ }
5659
5760 modules_path = os .path .join (self .cme_path , 'modules' )
5861 for module in os .listdir (modules_path ):
59- if module [- 3 :] == '.py' :
62+ if module [- 3 :] == '.py' and module != 'example_module.py' :
6063 module_path = os .path .join (modules_path , module )
6164 m = self .load_module (module_path )
6265 if m :
63- modules [m .name ] = {'path' : module_path , 'description' : m .__doc__ , 'options' : m .options .__doc__ }
66+ modules [m .name ] = {'path' : module_path , 'description' : m .description , 'options' : m .options .__doc__ }
6467
6568 return modules
6669
@@ -90,13 +93,9 @@ def init_module(self, module_path):
9093 args .server = getattr (module , 'required_server' )
9194
9295 if not self .server_port :
93- if self .args .server_port <= 1024 and os .geteuid () is not 0 :
94- self .logger .error ("I'm sorry {}, I'm afraid I can't let you do that" .format (getuser ()))
95- sys .exit (1 )
96-
9796 self . server_port = self .args .server_port
9897
99- server = CMEServer (module , context , self .args .server_host , self .server_port , self .args .server )
98+ server = CMEServer (module , context , self .logger , self . args .server_host , self .server_port , self .args .server )
10099 server .start ()
101100
102101 return module , context , server
0 commit comments