Example #1
0
    def __init__(self, args, message_level="normal", parent=None):
        """
        Initialization method
        
        @author: Roy Nielsen
        """
        super(StonixWrapper, self).__init__(parent)
        self.ui = Ui_StonixWrapper()
        self.ui.setupUi(self)
        self.args = args

        #self.message_level = message_level
        self.message_level = message_level
        self.myuid = os.getuid()

        #####
        # Set up signals and slots
        self.connect(self.ui.userButton, SIGNAL("clicked()"),
                     self.processCurrentUser)
        self.connect(self.ui.adminButton, SIGNAL("clicked()"),
                     self.processAdminUser)
        self.connect(self.ui.quitButton, SIGNAL("clicked()"), self.rejectApp)

        self.admin_creds = AdministratorCredentials(self.args,
                                                    self.message_level)
Example #2
0
    def __init__(self, args, message_level="normal", parent=None) :
        """
        Initialization method
        
        @author: Roy Nielsen
        """
        super(StonixWrapper, self).__init__(parent)
        self.ui = Ui_StonixWrapper()
        self.ui.setupUi(self)
        self.args = args
        
        #self.message_level = message_level
        self.message_level = message_level
        self.myuid = os.getuid()

        #####
        # Set up signals and slots
        self.connect(self.ui.userButton, SIGNAL("clicked()"), self.processCurrentUser)
        self.connect(self.ui.adminButton, SIGNAL("clicked()"), self.processAdminUser)
        self.connect(self.ui.quitButton, SIGNAL("clicked()"), self.rejectApp)

        self.admin_creds = AdministratorCredentials(self.args, self.message_level)
Example #3
0
class StonixWrapper(QDialog) :
    """
    Class controlling the stonix wrapper dialog
    """
    def __init__(self, args, message_level="normal", parent=None) :
        """
        Initialization method
        
        @author: Roy Nielsen
        """
        super(StonixWrapper, self).__init__(parent)
        self.ui = Ui_StonixWrapper()
        self.ui.setupUi(self)
        self.args = args
        
        #self.message_level = message_level
        self.message_level = message_level
        self.myuid = os.getuid()

        #####
        # Set up signals and slots
        self.connect(self.ui.userButton, SIGNAL("clicked()"), self.processCurrentUser)
        self.connect(self.ui.adminButton, SIGNAL("clicked()"), self.processAdminUser)
        self.connect(self.ui.quitButton, SIGNAL("clicked()"), self.rejectApp)

        self.admin_creds = AdministratorCredentials(self.args, self.message_level)
        

    def rejectApp(self) :
        """
        Reject slot, print a message before sending the reject signal...
        
        Author: Roy Nielsen
        """
        QMessageBox.warning(self, "Warning", "You hit Quit, exiting program.", QMessageBox.Ok)
        self.reject()


    def processCurrentUser(self) :
        """
        Run Stonix with the currently logged in user
        
        @author: Roy Nielsen
        """
        fullStonixPath = os.path.join(getResourcesDir(), "stonix.app/Contents/MacOS/stonix")
        
        if self.args:
            command = [fullStonixPath] + self.args
        else:
            command = [fullStonixPath, "-G", "-dv"]
        

        retval = ""
        reterr = ""
        
        child_pid = os.fork()
        if child_pid == 0 :
            print "Child Process: PID# %s" % os.getpid()
            retval, reterr = system_call_retval(command, self.message_level)

        else:
            print "Exiting parent process: PID# %s" % os.getpid()
            self.reject()
            
        self.reject()

        
    def processAdminUser(self) :
        """
        Run Stonix as an admin user - load AdministratorCredentials dialog
        with the current user as the default username.
        
        Have AdministratorCredentials handle it's own buttons.
        
        @author: Roy Nielsen
        """
        retval = self.admin_creds.exec_()
        self.admin_creds.raise_()
        
        if retval == 1 :
            self.accept

        log_message("processAdminUser complete...", "verbose", self.message_level)

        self.reject()
Example #4
0
class StonixWrapper(QDialog):
    """
    Class controlling the stonix wrapper dialog
    """
    def __init__(self, args, message_level="normal", parent=None):
        """
        Initialization method
        
        @author: Roy Nielsen
        """
        super(StonixWrapper, self).__init__(parent)
        self.ui = Ui_StonixWrapper()
        self.ui.setupUi(self)
        self.args = args

        #self.message_level = message_level
        self.message_level = message_level
        self.myuid = os.getuid()

        #####
        # Set up signals and slots
        self.connect(self.ui.userButton, SIGNAL("clicked()"),
                     self.processCurrentUser)
        self.connect(self.ui.adminButton, SIGNAL("clicked()"),
                     self.processAdminUser)
        self.connect(self.ui.quitButton, SIGNAL("clicked()"), self.rejectApp)

        self.admin_creds = AdministratorCredentials(self.args,
                                                    self.message_level)

    def rejectApp(self):
        """
        Reject slot, print a message before sending the reject signal...
        
        Author: Roy Nielsen
        """
        QMessageBox.warning(self, "Warning", "You hit Quit, exiting program.",
                            QMessageBox.Ok)
        self.reject()

    def processCurrentUser(self):
        """
        Run Stonix with the currently logged in user
        
        @author: Roy Nielsen
        """
        fullStonixPath = os.path.join(getResourcesDir(),
                                      "stonix.app/Contents/MacOS/stonix")

        if self.args:
            command = [fullStonixPath] + self.args
        else:
            command = [fullStonixPath, "-G", "-dv"]

        retval = ""
        reterr = ""

        child_pid = os.fork()
        if child_pid == 0:
            print "Child Process: PID# %s" % os.getpid()
            retval, reterr = system_call_retval(command, self.message_level)

        else:
            print "Exiting parent process: PID# %s" % os.getpid()
            self.reject()

        self.reject()

    def processAdminUser(self):
        """
        Run Stonix as an admin user - load AdministratorCredentials dialog
        with the current user as the default username.
        
        Have AdministratorCredentials handle it's own buttons.
        
        @author: Roy Nielsen
        """
        retval = self.admin_creds.exec_()
        self.admin_creds.raise_()

        if retval == 1:
            self.accept

        log_message("processAdminUser complete...", "verbose",
                    self.message_level)

        self.reject()