def StartServer(self, evt): """ Write the config file, then start the server. """ # Set Variables config.add_section("Pages") config.set("Pages", "error_dir", self.errorsControl.GetValue()) config.set("Pages", "_404", self._404Control.GetValue()) config.set("Pages", "siteroot", self.rootControl.GetValue()) config.set("Pages", "index", self.indexControl.GetValue()) config.add_section("Server") config.set("Server", "port", self.portControl.GetValue()) config.set("Server", "host_name", self.hostControl.GetValue()) # Write the configuration file to 'configure.cfg' with open("./Configuration/configure.cfg", "wb") as configfile: config.write(configfile) # Start the webserver in a new process (fork) import os pid = os.fork() if pid: import webserver webserver.main() else: # Start a browser for the user to see their work. import webbrowser webbrowser.open("http://" + str(self.hostControl.GetValue()) + ":" + str(self.portControl.GetValue()))
def start_client(command_line, fAttach, fchdir, pwd, fAllowUnencrypted, fRemote, host): child_pid = os.fork() if child_pid: sm = rpdb2.CSessionManager(pwd, fAllowUnencrypted, fRemote, host) debugger = Debugger(sm) debugger.start() time.sleep(1.0) try: if fAttach: sm.attach(command_line) elif command_line != '': sm.launch(fchdir, command_line) while True: time.sleep(5.0) except KeyboardInterrupt: pass except: sm.report_exception(*sys.exc_info()) traceback.print_exc() finally: debugger.shutdown() sm.detach() sm.shutdown() os.wait() # wait the child process, i.e, webserver to gracefully shutdown print 'Debugger Shutdown gracefully' else: import webserver webserver.main()
def test_run_main_site_up(self): """ tests that site can be turned down """ self.make_site_confs("down") sys.argv = ["webserver", "-s", "up", "-l", "DEBUG"] try: main() except SystemExit as sysexit: self.assertEqual("0", str(sysexit), "main returned: " + str(sysexit)) self.log("INFO: %s is up" % self.app_name)
def test_run_main_remove_static(self, own_app_mock, clone_app_mock): """ tests run main script with remove static parameter returns no error """ user = "******" os.makedirs(self.static_path) os.makedirs(self.media_path) os.makedirs(self.uwsgi_path) os.makedirs(self.down_path) webserver.DIST_VERSION = self.dist_version os.makedirs(os.path.join(self.app_home, self.app_name, self.app_name)) os.makedirs(os.path.join(os.path.dirname(self.app_home), "conf.d")) conf = [ {"file": "settings.json", "move_to": os.path.join(self.app_home, self.app_name)}, {"file": "settings_admin.py", "move_to": os.path.join(self.app_home, self.app_name, self.app_name)}, {"file": "%s_uwsgi.ini" % self.app_name, "move_to": self.app_home}, ] for f in conf: with open(os.path.join(os.path.dirname(self.app_home), "conf.d", f["file"]), "w") as config: config.write("%s file\n" % f["file"]) if self.dist_version == "14.04": self.python_version = "python3.4" elif self.dist_version == "16.04": self.python_version = "python3.5" os.makedirs(os.path.join(self.venv, "lib", self.python_version, "site-packages")) serve_django_static = ServeStatic( self.dist_version, self.app_home, self.log_file, self.log_level, git_repo=self.git_repo, sys_deps_file=self.sys_deps_file, reqs_file=self.reqs_file, venv=self.venv, ) serve_django_static.serve_static(user, user, self.down_path, self.static_path, self.media_path, self.uwsgi_path) sys.argv = ["webserver", "-x", "-l", "DEBUG"] try: main() except SystemExit as sysexit: self.assertEqual("0", str(sysexit), "main returned: " + str(sysexit)) fds = [self.down_path, self.static_path, self.media_path, self.uwsgi_path] for f in fds: self.assertTrue(os.path.exists(f), "%s not present" % f) self.log("INFO: removed files in %s" % f)
def test_run_main_reload_static(self, own_app_mock, clone_app_mock): """ tests run main script with move static parameter returns no error """ sys.argv = ["webserver", "-r", "-l", "DEBUG"] paths = [self.static_path, self.media_path, self.uwsgi_path, self.down_path] for p in paths: os.makedirs(p) webserver.DIST_VERSION = self.dist_version os.makedirs(os.path.join(self.app_home, self.app_name, self.app_name)) os.makedirs(os.path.join(os.path.dirname(self.app_home), "conf.d")) conf = [ {"file": "settings.json", "move_to": os.path.join(self.app_home, self.app_name)}, {"file": "settings_admin.py", "move_to": os.path.join(self.app_home, self.app_name, self.app_name)}, {"file": "%s_uwsgi.ini" % self.app_name, "move_to": self.app_home}, ] for f in conf: with open(os.path.join(os.path.dirname(self.app_home), "conf.d", f["file"]), "w") as config: config.write("%s file\n" % f["file"]) if self.dist_version == "14.04": self.python_version = "python3.4" elif self.dist_version == "16.04": self.python_version = "python3.5" os.makedirs(os.path.join(self.venv, "lib", self.python_version, "site-packages")) try: main() except SystemExit as sysexit: self.assertEqual("0", str(sysexit), "main returned: " + str(sysexit)) expected_calls = [ call(self.down_path, self.web_user, self.webserver_user), call(os.path.dirname(self.venv), self.web_user, self.web_user), call(self.app_home, self.web_user, self.web_user), call(self.static_path, self.web_user, self.webserver_user), call(self.media_path, self.web_user, self.webserver_user), call(self.uwsgi_path, self.web_user, self.webserver_user), ] for e in expected_calls: self.assertTrue(e in own_app_mock.mock_calls, "%s not in %s" % (e, own_app_mock.mock_calls)) self.assertEqual([call(self.app_home)] * 4, clone_app_mock.mock_calls, clone_app_mock.mock_calls) fds = [self.down_path, self.static_path, self.media_path, self.uwsgi_path] for f in fds: self.assertTrue(os.path.exists(f), "%s not present" % f) self.log("INFO: removed files in %s" % f)
def run(self): webserver.main(self.game_data, self.game_data_lock)
def startwlan(): ap_if.active(True) import webserver webserver.main()
def do_editmodule(self, arg): """Edits a module""" #Checks the module type and pass it to the correct module for processing for idx, c in enumerate(self.campaign): if arg.id == c["id"]: mod = self.campaign.pop(idx) if c["module"] == "c2": c2.main(self.campaign, mod, self.project_id) addModule(c2.module, self.campaign) self.update_choices(self.campaign) c2.module = {} break if c["module"] == "dns_record": dns_records.main(self.variables["domains"], self.campaign, mod, self.project_id) addModule(dns_records.module, self.campaign) self.update_choices(self.campaign) dns_records.module = {} break if c["module"] == "redirector": redirector.main(mod, self.campaign, self.project_id) addModule(redirector.module, self.campaign) self.update_choices(self.campaign) redirector.module = {} break if c["module"] == "gophish": gophish.main(self.campaign, mod, self.project_id) addModule(gophish.module, self.campaign) self.update_choices(self.campaign) gophish.module = {} break if c["module"] == "letsencrypt": letsencrypt.main( self.campaign, mod, self.project_id) #self.variables["domains"] addModule(letsencrypt.module, self.campaign) self.update_choices(self.campaign) letsencrypt.module = {} break if c["module"] == "mail": mail_server.main(self.variables["domains"], self.campaign, mod, self.project_id) addModule(mail_server.module, self.campaign) self.update_choices(self.campaign) mail_server.module = {} break if c["module"] == "webserver": webserver.main(self.campaign, mod, self.project_id) addModule(webserver.module, self.campaign) self.update_choices(self.campaign) webserver.module = {} break if c["module"] == "godaddy": godaddy.main(self.campaign, self.variables["domains"], mod, self.project_id) addModule(godaddy.module, self.campaign) self.update_choices(self.campaign) godaddy.module = {} break if c["module"] == "ansible": ansible.main(self.campaign, mod, self.project_id) addModule(ansible.module, self.campaign) self.update_choices(self.campaign) ansible.module = {} break
def usemodule_webserver(self, arg): """Opens the webserver module for configuration""" webserver.main(self.campaign, None, self.project_id) addModule(webserver.module, self.campaign) self.update_choices(self.campaign) webserver.module = {}
import webserver webserver.main()