Sync changes from the API to the local object.

        Note: syncs ip_addresses and storage_devices too (/server/uuid endpoint)
354481
def populate(self):
        
        server, IPAddresses, storages = self.cloud_manager.get_server_data(self.uuid)
        self._reset(
            server,
            ip_addresses=IPAddresses,
            storage_devices=storages,
            populated=True
        )
        return self
497125
def sync(filename, connection=None):
    
    c = connection or connect()
    rev = c.ls(filename)
    if rev:
        rev[0].sync()
68209
async def update(self, fields=''):
    '''
    '''
    path = 'Users/{{UserId}}/Items/{}'.format(self.id)
    info = await self.connector.getJson(path,
                                        remote=False,
                                        Fields='Path,Overview,'+fields
    )
    self.object_dict.update(info)
    self.extras = {}
    return self
1111995
def sync_with_s3(self):
        
        # Create a list to put all the files we're going to update
        self.update_list = []

        # Figure out which files need to be updated and upload all these files
        logger.debug("Comparing {} local files with {} bucket files".format(
            len(self.local_file_list),
            len(self.s3_obj_dict.keys())
        ))
        if self.no_pooling:
            [self.compare_local_file(f) for f in self.local_file_list]
        else:
            cpu_count = multiprocessing.cpu_count()
            logger.debug("Pooling local file comparison on {} CPUs".format(cpu_count))
            pool = ThreadPool(processes=cpu_count)
            pool.map(self.compare_local_file, self.local_file_list)

        logger.debug("Uploading {} new or updated files to bucket".format(len(self.update_list)))
        if self.no_pooling:
            [self.upload_to_s3(*u) for u in self.update_list]
        else:
            logger.debug("Pooling s3 uploads on {} CPUs".format(cpu_count))
            pool = ThreadPool(processes=cpu_count)
            pool.map(self.pooled_upload_to_s3, self.update_list)
456315
def synchronize(self):
        """"""

        # Get expected ACLs and rules
        expected_acls = self.get_expected_acls()

        # Get expected interface to ACL mappings
        all_expected_bindings = self.get_expected_bindings()

        # Check that config is correct on every registered switch
        for switch_ip in self._switches.keys():
            expected_bindings = all_expected_bindings.get(switch_ip, [])
            try:
                self.synchronize_switch(switch_ip, expected_acls,
                                        expected_bindings)
            except Exception:
                LOG.exception("Failed to sync SGs for %(switch)s",
                              {'switch': switch_ip})
425446
def patch(self, request, *args, **kwargs):
        
        with reversion.create_revision():
            reversion.set_user(request.user)
            reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
            kwargs['partial'] = True
            return self.update(request, *args, **kwargs)
230545
def sync(self, ids, detaching=True):
        
        changes = {"attached": [], "detached": [], "updated": []}

        if isinstance(ids, Collection):
            ids = ids.model_keys()

        current = self._new_pivot_query().lists(self._other_key).all()

        records = self._format_sync_list(ids)

        detach = [x for x in current if x not in records.keys()]

        if detaching and len(detach) > 0:
            self.detach(detach)

            changes["detached"] = detach

        changes.update(self._attach_new(records, current, False))

        if len(changes["attached"]) or len(changes["updated"]):
            self.touch_if_touching()

        return changes
365426
def __sync(self):
    """"""
    pad_length = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE
    if pad_length and pad_length != _BLOCK_SIZE:
      data = self.__reader.read(pad_length)
      if len(data) != pad_length:
        raise EOFError('Read %d bytes instead of %d' %
                       (len(data), pad_length))
1265823
def sync(self):
        
        LOGGER.debug("Application.sync")
        params = None
        if self.id is not None:
            params = {'id': self.id}
        elif self.name is not None:
            params = {'name': self.name}

        if params is not None:
            args = {'http_operation': 'GET', 'operation_path': 'get', 'parameters': params}
            response = ApplicationService.requester.call(args)
            if response.rc != 0:
                LOGGER.warning(
                    'Application.sync - Problem while syncing application (name:' + self.name + 'id: ' + str(self.id) +
                    '). Reason: ' + str(response.response_content) + '-' + str(response.error_message) +
                    " (" + str(response.rc) + ")"
                )
            else:
                json_obj = response.response_content
                self.id = json_obj['applicationID']
                self.name = json_obj['applicationName']
                self.description = json_obj['applicationDescription']
                self.short_name = json_obj['applicationShortName']
                self.color_code = json_obj['applicationColorCode']
                if json_obj['applicationCompanyID'] == -1:
                    self.company_id = None
                else:
                    self.company_id = json_obj['applicationCompanyID']
                if json_obj['applicationTeamID'] == -1:
                    self.team_id = None
                else:
                    self.team_id = json_obj['applicationTeamID']
                self.osi_ids = json_obj['applicationOSInstancesID']
983652
def put(self, request, *args, **kwargs):
        
        with reversion.create_revision():
            reversion.set_user(request.user)
            reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
            return self.update(request, *args, **kwargs)
926934
def sync_headers(cloud_obj, headers=None, header_patterns=HEADER_PATTERNS):
    
    if headers is None:
        headers = {}

    # don't set headers on directories
    content_type = getattr(cloud_obj, "content_type", None)
    if content_type == "application/directory":
        return
    matched_headers = {}
    for pattern, pattern_headers in header_patterns:
        if pattern.match(cloud_obj.name):
            matched_headers.update(pattern_headers.copy())
    # preserve headers already set
    matched_headers.update(cloud_obj.headers)
    # explicitly set headers overwrite matches and already set headers
    matched_headers.update(headers)
    if matched_headers != cloud_obj.headers:
        cloud_obj.headers = matched_headers
        cloud_obj.sync_metadata()
1149873
def _sync_io(self):
        """"""
        if self._file_epoch == self.file_object.epoch:
            return

        if self._io.binary:
            contents = self.file_object.byte_contents
        else:
            contents = self.file_object.contents

        self._set_stream_contents(contents)
        self._file_epoch = self.file_object.epoch
1094743
def save(self):
        
        body = {'ip_address': {'ptr_record': self.ptr_record}}
        data = self.cloud_manager.request('PUT', '/ip_address/' + self.address, body)
        self._reset(**data['ip_address'])
162808
def update(self, data):
        
        data = values.of({'Data': serialize.object(data), })

        payload = self._version.update(
            'POST',
            self._uri,
            data=data,
        )

        return SyncMapItemInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            map_sid=self._solution['map_sid'],
            key=self._solution['key'],
        )
1264593
def sync(
    ctx,
    state,
    bare=False,
    user=False,
    unused=False,
    **kwargs
):
    """"""
    from ..core import do_sync

    retcode = do_sync(
        ctx=ctx,
        dev=state.installstate.dev,
        three=state.three,
        python=state.python,
        bare=bare,
        dont_upgrade=(not state.installstate.keep_outdated),
        user=user,
        clear=state.clear,
        unused=unused,
        sequential=state.installstate.sequential,
        pypi_mirror=state.pypi_mirror,
    )
    if retcode:
        ctx.abort()
690805
def sync(self, clear_cache=False):
        
        self.persistence.update(self)

        if clear_cache:
            self.cache.clear()
457230
def fetch_synchronous(self, endpoint_name, query_params=None):
        """"""

        endpoint_url = constants.URL_PREFIX + "/" + self._version + "/" + endpoint_name

        if query_params is None:
            query_params = {}

        return self._request_client.get(endpoint_url, query_params)