Пример #1
0
class Widget(QtGui.QWidget, Screen):
    title = i18n("Packages")
    desc = i18n("Install / Remove Programs")

    screenSettings = {}
    screenSettings["hasChanged"] = False

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_packageWidget()
        self.ui.setupUi(self)

        # set up some variables
        notifier = '/usr/bin/octopi-notifier'
        desktop = '/usr/share/applications/octopi-notifier.desktop'
        autostart = '/usr/share/autostart/octopi-notifier.desktop'
        self.notifier_enabled = os.path.exists(autostart)

        # set initial states
        self.ui.checkUpdate.setEnabled(os.path.exists(notifier))
        self.ui.checkUpdate.setChecked(self.notifier_enabled)

    def applySettings(self):
        self.__class__.screenSettings["enabled"] = self.notifier_enabled
        if self.ui.checkUpdate.isChecked():
            # checks if octopi-notifier is not in the output of ps -Af
            if "octopi-notifier" not in subprocess.Popen(
                    "ps -Af", shell=True,
                    stdout=subprocess.PIPE).stdout.read():
                subprocess.Popen(["octopi-notifier"], stdout=subprocess.PIPE)

            # was octopi-notifier disabled before?
            if not self.notifier_enabled:
                self.__class__.screenSettings["hasChanged"] = True
            else:
                self.__class__.screenSettings["hasChanged"] = False

        else:
            # don't care if this fails
            os.system("killall octopi-notifier")

            # was octopi-notifier enabled to begin with?
            if self.notifier_enabled:
                self.__class__.screenSettings["hasChanged"] = True
            else:
                self.__class__.screenSettings["hasChanged"] = False

    def shown(self):
        pass

    def execute(self):
        self.applySettings()
        return True
Пример #2
0
class Widget(QtGui.QWidget, Screen):
    title = i18n("Packages")
    desc = i18n("Install / Remove Programs")

    screenSettings = {}
    screenSettings["hasChanged"] = False

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_packageWidget()
        self.ui.setupUi(self)

        # set up some variables
        notifier = '/usr/bin/octopi-notifier'
        desktop = '/usr/share/applications/octopi-notifier.desktop'
        autostart = '/usr/share/autostart/octopi-notifier.desktop' 
        self.notifier_enabled = os.path.exists(autostart)

        # set initial states
        self.ui.checkUpdate.setEnabled(os.path.exists(notifier))
        self.ui.checkUpdate.setChecked(self.notifier_enabled)

    def applySettings(self):
        self.__class__.screenSettings["enabled"] = self.notifier_enabled
        if self.ui.checkUpdate.isChecked():
            # checks if octopi-notifier is not in the output of ps -Af
            if "octopi-notifier" not in subprocess.Popen(
                    "ps -Af", shell=True, stdout=subprocess.PIPE).stdout.read():
                subprocess.Popen(["octopi-notifier"], stdout=subprocess.PIPE)

            # was octopi-notifier disabled before?
            if not self.notifier_enabled:
                self.__class__.screenSettings["hasChanged"] = True
            else:
                self.__class__.screenSettings["hasChanged"] = False

        else:
            # don't care if this fails
            os.system("killall octopi-notifier")

            # was octopi-notifier enabled to begin with?
            if self.notifier_enabled:
                self.__class__.screenSettings["hasChanged"] = True
            else:
                self.__class__.screenSettings["hasChanged"] = False

    def shown(self):
        pass

    def execute(self):
        self.applySettings()
        return True
Пример #3
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_packageWidget()
        self.ui.setupUi(self)

        # set up some variables
        notifier = '/usr/bin/octopi-notifier'
        desktop = '/usr/share/applications/octopi-notifier.desktop'
        autostart = '/usr/share/autostart/octopi-notifier.desktop'
        self.notifier_enabled = os.path.exists(autostart)

        # set initial states
        self.ui.checkUpdate.setEnabled(os.path.exists(notifier))
        self.ui.checkUpdate.setChecked(self.notifier_enabled)
Пример #4
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_packageWidget()
        self.ui.setupUi(self)

        # set up some variables
        notifier = '/usr/bin/octopi-notifier'
        desktop = '/usr/share/applications/octopi-notifier.desktop'
        autostart = '/usr/share/autostart/octopi-notifier.desktop' 
        self.notifier_enabled = os.path.exists(autostart)

        # set initial states
        self.ui.checkUpdate.setEnabled(os.path.exists(notifier))
        self.ui.checkUpdate.setChecked(self.notifier_enabled)