Used to do a service full check when saving it.
548120
def service_post_save(instance, *args, **kwargs):
    

    # check service
    if instance.is_monitored and settings.REGISTRY_SKIP_CELERY:
        check_service(instance.id)
    elif instance.is_monitored:
        check_service.delay(instance.id)
563255
public function onSaving()
    {
        // If the password is changing, hash it
        if ($this->isDirty('password')) {
            $this->password = bcrypt($this->password);
        }

        // Save or clear permission choices if the form had a "custom permissions"
        // pushed checkbox
        if (Request::exists('_custom_permissions')) {
            $this->permissions = request('_custom_permissions') ?
                json_encode(request('_permission')) : null;
        }
    }
342713
private boolean isDone()
   {
      switch (status) {
      case Status.STATUS_PREPARING:
      case Status.STATUS_PREPARED:
      case Status.STATUS_COMMITTING:
      case Status.STATUS_COMMITTED:
      case Status.STATUS_ROLLING_BACK:
      case Status.STATUS_ROLLEDBACK:
         return true;
      default:
         return false;
      }
   }
874532
public function onServiceDown()
    {
        if (!$this->serviceRunning) {
            return;
        }

        $this->getLogger()->debug('Service is no longer alive.');
        $this->serviceRunning = false;
        $this->shutdown();
    }
187873
public static void saveService(final RegisteredService service, final ServicesManager servicesManager) {
        servicesManager.load();

        if (servicesManager.findServiceBy(registeredService -> registeredService instanceof SamlRegisteredService
            && registeredService.getServiceId().equals(service.getServiceId())).isEmpty()) {
            LOGGER.info("Service [{}] does not exist in the registry and will be added.", service.getServiceId());
            servicesManager.save(service);
            servicesManager.load();
        } else {
            LOGGER.info("Service [{}] exists in the registry and will not be added again.", service.getServiceId());
        }
    }
792307
@Override
    public void checkIn(ServiceHandle<S> handle) throws Exception {
        checkNotNull(handle);

        S service = handle.getService();
        ServiceEndPoint endPoint = handle.getEndPoint();

        // Figure out if we should check this revision in.  If it was created before the last known invalid revision
        // for this particular end point, or the cache is closed, then we shouldn't check it in.
        Long invalidRevision = _invalidRevisions.get(endPoint);
        Long serviceRevision = _checkedOutRevisions.remove(handle);

        if (_isClosed || (invalidRevision != null && serviceRevision < invalidRevision)) {
            _pool.invalidateObject(endPoint, service);
        } else {
            _pool.returnObject(endPoint, service);
        }
    }
596526
function clientSave() {

    u.each(sources, function(source) {

      var dirtyFiles = u.filter(source.files, function(file) {
        if (file._dirty) {  // 1 means unsaved, 2 means saving
          file._dirty = 2;  // side effect of filter
          return true;
        }
        return false;
      });

      if (dirtyFiles.length) {

        var files = u.map(dirtyFiles, generator.serializeFile);

        debug('clientSave %s files, %s...', files.length, files[0].text.slice(0,200));

        // static save from browser directly to source
        if (opts.staticHost && source.staticSrc && source.src) {

          // NOTE: subtle difference in data compared to httpClient.put()
          source.src.put(files, function(err, savedFiles) {

            if (err || (u.size(savedFiles) !== u.size(dirtyFiles))) {
              // notify user on save errors
              return notify('error saving files, please check your internet connection');
            }

            u.each(dirtyFiles, function(file) {

              // no collision detection support with static saves (for now)
              file._oldtext = file.text;

              // only mark as clean if unchanged while waiting for save
              if (file._dirty === 2) { delete file._dirty; }
            });

            return source.verbose && notify(u.size(savedFiles) + ' file(s) saved');
          });
        }

        // normal (non-static) save from browser to pub-server
        else {
          httpClient.put({ source:source.name, files:files }, function(err, savedFiles) {

            if (err || (u.size(savedFiles) !== u.size(dirtyFiles))) {
              if (err) { log(err); }
              // notify user on save errors
              return notify('error saving files, please check your internet connection');
            }

            u.each(dirtyFiles, function(file, idx) {

              var savedFile = savedFiles[idx];

              if (typeof savedFile !== 'object') {
                // most likely a collision - must notify user
                return notify('error saving file: ' + savedFile);
              }

              // preserve for next update
              file._oldtext = savedFile.text;

              // only mark as clean if unchanged while waiting for save
              if (file._dirty === 2) { delete file._dirty; }

            });

            return source.verbose && notify(u.size(savedFiles) + ' file(s) saved');
          });
        }
      }
    });
  }
645222
private boolean checkRestrictorService(RestrictorCheck pCheck, Object ... args) {
        try {
            ServiceReference[] serviceRefs = bundleContext.getServiceReferences(Restrictor.class.getName(),null);
            if (serviceRefs != null) {
                boolean ret = true;
                boolean found = false;
                for (ServiceReference serviceRef : serviceRefs) {
                    Restrictor restrictor = (Restrictor) bundleContext.getService(serviceRef);
                    if (restrictor != null) {
                        ret = ret && pCheck.check(restrictor,args);
                        found = true;
                    }
                }
                return found && ret;
            } else {
                return false;
            }
        } catch (InvalidSyntaxException e) {
            // Will not happen, since we dont use a filter here
            throw new IllegalArgumentException("Impossible exception (we don't use a filter for fetching the services)",e);
        }
    }
1049955
private function savePartialData($partialDataSaved, $partialBase, $currBase, $partial, $curr, $quoteId)
    {
        if ($partialDataSaved) {
            /* get saved partial totals */
            $partialSavedBase = $partialDataSaved->getBasePartialAmount();
            $partialSaved = $partialDataSaved->getPartialAmount();
            if (
                ($partialSavedBase != $partialBase) ||
                ($partialSaved != $partial)
            ) {
                if ($partialBase > Cfg::DEF_ZERO) {
                    /* re-save quote partial in registry */
                    $partialDataSaved->setBasePartialAmount($partialBase);
                    $partialDataSaved->setPartialAmount($partial);
                    $this->daoPartialQuote->updateById($quoteId, $partialDataSaved);
                } else {
                    $this->daoPartialQuote->deleteById($quoteId);
                }
            }
        } else {
            if ($partialBase > Cfg::DEF_ZERO) {
                /* create new record in the registry */
                $partialDataSaved = new \Praxigento\Wallet\Repo\Data\Partial\Quote();
                $partialDataSaved->setQuoteRef($quoteId);
                $partialDataSaved->setBasePartialAmount($partialBase);
                $partialDataSaved->setBaseCurrency($currBase);
                $partialDataSaved->setPartialAmount($partial);
                $partialDataSaved->setCurrency($curr);
                $this->daoPartialQuote->create($partialDataSaved);
            }
        }
    }
272542
def save(self):
        """"""
        if ( self._new or
            (self._validID() and self._changed) or
            (self._updated and self._changed > self._updated) ):
            # Don't save if we have not loaded existing data!
            self._saveDB()
            return True
        return False
932299
function (data) {
          var isSigned = isTokenSigned(data.file);
          var isFinished = data.status === 'finished';
          var isComplete = isSigned && isFinished;
          debug('checking if run', url, 'is finished', isComplete);
          if (isComplete) {
            testRuns.removeListener('patched', checkIfRunIsFinished);
            resolve(data);
          }
        }
676185
def start_executing_svc_checks(self):
        
        # todo: #783 create a dedicated brok for global parameters
        if not self.my_conf.execute_service_checks:
            self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
            self.my_conf.execute_service_checks = True
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
7486
def service_checks():
    """"""
    root = get_root()
    echo_info("Validating all service_checks.json files...")
    failed_checks = 0
    ok_checks = 0
    for check_name in sorted(os.listdir(root)):
        service_checks_file = os.path.join(root, check_name, 'service_checks.json')

        if file_exists(service_checks_file):
            file_failed = False
            display_queue = []

            try:
                decoded = json.loads(read_file(service_checks_file).strip(), object_pairs_hook=OrderedDict)
            except JSONDecodeError as e:
                failed_checks += 1
                echo_info("{}/service_checks.json... ".format(check_name), nl=False)
                echo_failure("FAILED")
                echo_failure('  invalid json: {}'.format(e))
                continue

            unique_names = set()
            unique_checks = set()
            for service_check in decoded:
                # attributes are valid
                attrs = set(service_check)
                for attr in sorted(attrs - REQUIRED_ATTRIBUTES):
                    file_failed = True
                    display_queue.append((echo_failure, '  Attribute `{}` is invalid'.format(attr)))
                for attr in sorted(REQUIRED_ATTRIBUTES - attrs):
                    file_failed = True
                    display_queue.append((echo_failure, '  Attribute `{}` is required'.format(attr)))

                # agent_version
                agent_version = service_check.get('agent_version')
                version_parts = parse_version_parts(agent_version)
                if len(version_parts) != 3:
                    file_failed = True

                    if not agent_version:
                        output = '  required non-null string: agent_version'
                    else:
                        output = '  invalid `agent_version`: {}'.format(agent_version)

                    display_queue.append((echo_failure, output))

                # check
                check = service_check.get('check')
                if not check or not isinstance(check, string_types):
                    file_failed = True
                    display_queue.append((echo_failure, '  required non-null string: check'))
                else:
                    if check in unique_checks:
                        file_failed = True
                        display_queue.append((echo_failure, '  {} is not a unique check'.format(check)))
                    else:
                        unique_checks.add(check)

                # description
                description = service_check.get('description')
                if not description or not isinstance(description, string_types):
                    file_failed = True
                    display_queue.append((echo_failure, '  required non-null string: description'))

                # groups
                groups = service_check.get('groups')
                if groups is None or not isinstance(groups, list):
                    file_failed = True
                    display_queue.append((echo_failure, '  required list: groups'))

                # integration
                integration = service_check.get('integration')
                if integration is None or not isinstance(integration, string_types):
                    file_failed = True
                    display_queue.append((echo_failure, '  required non-null string: integration'))

                # name
                name = service_check.get('name')
                if not name or not isinstance(name, string_types):
                    file_failed = True
                    display_queue.append((echo_failure, '  required non-null string: name'))
                else:
                    if name in unique_names:
                        file_failed = True
                        display_queue.append((echo_failure, '  {} is not a unique name'.format(name)))
                    else:
                        unique_names.add(name)

                # statuses
                statuses = service_check.get('statuses')
                if not statuses or not isinstance(statuses, list):
                    file_failed = True
                    display_queue.append((echo_failure, '  required non empty list: statuses'))

            if file_failed:
                failed_checks += 1
                # Display detailed info if file invalid
                echo_info("{}/service_checks.json... ".format(check_name), nl=False)
                echo_failure("FAILED")
                for display_func, message in display_queue:
                    display_func(message)
            else:
                ok_checks += 1

    if ok_checks:
        echo_success("{} valid files".format(ok_checks))
    if failed_checks:
        echo_failure("{} invalid files".format(failed_checks))
        abort()
521213
def _process_restartcheck_result(rs_result, **kwargs):
    '''
    
    '''
    if 'No packages seem to need to be restarted' in rs_result:
        return
    reboot_required = False
    for rstr in rs_result:
        if 'System restart required' in rstr:
            _update_nilrt_restart_state()
            __salt__['system.set_reboot_required_witnessed']()
            reboot_required = True
    if kwargs.get('always_restart_services', True) or not reboot_required:
        for rstr in rs_result:
            if 'System restart required' not in rstr:
                service = os.path.join('/etc/init.d', rstr)
                if os.path.exists(service):
                    __salt__['cmd.run']([service, 'restart'])
885407
def check(self, check_all=True, do_reload=True):
        """"""
        with enaml.imports():
            super(EnamlReloader, self).check(check_all=check_all, do_reload=do_reload)
272660
function ensureExistsAndClean (dir) {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir)
  } else {
    cleanDir(dir)
  }
}
1270913
def hasUnsavedChanges(self):
        

        # Sanity check - this case shouldn't occur
        assert self._lastSavedState is not None, \
               "BUG: Please report this as it should never occur."

        # Force the current GUI values into our model in memory, but don't
        # change anything.  Don't save to file, don't even convert bad
        # values to their previous state in the gui.  Note that this can
        # leave the GUI in a half-saved state, but since we are about to exit
        # this is OK.  We only want prompting to occur if they decide to save.
        badList = self.checkSetSaveEntries(doSave=False, fleeOnBadVals=True,
                                           allowGuiChanges=False)
        if badList:
            return True

        # Then compare our data to the last known saved state.  MAKE SURE
        # the LHS is the actual dict (and not 'self') to invoke the dict
        # comparison only.
        return self._lastSavedState != self._taskParsObj