Example #1
0
class NewDatabasePage(gtk.Frame):
    def __init__(self,par,server):
        self.par = par
        gtk.Frame.__init__(self, _("Skarphed Admin :: Register Database"))

        self.serverId = server.getLocalId()

        self.table = gtk.Table(4,2,False)
        self.instruction = gtk.Label(_("Please enter DBA-Credentials here:"))
        self.dba_user_label = gtk.Label(_("DBA-User:"******"Password:"******"SYSDBA")
        self.dba_pass_entry = DefaultEntry(default_message=_("password"))
        self.buttonhbox = gtk.HBox()
        self.cancel = gtk.Button(stock=gtk.STOCK_CLOSE)
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        self.buttonhbox.add(self.cancel)
        self.buttonhbox.add(self.ok)
        
        self.table.attach(self.instruction,0,2,0,1)
        self.table.attach(self.dba_user_label,0,1,1,2)
        self.table.attach(self.dba_user_entry,1,2,1,2)
        self.table.attach(self.dba_pass_label,0,1,2,3)
        self.table.attach(self.dba_pass_entry,1,2,2,3)
        self.table.attach(self.buttonhbox,1,2,3,4)

        self.ok.connect("clicked", self.cb_Ok)
        self.cancel.connect("clicked", self.cb_Cancel)
        self.connect("delete-event", self.cb_Cancel)

        server.addCallback(self.render)

        self.table.set_border_width(10)
        self.add(self.table)
        self.getApplication().getMainWindow().openDialogPane(self)


    def cb_Ok(self,widget=None,data=None):
        server = self.getApplication().getLocalObjectById(self.serverId)
        server.setDatabase(self.dba_user_entry.get_text(), self.dba_pass_entry.get_text())
        self.getApplication().getMainWindow().closeDialogPane()

    def cb_Cancel(self, widget=None, data=None):
        self.getApplication().getMainWindow().closeDialogPane()

    def render(self):
        try:
            server = self.getApplication().getLocalObjectById(self.serverId)
        except GenericObjectStoreException, e:
            self.getApplication().getMainWindow().closeDialogPane()
Example #2
0
class NewProfile(gtk.Frame):
    def __init__(self, parent):
        gtk.Frame.__init__(self, _("Create a new profile"))
        self.par=parent

        self.fixed = gtk.Fixed()
        
        self.l_user = gtk.Label(_("User"))
        self.e_user = DefaultEntry(default_message=_("username"))
        self.l_password = gtk.Label(_("Password"))
        self.e_password = gtk.Entry()
        self.l_password_r = gtk.Label (_("Repeat password"))
        self.e_password_r = gtk.Entry()
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        
        self.e_password.set_invisible_char("●")
        self.e_password_r.set_invisible_char("●")
        self.e_password.set_visibility(False)
        self.e_password_r.set_visibility(False)
        
        self.fixed.put(self.l_user,10,10)
        self.fixed.put(self.e_user,110,10)
        self.fixed.put(self.l_password,10,35)
        self.fixed.put(self.e_password,110,35)
        self.fixed.put(self.l_password_r,10,60)
        self.fixed.put(self.e_password_r,110,60)
        self.fixed.put(self.ok,110,85)

        self.add(self.fixed)
        
        self.ok.connect("clicked", self.cb_OK)
        
    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()
    
    def cb_OK(self,widget=None,data=None):
        pw1 = self.e_password.get_text()
        pw2 = self.e_password_r.get_text()
        username = self.e_user.get_text()
        if username and pw1 == pw2:
            hash = hashlib.md5()
            hash.update(pw1)
            self.getApplication().createProfile(username,hash.hexdigest())
            self.getApplication().getMainWindow().closeDialogPane()
Example #3
0
class UseProfile(gtk.Frame):
    def __init__(self,parent):
        gtk.Frame.__init__(self, _("Login to profile"))
        self.par=parent
        
        self.fixed = gtk.Fixed()
        self.l_user = gtk.Label(_("User"))
        self.e_user = DefaultEntry(default_message=_("username"))
        self.l_password = gtk.Label(_("Password"))
        self.e_password = gtk.Entry()
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        
        self.e_password.set_invisible_char("●")
        self.e_password.set_visibility(False)
        
        self.fixed.put(self.l_user,10,10)
        self.fixed.put(self.e_user,110,10)
        self.fixed.put(self.l_password,10,35)
        self.fixed.put(self.e_password,110,35)
        self.fixed.put(self.ok,110,60)

        self.add(self.fixed)
        
        self.ok.connect("clicked", self.cb_OK)
        
    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()

    def cb_OK(self,widget=None,date=None):
        username=self.e_user.get_text()
        password=self.e_password.get_text()
        if username and password:
            try:
                hash = hashlib.md5()
                hash.update(password)
                self.getApplication().doLoginTry(username,hash.hexdigest())
            except Exception,e :
                raise e
            else:
                self.getPar().destroy()
            self.getApplication().getMainWindow().closeDialogPane()
Example #4
0
class InstancePage(gtk.Frame):
    def __init__(self,parent, server=None, instance = None):
        gtk.Frame.__init__(self)
        self.par = parent
        self.serverId = None
        if server is not None:
            self.serverId = server.getLocalId()
        self.instanceId = None
        if instance is not None:
            self.instanceId = instance.getLocalId()
        self.instanceTypes = self.getApplication().getInstanceTypes()
        
        self.set_label(_("Skarphed Admin :: Configure Instance"))
        self.vbox = gtk.VBox()
        self.label = gtk.Label(_("Please configure the Instance"))
        self.vspace = gtk.Label("")
        self.vbox.pack_start(self.label,False)
        self.vbox.pack_start(self.vspace,True)
        
        self.table = gtk.Table(2,4,False)
        self.typeLabel = gtk.Label(_("InstanceType:"))
        
        self.typeStore = gtk.ListStore(str)
        self.typeCombo = gtk.ComboBox(self.typeStore)
        self.typeRenderer = gtk.CellRendererText()
        self.typeCombo.pack_start(self.typeRenderer, True)
        self.typeCombo.add_attribute(self.typeRenderer, 'text', 0)  
        for instanceType in self.instanceTypes:
            self.typeStore.append((instanceType.displayName,))
        self.typeCombo.set_active(0)
        self.urlLabel = gtk.Label(_("URL:"))
        self.urlEntry = DefaultEntry(default_message="http://instance.org")
        self.urlEntry.set_text("http://")
        self.userLabel = gtk.Label(_("Username:"******"username"))
        self.passLabel = gtk.Label(_("Password:"******"●")
        self.table.attach(self.typeLabel,0,1,0,1)
        self.table.attach(self.typeCombo,1,2,0,1)
        self.table.attach(self.urlLabel,0,1,1,2)
        self.table.attach(self.urlEntry,1,2,1,2)
        self.table.attach(self.userLabel,0,1,2,3)
        self.table.attach(self.userEntry,1,2,2,3)
        self.table.attach(self.passLabel,0,1,3,4)
        self.table.attach(self.passEntry,1,2,3,4)
        self.vbox.pack_start(self.table,False)
        
        self.buttonBox = gtk.HBox()
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        self.cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.viewpass = ViewPasswordButton()
        self.viewpass.addEntry(self.passEntry)
        self.space = gtk.Label("")
        self.buttonBox.pack_start(self.space,True)
        self.buttonBox.pack_start(self.viewpass,False)
        self.buttonBox.pack_start(self.cancel,False)
        self.buttonBox.pack_start(self.ok,False)
        self.ok.connect("clicked",self.cb_Ok)
        self.cancel.connect("clicked",self.cb_Cancel)
        self.vbox.pack_start(self.buttonBox,False)
        
        self.add(self.vbox)
        self.getApplication().getMainWindow().openDialogPane(self)
        if instance is not None:
            self.urlEntry.set_sensitive(False)
            self.render()
    
    def render(self):
        try:
            instance = self.getApplication().getLocalObjectById(self.instanceId)
        except GenericObjectStoreException:
            self.getApplication().getMainWindow().closeDialogPane(self)
            return
    
        self.urlEntry.set_text(instance.getUrl())
        self.userEntry.set_text(instance.getUsername())
        self.passEntry.set_text(instance.getPassword())
    
    def getInstanceType(self,text):
        for instanceType in self.instanceTypes:
            if instanceType.displayName == text:
                return instanceType
        return None
    
    def cb_Cancel(self, widget=None, data=None):
        self.getApplication().getMainWindow().closeDialogPane()
    
    def cb_Ok (self, widget=None, data=None):
        def errorMessage(msgId):
            msgs = (_("This URL cannot be resolved"),
                    )
            dia = gtk.MessageDialog(parent=self.getPar().getPar(), flags=0, type=gtk.MESSAGE_WARNING, \
                                  buttons=gtk.BUTTONS_OK, message_format=msgs[msgId])
            dia.run()
            dia.destroy()
        
        instance = None
        if self.instanceId is not None:
            instance = self.getApplication().getLocalObjectById(self.instanceId)
        server = self.getApplication().getLocalObjectById(self.serverId)
        
        if instance is not None:
            instance.setUsername(self.userEntry.get_text())
            instance.setPassword(self.passEntry.get_text())
            instance.establishConnections()
        else:
            url = self.urlEntry.get_text()
            if server is None:
                try:
                    server = self.getApplication().createServerFromInstanceUrl(url)
                except DNSError:
                    errorMessage(0)
                    return
            
            selection = self.typeStore[self.typeCombo.get_active()][0]  
            instanceType = self.getInstanceType(selection)
            
            username = self.userEntry.get_text()
            password = self.passEntry.get_text()
            try:
                if not server.createInstance(instanceType, url, username, password):
                    MessagePage(self, _("This URL resolves to another server. You can't add that here."))
                    return
            except None:
                return
        self.getApplication().getMainWindow().closeDialogPane()

        
    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()
Example #5
0
class ActionWidgetConfig(gtk.Table):
    def __init__(self, par, action):
        self.par = par
        gtk.Table.__init__(self,4,4,False)
        self.actionId = action.getLocalId()
        
        self.radio_url = gtk.RadioButton(None, _("URL:"))
        self.radio_widgetSpaceConstellation = gtk.RadioButton(self.radio_url, _("Widget into Space:"))
        self.radio_view = gtk.RadioButton(self.radio_url, _("Other View:"))
        
        self.entry_url = DefaultEntry(default_message=_("http://www.example.org"))
        self.entry_widget = ObjectCombo(self, 
                                     Widget,
                                     selectFirst=True,
                                     virtualRootObject=action.getActionList().getMenuItem().getMenu().getSite().getSkarphed())
        self.entry_space = SpaceCombo(self,action.getActionList().getMenuItem().getMenu().getSite())
        self.entry_view = ObjectCombo(self, 
                                   View,
                                   selectFirst=True,
                                   virtualRootObject=action.getActionList().getMenuItem().getMenu().getSite().getSkarphed())
        self.entry_url.connect("focus-in-event",self.focusCallback)
        self.entry_widget.connect("popup",self.focusCallback)
        self.entry_widget.connect("changed",self.focusCallback)
        self.entry_space.connect("focus-in-event",self.focusCallback)
        self.entry_view.connect("popup",self.focusCallback)
        self.entry_widget.connect("changed",self.focusCallback)
        
        self.deleteButton = gtk.Button(stock=gtk.STOCK_DELETE)
        self.increaseOrderButton = gtk.Button(stock=gtk.STOCK_GO_UP)
        self.decreaseOrderButton = gtk.Button(stock=gtk.STOCK_GO_DOWN)
        self.saveButton = gtk.Button(stock=gtk.STOCK_SAVE)
        self.deleteButton.connect("clicked", self.deleteCallback)
        self.increaseOrderButton.connect("clicked", self.increaseOrderCallback)
        self.decreaseOrderButton.connect("clicked", self.decreaseOrderCallback)
        self.saveButton.connect("clicked", self.saveCallback)
        
        self.attach(self.radio_url,0,1,0,1)
        self.attach(self.entry_url,1,3,0,1)
        self.attach(self.radio_widgetSpaceConstellation,0,1,1,2)
        self.attach(self.entry_widget,1,2,1,2)
        self.attach(self.entry_space,2,3,1,2)
        self.attach(self.radio_view,0,1,2,3)
        self.attach(self.entry_view,1,3,2,3)
        self.attach(self.deleteButton,0,1,3,4)
        self.attach(self.increaseOrderButton,1,2,3,4)
        self.attach(self.decreaseOrderButton,2,3,3,4)
        self.attach(self.saveButton,3,4,3,4)
        action.addCallback(self.render)
        self.show_all()
        
        self.render()
        
    def render(self):
        try:
            action = self.getApplication().getLocalObjectById(self.actionId)
        except GenericObjectStoreException:
            self.getPar().destroy()
            return
        if action.data['type'] == 'url':
            self.radio_url.set_active(True)
            self.entry_url.set_text(action.data['url'])
        elif action.data['type'] == 'widgetSpaceConstellation':
            self.radio_widgetSpaceConstellation.set_active(True)
            widget=action.getWidget()
            space=action.getSpaceId()
            self.entry_space.setSpaceId(space)
            self.entry_widget.setSelected(widget)
        elif action.data['type'] == 'view':
            self.radio_view.set_active(True)
            view=action.getView()
            self.entry_view.setSelected(view)
    
    def focusCallback(self,widget=None,event=None):
        if widget == self.entry_url:
            self.radio_url.activate()
        elif widget == self.entry_space or widget == self.entry_widget:
            self.radio_widgetSpaceConstellation.activate()
        elif widget == self.entry_view:
            self.radio_view.activate()
        
    
    def deleteCallback(self, widget=None, data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        action.getPar().deleteChildAction(action)
    
    def increaseOrderCallback(self, widget=None, data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        action.increaseOrder()
        
    def decreaseOrderCallback(self, widget=None, data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        action.decreaseOrder()
        
    def saveCallback(self, widget=None,data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        if self.radio_url.get_active():
            action.setUrl(self.entry_url.get_text())
        elif self.radio_widgetSpaceConstellation.get_active():
            widget = self.entry_widget.getSelected()
            action.setWidgetSpaceConstellation(widget.getLocalId(),self.entry_space.getSpaceId())
        elif self.radio_view.get_active():
            action.setView(self.entry_view.getSelected().getLocalId())
    
    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()
Example #6
0
class ServerPropertyPage(gtk.Frame):
    addWindowOpen = False
    MODE_EDIT = 0
    MODE_NEW = 1

    def __init__(self, parent, server=None):
        gtk.Frame.__init__(self)
        self.par = parent
        self.serverId = None
        if server is None:
            self.set_label(_("Skarphed Admin Pro :: New Server"))
            self.mode = ServerPropertyPage.MODE_NEW
        else:
            self.serverId = server.getLocalId()
            self.set_label(_("Skarphed Admin Pro :: Server Properties of ") + server.getIp())
            self.mode = ServerPropertyPage.MODE_EDIT

        self.vbox = gtk.VBox()

        self.instructionlabel = gtk.Label(_("Please enter the Server credentials"))
        self.vbox.pack_start(self.instructionlabel, False)

        self.ipFrame = gtk.Frame(_("Common"))
        self.ipFrameT = gtk.Table(2, 3, False)
        self.ipFrame_IPLabel = gtk.Label(_("IP:"))
        self.ipFrame_IPEntry = DefaultEntry(default_message="172.16.13.37")
        self.ipFrameT.attach(self.ipFrame_IPLabel, 0, 1, 0, 1)
        self.ipFrameT.attach(self.ipFrame_IPEntry, 1, 2, 0, 1)
        self.ipFrame_NameLabel = gtk.Label(_("Name:"))
        self.ipFrame_NameEntry = DefaultEntry(default_message="Server1")
        self.ipFrameT.attach(self.ipFrame_NameLabel, 0, 1, 1, 2)
        self.ipFrameT.attach(self.ipFrame_NameEntry, 1, 2, 1, 2)
        self.ipFrame_Target_Label = gtk.Label("Target system:")
        self.ipFrame_Target_model = gtk.ListStore(str)
        for target in Server.INSTALLATION_TARGETS:
            self.ipFrame_Target_model.append((target.getName(),))
        self.ipFrame_Target_renderer = gtk.CellRendererText()
        self.ipFrame_Target = gtk.ComboBox(self.ipFrame_Target_model)
        self.ipFrame_Target.pack_start(self.ipFrame_Target_renderer, True)
        self.ipFrame_Target.add_attribute(self.ipFrame_Target_renderer, "text", 0)
        self.ipFrameT.attach(self.ipFrame_Target_Label, 0, 1, 2, 3)
        self.ipFrameT.attach(self.ipFrame_Target, 1, 2, 2, 3)
        self.ipFrame.add(self.ipFrameT)

        self.vbox.pack_start(self.ipFrame, False)

        self.sshFrame = gtk.Frame(_("SSH"))
        self.sshFrameT = gtk.Table(2, 2, False)
        self.sshFrame_NameLabel = gtk.Label(_("Username:"******"root")
        self.sshFrame_PassLabel = gtk.Label(_("Password:"******"●")
        self.sshFrameT.attach(self.sshFrame_NameLabel, 0, 1, 0, 1)
        self.sshFrameT.attach(self.sshFrame_NameEntry, 1, 2, 0, 1)
        self.sshFrameT.attach(self.sshFrame_PassLabel, 0, 1, 1, 2)
        self.sshFrameT.attach(self.sshFrame_PassEntry, 1, 2, 1, 2)
        self.sshFrame.add(self.sshFrameT)
        self.vbox.pack_start(self.sshFrame, False)

        self.instFrame = gtk.Frame(_("Instances"))
        self.instFrameT = gtk.Table(2, 4, False)
        self.instList = gtk.TreeView()
        self.instStore = gtk.ListStore(gtk.gdk.Pixbuf, str, int)
        self.instList.set_model(self.instStore)
        self.instCol_Icon = gtk.TreeViewColumn()
        self.instCol_Name = gtk.TreeViewColumn(_("Instance"))
        self.instRen_Icon = gtk.CellRendererPixbuf()
        self.instRen_Name = gtk.CellRendererText()
        self.instCol_Icon.pack_start(self.instRen_Icon, False)
        self.instCol_Name.pack_start(self.instRen_Name, True)
        self.instCol_Icon.add_attribute(self.instRen_Icon, "pixbuf", 0)
        self.instCol_Name.add_attribute(self.instRen_Name, "text", 1)
        self.instList.append_column(self.instCol_Icon)
        self.instList.append_column(self.instCol_Name)
        self.instAdd = gtk.Button(stock=gtk.STOCK_ADD)
        self.instRemove = gtk.Button(stock=gtk.STOCK_REMOVE)
        self.instEdit = gtk.Button(stock=gtk.STOCK_EDIT)
        self.instFrameT.attach(self.instList, 0, 1, 0, 4)
        self.instFrameT.attach(self.instAdd, 1, 2, 0, 1)
        self.instFrameT.attach(self.instRemove, 1, 2, 1, 2)
        self.instFrameT.attach(self.instEdit, 1, 2, 2, 3)
        self.instAdd.connect("clicked", self.cb_Add)
        self.instRemove.connect("clicked", self.cb_Remove)
        self.instEdit.connect("clicked", self.cb_Edit)
        self.instList.connect("cursor-changed", self.cb_cursorChanged)
        self.instFrame.add(self.instFrameT)
        self.vbox.pack_start(self.instFrame, False)

        self.fill = gtk.Label("")
        self.vbox.pack_start(self.fill, True)

        self.buttons = gtk.HBox()
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        self.cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.viewpass = ViewPasswordButton()
        self.viewpass.addEntry(self.sshFrame_PassEntry)
        self.ok.connect("clicked", self.cb_OK)
        self.cancel.connect("clicked", self.cb_Cancel)
        self.buttons.pack_end(self.ok, False)
        self.buttons.pack_end(self.cancel, False)
        self.buttons.pack_end(self.viewpass, False)
        self.vbox.pack_start(self.buttons, False)

        self.add(self.vbox)

        if server is not None:
            self.ipFrame_IPEntry.set_text(server.getIp())
            self.ipFrame_NameEntry.set_text(server.getRawName())
            self.sshFrame_NameEntry.set_text(server.getSSHName())
            self.sshFrame_PassEntry.set_text(server.getSSHPass())
            server.addCallback(self.render)
        self.getApplication().getMainWindow().openDialogPane(self)
        self.render()

    def render(self):
        def search(model, path, rowiter, target):
            text = model.get_value(rowiter, 0)
            if text == target.getName():
                self.ipFrame_Target.set_active_iter(rowiter)

        server = None
        try:
            server = self.getApplication().getLocalObjectById(self.serverId)
        except GenericObjectStoreException:
            if self.mode == ServerPropertyPage.MODE_EDIT:
                self.getApplication().getMainWindow().closeDialogPane()
                return

        self.instFrame.set_visible(self.mode == ServerPropertyPage.MODE_EDIT)

        if server is not None and server.isTargetUsable():
            self.ipFrame_Target_model.foreach(search, server.getTarget())

        self.instStore.clear()
        if server is not None:
            for instance in server.getInstances():
                icon = IconStock.SKARPHED  # TODO: Implement Icon
                self.instStore.append((icon, instance.getName(), instance.getLocalId()))
        self.cb_cursorChanged()

    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()

    def cb_Add(self, widget=None, data=None):
        server = self.getApplication().getLocalObjectById(self.serverId)
        InstancePage(self, server)

    def cb_Remove(self, widget=None, data=None):
        instance = self.getCurrentInstance()
        if instance is None:
            return
        try:
            server = self.getApplication().getLocalObjectById(self.serverId)
        except GenericObjectStoreException:
            server = None
        server.removeInstance(instance)
        selection = self.instList.get_selection()
        rowiter = selection.get_selected()[1]
        self.instStore.remove(rowiter)
        self.render()

    def cb_Edit(self, widget=None, data=None):
        instance = self.getCurrentInstance()
        try:
            server = self.getApplication().getLocalObjectById(self.serverId)
        except GenericObjectStoreException:
            server = None
        if instance is None or server is None:
            return
        InstancePage(self, server, instance)

    def cb_cursorChanged(self, tree=None, path=None, data=None):
        selection = self.instList.get_selection()
        if selection is None:
            state = False
        else:
            rowiter = selection.get_selected()[1]
            state = rowiter is not None
        self.instEdit.set_sensitive(state)
        self.instRemove.set_sensitive(state)

    def getCurrentInstance(self, onlyId=True):
        try:
            server = self.getApplication().getLocalObjectById(self.serverId)
        except GenericObjectStoreException:
            server = None
        if server is None:
            return None
        selection = self.instList.get_selection()
        rowiter = selection.get_selected()[1]
        return self.getApplication().getLocalObjectById(self.instStore.get_value(rowiter, 2))

    def cb_OK(self, widget=None, data=None):
        try:
            concernedServer = self.getApplication().getLocalObjectById(self.serverId)
        except GenericObjectStoreException:
            concernedServer = None
        if self.serverId is None:
            server = self.getApplication().getData().createServer()
            self.mode = ServerPropertyPage.MODE_EDIT
        else:
            server = concernedServer
        server.setIp(self.ipFrame_IPEntry.get_text())
        server.setName(self.ipFrame_NameEntry.get_text())
        server.setSSHName(self.sshFrame_NameEntry.get_text())
        server.setSSHPass(self.sshFrame_PassEntry.get_text())
        server.setTarget(self.ipFrame_Target.get_active_text())
        server.load = server.LOADED_PROFILE
        server.establishConnections()

        self.getApplication().getMainWindow().closeDialogPane()

    def cb_Cancel(self, widget=None, data=None):
        self.getApplication().getMainWindow().closeDialogPane()
Example #7
0
class NewSchemaPage(gtk.Frame):
    class Pulse(Thread):
        def __init__(self, window):
            Thread.__init__(self)
            self.window = window

        def run(self):
            while True:
                if self.window.working:
                    self.window.progress.pulse()
                if not self.window.working:
                    break
                sleep(0.1)


    def __init__(self,par,database):
        gtk.Frame.__init__(self, _("Skarphed Admin :: New Schema"))
        self.par = par

        self.databaseId = database.getLocalId()

        self.working = True

        self.table = gtk.Table(4,2,False)
        
        self.instruction = gtk.Label(_("Enter the name of the new schema.\n\
         The first user (root) of the new skarphed db will have the password 'root'.\n\
         Please change this password after your first login."))

        self.name_label = gtk.Label(_("Name:"))
        self.name_entry = DefaultEntry(default_message=_("new_database_name"))
        self.buttonhbox = gtk.HBox()
        self.progress = gtk.ProgressBar()
        self.cancel = gtk.Button(stock=gtk.STOCK_CLOSE)
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        self.buttonhbox.add(self.cancel)
        self.buttonhbox.add(self.ok)
        
        self.table.attach(self.instruction,0,2,0,1)
        self.table.attach(self.name_label,0,1,1,2)
        self.table.attach(self.name_entry,1,2,1,2)
        self.table.attach(self.buttonhbox,1,2,3,4)

        self.ok.connect("clicked", self.cb_Ok)
        self.cancel.connect("clicked", self.cb_Cancel)
        self.connect("delete-event", self.cb_Cancel)

        database.addCallback(self.render)

        self.table.set_border_width(10)
        self.add(self.table)
        self.getApplication().getMainWindow().openDialogPane(self)


    def cb_Ok(self,widget=None,data=None):
        database = self.getApplication().getLocalObjectById(self.databaseId)
        self.Pulse(self).start()
        database.createSchema(self.name_entry.get_text())

    def cb_Cancel(self, widget=None, data=None):
        self.getApplication().getMainWindow().closeDialogPane()

    def render(self):
        try:
            database = self.getApplication().getLocalObjectById(self.databaseId)
        except GenericObjectStoreException:
            self.getApplication().getMainWindow().closeDialogPane()
        if database.installFinished is not None and database.installFinished:
            self.working=False
            self.getApplication().getMainWindow().closeDialogPane()

    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()
Example #8
0
class Skarphed_repoPage(ObjectPageAbstract):
    def __init__(self, par, repo):
        ObjectPageAbstract.__init__(self, par, repo)

        self.table = gtk.Table(2, 4, False)

        self.moduleFrame = PageFrame(self, _("Modules"), IconStock.MODULE)
        self.moduleList = ModuleList(self, repo)
        self.moduleFrame.add(self.moduleList)
        self.pack_start(self.moduleFrame, False)

        self.mUploadFrame = PageFrame(self, _("Upload Module"), IconStock.MODULE)
        self.mUploadbox = gtk.HBox()
        self.mUploadbox.set_border_width(10)
        self.mUpload_label = gtk.Label(_("Please choose the Module and click OK"))
        self.mUpload_filechoose = gtk.FileChooserButton(_("Select Module"), None)
        self.mUpload_filechoose.connect("file-set", self.moduleFileChosen)
        self.mUpload_filechoose.set_size_request(200, 30)
        self.mUpload_enter = gtk.Button(stock=gtk.STOCK_OK)
        self.mUpload_enter.connect("clicked", self.uploadModule)
        self.mUpload_dummy = gtk.Label("")
        self.mUploadbox.pack_start(self.mUpload_label, False)
        self.mUploadbox.pack_start(self.mUpload_filechoose, False)
        self.mUploadbox.pack_start(self.mUpload_enter, False)
        self.mUploadbox.pack_start(self.mUpload_dummy, True)
        self.mUploadFrame.add(self.mUploadbox)
        self.pack_start(self.mUploadFrame, False)

        self.templateFrame = PageFrame(self, _("Templates"), IconStock.TEMPLATE)
        self.templateVBox = gtk.VBox()
        self.templateButtonBox = gtk.HBox()
        self.templateDeleteButton = gtk.Button(stock=gtk.STOCK_DELETE)
        self.templateDummy = gtk.Label("")
        self.templateList = TemplateList(self, repo)
        self.templateVBox.pack_start(self.templateList, True)
        self.templateVBox.pack_start(self.templateButtonBox, False)
        self.templateButtonBox.pack_start(self.templateDummy, True)
        self.templateButtonBox.pack_start(self.templateDeleteButton, False)
        self.templateDeleteButton.connect("clicked", self.cb_DeleteTemplate)
        self.templateFrame.add(self.templateVBox)
        self.pack_start(self.templateFrame, False)

        self.tUploadFrame = PageFrame(self, _("Upload Template"), IconStock.TEMPLATE)
        self.tUploadbox = gtk.HBox()
        self.tUploadbox.set_border_width(10)
        self.tUpload_label = gtk.Label(_("Please choose the Template and click OK"))
        self.tUpload_filechoose = gtk.FileChooserButton(_("Select Template"), None)
        self.tUpload_filechoose.connect("file-set", self.templateFileChosen)
        self.tUpload_filechoose.set_size_request(200, 30)
        self.tUpload_enter = gtk.Button(stock=gtk.STOCK_OK)
        self.tUpload_enter.connect("clicked", self.uploadTemplate)
        self.tUpload_dummy = gtk.Label("")
        self.tUploadbox.pack_start(self.tUpload_label, False)
        self.tUploadbox.pack_start(self.tUpload_filechoose, False)
        self.tUploadbox.pack_start(self.tUpload_enter, False)
        self.tUploadbox.pack_start(self.tUpload_dummy, True)
        self.tUploadFrame.add(self.tUploadbox)
        self.pack_start(self.tUploadFrame, False)

        self.adminFrame = PageFrame(self, _("Change Password"), IconStock.CREDENTIAL)
        self.adminHBox = gtk.HBox()
        self.adminHBoxDummy = gtk.Label("")
        self.adminTable = gtk.Table(2, 4, False)
        self.adminLabel = gtk.Label(_("Change admin-password here:"))
        self.adminPasswordLabel = gtk.Label(_("New password"))
        self.adminRepeatLabel = gtk.Label(_("New password (repeat)"))
        self.adminPasswordEntry = gtk.Entry()
        self.adminPasswordEntry.set_visibility(False)
        self.adminPasswordEntry.set_invisible_char("●")
        self.adminRepeatEntry = gtk.Entry()
        self.adminRepeatEntry.set_visibility(False)
        self.adminRepeatEntry.set_invisible_char("●")
        self.adminButtonDummy = gtk.Label()
        self.adminButtonHBox = gtk.HBox()
        self.adminButtonChange = gtk.Button(stock=gtk.STOCK_OK)
        self.adminButtonHBox.pack_start(self.adminButtonDummy, True)
        self.adminButtonHBox.pack_start(self.adminButtonChange, False)
        self.adminTable.attach(self.adminLabel, 0, 2, 0, 1)
        self.adminTable.attach(self.adminPasswordLabel, 0, 1, 1, 2)
        self.adminTable.attach(self.adminPasswordEntry, 1, 2, 1, 2)
        self.adminTable.attach(self.adminRepeatLabel, 0, 1, 2, 3)
        self.adminTable.attach(self.adminRepeatEntry, 1, 2, 2, 3)
        self.adminTable.attach(self.adminButtonHBox, 0, 2, 3, 4)
        self.adminHBox.pack_start(self.adminTable, False)
        self.adminHBox.pack_start(self.adminHBoxDummy, True)
        self.adminFrame.add(self.adminHBox)
        self.adminButtonChange.connect("clicked", self.cb_ChangePassword)
        self.pack_start(self.adminFrame, False)

        self.developerFrame = PageFrame(self, _("Developers"), IconStock.USER)
        self.developerHBox = gtk.HBox()
        self.developerList = DeveloperList(self, repo)
        self.developerHBox.pack_start(self.developerList, True)
        self.developerTable = gtk.Table(2, 5, False)
        self.developerButtonHBox = gtk.HBox()
        self.developerButtonHBoxDummy = gtk.Label()
        self.developerLabel = gtk.Label(_("Please enter the information for a new Developer here:"))
        self.developerNameLabel = gtk.Label(_("Nickname:"))
        self.developerFullnameLabel = gtk.Label(_("Full Name:"))
        self.developerPublicKeyLabel = gtk.Label(_("Public Key:"))
        self.developerNameEntry = DefaultEntry(default_message=_("nickname"))
        self.developerFullnameEntry = DefaultEntry(default_message=_("Firstname Lastname"))
        self.developerPublicKeyEntry = gtk.TextView()
        self.developerAddButton = gtk.Button(stock=gtk.STOCK_ADD)
        self.developerAddButton.connect("clicked", self.cb_Add)
        self.developerButtonHBox.pack_start(self.developerButtonHBoxDummy, True)
        self.developerButtonHBox.pack_start(self.developerAddButton, False)
        self.developerTable.attach(self.developerLabel, 0, 2, 0, 1)
        self.developerTable.attach(self.developerNameLabel, 0, 1, 1, 2)
        self.developerTable.attach(self.developerNameEntry, 1, 2, 1, 2)
        self.developerTable.attach(self.developerFullnameLabel, 0, 1, 2, 3)
        self.developerTable.attach(self.developerFullnameEntry, 1, 2, 2, 3)
        self.developerTable.attach(self.developerPublicKeyLabel, 0, 1, 3, 4)
        self.developerTable.attach(self.developerPublicKeyEntry, 1, 2, 3, 4)
        self.developerTable.attach(self.developerButtonHBox, 0, 2, 4, 5)
        self.developerHBox.pack_start(self.developerTable, False)
        self.developerFrame.add(self.developerHBox)
        self.pack_start(self.developerFrame, False)

        self.show_all()

    def render(self):
        repo = self.getMyObject()
        if not repo:
            return

        auth = repo.isAuthenticated()

        self.adminFrame.set_visible(auth)
        self.developerFrame.set_visible(auth)
        self.templateDeleteButton.set_visible(auth)
        self.moduleList.render()
        self.developerList.render()

    def cb_ChangePassword(self, widget=None, data=None):
        pw1 = self.adminPasswordEntry.get_text()
        pw2 = self.adminRepeatEntry.get_text()
        if pw1 == pw2:
            repo = self.getMyObject()
            repo.changePassword(pw1)
        else:
            pass  # TODO: Implement error behaviour

    def cb_DeleteTemplate(self, widget=None, data=None):
        def execute():
            repo = self.getMyObject()
            repo.deleteTemplate(self.templateToDelete)
            self.templateToDelete = None

        selection = self.templateList.treeview.get_selection()
        rowiter = selection.get_selected()[1]
        nr = self.templateList.store.get_value(rowiter, 4)
        self.templateToDelete = nr
        YesNoPage(
            self.getApplication().getMainWindow(),
            _("Do you really want to delete this Template from the Repository?"),
            execute,
        )

    def cb_Add(self, widget=None, data=None):
        name = self.developerNameEntry.get_text()
        fullName = self.developerFullnameEntry.get_text()
        textBuffer = self.developerPublicKeyEntry.get_buffer()
        publicKey = textBuffer.get_text(textBuffer.get_start_iter(), textBuffer.get_end_iter())

        repo = self.getMyObject()
        if not repo:
            return
        repo.registerDeveloper(name, fullName, publicKey)

    def moduleFileChosen(self, widget=None, data=None):
        self.moduleFileToUpload = widget.get_filename()

    def templateFileChosen(self, widget=None, data=None):
        self.templateFileToUpload = widget.get_filename()

    def uploadModule(self, widget=None, data=None):
        repo = self.getMyObject()
        if not repo:
            return
        repo.uploadModule(self.moduleFileToUpload)

    def uploadTemplate(self, widget=None, data=None):
        repo = self.getMyObject()
        if not repo:
            return
        repo.uploadTemplate(self.templateFileToUpload)
Example #9
0
class RegisterSchemaPage(gtk.Frame):
    def __init__(self, par, database):
        self.par = par
        gtk.Frame.__init__(self, _("Skarphed Admin :: Register Schema"))

        self.databaseId = database.getLocalId()

        self.table = gtk.Table(4,2,False)
        self.instruction = gtk.Label(_("Please enter Credentials here:"))
        self.name_label = gtk.Label(_("Schema-Name"))
        self.user_label = gtk.Label(_("Schema-User:"******"Schema-Password:"******"user"))
        self.pass_entry = DefaultEntry(default_message=_("password"))
        self.name_entry = DefaultEntry(default_message=_("schema"))
        self.buttonhbox = gtk.HBox()
        self.cancel = gtk.Button(stock=gtk.STOCK_CLOSE)
        self.ok = gtk.Button(stock=gtk.STOCK_OK)
        self.buttonhbox.add(self.cancel)
        self.buttonhbox.add(self.ok)
        
        self.table.attach(self.instruction,0,2,0,1)
        self.table.attach(self.name_label,0,1,1,2)
        self.table.attach(self.name_entry,1,2,1,2)
        self.table.attach(self.user_label,0,1,2,3)
        self.table.attach(self.user_entry,1,2,2,3)
        self.table.attach(self.pass_label,0,1,3,4)
        self.table.attach(self.pass_entry,1,2,3,4)
        self.table.attach(self.buttonhbox,1,2,4,5)

        self.ok.connect("clicked", self.cb_Ok)
        self.cancel.connect("clicked", self.cb_Cancel)
        self.connect("delete-event", self.cb_Cancel)

        database.addCallback(self.render)

        self.table.set_border_width(10)
        self.add(self.table)
        self.getApplication().getMainWindow().openDialogPane(self)


    def cb_Ok(self,widget=None,data=None):
        database = self.getApplication().getLocalObjectById(self.databaseId)
        database.registerSchema(self.name_entry.get_text(),
                                self.user_entry.get_text(), 
                                self.pass_entry.get_text())
        self.getApplication().getMainWindow().closeDialogPane()

    def cb_Cancel(self, widget=None, data=None):
        self.getApplication().getMainWindow().closeDialogPane()

    def render(self):
        try:
            self.getApplication().getLocalObjectById(self.databaseId)
        except GenericObjectStoreException:
            self.getApplication().getMainWindow().closeDialogPane()

    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()