Browse Source

fix status change

tags/mservice-0.1
sonakinci41 4 months ago
parent
commit
d3c17c5020
1 changed files with 12 additions and 5 deletions
  1. +12
    -5
      MService.py

+ 12
- 5
MService.py View File

@@ -14,6 +14,7 @@ class MService(Gtk.Window):
box = Gtk.VBox()
self.add(box)

self.services_black_list = ["halt","initbase","random","rc","reboot","sendsignals"]
self.icon_dir = "./icons"
self.set_icon(GdkPixbuf.Pixbuf.new_from_file("{}/simge.svg".format(self.icon_dir)))

@@ -59,10 +60,12 @@ class MService(Gtk.Window):
get = question.run()
if get == Gtk.ResponseType.OK:
if status:
subprocess.Popen(["service","stop",select])
get = subprocess.Popen(["service","stop",select], stdout = subprocess.PIPE)
else:
subprocess.Popen(["service","start",select])
get = subprocess.Popen(["service","start",select], stdout = subprocess.PIPE)
get.wait()
self.get_services()
self.search_widget.set_text("")
self.append_tree(self.services)
question.destroy()
elif event.button == 3:
@@ -84,6 +87,7 @@ class MService(Gtk.Window):

def enable_service(self,widget,service):
get = subprocess.Popen(["service","enable",service], stdout = subprocess.PIPE)
get.wait()
get = self.subprocess_parse(get)
info = Gtk.MessageDialog(self,0,Gtk.MessageType.INFO, Gtk.ButtonsType.OK,"{} servisi aktif hale getirildi.".format(service))
info.set_title("{} servisi aktif hale getirildi.".format(service))
@@ -93,9 +97,10 @@ class MService(Gtk.Window):

def disable_service(self,widget,service):
get = subprocess.Popen(["service","disable",service], stdout = subprocess.PIPE)
get.wait()
get = self.subprocess_parse(get)
info = Gtk.MessageDialog(self,0,Gtk.MessageType.INFO, Gtk.ButtonsType.OK,"{} servisi aktif hale getirildi.".format(service))
info.set_title("{} servisi aktif hale getirildi.".format(service))
info = Gtk.MessageDialog(self,0,Gtk.MessageType.INFO, Gtk.ButtonsType.OK,"{} servisi pasif hale getirildi.".format(service))
info.set_title("{} servisi pasif hale getirildi.".format(service))
info.format_secondary_text(get)
info.run()
info.destroy()
@@ -106,7 +111,8 @@ class MService(Gtk.Window):
if os.path.exists(service_dir):
services = os.listdir(service_dir)
for service in services:
self.services[service] = self.get_service_status(service)
if service not in self.services_black_list:
self.services[service] = self.get_service_status(service)
else:
dialog = Gtk.MessageDialog(None,0, Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK, "Hata")
@@ -116,6 +122,7 @@ class MService(Gtk.Window):

def get_service_status(self,service):
get = subprocess.Popen(["service","status",service], stdout = subprocess.PIPE)
get.wait()
get = self.subprocess_parse(get)
get = get.split("\n")[0]
get = get.split(" ")


Loading…
Cancel
Save