Exemple #1
0
def create_ufwi_rpcd_application(name, resource=None, locale=None,
create_options=None, release=None):
    """
    Create a Rpcd client application:
     - name: application identifier, short string in lower case
     - resource: filename of the resources, see load_resource()
     - name: name of the locales, see setup_locale()
     - create_options: callback to create more command line options, call
       create_options(parser) where parser is an optparse.OptionParser object,
       see parse_options()
    """
    # Parse command line options and setup the logging module
    options = parse_options(create_options)
    setup_logging(options)

    # Create the application
    app = create_application(resource, locale, options.debug)
    app.options = options

    # Create Rpcd client
    client = AuthWindow(options=app.options).get_client(name, client_release=release)
    if not client:
        print >>stderr, tr("Abort authentication")
        exit(1)
    return app, client
Exemple #2
0
def create_options_parser():
    parser = OptionParser(usage="%prog [options]")
    parser.add_option('-u', '--username',
        help=tr("Username for Rpcd authentication"),
        type="str", default=None)
    parser.add_option('-p', '--password',
        help=tr("Password for Rpcd authentication"),
        type="str", default=None)
    parser.add_option('--host',
        help=tr("Rpcd server hostname or IP address"),
        type="str", default=None)
    parser.add_option('--port',
        help=tr("Rpcd server port"),
        type="int", default=None)
    parser.add_option('--cleartext',
        help=tr("Use cleartext protocol instead of default secure (TLS)"),
        action="store_true", default=False)
    parser.add_option('--secure',
        help=tr("Use secure (TLS) protocol"),
        action="store_true", default=False)
    parser.add_option('--streaming-port',
        help=tr("UDP streaming port"),
        type="int", default=None)
    parser.add_option('--verbose', '-v',
        help="Enable verbose mode (use INFO log level, default: ERROR)",
        action="store_true", default=False)
    parser.add_option('--debug',
        help="Enable debug mode (use DEBUG log level, default: ERROR)",
        action="store_true", default=False)
    return parser
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 GNU General Public License for more details. 
 
 You should have received a copy of the GNU General Public License 
 along with NuFirewall.  If not, see <http://www.gnu.org/licenses/>
"""


from PyQt4.QtGui import QFrame, QLabel, QHBoxLayout, QPixmap, QColor, QPalette
from PyQt4.QtCore import QSize
from ufwi_rpcd.common.service_status_values import ServiceStatusValues
from ufwi_rpcd.common.i18n import tr
from time import ctime

_TOOLTIP = tr(
    'Service "%(SERVICE)s" is %(STATUS)s<br/>(checked at %(TIMESTAMP)s)'
    )

class ServiceStatusItem(QFrame):
    """
    A small frame with borders, displaying a service name and an icon
    supported statuses: StatusValues.monitor_status
    """

    #'Static' class data is stored here
    pix_n_colors = None
    __PIXMAP, __PALETTE, __MSG = range(3)

    def __init__(self, name, on_off, parent):

        QFrame.__init__(self, parent)