1 import sys 2 import os 3 4 from gi.repository import Gtk 5 login = os.getenv("HOME") 6 7 8 class main: 9 10 if os.path.exists(login+"/.minidlna/cache") == False: 11 os.system("mkdir -p ~/.minidlna/cache") 12 if os.path.isfile("/etc/minidlna.conf") == True: 13 os.system("cp /etc/minidlna.conf ~/.minidlna") 14 else: 15 print "Please install minidlna with apt-get install minidlna" 16 17 def __init__(self): 18 builder = Gtk.Builder() 19 builder.add_from_file("/usr/share/geodlna/data/gui/GeoDLNA.ui") 20 self.window = builder.get_object("Main") 21 self.bconectar = builder.get_object("Conectar") 22 self.bactualizar = builder.get_object("Actualizar") 23 24 dict = {"on_Main_delete_event": self.quit, 25 "on_conection_clicked": self.connect, 26 "on_Reloaded_clicked":self.reloaded, 27 } 28 builder.connect_signals(dict) 29 30 31 #Definicion del comando iniciar el servidor miniDLNA 32 def connect(self, widget): 33 if self.bconectar.get_stock_id() == "gtk-disconnect": 34 os.system("minidlna -f"+login+"/.minidlna/minidlna.conf -P"+login+"/.minidlna/minidlna.pid") 35 self.bconectar.set_stock_id("gtk-connect") 36 self.bactualizar.set_sensitive(False) 37 else: 38 self.bconectar.set_stock_id("gtk-disconnect") 39 self.bactualizar.set_sensitive(True) 40 os.system("pkill minidlna") 41 42 #Definicion de actualizar el servidor miniDLNA 43 def reloaded(self,widget): 44 os.system("minidlna -f"+login+"/.minidlna/minidlna.conf -R") 45 self.bactualizar.set_sensitive(False) 46 self.bconectar.set_stock_id("gtk-connect") 47 48 def quit(self,*args): 49 os.system("pkill minidlna") 50 Gtk.main_quit() 51 52 53 #Ejecucion del programa 54 if __name__ == "__main__": 55 main() 56 Gtk.main() 57