How to use gconf - 10 common examples

To help you get started, we’ve selected a few gconf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aliva / rhythmbox-microblogger / rbmbSettings.py View on Github external
def _read_conf(self):
        conf={}

        client=gconf.client_get_default()
        if client.get_string(KEYS['version'])==None:
            return None
        
        ver=client.get_string(KEYS['version'])

        ver=ver.split('.')
        ver[0], ver[1], ver[2]=int(ver[0]), int(ver[1]), int(ver[2])
        if ver[1]<5:
            self._remove_conf(None)
            return None

        if ver[0]==0:
            if ver[1]==5:
                if ver[2]==0:
                    client.set_string(KEYS['template'], DEFAULT['template'])
                if ver[2]<=1:
github thesamet / webilder / src / webilder / config.py View on Github external
for s in conf_client.all_dirs('/apps/compiz/general')
               if s.split('/')[-1][:6] == 'screen']

    # Check that the screen is one of the ones supported by compiz
    if screen not in screens:
        screen = screens[0]

    # Get the number of faces on this screen
    number_of_faces = (
        conf_client.get_int('/apps/compiz/general/%s/options/hsize' % screen) *
        conf_client.get_int('/apps/compiz/general/%s/options/vsize' % screen))

    # Get the current list of wallpapers on this screen
    wallpapers = conf_client.get_list(
        '/apps/compiz/plugins/wallpaper/%s/options/bg_image' % screen,
        gconf.VALUE_STRING)

    # If list of wallpapers is too short, populate it to the correct length
    if len(wallpapers) < number_of_faces:
        wallpapers.extend([filename] * (number_of_faces - len(wallpapers)))
        prefix = '/apps/compiz/plugins/wallpaper/%s/options/' % screen
        settings = {
            'bg_color1'   : (gconf.VALUE_STRING, '#000000ff'),
            'bg_color2'   : (gconf.VALUE_STRING, '#000000ff'),
            'bg_fill_type': (gconf.VALUE_INT,    0),
            'bg_image_pos': (gconf.VALUE_INT,    0),
        }
        for key, value in settings.items():
            ext_list = conf_client.get_list(prefix + key, value[0])
            ext_list.extend([value[1]] * (number_of_faces - len(ext_list)))
            conf_client.set_list(prefix + key, value[0], ext_list)
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
def rsync(self, files, *args, **kw):
        """invoke rsync"""
        if not files:
            raise GsyncdError("no files to sync")
        logging.debug("files: " + ", ".join(files))
        argv = gconf.rsync_command.split() + \
            ['-aR0', '--inplace', '--files-from=-', '--super',
             '--stats', '--numeric-ids', '--no-implied-dirs'] + \
            gconf.rsync_options.split() + \
            (boolify(gconf.sync_xattrs) and ['--xattrs'] or []) + \
            (boolify(gconf.sync_acls) and ['--acls'] or []) + \
            ['.'] + list(args)

        if gconf.log_rsync_performance:
            # use stdout=PIPE only when log_rsync_performance enabled
            # Else rsync will write to stdout and nobody is their
            # to consume. If PIPE is full rsync hangs.
            po = Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE)
        else:
            po = Popen(argv, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
g2.master.server = brickserver
                g3.master.server = brickserver
            else:
                (g1, g2, g3) = self.gmaster_instantiate_tuple(slave)
                g1.master.server.aggregated = gmaster.master.server
                g2.master.server.aggregated = gmaster.master.server
                g3.master.server.aggregated = gmaster.master.server
            # bad bad bad: bad way to do things like this
            # need to make this elegant
            # register the crawlers and start crawling
            # g1 ==> Xsync, g2 ==> config.change_detector(changelog by default)
            # g3 ==> changelog History
            changelog_register_failed = False
            (inf, ouf, ra, wa) = gconf.rpc_fd.split(',')
            changelog_agent = RepceClient(int(inf), int(ouf))
            status = GeorepStatus(gconf.state_file, gconf.local_path)
            status.reset_on_worker_start()
            rv = changelog_agent.version()
            if int(rv) != CHANGELOG_AGENT_CLIENT_VERSION:
                raise GsyncdError(
                    "RePCe major version mismatch(changelog agent): "
                    "local %s, remote %s" %
                    (CHANGELOG_AGENT_CLIENT_VERSION, rv))

            try:
                workdir = g2.setup_working_dir()
                # Register only when change_detector is not set to
                # xsync, else agent will generate changelog files
                # in .processing directory of working dir
                if gconf.change_detector != 'xsync':
                    # register with the changelog library
                    # 9 == log level (DEBUG)
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
def rsync(self, files, log_err=False):
        return sup(self, files, '-e',
                   " ".join(gconf.ssh_command.split() +
                            ["-p", str(gconf.ssh_port)] +
                            gconf.ssh_ctl_args),
                   *(gconf.rsync_ssh_options.split() + [self.slaveurl]),
                   log_err=log_err)
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
def connect(self):
        """inhibit the resource beyond

        Choose mounting backend (direct or mountbroker),
        set up glusterfs parameters and perform the mount
        with given backend
        """

        label = getattr(gconf, 'mountbroker', None)
        if not label and not privileged():
            label = syncdutils.getusername()
        mounter = label and self.MountbrokerMounter or self.DirectMounter
        params = gconf.gluster_params.split() + \
            (gconf.gluster_log_level and ['log-level=' +
                                          gconf.gluster_log_level] or []) + \
            ['log-file=' + gconf.gluster_log_file, 'volfile-server=' +
             self.host, 'volfile-id=' + self.volume, 'client-pid=-1']
        mounter(params).inhibit(*[l for l in [label] if l])
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
(g1, g2, g3) = self.gmaster_instantiate_tuple(slave)
                g1.master.server = brickserver
                g2.master.server = brickserver
                g3.master.server = brickserver
            else:
                (g1, g2, g3) = self.gmaster_instantiate_tuple(slave)
                g1.master.server.aggregated = gmaster.master.server
                g2.master.server.aggregated = gmaster.master.server
                g3.master.server.aggregated = gmaster.master.server
            # bad bad bad: bad way to do things like this
            # need to make this elegant
            # register the crawlers and start crawling
            # g1 ==> Xsync, g2 ==> config.change_detector(changelog by default)
            # g3 ==> changelog History
            changelog_register_failed = False
            (inf, ouf, ra, wa) = gconf.rpc_fd.split(',')
            changelog_agent = RepceClient(int(inf), int(ouf))
            status = GeorepStatus(gconf.state_file, gconf.local_path)
            status.reset_on_worker_start()
            rv = changelog_agent.version()
            if int(rv) != CHANGELOG_AGENT_CLIENT_VERSION:
                raise GsyncdError(
                    "RePCe major version mismatch(changelog agent): "
                    "local %s, remote %s" %
                    (CHANGELOG_AGENT_CLIENT_VERSION, rv))

            try:
                workdir = g2.setup_working_dir()
                # Register only when change_detector is not set to
                # xsync, else agent will generate changelog files
                # in .processing directory of working dir
                if gconf.change_detector != 'xsync':
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
def rsync(self, files, *args, **kw):
        """invoke rsync"""
        if not files:
            raise GsyncdError("no files to sync")
        logging.debug("files: " + ", ".join(files))
        argv = gconf.rsync_command.split() + \
            ['-aR0', '--inplace', '--files-from=-', '--super',
             '--stats', '--numeric-ids', '--no-implied-dirs'] + \
            gconf.rsync_options.split() + \
            (boolify(gconf.sync_xattrs) and ['--xattrs'] or []) + \
            (boolify(gconf.sync_acls) and ['--acls'] or []) + \
            ['.'] + list(args)

        if gconf.log_rsync_performance:
            # use stdout=PIPE only when log_rsync_performance enabled
            # Else rsync will write to stdout and nobody is their
            # to consume. If PIPE is full rsync hangs.
            po = Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE)
        else:
            po = Popen(argv, stdin=subprocess.PIPE, stderr=subprocess.PIPE)

        for f in files:
            po.stdin.write(f)
            po.stdin.write('\0')
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
def make_cli_argv(cls):
            return [cls.get_glusterprog()] + ['--remote-host=localhost'] + \
                gconf.gluster_cli_options.split() + ['system::']
github gluster / glusterfs / geo-replication / syncdaemon / resource.py View on Github external
raise GsyncdError(
                    "RePCe major version mismatch(changelog agent): "
                    "local %s, remote %s" %
                    (CHANGELOG_AGENT_CLIENT_VERSION, rv))

            try:
                workdir = g2.setup_working_dir()
                # Register only when change_detector is not set to
                # xsync, else agent will generate changelog files
                # in .processing directory of working dir
                if gconf.change_detector != 'xsync':
                    # register with the changelog library
                    # 9 == log level (DEBUG)
                    # 5 == connection retries
                    changelog_agent.init()
                    changelog_agent.register(gconf.local_path,
                                             workdir, gconf.changelog_log_file,
                                             g2.CHANGELOG_LOG_LEVEL,
                                             g2.CHANGELOG_CONN_RETRIES)

                register_time = int(time.time())
                g2.register(register_time, changelog_agent, status)
                g3.register(register_time, changelog_agent, status)
            except ChangelogException as e:
                logging.error("Changelog register failed, %s" % e)
                sys.exit(1)

            g1.register(status=status)
            logging.info("Register time: %s" % register_time)
            # oneshot: Try to use changelog history api, if not
            # available switch to FS crawl
            # Note: if config.change_detector is xsync then