def finish_initializing(self, builder): # pylint: disable=E1002 """Set up the main window""" super(OricusWindow, self).finish_initializing(builder) self.AboutDialog = AboutOricusDialog self.PreferencesDialog = PreferencesOricusDialog # Code for other initialization actions should be added here. if not Apache.is_installed(): dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO, _("Apache is not installed. Would you like to intall it?")) response = dialog.run() if response == Gtk.ResponseType.NO: sys.exit() worked = subprocess.call(['/usr/bin/gksu', '/usr/bin/apt-get install apache2']) if worked > 0: sys.exit() dialog.destroy() Vhosts.import_all() self.status = Status.StatusBar(self.builder.get_object('statusbar1')) self.builder.get_object('statusToggleSwitch').set_active(Apache.is_running()) self.status.set(Apache.get_status(), Status.Types.STARTUP) self.status.clear(Status.Types.STARTUP, 5000) self.done_setting_up = True
def on_statusToggleSwitch_notify(self, widget, user_data=None): if not user_data.name == 'active': return if not self.done_setting_up: return if widget.get_active() and not Apache.is_running(): self.status.set(_("Starting Apache..."), Status.Types.TOGGLE); Apache.start() self.status.clear(Status.Types.TOGGLE) else: self.status.set(_("Stopping Apache..."), Status.Types.TOGGLE); Apache.stop() self.status.clear(Status.Types.TOGGLE)
def import_config(self): with open(os.path.join(Apache.get_conf_dir('sites-available'), self.filename), 'r') as f: for line in f: if not self.__finished_with_vhost: self.parse_line(line)
def import_all(): sites_available = Apache.get_conf_dir('sites-available') all_sites = [ f for f in os.listdir(sites_available) if os.path.isfile(os.path.join(sites_available, f)) ] for site in all_sites: Vhost(site).import_config()