Exemplo n.º 1
0
    def __init__(self, arg, value, fetcher=None, compatibility=None, transform_label=True, parent=None):
        """
            This objet can be used to graphical representation of a value.

            @param arg [str]  the argument name
            @param value  the value can be a string, or a tuple of two strings
                          if there is a distinction between label (displayed)
                          and the value (used to link to others pages)
                          A function can be overloaded to get an other string
                          or a Qt widget from data.
            @param fetcher  this object is used to communicate with background
            @param transform_label [bool]  the label transformation is made only
                                           if this is true (default)
        """

        QObject.__init__(self, parent)

        self.arg = arg
        self.fetcher = fetcher
        self.compatibility = compatibility
#        if parent:
#            self.compatibility = parent.user_settings.compatibility

        self._fill_value(value)

        if transform_label and self.label != None:
            try:
                self.label = self._get_label()
            except Exception, err:
                writeError(err, "Error on getting argument label")
Exemplo n.º 2
0
    def writeError(self, err, title="ERROR", **kw):
        """
        Write the error 'err' using the logging module (eg. stdout).
        Prefix the error message by title + ": ".

        Write also the backtrace with a lower log level (WARNING).
        """
        writeError(err, title, **kw)
Exemplo n.º 3
0
def emit(name,*args, **kwargs):
    """ Send event and call all associated functions, passing arguments
    """
    evm = EventManager
    if name not in evm.event_map:
        return
    for callback in evm.event_map[name]:
        try:
            callback(*args, **kwargs);
        except RPCD_ERRORS, err:
            writeError(err, "Error on calling %s for event %r"
                % (callback, name))
Exemplo n.º 4
0
 def get_client(self, client_name, client_release=None):
     tries = 0
     while True:
         tries += 1
         if (1 < tries) \
         or (self.options and not(self.options.username and self.options.password and self.options.host)):
             ret = self.exec_()
             if not ret:
                 return None
         try:
             self.host = unicode(self.host_edit.lineEdit().text())
             self.protocol = PROTOCOLS[self.protocol_combo.currentIndex()]
             if self.custom_radio.isChecked():
                 self.port = self.port_spinbox.value()
             elif self.protocol == 'https':
                 self.port = DEFAULT_HTTPS_PORT
             else: # self.protocol == 'http'
                 self.port = DEFAULT_HTTP_PORT
             self.streaming_port = self.streaming_spinbox.value()
             self.login = self.login_edit.text()
             protocol = unicode(self.protocol)
             options = {
                 'host': unicode(self.host),
                 'protocol': protocol,
                 'client_name': client_name,
                 'client_release': client_release,
             }
             options['port'] = self.port
             options['streaming_port'] = self.streaming_port
             options['ssl_config'] = self.ssl_options
             self.check_proto_not_cleartext(options)
             client = RpcdClient(**options)
             client.authenticate(
                 unicode(self.login),
                 unicode(self.password_edit.text()))
             self.save_settings()
             self.ssl_options.saveOptions()
             return client
         except RpcdError, err:
             writeError(err, unicode(self.tr("Connection error")))
             QMessageBox.critical(self, self.tr("Connection error"), unicode(err))
Exemplo n.º 5
0
 def writeError(self, error, *args, **options):
     options['logger'] = self
     writeError(error, *args, **options)