def translateForm(self):
        global qtTranslator, idioma
        app.removeTranslator(qtTranslator)
        qtTranslator = QTranslator()
        qtTranslator.load("/usr/share/kademar/utils/kademarcenter/tr/"+idioma+".qm")
        app.installTranslator(qtTranslator)
        self.ui_kademarstart.retranslateUi(self)
        
        #Set kademar Label
        versiokademar=funcions_k.versiokademar()
        tipuskademar=funcions_k.tipuskademar()
        self.ui_kademarstart.l_kademar.setText("kademar "+tipuskademar+" "+versiokademar+" GNU/Linux")

        path="/usr/share/kademar/html/"
Ejemplo n.º 2
0
    def __init__(self):
        QMainWindow.__init__(self)
        global tipus
        self.avisa = True  # avisa la sortida

        self.ui_cadi = Ui_Form()
        self.ui_cadi.setupUi(self)

        self.ui_cadi.label_3.setVisible(False)
        self.ui_cadi.label_11.setVisible(False)
        self.ui_cadi.b_root.setVisible(False)

        #############
        ####  PC INFO
        #############

        # Get PC info & put on info labels
        kernel = funcions_k.versiokernel()
        versiokademar = funcions_k.versiokademar()
        tipuskademar = funcions_k.tipuskademar()

        cpu = getoutput(""" grep 'cpu MHz' /proc/cpuinfo | awk '{ print $4 }' """)
        cpuinfo = getoutput(" cat /proc/cpuinfo | grep 'model name' ")
        ram = getoutput("""  grep 'MemTotal' /proc/meminfo | awk '{ print $2 }' """)
        hostname = getoutput("hostname -f")
        logedusers = getoutput("users")
        numlogedusers = len(logedusers.split(" "))

        self.ui_cadi.l_kdm.setText("kademar")
        self.ui_cadi.l_kern.setText(kernel)
        self.ui_cadi.l_ver.setText(versiokademar)
        self.ui_cadi.l_tipu.setText(tipuskademar)
        self.ui_cadi.l_cpu.setText(cpu.split("\n")[0] + " Mhz")
        self.ui_cadi.l_cpuinfo.setText(cpuinfo)
        self.ui_cadi.l_ram.setText(ram + " Mb")
        self.ui_cadi.l_host.setText(hostname)

        if not funcions_k.instalat():
            for i in [self.ui_cadi.b_users, self.ui_cadi.b_language]:
                i.setVisible(0)

        #############
        ####  END PC INFO
        #############

        # Ponemos el splash
        self.ui_cadi.pages.setCurrentWidget(self.ui_cadi.tab_principal)

        self.path = "/usr/share/kademar/utils/cadi"
        #####  Signals & Slots  #####

        self.connect(self.ui_cadi.b_sortir, SIGNAL("clicked()"), self.close)

        self.connect(self.ui_cadi.b_root, SIGNAL("clicked()"), self.boto_root)

        # Software
        self.connect(self.ui_cadi.b_software, SIGNAL("clicked()"), self.boto_software)
        # Hardware
        self.connect(self.ui_cadi.b_hardware, SIGNAL("clicked()"), self.boto_hardware)
        # Xarxa
        self.connect(self.ui_cadi.b_xarxa, SIGNAL("clicked()"), self.boto_xarxa)
        # Sistema
        self.connect(self.ui_cadi.b_sistema, SIGNAL("clicked()"), self.boto_sistema)

        # SOFTWARE
        # Boto Preferencies del sistema
        self.connect(self.ui_cadi.b_preferencies_sistema, SIGNAL("clicked()"), self.boto_preferencies)
        ##Synaptic
        self.connect(self.ui_cadi.b_synaptic, SIGNAL("clicked()"), self.boto_synaptic)

        # HARDWARE
        # Impressores
        self.connect(self.ui_cadi.b_impressores, SIGNAL("clicked()"), self.boto_impressores)
        # Bluetooth
        self.connect(self.ui_cadi.b_bluetooth, SIGNAL("clicked()"), self.boto_bluetooth)
        # Teclats Multimedia
        self.connect(self.ui_cadi.b_teclats_multimedia, SIGNAL("clicked()"), self.boto_teclats_multimedia)
        # Kinfocenter
        self.connect(self.ui_cadi.b_kinfocenter, SIGNAL("clicked()"), self.boto_kinfocenter)
        # Ndiswrapper
        self.connect(self.ui_cadi.b_ndiswrapper, SIGNAL("clicked()"), self.boto_ndiswrapper)

        # XARXA
        # Internet & Conectivity Module
        self.connect(self.ui_cadi.b_internet, SIGNAL("clicked()"), self.boto_internet)
        # Modem
        self.connect(self.ui_cadi.b_modem, SIGNAL("clicked()"), self.boto_modem)
        # ADSL/PPPoE
        self.connect(self.ui_cadi.b_pppoe, SIGNAL("clicked()"), self.boto_pppoe)
        # GPRS
        self.connect(self.ui_cadi.b_gprs, SIGNAL("clicked()"), self.boto_gprs)

        # SYSTEM
        # Display
        self.connect(self.ui_cadi.b_display_configuration, SIGNAL("clicked()"), self.boto_display_configuration)
        # Users
        self.connect(self.ui_cadi.b_users, SIGNAL("clicked()"), self.boto_users)
        # Services
        self.connect(self.ui_cadi.b_services, SIGNAL("clicked()"), self.boto_services)
        # Language
        self.connect(self.ui_cadi.b_language, SIGNAL("clicked()"), self.boto_language)
        # Grub
        self.connect(self.ui_cadi.b_grub, SIGNAL("clicked()"), self.boto_grub)

        #### END Signals & Slots ####

        self.modules = [
            ("preferences", self.boto_preferencies),
            ("synaptic", self.boto_synaptic),
            ("printer", self.boto_impressores),
            ("bluetooth", self.boto_bluetooth),
            ("kboardmmedia", self.boto_teclats_multimedia),
            ("kinfocenter", self.boto_kinfocenter),
            ("ndiswrapper", self.boto_ndiswrapper),
            ("internet", self.boto_internet),
            ("modem", self.boto_modem),
            ("pppoe", self.boto_pppoe),
            ("gprs", self.boto_gprs),
            ("display", self.boto_display_configuration),
            ("users", self.boto_users),
            ("services", self.boto_services),
            ("language", self.boto_language),
            ("grub", self.boto_grub),
        ]

        self.tabs = [
            ("software", self.boto_software),
            ("hardware", self.boto_hardware),
            ("net", self.boto_xarxa),
            ("system", self.boto_sistema),
        ]

        a = b = ""
        # Open a module if you have passed as a parameter
        for i in sys.argv[1:]:
            if i.find("--module=") <> -1:  # --module=wifi
                module = i.split("=")[1]  # get only wifi
                for i in self.modules:  # search and open it
                    if i[0].find(module) <> -1:
                        i[1]()
            elif i.find("--tab=") <> -1:  # --tab=hadware
                tab = i.split("=")[1]  # get only hardware
                for i in self.tabs:  # search and open it
                    if i[0].find(tab) <> -1:
                        i[1]()
            elif i.find("--help") <> -1:
                print
                print
                print "CADI: The configurator tool"
                print "---------------------------"
                print
                print "* To open a tab, call with --tab=xxx  param"
                print " - Tabs Availables:"
                for i in self.tabs:
                    b = b + " " + i[0]
                print b
                print
                print "* To open a module, call with --module=xxx  param"
                print " - Modules Availables:"
                for i in self.modules:
                    a = a + " " + i[0]
                print a
                print
    def __init__(self):
        QWidget.__init__(self)

        #Carrega el Gui
        self.ui = uikademarcenter()
        self.ui.setupUi(self)
        self.usbtrayclosed=True


####
# SOUND CONFIGURATION
####
        self.play="paplay" #Play Program
        self.soundconnect="/usr/share/sounds/KDE_Dialog_Appear.wav" #Sound USB connect
        self.sounddisconnect="/usr/share/sounds/KDE_Dialog_Disappear.wav"

####
# END SOUND CONFIGURATION
####

        self.connect(self.ui.b_settings, SIGNAL("clicked()"), self.showsettings)

        global notifier

        #Load configuration files
        self.load_kademarcenter_config()

####  UsbTray Module  ####
        self.usbtray = UsbTray()
        self.connect(self.usbtray, SIGNAL("showmsg"), self.showmsg)
##########################

####  IvMan Work  ####
        self.HardwareDetect = HardwareDetect()
        self.connect(self.HardwareDetect, SIGNAL("showmsg"), self.showmsg)
        self.connect(self.HardwareDetect, SIGNAL("regeneraformusbtray"), self.regeneraformusbtray)
        self.connect(self.HardwareDetect, SIGNAL("showusbtray"), self.showusbtray)
        self.HardwareDetect.start()
######################

#############
####  TRAY MODULE & ACTIONS
#############
        #### TRAY ####
        self.tray = QSystemTrayIcon(self)
        self.trayMenu = QMenu()
        #Definicio de items del menu (solament el que son, icona i descripcio)
        #self.action_quit = QAction(QIcon("/usr/share/kademar/icons/convertir.png"), self.tr('Quit'), self)
        self.action_mainwindow = QAction(QIcon("/usr/share/kademar/icons/endavant.png"), self.tr("Open kademar Center"), self)
        self.action_settings = QAction(QIcon("/usr/share/kademar/icons/configure.png"), self.tr("Configure"), self)


        #Afegit opcions de dalt, en el menu del context
        self.trayMenu.addAction(self.action_mainwindow)
        self.trayMenu.addAction(self.action_settings)

        #self.trayMenu.addAction(self.action_quit)

        #Connectar Accions al fer click a un del menu, la function que executa
        self.connect(self.action_mainwindow, SIGNAL("triggered()"), self.mainwindow)
        self.connect(self.action_settings, SIGNAL("triggered()"), self.showsettings)

        #self.connect(self.action_quit, SIGNAL("triggered()"), self.quitusbtray)

        #Quan fas clic al tray executa eventsdeltray (function)
        self.tray.connect( self.tray, SIGNAL( "activated(QSystemTrayIcon::ActivationReason)" ), self.eventsdeltray )

        self.trayIcon = QIcon("/usr/share/kademar/utils/kademarcenter/img/kademar.png")
        self.tray.setContextMenu(self.trayMenu)
        self.tray.setIcon(self.trayIcon)
        self.tray.setToolTip("kademar Center")
        self.tray.show()
#############
####  END  TRAY MODULE & ACTIONS
#############

#### INITIAL Services Start  ####
        #Initial start of services
        system(scripts.initial_service_start)
#################################

#### INITIAL DEVICE MOUNT ####
        #Initial mount of already plugged devices
        for udi in getoutput(scripts.initial_mount).split():
            print udi
            print "INITIAL DEVICE"
            system("touch /tmp/kademarcenter-inicial")
            self.HardwareDetect.processa_udi(udi, "add")
            system("rm -f /tmp/kademarcenter-inicial")
##############################

#############
####  PC INFO
#############

#Get PC info & put on info labels
        kernel=funcions_k.versiokernel()
        versiokademar=funcions_k.versiokademar()
        tipuskademar=funcions_k.tipuskademar()

        cpu=getoutput(""" grep 'cpu MHz' /proc/cpuinfo | awk '{ print $4 }' """)
        cpuinfo=getoutput(" cat /proc/cpuinfo | grep 'model name' ")
        ram=getoutput("""  grep 'MemTotal' /proc/meminfo | awk '{ print $2 }' """)
        hostname=getoutput("hostname -f")
        logedusers=getoutput("users")
        numlogedusers=len(logedusers.split(" "))

        self.ui.l_kdm.setText("kademar")
        self.ui.l_kern.setText(kernel)
        self.ui.l_ver.setText(versiokademar)
        self.ui.l_tipu.setText(tipuskademar)
        self.ui.l_cpu.setText(cpu.split("\n")[0]+" Mhz")
        self.ui.l_cpuinfo.setText(cpuinfo)
        self.ui.l_ram.setText(ram+" Mb")
        self.ui.l_host.setText(hostname)

        self.kademarstart()
        
        #if live-cd check if executing 32bit kademar on 64bit Machine
        global kademarstartconfig
        if not funcions_k.instalat() and kademarstartconfig.arch_warning:
            if getoutput("arch") != "x86_64": #if system kernel ISN'T 64bit
                #check if machine can support 64 bit system
                check64bit=getoutput(""" for i in `grep cache_alignment /proc/cpuinfo | cut -d: -f2`; do echo $i; break; done """).strip()
                checkSse3=getoutput("""  grep -i sse3 /proc/cpuinfo 2>/dev/null """)
                checkSse4=getoutput("""  grep -i sse4 /proc/cpuinfo 2>/dev/null """)
                if checkSse3 or checkSse4:  #if have sse3 or 4
                    if int(check64bit) >= 64:
                    #warn if it's a machine 64bit capable with a 32bit system
                        QMessageBox.critical(self, self.tr('Executing 32bit kademar on a 64bit Machine'), self.tr("Your computer is a 64bit capable, but you are executing a 32bit kademar.\nThis can cause performance issues and kademar experience could be reduced.\n\nFor live-cd use there's no problem, but if you want to install kademar on this machine, would be better if you download 64bit version from www.kademar.org"))


#############
####  END PC INFO
#############

        #Comprueba dispositivos USB y muestralo si eso
        self.regeneraformusbtray()
    def __init__(self, standalone=None):
        QWidget.__init__(self)

        self.standalone=standalone

        global config
        load_config()

        #Load Form
        self.ui_kademarstart = Ui_Form()
        self.ui_kademarstart.setupUi(self)
        self.ui_kademarstart.pages.setCurrentWidget(self.ui_kademarstart.tab_ppal)

        #if not standalone:
        self.ui_kademarstart.b_band_cat.setVisible(0)
        self.ui_kademarstart.b_band_esp.setVisible(0)

        #print config
        if not int(config.autostart):
            self.ui_kademarstart.cb_autostart.setVisible(0)

        #####################
        # Signals & Slots Buttons
        #####################
        #Sortir i Enrera
        self.connect(self.ui_kademarstart.b_sortir, SIGNAL("clicked()"), self.close)
        self.connect(self.ui_kademarstart.b_enrera, SIGNAL("clicked()"), self.boto_enrera)

        # Banderes
        self.connect(self.ui_kademarstart.b_band_cat, SIGNAL("clicked()"), self.boto_cat)
        self.connect(self.ui_kademarstart.b_band_esp, SIGNAL("clicked()"), self.boto_esp)

        # Principal
        self.connect(self.ui_kademarstart.b_notes, SIGNAL("clicked()"), self.boto_notesversio)
        self.connect(self.ui_kademarstart.b_configurar, SIGNAL("clicked()"), self.boto_configurarsistema)
        self.connect(self.ui_kademarstart.b_equip, SIGNAL("clicked()"), self.boto_equip)
        self.connect(self.ui_kademarstart.b_suport, SIGNAL("clicked()"), self.boto_suport)

        # Programes
        self.connect(self.ui_kademarstart.b_cadi, SIGNAL("clicked()"), self.boto_cadi)
        self.connect(self.ui_kademarstart.b_kcontrol, SIGNAL("clicked()"), self.boto_kcontrol)

        # Suport
        self.connect(self.ui_kademarstart.b_faq, SIGNAL("clicked()"), self.boto_faq)
        self.connect(self.ui_kademarstart.b_foro, SIGNAL("clicked()"), self.boto_foro)
        self.connect(self.ui_kademarstart.b_doc, SIGNAL("clicked()"), self.boto_doc)
        self.connect(self.ui_kademarstart.b_email, SIGNAL("clicked()"), self.boto_email)


	#if no Notes versio, do not show
        ruta="/usr/share/kademar/utils/kademarcenter/html/"
        if path.exists(ruta+"notesversio_ca.html") or path.exists(ruta+"notesversio_es.html"):
            pass
        else:
            self.ui_kademarstart.pages.removeTab(1)
            self.ui_kademarstart.b_notes.setEnabled(0)
        #####################
        # END Signals & Slots Buttons
        #####################
        #locale = QLocale.system().name()   #ca_ES
        #global qtTranslator, idioma
        #idioma=locale.split("_")[0]
        #qtTranslator = QTranslator()
        #if qtTranslator.load("/usr/share/kademar/utils/kademarcenter/tr/"+locale.split("_")[0]+".qm"):
            #app.installTranslator(qtTranslator)
            #print "Loaded "+locale
        #elif qtTranslator.load("/usr/share/kademar/utils/kademarcenter/tr/es.qm"):
            #app.installTranslator(qtTranslator)
            #print "Loaded en"
        #Set kademar Label
        versiokademar=funcions_k.versiokademar()
        tipuskademar=funcions_k.tipuskademar()
        self.ui_kademarstart.l_kademar.setText("kademar "+tipuskademar+" "+versiokademar+" GNU/Linux")
        
        locale = QLocale.system().name()
        idioma=locale.split("_")[0]

        if path.exists("file:///usr/share/kademar/utils/kademarcenter/html/equip_"+idioma+".html"):
            self.ui_kademarstart.web_equip.setUrl(QUrl("file:///usr/share/kademar/utils/kademarcenter/html/equip_"+idioma+".html"))
        else:
            self.ui_kademarstart.web_equip.setUrl(QUrl("file:///usr/share/kademar/utils/kademarcenter/html/equip_es.html"))

        if path.exists("file:///usr/share/kademar/utils/kademarcenter/html/notesversio_"+idioma+".html"):
            self.ui_kademarstart.web_notes.setUrl(QUrl("file:///usr/share/kademar/utils/kademarcenter/html/notesversio_"+idioma+".html"))
        else:
            self.ui_kademarstart.web_notes.setUrl(QUrl("file:///usr/share/kademar/utils/kademarcenter/html/notesversio_es.html"))