returns 0 if it doesn't correspond to an uploaded container
                   -1 if it corresponds to an uploaded container but it is corrupted
                    1 if it corresponds to an uploaded container and is OK
7038
def is_uploaded_container(self, msg_info):
        
        results = {
            'BAD': -1,
            'NOT_FCB': 0,
            'OK': 1
        }

        for part in msg_info.msg_body.walk():
            if part.is_multipart():
                continue

            """
            if part.get('Content-Disposition') is None:
                print("no content dispo")
                continue
            """
            if part.get_content_type() == 'text/plain':
                if self._is_content_from_fcb(part.get_payload()):
                    self._log.debug("Body detected as FCB: %s", part.get_payload())
                else:
                    self._log.debug("Body doesn't match FCB: %s", part.get_payload())
                    continue

            attachment_name = self._get_attachment_name(part)
            if not attachment_name:
                self._log.debug("Couldn't get attachment name. Will ignore the part.")
                continue

            files_container = self._get_files_container_by_name(attachment_name)
            if files_container:
                sha1_in_db = files_container.sha1
                msg_info.files_containers_id = files_container.id
                tmp_file = FileInfo(os.path.join(tempfile.gettempdir(), "downloaded.tmp"))
                fp = open(tmp_file.path, 'wb')
                fp.write(part.get_payload(decode=1))
                fp.flush()
                fp.close()

                if tmp_file.sha1 == sha1_in_db:
                    self._log.info("File container '%s' verified!", attachment_name)
                    result = results['OK']
                else:
                    self._log.error("File container '%s' doesn't match the sha1 sum. Expected '%s' but got '%s'",
                                    attachment_name, sha1_in_db, tmp_file.sha1)
                    result = results['BAD']
                os.remove(tmp_file.path)
                return result
            else:
                self._log.debug("Attached file '%s' not found in DB. Will ignore this mail.", attachment_name)
        return results['NOT_FCB']
509006
def validate_submission(self, filename):
    
    self._prepare_temp_dir()
    # Convert filename to be absolute path, relative path might cause problems
    # with mounting directory in Docker
    filename = os.path.abspath(filename)
    # extract submission
    if not self._extract_submission(filename):
      return None
    # verify submission size
    if not self._verify_submission_size():
      return None
    # Load metadata
    metadata = self._load_and_verify_metadata()
    if not metadata:
      return None
    submission_type = metadata['type']
    # verify docker container size
    if not self._verify_docker_image_size(metadata['container_gpu']):
      return None
    # Try to run submission on sample data
    self._prepare_sample_data(submission_type)
    if not self._run_submission(metadata):
      logging.error('Failure while running submission')
      return None
    if not self._verify_output(submission_type):
      logging.warning('Some of the outputs of your submission are invalid or '
                      'missing. You submission still will be evaluation '
                      'but you might get lower score.')
    return metadata
967459
def verify_upload(self):
        
        if self.request.status_code == 204:
            return True
        else:
            raise TusUploadFailed('', self.request.status_code, self.request.response_content)
603326
async def container_dump(self, container, container_type, params=None):
        
        await self.container_size(len(container), container_type, params)

        elem_type = x.container_elem_type(container_type, params)
        for idx, elem in enumerate(container):
            try:
                self.tracker.push_index(idx)
                await self._dump_field(elem, elem_type, params[1:] if params else None)
                self.tracker.pop()
            except Exception as e:
                raise helpers.ArchiveException(e, tracker=self.tracker) from e
536216
private int compareChunks(final String thisChunk, final String thatChunk) {
        final int thisChunkLength = thisChunk.length();
        for (int i = 0; i < thisChunkLength; i++) {
            final int result = thisChunk.charAt(i) - thatChunk.charAt(i);
            if (result != 0) {
                return result;
            }
        }
        return 0;
    }
1292816
function () {
    if (this.frameData.length == 0) {
      return 0
    }
    return this.frameData.length / (this.frameData[this.frameData.length - 1].timestamp - this.frameData[0].timestamp) * 1000000;
  }
831312
function length(item) {
        if (!validateHelpers.isUndefined(item.length)) {
            return item.length;
        }

        if (validateHelpers.isObject(item)) {
            return Object.keys(item).length;
        }

        return 0;
    }
1189
async def _load_container(
            self, reader, container_type, params=None, container=None
    ):
        

        c_len = (
            container_type.SIZE
            if container_type.FIX_SIZE
            else await load_uvarint(reader)
        )
        if container and get_elem(container) and c_len != len(container):
            raise ValueError("Size mismatch")

        elem_type = container_elem_type(container_type, params)
        res = container if container else []
        for i in range(c_len):
            try:
                self.tracker.push_index(i)
                fvalue = await self.load_field(
                    reader,
                    elem_type,
                    params[1:] if params else None,
                    eref(res, i) if container else None,
                )
                self.tracker.pop()
            except Exception as e:
                raise helpers.ArchiveException(e, tracker=self.tracker) from e

            if not container:
                res.append(fvalue)
        return res
326767
def is_alive(self, container: Container) -> bool:
        
        uid = container.uid
        r = self.__api.get('containers/{}/alive'.format(uid))

        if r.status_code == 200:
            return r.json()

        if r.status_code == 404:
            raise KeyError("no container found with given UID: {}".format(uid))

        self.__api.handle_erroneous_response(r)
846554
def check_content_length(status, headers, env)
      headers.each { |key, value|
        if key.downcase == 'content-length'
          ## There must not be a <tt>Content-Length</tt> header when the
          ## +Status+ is 1xx, 204 or 304.
          assert("Content-Length header found in #{status} response, not allowed") {
            not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
          }

          bytes = 0
          string_body = true

          if @body.respond_to?(:to_ary)
            @body.each { |part|
              unless part.kind_of?(String)
                string_body = false
                break
              end

              bytes += Rack::Utils.bytesize(part)
            }

            if env["REQUEST_METHOD"] == "HEAD"
              assert("Response body was given for HEAD request, but should be empty") {
                bytes == 0
              }
            else
              if string_body
                assert("Content-Length header was #{value}, but should be #{bytes}") {
                  value == bytes.to_s
                }
              end
            end
          end

          return
        end
      }
    end
460416
async def container_val(self, elem, container_type, params=None):
        
        if hasattr(container_type, "serialize_archive"):
            raise ValueError("not supported")
        if self.writing:
            return await self._dump_container_val(
                self.iobj, elem, container_type, params
            )
        else:
            raise ValueError("Not supported")
483781
def _check_zero_size(self):
        '''
        
        '''
        block_zero = self.end[0] <= self.start[0] or self.end[1] <= self.start[1]
        if block_zero:
            self.flag_change(self.flags, 'fatal', worksheet=self.worksheet,
                             message=self.FLAGS['0-size'])
        return block_zero
1369878
def sd
      return 0.0 if num < 2

      # (sqrt( ((s).sumsq - ( (s).sum * (s).sum / (s).num)) / ((s).num-1) ))
      begin
        return Math.sqrt( (sumsq - ( sum * sum / num)) / (num-1) )
      rescue Errno::EDOM
        return 0.0
      end
    end
1253427
def object_absent(container, name, profile):
    '''
    
    '''
    existing_object = __salt__['libcloud_storage.get_container_object'](container, name, profile)
    if existing_object is None:
        return state_result(True, "Object already absent", name, {})
    else:
        result = __salt__['libcloud_storage.delete_object'](container, name, profile)
        return state_result(result, "Deleted object", name, {})
527343
def get(self, key):
        
        upload = None
        files_states = self.backend.get(key)
        files = MultiValueDict()
        if files_states:
            for name, state in files_states.items():
                f = BytesIO()
                f.write(state['content'])

                # If the post is too large, we cannot use a
                # InMemoryUploadedFile instance.
                if state['size'] > settings.FILE_UPLOAD_MAX_MEMORY_SIZE:
                    upload = TemporaryUploadedFile(
                        state['name'],
                        state['content_type'],
                        state['size'],
                        state['charset'],
                    )
                    upload.file = f
                else:
                    f = BytesIO()
                    f.write(state['content'])
                    upload = InMemoryUploadedFile(
                        file=f,
                        field_name=name,
                        name=state['name'],
                        content_type=state['content_type'],
                        size=state['size'],
                        charset=state['charset'],
                    )
                files[name] = upload

                # Go to the first byte in the file for future use
                upload.file.seek(0)

        return files
1338485
def has_perf_results(self):
        '''
            
        '''
        num_results = SubmissionTestResult.objects.filter(perf_data__isnull=False).filter(submission_file__submissions__assignment=self).count()
        return num_results != 0
133716
def determine_num_chunks(chunk_size, file_size):
        
        if file_size == 0:
            return 1
        return int(math.ceil(float(file_size) / float(chunk_size)))