Verify that one or more resources were downloaded successfully.
17491
def verify(opts):
    
    resources = _load(opts.resources, opts.output_dir)
    if opts.all:
        opts.resource_names = ALL
    invalid = _invalid(resources, opts.resource_names)
    if not invalid:
        if not opts.quiet:
            print("All resources successfully downloaded")
        return 0
    else:
        if not opts.quiet:
            print("Invalid or missing resources: {}".format(', '.join(invalid)))
        return 1
1036569
def approve(self, filepath):
        """"""

        try:
            signature_valid = self.validate_signature(filepath)

        except ValueError:
            # GPG is not installed
            signature_valid = False

        if signature_valid:
            self.leave_safe_mode()
            post_command_event(self.main_window, self.SafeModeExitMsg)

            statustext = _("Valid signature found. File is trusted.")
            post_command_event(self.main_window, self.StatusBarMsg,
                               text=statustext)

        else:
            self.enter_safe_mode()
            post_command_event(self.main_window, self.SafeModeEntryMsg)

            statustext = \
                _("File is not properly signed. Safe mode "
                  "activated. Select File -> Approve to leave safe mode.")
            post_command_event(self.main_window, self.StatusBarMsg,
                               text=statustext)
316162
def verify(info, directory_path):
    
    base_path = os.path.join(directory_path, info['name'])
    if 'length' in info:
        if os.stat(base_path).st_size != info['length']:
            return False
        getfile = lambda: open(base_path, 'rb')
    else:
        assert 'files' in info, 'invalid torrent file'
        for f in info['files']:
            p = os.path.join(base_path, *f['path'])
            if os.stat(p).st_size != f['length']:
                return False
        getfile = lambda: ConcatenatedFile(base_path, info['files'])
    with getfile() as f:
        return compare_checksum(info, f)
811429
def _handle_download_result(self, resource, tmp_dir_path, sha256, dl_size):
    """"""
    fnames = tf.io.gfile.listdir(tmp_dir_path)
    if len(fnames) > 1:
      raise AssertionError('More than one file in %s.' % tmp_dir_path)
    original_fname = fnames[0]
    tmp_path = os.path.join(tmp_dir_path, original_fname)
    self._recorded_sizes_checksums[resource.url] = (dl_size, sha256)
    if self._register_checksums:
      self._record_sizes_checksums()
    elif (dl_size, sha256) != self._sizes_checksums.get(resource.url, None):
      raise NonMatchingChecksumError(resource.url, tmp_path)
    download_path = self._get_final_dl_path(resource.url, sha256)
    resource_lib.write_info_file(resource, download_path, self._dataset_name,
                                 original_fname)
    # Unconditionally overwrite because either file doesn't exist or
    # FORCE_DOWNLOAD=true
    tf.io.gfile.rename(tmp_path, download_path, overwrite=True)
    tf.io.gfile.rmtree(tmp_dir_path)
    return download_path
766047
def verify(self, base_path, update=False):
        """"""
        return self.project.verify_submission(base_path, self, update=update)
389428
def check_existance(f):
    """"""
    if not opath.isfile(f):
        logging.error("Nanoget: File provided doesn't exist or the path is incorrect: {}".format(f))
        sys.exit("File provided doesn't exist or the path is incorrect: {}".format(f))
724501
def check_success(self, device_id, sent_cmd1, sent_cmd2):
        """"""
        device_id = device_id.upper()

        self.logger.info('check_success: for device %s cmd1 %s cmd2 %s',
                         device_id, sent_cmd1, sent_cmd2)

        sleep(2)
        status = self.get_buffer_status(device_id)
        check_id = status.get('id_from', '')
        cmd1 = status.get('cmd1', '')
        cmd2 = status.get('cmd2', '')
        if (check_id == device_id) and (cmd1 == sent_cmd1) and (cmd2 == sent_cmd2):
            self.logger.info("check_success: Response device %s cmd %s cmd2 %s SUCCESS",
                             check_id, cmd1, cmd2)
            return True

        self.logger.info("check_success: No valid response found for device %s cmd %s cmd2 %s",
                         device_id, sent_cmd1, sent_cmd2)
        return False
1284507
def download_if_not_exists(url: str, filename: str,
                           skip_cert_verify: bool = True,
                           mkdir: bool = True) -> None:
    
    if os.path.isfile(filename):
        log.info("No need to download, already have: {}", filename)
        return
    if mkdir:
        directory, basename = os.path.split(os.path.abspath(filename))
        mkdir_p(directory)
    download(url=url,
             filename=filename,
             skip_cert_verify=skip_cert_verify)
17462
def ensure_file(url, path, md5sum=None):
    

    if not os.path.isfile(path) or (md5sum and md5sum != file_md5(path)):
        download_file(url, path)
684204
def action_verify_checksum(self, ids):
        """"""
        try:
            count = 0
            for file_id in ids:
                f = FileInstance.query.filter_by(
                    id=uuid.UUID(file_id)).one_or_none()
                if f is None:
                    raise ValueError(_("Cannot find file instance."))
                verify_checksum.delay(file_id)
                count += 1
            if count > 0:
                flash(_('Fixity check(s) sent to queue.'), 'success')
        except Exception as exc:
            if not self.handle_view_exception(exc):
                raise
            current_app.logger.exception(str(exc))  # pragma: no cover
            flash(_('Failed to run fixity checks.'),
                  'error')
1185686
def verify_state(self):
        """"""
        if self.state == CONNECTING:
            self.state = OPEN

            self.conn.on_open(self.conn_info)
755037
function verifyChecksum(fileName, checksum) {
  return kew.resolve(hasha.fromFile(fileName, {algorithm: 'sha256'})).then(function (hash) {
    var result = checksum == hash
    if (result) {
      console.log('Verified checksum of previously downloaded file')
    } else {
      console.log('Checksum did not match')
    }
    return result
  }).fail(function (err) {
    console.error('Failed to verify checksum: ', err)
    return false
  })
}
670275
def verify_submission(self, base_path, submission, update):
        """"""
        results = VerificationResults()
        valid_files = set()
        file_mapping = submission.file_mapping()

        # Create a list of in-use file verifiers
        file_verifiers = set(fv for testable in self.testables
                             for fv in testable.file_verifiers)

        for fv in file_verifiers:
            if fv.filename in file_mapping:
                errors, warnings = fv.verify(base_path,
                                             file_mapping[fv.filename])
                if errors:
                    results.set_errors_for_filename(errors, fv.filename)
                else:
                    valid_files.add(fv.filename)
                if warnings:
                    results.set_warnings_for_filename(warnings, fv.filename)
                del file_mapping[fv.filename]
            elif not fv.optional:
                results.set_errors_for_filename(['missing'], fv.filename)
        if file_mapping:
            results.set_extra_filenames(frozenset(file_mapping.keys()))

        # Determine valid testables
        retval = []
        for testable in self.testables:
            missing = frozenset(x.filename for x in testable.file_verifiers
                                if not x.optional) - valid_files
            if missing:
                results._missing_to_testable_ids.setdefault(
                    missing, set()).add(testable.id)
            elif testable.file_verifiers:
                retval.append(testable)

        if update:
            # Reset existing attributes
            submission.test_case_results = []
            submission.testable_results = []
            # Set new information
            submission.verification_results = results
            submission.verified_at = func.now()
        return retval
1255379
def success(self):
        """"""
        self._check_valid()
        return self._problem._p.get_status() == qsoptex.SolutionStatus.OPTIMAL
951332
def _download(self, url, path=None, force=False):
        """"""
        if path is None:
            path = url.split('/')[-1]

        # Make dir if non existent
        folder = os.path.dirname(os.path.abspath(path))

        if not os.path.isdir(folder):
            os.makedirs(folder)

        # Start actual download
        try:
            r = requests.get(url, stream=True, proxies=self.proxy_servers)
        except Exception as error:
            print('ERROR', 'here', error)
            logger.error(str(error))
            # Break if error found!
#            self._sig_download_finished.emit(url, path)
#            return path

        total_size = int(r.headers.get('Content-Length', 0))

        # Check if file exists
        if os.path.isfile(path) and not force:
            file_size = os.path.getsize(path)

            # Check if existing file matches size of requested file
            if file_size == total_size:
                self._sig_download_finished.emit(url, path)
                return path

        # File not found or file size did not match. Download file.
        progress_size = 0
        with open(path, 'wb') as f:
            for chunk in r.iter_content(chunk_size=self._chunk_size):
                if chunk:
                    f.write(chunk)
                    progress_size += len(chunk)
                    self._sig_download_progress.emit(url, path,
                                                     progress_size,
                                                     total_size)
            self._sig_download_finished.emit(url, path)

        return path
804030
def check_release_files(package_info, *args):
    
    reason = "No release files uploaded"
    result = False

    release_urls = args[0]
    if len(release_urls) > 0:
        result = True

    return result, reason, HAS_RELEASE_FILES
391830
def maybe_download(url, filename):
  """"""
  if not os.path.exists(WORK_DIRECTORY):
    os.mkdir(WORK_DIRECTORY)
  filepath = os.path.join(WORK_DIRECTORY, filename)
  if not os.path.exists(filepath):
    filepath, _ = request.urlretrieve(url + filename, filepath)
    statinfo = os.stat(filepath)
    print('Successfully downloaded', filename, statinfo.st_size, 'bytes.')
  return filepath