Ejemplo n.º 1
0
def action_triggered(*args):
    debug.info(args[0])
    if (args[0] == QtWidgets.QSystemTrayIcon.Trigger):
        args[-1].hide()
        args[-1].show()
        args[-1].move(QtGui.QCursor.pos() -
                      QtCore.QPoint(0, args[-1].height()))
        update_config(args[-1])
        args[-1].raise_()
Ejemplo n.º 2
0
def rbhus_notify_done(id):
    debug.info(id)
    try:
        rbhus_notify_ids[id].deleteLater()
        utilsTray.seeNotification(id)
        del (rbhus_notify_ids[id])
    except:
        debug.error("THIS SHOULD NOT HAPPEN ")
        debug.error(sys.exc_info())
Ejemplo n.º 3
0
def notity_pidgin_received_msg(tray, *args):
    debug.info(args)
    if (options_dict['pidgin-notify'] == QtCore.Qt.Checked):
        localtime = time.localtime()
        tray.showMessage(args[0][1].split("@")[0] + " - " +
                         unicode(localtime.tm_hour) + ":" +
                         unicode(localtime.tm_min),
                         args[0][2],
                         msecs=1000 * options_dict['pidgin-notify-timeout'],
                         icon=QtWidgets.QSystemTrayIcon.Information)
Ejemplo n.º 4
0
def userList():
    userList_cmd = userList_file + " --ui"
    try:
        p = subprocess.Popen(userList_cmd,
                             shell=True,
                             stderr=subprocess.PIPE,
                             stdout=subprocess.PIPE)
        debug.info(p)
    except:
        debug.error(sys.exc_info())
Ejemplo n.º 5
0
def start_scroll_ui_timer(scroll_timer, scroll_ui):
    current_time = QtCore.QTime.currentTime()
    secs_to_stop = current_time.secsTo(scroll_ui.timeEdit.time())
    if (scroll_ui.groupBoxAfterTime.isChecked()):
        if (scroll_timer.isActive()):
            scroll_timer.stop()
        if (secs_to_stop > 0):
            debug.info(secs_to_stop)
            scroll_timer.start(2000 * secs_to_stop)
    else:
        scroll_ui.timeEdit.setTime(QtCore.QTime.currentTime())
Ejemplo n.º 6
0
    def connectToPidgin(self):
        try:
            self.purple = self.bus.get_object(
                "im.pidgin.purple.PurpleService",
                "/im/pidgin/purple/PurpleObject")

            debug.info("connected to pidgin")
            self.isAlive = True
            self.connected.emit()
        except:
            self.not_connected.emit()
            debug.error(sys.exc_info())
Ejemplo n.º 7
0
def run_once():
    if (os.path.exists(os.path.join(homeconfig, "per-app-framework-default"))):
        try:
            p = subprocess.Popen(os.path.join(homeconfig,
                                              "per-app-framework-default"),
                                 shell=True,
                                 stderr=subprocess.PIPE,
                                 stdout=subprocess.PIPE).communicate()[0]
            debug.info(p)
        except:
            debug.error(sys.exc_info())
    utilsTray.updateUserData()
Ejemplo n.º 8
0
def app_lock(tray):
    import random
    time.sleep(random.uniform(0.000, 0.500))
    if (os.path.exists(app_lock_file)):
        f = open(app_lock_file, "r")
        pid = f.read().strip()
        f.close()
        debug.info(pid)
        try:
            p = psutil.Process(int(pid))
            debug.info(p.cmdline()[1])
            if (os.path.abspath(p.cmdline()[1]) == os.path.abspath(__file__)):
                tray.showMessage('tray-server',
                                 'Already an instance of the app is running.',
                                 msecs=10000)
                tray.showMessage(
                    'tray-server',
                    'Delete the file \'{0}\' if you want to force run it'.
                    format(app_lock_file),
                    msecs=10000)
                debug.warning("already an instance of the app is running.")
                debug.warning("delete the file {0}".format(app_lock_file))
                QtCore.QCoreApplication.instance().quit()
                os._exit(1)
            else:
                raise Exception(
                    "seems like a different process has the same pid")
        except:
            debug.warn(sys.exc_info())
            f = open(app_lock_file, "w")
            try:
                fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
            except:
                debug.error(sys.exc_info())
                QtCore.QCoreApplication.instance().quit()
                os._exit(1)
            f.write(unicode(os.getpid()))
            f.flush()
            fcntl.flock(f, fcntl.LOCK_UN)
            f.close()
    else:
        f = open(app_lock_file, "w")
        try:
            fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
        except:
            debug.error(sys.exc_info())
            QtCore.QCoreApplication.instance().quit()
            os._exit(1)
        f.write(unicode(os.getpid()))
        f.flush()
        fcntl.flock(f, fcntl.LOCK_UN)
        f.close()
Ejemplo n.º 9
0
def rbhus_notify_open_types(id, type_script, type_script_args, button=None):
    type_script_exe = os.path.join(type_dir, type_script)
    type_script_exe_with_args = type_script_exe + " " + type_script_args
    p = subprocess.Popen(type_script_exe_with_args,
                         shell=True,
                         stderr=subprocess.PIPE,
                         stdout=subprocess.PIPE)
    out = p.communicate()[0]
    if (p.returncode != 0):
        debug.error(out)
    else:
        debug.info(out)
        utilsTray.markAsChecked(id)
        button.setText("checked")
Ejemplo n.º 10
0
def run_per_app(tray, appdets):
    debug.info(appdets)
    if (options_dict['notify-app-changes'] == QtCore.Qt.Checked):
        tray.showMessage("app-changed", appdets)
    if (options_dict['per-app-framework'] == QtCore.Qt.Checked):
        if (os.path.exists(os.path.join(homeconfig, appdets))):
            try:
                p = subprocess.Popen(os.path.join(homeconfig, appdets),
                                     shell=True,
                                     stderr=subprocess.PIPE,
                                     stdout=subprocess.PIPE).communicate()[0]
                debug.info(p)
            except:
                debug.error(sys.exc_info())
Ejemplo n.º 11
0
 def isConnected(self):
     if (self.purple):
         try:
             self.bus.get_object("im.pidgin.purple.PurpleService",
                                 "/im/pidgin/purple/PurpleObject")
             if (self.isAlive == False):
                 self.not_connected.emit()
                 debug.info("re-connecting")
             debug.info("connected")
             self.isAlive = True
         except:
             self.isAlive = False
             self.purple = None
             self.not_connected.emit()
             debug.error("re-disconnected")
Ejemplo n.º 12
0
def write_config(option_ui):
    debug.info("writing config file - start")
    debug.info(option_ui.checkBox_paf_enable.checkState())
    options_dict[
        'per-app-framework'] = option_ui.checkBox_paf_enable.checkState()
    options_dict[
        'notify-app-changes'] = option_ui.checkBox_paf_notify.checkState()
    options_dict['pidgin-notify'] = option_ui.checkBox_pidgin.checkState()
    # options_dict['render-auto'] = option_ui.checkBox_renderauto.checkState()
    options_dict['pidgin-notify-timeout'] = option_ui.spinBoxTimeOut.value()
    try:
        config_parser.add_section("tray")
    except:
        debug.warn(sys.exc_info())
    for x in options_dict.keys():
        if (x):
            config_parser.set("tray", x, options_dict[x])

    with open(config_file, "wb") as config_fd:
        config_parser.write(config_fd)
    debug.info("writing config file - done")
Ejemplo n.º 13
0
signal.signal(signal.SIGINT, receive_signal)
signal.signal(signal.SIGABRT, receive_signal)
signal.signal(signal.SIGHUP, receive_signal)
signal.signal(signal.SIGSEGV, receive_signal)

acl = rbhus.auth.login()
acl.useEnvUser()

homeconfig = appdirs.user_config_dir("tray-server")
try:
    os.makedirs(homeconfig)
except:
    debug.warn(sys.exc_info())

type_dir = os.path.join(basepath, "type")
debug.info(type_dir)
options_ui_file = os.path.join(basepath, "lib-ui", "selectionBox.ui")
scroll_ui_file = os.path.join(basepath, "lib-ui", "scrollWidget.ui")
textBox_ui_file = os.path.join(basepath, "lib-ui", "textBox.ui")
userList_file = os.path.join(basepath, "tools", "userList.py")
config_file = os.path.join(homeconfig, "tray-server.ini")
app_lock_file = os.path.join(tempfile.gettempdir(),
                             "tray-server-{0}.lock".format(os.environ['USER']))
debug.info(app_lock_file)
app_icon = os.path.join(basepath, "lib-ui", "paf.png")
pidgin_notity_icon = os.path.join(basepath, "lib-ui", "pidgin.png")
config_parser = ConfigParser.ConfigParser()
options_dict = {}

rbhus_notify_ids = {}
afterTimeNotification = None
Ejemplo n.º 14
0
def rbhus_notify(scroll_ui, *args):
    oldno = len(rbhus_notify_ids.keys())
    showui = False

    for x in args[0]:
        checked = True
        if (x['isChecked']):
            checked = True
        else:
            checked = False

        if (not rbhus_notify_ids.has_key(x['id'])):
            msg_box = uic.loadUi(textBox_ui_file)
            msg_box.setParent(scroll_ui)
            msg_box.labelTitle.setText(x['title'])
            msg_box.labelUsers.setText(x['fromUsers'])
            msg_box.labelDate.setText("{0}".format(x['created'].ctime()))
            msg_box.msgBox.setText(x['msg'])
            if (x['isChecked']):
                msg_box.pushButton_open.setText("checked")
                msg_box.isOpenChecked = True
            else:
                msg_box.pushButton_open.setText("open")
                msg_box.isOpenChecked = False
            msg_box.pushButton_open.clicked.connect(
                lambda s, button=msg_box.pushButton_open, id=x[
                    'id'], type_script=x['type_script'], type_script_args=x[
                        'type_script_args']: rbhus_notify_open_types(
                            id, type_script, type_script_args, button=button))
            msg_box.pushButton_done.clicked.connect(
                lambda s, id=x['id']: rbhus_notify_done(id))
            scroll_ui.verticalLayout_2.addWidget(msg_box)
            rbhus_notify_ids[x['id']] = msg_box
            debug.info(x)
        else:
            debug.info(rbhus_notify_ids[x['id']].isOpenChecked)
            if (rbhus_notify_ids[x['id']].isOpenChecked != checked):
                rbhus_notify_ids[x['id']].deleteLater()
                msg_box = uic.loadUi(textBox_ui_file)
                msg_box.setParent(scroll_ui)
                msg_box.labelTitle.setText(x['title'])
                msg_box.labelUsers.setText(x['fromUsers'])
                msg_box.labelDate.setText("{0}".format(x['created'].ctime()))
                msg_box.msgBox.setText(x['msg'])
                if (x['isChecked']):
                    msg_box.pushButton_open.setText("checked")
                    msg_box.isOpenChecked = True
                else:
                    msg_box.pushButton_open.setText("open")
                    msg_box.isOpenChecked = False
                msg_box.pushButton_open.clicked.connect(
                    lambda s, button=msg_box.pushButton_open, id=x['id'],
                    type_script=x['type_script'], type_script_args=x[
                        'type_script_args']: rbhus_notify_open_types(
                            id, type_script, type_script_args, button=button))
                msg_box.pushButton_done.clicked.connect(
                    lambda s, id=x['id']: rbhus_notify_done(id))
                scroll_ui.verticalLayout_2.addWidget(msg_box)
                rbhus_notify_ids[x['id']] = msg_box
                debug.info(x)
                showui = True

    newno = len(rbhus_notify_ids.keys())
    if ((oldno != newno) or (showui == True)):
        showui = False
        show_rbhus_notify(scroll_ui)
Ejemplo n.º 15
0
 def startListening(self):
     self.purple.connect_to_signal("ReceivedImMsg", self.receive_msg)
     # self.purple.connect_to_signal("SendingImMsg", self.receive_msg)
     debug.info("started listening")
     self.listening.emit()
Ejemplo n.º 16
0
def messageClicked(*args):
    QtWidgets.QMessageBox.information(None, "tray-server", "testing msgbox",
                                      QtWidgets.QMessageBox.Ok)
    debug.info(args)
Ejemplo n.º 17
0
def hide_options_ui(options_ui, arg):
    write_config(options_ui)
    debug.info(arg)
    options_ui.hide()