Sync a layer in Solr.
502943
def layer_to_solr(self, layer):
        
        success = True
        message = 'Synced layer id %s to Solr' % layer.id

        layer_dict, message = layer2dict(layer)
        if not layer_dict:
            success = False
        else:
            layer_json = json.dumps(layer_dict)
            try:
                url_solr_update = '%s/solr/hypermap/update/json/docs' % SEARCH_URL
                headers = {"content-type": "application/json"}
                params = {"commitWithin": 1500}
                res = requests.post(url_solr_update, data=layer_json, params=params,  headers=headers)
                res = res.json()
                if 'error' in res:
                    success = False
                    message = "Error syncing layer id %s to Solr: %s" % (layer.id, res["error"].get("msg"))
            except Exception, e:
                success = False
                message = "Error syncing layer id %s to Solr: %s" % (layer.id, sys.exc_info()[1])
                LOGGER.error(e, exc_info=True)
        if success:
            LOGGER.info(message)
        else:
            LOGGER.error(message)
        return success, message
1291052
def sync_objects_in(self):
        """"""
        self.dstate = self.STATES.BUILDING
        self.build_source_files.record_to_objects()
390387
def _update(self, layer=None):
        
        meta = getattr(self, ModelBase._meta_attr)
        if not layer:
            layers = self.layers
        else:
            # convert non-sequence to tuple
            layers = _listify(layer)
        for layer in layers:
            # relative path to layer files from model file
            path = os.path.abspath(os.path.join(meta.modelpath, layer))
            getattr(self, layer).load(path)
256439
def sync_in_records(self, force=False):
        """"""
        self.log('---- Sync Files ----')

        for f in self.build_source_files:
            f.record_to_objects()

        # Only the metadata needs to be driven to the objects, since the other files are used as code,
        # directly from the file record.
        self.build_source_files.file(File.BSFILE.META).record_to_objects()

        self.commit()
1217431
def update_payload(self, fields=None):
        """"""
        data = super(SyncPlan, self).update_payload(fields)
        if isinstance(data.get('sync_date'), datetime):
            data['sync_date'] = data['sync_date'].strftime('%Y-%m-%d %H:%M:%S')
        return data
1232431
def sync(self):
        """"""
        self.elk.send(cs_encode())
        self.get_descriptions(TextDescriptions.OUTPUT.value)
1358197
def sync(self, force=None):
        """"""

        try:
            if force:
                sd = force
            else:
                sd = self.sync_dir()

            if sd == self.SYNC_DIR.FILE_TO_RECORD:

                if force and not self.exists():
                    return None

                self.fs_to_record()

            elif sd == self.SYNC_DIR.RECORD_TO_FILE:
                self.record_to_fs()

            else:
                return None

            self._dataset.config.sync[self.file_const][sd] = time.time()
            return sd
        except Exception as e:
            self._bundle.rollback()
            self._bundle.error("Failed to sync '{}': {}".format(self.file_const, e))
            raise
30686
def _sync(pack):
    """"""
    task_queue = Queue()
    result_queue = Queue()
    task = SignedPackage.loads(pack)
    task_queue.put(task)
    task_queue.put('STOP')
    worker(task_queue, result_queue, Value('f', -1))
    result_queue.put('STOP')
    monitor(result_queue)
    task_queue.close()
    task_queue.join_thread()
    result_queue.close()
    result_queue.join_thread()
    return task['id']
1187215
def _synced(method, self, args, kwargs):
    """"""
    with self._lock:
        return method(*args, **kwargs)
36617
def sync(opts,
         form,
         saltenv=None,
         extmod_whitelist=None,
         extmod_blacklist=None):
    '''
    
    '''
    if saltenv is None:
        saltenv = ['base']

    if extmod_whitelist is None:
        extmod_whitelist = opts['extmod_whitelist']
    elif isinstance(extmod_whitelist, six.string_types):
        extmod_whitelist = {form: extmod_whitelist.split(',')}
    elif not isinstance(extmod_whitelist, dict):
        log.error('extmod_whitelist must be a string or dictionary: %s',
                  extmod_whitelist)

    if extmod_blacklist is None:
        extmod_blacklist = opts['extmod_blacklist']
    elif isinstance(extmod_blacklist, six.string_types):
        extmod_blacklist = {form: extmod_blacklist.split(',')}
    elif not isinstance(extmod_blacklist, dict):
        log.error('extmod_blacklist must be a string or dictionary: %s',
                  extmod_blacklist)

    if isinstance(saltenv, six.string_types):
        saltenv = saltenv.split(',')
    ret = []
    remote = set()
    source = salt.utils.url.create('_' + form)
    mod_dir = os.path.join(opts['extension_modules'], '{0}'.format(form))
    touched = False
    with salt.utils.files.set_umask(0o077):
        try:
            if not os.path.isdir(mod_dir):
                log.info('Creating module dir \'%s\'', mod_dir)
                try:
                    os.makedirs(mod_dir)
                except (IOError, OSError):
                    log.error(
                        'Cannot create cache module directory %s. Check '
                        'permissions.', mod_dir
                    )
            fileclient = salt.fileclient.get_file_client(opts)
            for sub_env in saltenv:
                log.info(
                    'Syncing %s for environment \'%s\'', form, sub_env
                )
                cache = []
                log.info('Loading cache from %s, for %s', source, sub_env)
                # Grab only the desired files (.py, .pyx, .so)
                cache.extend(
                    fileclient.cache_dir(
                        source, sub_env, include_empty=False,
                        include_pat=r'E@\.(pyx?|so|zip)$', exclude_pat=None
                    )
                )
                local_cache_dir = os.path.join(
                        opts['cachedir'],
                        'files',
                        sub_env,
                        '_{0}'.format(form)
                        )
                log.debug('Local cache dir: \'%s\'', local_cache_dir)
                for fn_ in cache:
                    relpath = os.path.relpath(fn_, local_cache_dir)
                    relname = os.path.splitext(relpath)[0].replace(os.sep, '.')
                    if extmod_whitelist and form in extmod_whitelist and relname not in extmod_whitelist[form]:
                        continue
                    if extmod_blacklist and form in extmod_blacklist and relname in extmod_blacklist[form]:
                        continue
                    remote.add(relpath)
                    dest = os.path.join(mod_dir, relpath)
                    log.info('Copying \'%s\' to \'%s\'', fn_, dest)
                    if os.path.isfile(dest):
                        # The file is present, if the sum differs replace it
                        hash_type = opts.get('hash_type', 'md5')
                        src_digest = salt.utils.hashutils.get_hash(fn_, hash_type)
                        dst_digest = salt.utils.hashutils.get_hash(dest, hash_type)
                        if src_digest != dst_digest:
                            # The downloaded file differs, replace!
                            shutil.copyfile(fn_, dest)
                            ret.append('{0}.{1}'.format(form, relname))
                    else:
                        dest_dir = os.path.dirname(dest)
                        if not os.path.isdir(dest_dir):
                            os.makedirs(dest_dir)
                        shutil.copyfile(fn_, dest)
                        ret.append('{0}.{1}'.format(form, relname))

                    # If the synchronized module is an utils
                    # directory, we add it to sys.path
                    for util_dir in opts['utils_dirs']:
                        if mod_dir.endswith(util_dir) and mod_dir not in sys.path:
                            sys.path.append(mod_dir)

            touched = bool(ret)
            if opts['clean_dynamic_modules'] is True:
                current = set(_listdir_recursively(mod_dir))
                for fn_ in current - remote:
                    full = os.path.join(mod_dir, fn_)
                    if os.path.isfile(full):
                        touched = True
                        os.remove(full)
                # Cleanup empty dirs
                while True:
                    emptydirs = _list_emptydirs(mod_dir)
                    if not emptydirs:
                        break
                    for emptydir in emptydirs:
                        touched = True
                        shutil.rmtree(emptydir, ignore_errors=True)
        except Exception as exc:
            log.error('Failed to sync %s module: %s', form, exc)
    return ret, touched
816644
def sync(self, graph_commons):
        """"""
        if self['id'] is None:
            return

        remote_graph = graph_commons.graphs(self['id'])

        # TODO: less forceful, more elegant
        self.edges = remote_graph.edges
        self.nodes = remote_graph.nodes
        self.node_types = remote_graph.node_types
        self.edge_types = remote_graph.edge_types
        self._edges = dict((edge['id'], edge) for edge in self.edges)
        self._nodes = dict((node['id'], node) for node in self.nodes)
        self._node_types = dict((t['id'], t) for t in self.node_types)
        self._edge_types = dict((t['id'], t) for t in self.edge_types)
1041774
def sync(self):
        """"""
        if self.writeback and self.cache:
            super(_TimeoutMixin, self).__delitem__(self._INDEX)
            super(_TimeoutMixin, self).sync()
            self.writeback = False
            super(_TimeoutMixin, self).__setitem__(self._INDEX, self._index)
            self.writeback = True
        if hasattr(self.dict, 'sync'):
            self.dict.sync()
56087
def sync(self):
        """"""
        self.elk.send(az_encode())
        self.elk.send(zd_encode())
        self.elk.send(zp_encode())
        self.elk.send(zs_encode())
        self.get_descriptions(TextDescriptions.ZONE.value)
133543
def push(self):
        """"""
        self._refresh_connection()

        # Check if we need to update mappings as this needs to be done
        # before we push anything to the Elasticsearch server.
        # This must be done even if the queue is empty, as otherwise ES
        # will fail when retrieving data.
        if not self._mapping_created:
            logger.debug("Pushing mapping for Elasticsearch index '%s'.", self.__class__.__name__)
            self.create_mapping()

        if not self.push_queue:
            logger.debug("No documents to push, skipping push.")
            return

        logger.debug("Found %s documents to push to Elasticsearch.", len(self.push_queue))

        bulk(connections.get_connection(), (doc.to_dict(True) for doc in self.push_queue), refresh=True)
        self.push_queue = []

        logger.debug("Finished pushing builded documents to Elasticsearch server.")
446305
function sync(collection, newCollection, index) {
        if (index === void 0) { index = 'id'; }
        var answer = removeElements(collection, newCollection, index);
        if (newCollection) {
            newCollection.forEach(function (item) {
                var oldItem = _.find(collection, function (c) { return c[index] === item[index]; });
                if (!oldItem) {
                    answer = true;
                    collection.push(item);
                }
                else {
                    if (item !== oldItem) {
                        angular.copy(item, oldItem);
                        answer = true;
                    }
                }
            });
        }
        return answer;
    }
740321
def sync(self, bForce):
        """"""

        fn = self.function_table.sync
        peError = EVRSettingsError()
        result = fn(bForce, byref(peError))
        return result, peError
863575
protected void synchronizeField(QueryPage queryPage, List<String> options, String fieldName, String fieldCaption, Boolean mandatory) {
    QueryFieldDAO queryFieldDAO = new QueryFieldDAO();
    QueryOptionFieldDAO queryOptionFieldDAO = new QueryOptionFieldDAO();

    QueryOptionField queryField = (QueryOptionField) queryFieldDAO.findByQueryPageAndName(queryPage, fieldName);
    if (queryField != null) {
      queryFieldDAO.updateMandatory(queryField, mandatory);
      queryFieldDAO.updateCaption(queryField, fieldCaption);
    } else {
      queryField = queryOptionFieldDAO.create(queryPage, fieldName, mandatory, fieldCaption);
    }

    synchronizeFieldOptions(options, queryField);
  }