Returns whether all analyses from this Analysis Request are open
        (their status is either "assigned" or "unassigned")
163632
def isOpen(self):
        
        for analysis in self.getAnalyses():
            if not api.get_object(analysis).isOpen():
                return False
        return True
231399
def guard_assign(analysis):
    
    # Only if the request was done from worksheet context.
    if not is_worksheet_context():
        return False

    # Cannot assign if the Sample has not been received
    if not analysis.isSampleReceived():
        return False

    # Cannot assign if the analysis has a worksheet assigned already
    if analysis.getWorksheet():
        return False

    # Cannot assign if user does not have permissions to manage worksheets
    return user_can_manage_worksheets()
410426
def get_analysisrequests_section(self):
        
        out = []
        catalog = getToolByName(self.context, CATALOG_ANALYSIS_REQUEST_LISTING)
        query = {'portal_type': "AnalysisRequest",
                 'is_active': True}

        # Check if dashboard_cookie contains any values to query
        # elements by
        query = self._update_criteria_with_filters(query, 'analysisrequests')

        # Active Samples (All)
        total = self.search_count(query, catalog.id)

        # Sampling workflow enabled?
        if self.context.bika_setup.getSamplingWorkflowEnabled():
            # Samples awaiting to be sampled or scheduled
            name = _('Samples to be sampled')
            desc = _("To be sampled")
            purl = 'samples?samples_review_state=to_be_sampled'
            query['review_state'] = ['to_be_sampled', ]
            out.append(self._getStatistics(name, desc, purl, catalog, query, total))

            # Samples awaiting to be preserved
            name = _('Samples to be preserved')
            desc = _("To be preserved")
            purl = 'samples?samples_review_state=to_be_preserved'
            query['review_state'] = ['to_be_preserved', ]
            out.append(self._getStatistics(name, desc, purl, catalog, query, total))

            # Samples scheduled for Sampling
            name = _('Samples scheduled for sampling')
            desc = _("Sampling scheduled")
            purl = 'samples?samples_review_state=scheduled_sampling'
            query['review_state'] = ['scheduled_sampling', ]
            out.append(self._getStatistics(name, desc, purl, catalog, query, total))

        # Samples awaiting for reception
        name = _('Samples to be received')
        desc = _("Reception pending")
        purl = 'analysisrequests?analysisrequests_review_state=sample_due'
        query['review_state'] = ['sample_due', ]
        out.append(self._getStatistics(name, desc, purl, catalog, query, total))

        # Samples under way
        name = _('Samples with results pending')
        desc = _("Results pending")
        purl = 'analysisrequests?analysisrequests_review_state=sample_received'
        query['review_state'] = ['attachment_due',
                                 'sample_received', ]
        out.append(self._getStatistics(name, desc, purl, catalog, query, total))

        # Samples to be verified
        name = _('Samples to be verified')
        desc = _("To be verified")
        purl = 'analysisrequests?analysisrequests_review_state=to_be_verified'
        query['review_state'] = ['to_be_verified', ]
        out.append(self._getStatistics(name, desc, purl, catalog, query, total))

        # Samples verified (to be published)
        name = _('Samples verified')
        desc = _("Verified")
        purl = 'analysisrequests?analysisrequests_review_state=verified'
        query['review_state'] = ['verified', ]
        out.append(self._getStatistics(name, desc, purl, catalog, query, total))

        # Samples published
        name = _('Samples published')
        desc = _("Published")
        purl = 'analysisrequests?analysisrequests_review_state=published'
        query['review_state'] = ['published', ]
        out.append(self._getStatistics(name, desc, purl, catalog, query, total))

        # Samples to be printed
        if self.context.bika_setup.getPrintingWorkflowEnabled():
            name = _('Samples to be printed')
            desc = _("To be printed")
            purl = 'analysisrequests?analysisrequests_getPrinted=0'
            query['getPrinted'] = '0'
            query['review_state'] = ['published', ]
            out.append(
                self._getStatistics(name, desc, purl, catalog, query, total))

        # Chart with the evolution of ARs over a period, grouped by
        # periodicity
        outevo = self.fill_dates_evo(catalog, query)
        out.append({'type':         'bar-chart-panel',
                    'name':         _('Evolution of Samples'),
                    'class':        'informative',
                    'description':  _('Evolution of Samples'),
                    'data':         json.dumps(outevo),
                    'datacolors':   json.dumps(self.get_colors_palette())})

        return {'id': 'analysisrequests',
                'title': _('Samples'),
                'panels': out}
538519
def searchResults(self, REQUEST=None, used=None, **kw):
    
    if REQUEST and REQUEST.get('getRequestUID') \
            and self.id == CATALOG_ANALYSIS_LISTING:

        # Fetch all analyses that have the request UID passed in as an ancestor,
        # cause we want Primary ARs to always display the analyses from their
        # derived ARs (if result is not empty)

        request = REQUEST.copy()
        orig_uid = request.get('getRequestUID')

        # If a list of request uid, retrieve them sequentially to make the
        # masking process easier
        if isinstance(orig_uid, list):
            results = list()
            for uid in orig_uid:
                request['getRequestUID'] = [uid]
                results += self.searchResults(REQUEST=request, used=used, **kw)
            return results

        # Get all analyses, those from descendant ARs included
        del request['getRequestUID']
        request['getAncestorsUIDs'] = orig_uid
        results = self.searchResults(REQUEST=request, used=used, **kw)

        # Masking
        primary = filter(lambda an: an.getParentUID == orig_uid, results)
        derived = filter(lambda an: an.getParentUID != orig_uid, results)
        derived_keys = map(lambda an: an.getKeyword, derived)
        results = filter(lambda an: an.getKeyword not in derived_keys, primary)
        return results + derived

    # Normal search
    return self._catalog.searchResults(REQUEST, used, **kw)
680018
def analysis_list(self):
        
        response = self._post(self.apiurl + '/v2/analysis/list', data={'apikey': self.apikey})

        return self._raise_or_extract(response)
1111306
def guard_submit(analysis):
    
    # Cannot submit without a result
    if not analysis.getResult():
        return False

    # Cannot submit with interims without value
    for interim in analysis.getInterimFields():
        if not interim.get("value", ""):
            return False

    # Cannot submit if attachment not set, but is required
    if not analysis.getAttachment():
        if analysis.getAttachmentOption() == 'r':
            return False

    # Check if can submit based on the Analysis Request state
    if IRequestAnalysis.providedBy(analysis):
        point_of_capture = analysis.getPointOfCapture()
        # Cannot submit if the Sample has not been received
        if point_of_capture == "lab" and not analysis.isSampleReceived():
            return False
        # Cannot submit if the Sample has not been sampled
        if point_of_capture == "field" and not analysis.isSampleSampled():
            return False

    # Check if the current user can submit if is not assigned
    if not analysis.bika_setup.getAllowToSubmitNotAssigned():
        if not user_has_super_roles():
            # Cannot submit if unassigned
            if not analysis.getAnalyst():
                return False
            # Cannot submit if assigned analyst is not the current user
            if analysis.getAnalyst() != api.get_current_user().getId():
                return False

    # Cannot submit unless all dependencies are submitted or can be submitted
    for dependency in analysis.getDependencies():
        if not is_submitted_or_submittable(dependency):
            return False
    return True
158790
def existing_analysis(using):
    
    es = connections.get_connection(using)
    index_name = settings.ELASTICSEARCH_CONNECTIONS[using]['index_name']
    if es.indices.exists(index=index_name):
        return stringer(es.indices.get_settings(index=index_name)[index_name]['settings']['index'].get('analysis', {}))
    return DOES_NOT_EXIST
888039
private boolean checkEnabled() {
        /* Enable this analyzer ONLY if the Nexus URL has been set to something
         other than the default one (if it's the default one, we'll use the
         central one) and it's enabled by the user.
         */
        boolean retval = false;
        try {
            if (!DEFAULT_URL.equals(getSettings().getString(Settings.KEYS.ANALYZER_NEXUS_URL))
                    && getSettings().getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)) {
                LOGGER.info("Enabling Nexus analyzer");
                retval = true;
            } else {
                LOGGER.debug("Nexus analyzer disabled, using Central instead");
            }
        } catch (InvalidSettingException ise) {
            LOGGER.warn("Invalid setting. Disabling Nexus analyzer");
        }

        return retval;
    }
647393
def analyse(self, demand_item, demand_item_code):
        
        my_analysis = Bw2Analysis(self)
        self.result_set = my_analysis.run_analyses(demand_item, demand_item_code, **self.analysis_settings)

        return True
98544
def is_verified_or_verifiable(analysis):
    
    if IVerified.providedBy(analysis):
        return True
    if wf.isTransitionAllowed(analysis, "verify"):
        return True
    if wf.isTransitionAllowed(analysis, "multi_verify"):
        return True
    return False
919187
public function is_available() {
        $target = $this->get_target();
        if (!$target) {
            return false;
        }

        $classname = $target->get_analyser_class();
        if (!class_exists($classname)) {
            return false;
        }

        return true;
    }
644765
public boolean areAnyOpen() {
        //==========================================================================//
        //============== Describe Spot Instance Requests to determine =============//
        //==========================================================================//

        // Create the describeRequest with tall of the request id to monitor (e.g. that we started).
        DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest();
        describeRequest.setSpotInstanceRequestIds(spotInstanceRequestIds);

        System.out.println("Checking to determine if Spot Bids have reached the active state...");

        // Initialize variables.
        instanceIds = new ArrayList<String>();

        try
        {
            // Retrieve all of the requests we want to monitor.
            DescribeSpotInstanceRequestsResult describeResult = ec2.describeSpotInstanceRequests(describeRequest);
            List<SpotInstanceRequest> describeResponses = describeResult.getSpotInstanceRequests();

            // Look through each request and determine if they are all in the active state.
            for (SpotInstanceRequest describeResponse : describeResponses) {
                System.out.println(" " +describeResponse.getSpotInstanceRequestId() +
                                   " is in the "+describeResponse.getState() + " state.");

                // If the state is open, it hasn't changed since we attempted to request it.
                // There is the potential for it to transition almost immediately to closed or
                // cancelled so we compare against open instead of active.
                if (describeResponse.getState().equals("open")) {
                    return true;
                }

                // Add the instance id to the list we will eventually terminate.
                instanceIds.add(describeResponse.getInstanceId());
            }
        } catch (AmazonServiceException e) {
            // Print out the error.
            System.out.println("Error when calling describeSpotInstances");
            System.out.println("Caught Exception: " + e.getMessage());
            System.out.println("Reponse Status Code: " + e.getStatusCode());
            System.out.println("Error Code: " + e.getErrorCode());
            System.out.println("Request ID: " + e.getRequestId());

            // If we have an exception, ensure we don't break out of the loop.
            // This prevents the scenario where there was blip on the wire.
            return true;
        }

        return false;
    }
756276
def updateSeriesRegistrationStatus():
    '''
    
    '''
    from .models import Series

    if not getConstant('general__enableCronTasks'):
        return

    logger.info('Checking status of Series that are open for registration.')

    open_series = Series.objects.filter().filter(**{'registrationOpen': True})

    for series in open_series:
        series.updateRegistrationStatus()
670366
def getAnalysis(self):
        
        analysis = None
        ans = self.getLinkedAnalyses()

        if len(ans) > 1:
            # Attachment is assigned to more than one Analysis. This might
            # happen when the AR was invalidated
            an_ids = ", ".join(map(api.get_id, ans))
            logger.info("Attachment assigned to more than one Analysis: [{}]. "
                        "The first Analysis will be returned".format(an_ids))

        if len(ans) >= 1:
            analysis = ans[0]

        return analysis
17084
def analysis(analysis_id):
    """"""
    analysis_obj = store.analysis(analysis_id)
    if analysis_obj is None:
        return abort(404)

    if request.method == 'PUT':
        analysis_obj.update(request.json)
        store.commit()

    data = analysis_obj.to_dict()
    data['failed_jobs'] = [job_obj.to_dict() for job_obj in analysis_obj.failed_jobs]
    data['user'] = analysis_obj.user.to_dict() if analysis_obj.user else None
    return jsonify(**data)
785719
def analyze(self):
        
        key = '/library/sections/%s/analyze' % self.key
        self._server.query(key, method=self._server._session.put)
77205
def analyses(self, *, family: str=None, query: str=None, status: str=None, deleted: bool=None,
                 temp: bool=False, before: dt.datetime=None, is_visible: bool=None):
        """"""
        analysis_query = self.Analysis.query
        if family:
            analysis_query = analysis_query.filter_by(family=family)
        elif query:
            analysis_query = analysis_query.filter(sqa.or_(
                self.Analysis.family.like(f"%{query}%"),
                self.Analysis.status.like(f"%{query}%"),
            ))
        if status:
            analysis_query = analysis_query.filter_by(status=status)
        if isinstance(deleted, bool):
            analysis_query = analysis_query.filter_by(is_deleted=deleted)
        if temp:
            analysis_query = analysis_query.filter(self.Analysis.status.in_(TEMP_STATUSES))
        if before:
            analysis_query = analysis_query.filter(self.Analysis.started_at < before)
        if is_visible is not None:
            analysis_query = analysis_query.filter_by(is_visible=is_visible)
        return analysis_query.order_by(self.Analysis.started_at.desc())