Changeset 3841
- Timestamp:
- 12/16/08 13:16:38 (4 years ago)
- Location:
- branch/UmitWeb
- Files:
-
- 6 modified
-
share/umit/config/umitweb.conf (modified) (2 diffs)
-
umitCore/BasePaths.py (modified) (2 diffs)
-
umitWeb/Database.py (modified) (2 diffs)
-
umitWeb/Server.py (modified) (2 diffs)
-
umitWeb/WebPaths.py (modified) (4 diffs)
-
umitweb.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branch/UmitWeb/share/umit/config/umitweb.conf
r3587 r3841 98 98 enable_highlight = True 99 99 100 [paths]101 config_file = config/umit.conf102 umit_icon = share/icons/umit/umit_48.ico103 nmap_command_path = nmap104 locale_dir = share/locale105 misc_dir = misc106 icons_dir = share/icons/umit107 pixmaps_dir = share/pixmaps108 config_dir = /home/rodox/.umit109 docs_dir = docs110 111 100 [port_list_highlight] 112 101 regex = PORT\s+STATE\s+SERVICE(\s+VERSION)?.* … … 117 106 underline = 0 118 107 108 [web] 109 server_port = 8859 110 server_address = 0.0.0.0 111 requires_root = true -
branch/UmitWeb/umitCore/BasePaths.py
r3232 r3841 47 47 48 48 base_paths = dict(config_file = 'umit.conf', 49 webconfig_file = 'umitweb.conf',50 security_file = 'security.xml',51 49 config_dir = '.umit', 52 50 user_dir = os.path.join(HOME, '.umit'), … … 73 71 i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR), HOME], 74 72 umitdb = "umit.db", 75 umitdb_web = "umitweb.db",76 73 77 74 services = "nmap-services", -
branch/UmitWeb/umitWeb/Database.py
r1263 r3841 24 24 from types import ListType 25 25 from traceback import print_exc 26 from umitWeb.WebPaths import WPath as Path 26 27 27 28 try: … … 32 33 import pysqlite2 as sqlite 33 34 34 #Temporary - waiting instructions about UmitConf 35 __connection__ = dbmodule.connect(os.path.join("web.db")) 35 try: 36 webdb = Path.web_db 37 except: 38 webdb = os.path.join(Path.config_dir, "web.db") 39 Path.web_db = webdb 40 41 __connection__ = dbmodule.connect(Path.web_db) 36 42 37 43 -
branch/UmitWeb/umitWeb/Server.py
r1332 r3841 34 34 from umitWeb.WebLogger import getLogger 35 35 from umitWeb.Security import Context 36 from umitWeb.WebPaths import WPath as Path 36 37 from threading import Thread 37 38 … … 260 261 261 262 def __init__(self): 262 HTTPServer.__init__(self, ( "0.0.0.0", 8059), UmitRequestHandler)263 HTTPServer.__init__(self, (Path.web_server_address, int(Path.web_server_port)), UmitRequestHandler) 263 264 UmitWebServer.currentInstance = self 264 265 -
branch/UmitWeb/umitWeb/WebPaths.py
r3810 r3841 17 17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 19 from os.path import join, split, exists 20 from umitCore.BasePaths import base_paths, HOME 19 from os.path import join, split, exists, dirname 20 import re 21 from umitCore.BasePaths import base_paths, HOME, CONFIG_DIR 21 22 from umitCore.Paths import Paths, Path, copy_config_file 22 23 … … 25 26 26 27 base_paths.update(dict(webconfig_file='umitweb.conf', 27 security_file='security.xml')) 28 config_file='umitweb.conf', 29 security_file='security.xml', 30 web_db=join('share', 'config', 'web.db'))) 28 31 29 32 class WebPaths(Paths): 30 33 templates_dir = TEMPLATES_DIR 31 34 media_dir = MEDIA_DIR 35 web_section = "web" 32 36 33 37 def __init__(self): … … 41 45 "webconfig_file", 42 46 "security_file", 43 "umitdb_web" 47 "web_db" 48 ] 49 50 self.web_settings = [ 51 "web_server_port", 52 "web_server_address", 53 "web_requires_root" 44 54 ] 45 55 … … 50 60 not exists(join(self.config_dir, "umitweb.conf")): 51 61 create_web_files(self.config_file, HOME) 62 63 def __getattr__(self, name): 64 if self.config_file_set: 65 try: 66 attr = Paths.__getattr__(self, name) 67 return attr 68 except NameError, e: 69 if name in self.web_settings: 70 return self.config_parser.get(self.web_section, re.sub(r"^web_", "", name)) 71 else: 72 raise e 73 else: 74 raise Exception("Must set config file location first") 52 75 53 76 54 77 def create_web_files(config_file, user_home): 55 78 user_dir = join(user_home, base_paths['config_dir']) 56 main_dir = split(config_file)[0]79 main_dir = join(dirname(__file__), CONFIG_DIR) 57 80 copy_config_file("security.xml", main_dir, user_dir) 58 81 copy_config_file("umitweb.conf", main_dir, user_dir) -
branch/UmitWeb/umitweb.py
r3810 r3841 40 40 41 41 def main(): 42 if sys.platform in ["linux", "darwin"]: 43 if os.getuid() != 0: 44 raise Exception, "Server MUST run as root." 42 if Path.web_requires_root in ["true", "on", "1"]: 43 if sys.platform in ["linux", "darwin"]: 44 if os.getuid() != 0: 45 raise Exception, "Server MUST run as root." 45 46 46 47 server = UmitWebServer() 47 48 try: 48 print "UmitWebServer started on 0.0.0.0:8059"49 print "UmitWebServer started on %s:%d" % (Path.web_server_address, int(Path.web_server_port)) 49 50 server.run() 50 51 except KeyboardInterrupt:
