Toggle between pausing or resuming downloading.
353151
def pause_resume(self):
        """"""
        if self.is_paused():
            urlopen(self.url + "&mode=resume")
        else:
            urlopen(self.url + "&mode=pause")
1188400
def stop(self):
        
        if self.status in (TransferState.PAUSED, TransferState.RUNNING):
            self._stop_signal = True
            self.join()
            self._status = TransferState.STOPPED
            if self._callback:
                return self._callback(self._status)
        else:
            raise SbgError(
                'Can not stop. Download not in PAUSED or RUNNING state.'
            )
334074
def pause():
	""""""

	if not settings.platformCompatible():
		return False

	(output, error) = subprocess.Popen(["osascript", "-e", PAUSE], stdout=subprocess.PIPE).communicate()
487783
def pause(self):
        """"""
        if self.state == PygAnimation.PLAYING:
            self.elapsedAtPause = self.elapsed
            # only change state if it was playing
            self.state = PygAnimation.PAUSED

        elif self.state == PygAnimation.STOPPED:
            pass  # nothing to do

        elif self.state == PygAnimation.PAUSED:
            pass
404308
def switch_off(self):
        """"""
        success = self.set_status(CONST.STATUS_CLOSED_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_CLOSED

        return success
926474
def choice_download(self):
        
        Download(path="", url=self.dwn_srcs, repo="sbo").start()
        raise SystemExit()
1374220
def on_app_shutdown(self, app):
        ''''''

        if self.filewatcher:
            self.filewatcher.stop()
        if self.profile:
            self.upload_page.on_destroy()
            self.download_page.on_destroy()
645550
function pause(req, res) {
  res.send(null, Constants.OK);
  this.state.pause(req.args[0]);
}
1186088
def toggle_play_pause(self):
        """"""
        # Use Play/Pause button only for sources which support NETAUDIO
        if (self._state == STATE_PLAYING and
                self._input_func in self._netaudio_func_list):
            return self._pause()
        elif self._input_func in self._netaudio_func_list:
            return self._play()
983834
def pause(env, identifier):
    """"""

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')

    if not (env.skip_confirmations or
            formatting.confirm('This will pause the VS with id %s. Continue?'
                               % vs_id)):
        raise exceptions.CLIAbort('Aborted.')

    env.client['Virtual_Guest'].pause(id=vs_id)
957127
private void executeDownload(DownloadRequest request) {
    if (Thread.currentThread().isInterrupted()) {
      return;
    }

    Downloader downloader = request.downloader();
    RandomAccessFile raf = null;
    InputStream is = null;

    try {
      if (request.destinationFilePath() == null) {
        request.updateDestinationFilePath(downloader.detectFilename(request.uri()));
      }

      File file = new File(request.tempFilePath());
      raf = new RandomAccessFile(file, "rw");
      long breakpoint = file.length();
      long bytesWritten = 0;
      if (file.exists()) {
        /* set the range to continue the downloading */
        raf.seek(breakpoint);
        bytesWritten = breakpoint;
        logger.log(
            "Detect existed file with " + breakpoint + " bytes, start breakpoint downloading");
      }

      int statusCode = downloader.start(request.uri(), breakpoint);
      is = downloader.byteStream();
      if (statusCode != HTTP_OK && statusCode != HTTP_PARTIAL) {
        logger.log("Incorrect http code got: " + statusCode);
        throw new DownloadException(statusCode, "download fail");
      }

      long contentLength = downloader.contentLength();
      if (contentLength <= 0 && is == null) {
        throw new DownloadException(statusCode, "content length error");
      }
      boolean noContentLength = contentLength <= 0;
      contentLength += bytesWritten;

      updateStart(request, contentLength);
      logger.log("Start to download, content length: " + contentLength + " bytes");

      if (is != null) {
        byte[] buffer = new byte[BUFFER_SIZE];
        int length;

        while (true) {
          /* if the request has canceld, stop the downloading */
          if (Thread.currentThread().isInterrupted() || request.isCanceled()) {
            request.finish();
            return;
          }

          /* if current is not wifi and mobile network is not allowed, stop */
          if (request.allowedNetworkTypes() != 0
              && !Utils.isWifi(request.context())
              && (request.allowedNetworkTypes() & DownloadRequest.NETWORK_MOBILE) == 0) {
            throw new DownloadException(statusCode, "allow network error");
          }

          /* read data into buffer from input stream */
          length = readFromInputStream(buffer, is);
          long fileSize = raf.length();
          long totalBytes = noContentLength ? fileSize : contentLength;

          if (length == -1) {
            updateSuccess(request);
            return;
          } else if (length == Integer.MIN_VALUE) {
            throw new DownloadException(statusCode, "transfer data error");
          }

          bytesWritten += length;
          /* write buffer into local file */
          raf.write(buffer, 0, length);

          /* deliver progress callback */
          updateProgress(request, bytesWritten, totalBytes);
        }
      } else {
        throw new DownloadException(statusCode, "input stream error");
      }
    } catch (IOException e) {
      logger.log("Caught new exception: " + e.getMessage());

      if (e instanceof DownloadException) {
        DownloadException exception = (DownloadException) e;
        updateFailure(request, exception.getCode(), exception.getMessage());
      } else {
        updateFailure(request, 0, e.getMessage());
      }
    } finally {
      downloader.close();
      silentCloseFile(raf);
      silentCloseInputStream(is);
    }
  }
970928
def _start(self, items):
        
        # TODO: Filter by a custom date field, for scheduled downloads starting at a certain time, or after a given delay

        # TODO: Don't start anything more if download BW is used >= config threshold in %

        # Check if anything more is ready to start downloading
        startable = [i for i in items if self.config.startable.match(i)]
        if not startable:
            self.LOG.debug("Checked %d item(s), none startable according to [ %s ]",
                           len(items), self.config.startable)
            return

        # Check intermission delay
        now = time.time()
        if now < self.last_start:
            # compensate for summer time and other oddities
            self.last_start = now
        delayed = int(self.last_start + self.config.intermission - now)
        if delayed > 0:
            self.LOG.debug("Delaying start of {:d} item(s),"
                           " due to {:d}s intermission with {:d}s left"
                           .format(len(startable), self.config.intermission, delayed))
            return

        # TODO: sort by priority, then loaded time

        # Stick to "start_at_once" parameter, unless "downloading_min" is violated
        downloading = [i for i in items if self.config.downloading.match(i)]
        start_now = max(self.config.start_at_once, self.config.downloading_min - len(downloading))
        start_now = min(start_now, len(startable))

        #down_traffic = sum(i.down for i in downloading)
        ##self.LOG.info("%d downloading, down %d" % (len(downloading), down_traffic))

        # Start eligible items
        for idx, item in enumerate(startable):
            # Check if we reached 'start_now' in this run
            if idx >= start_now:
                self.LOG.debug("Only starting %d item(s) in this run, %d more could be downloading" % (
                    start_now, len(startable)-idx,))
                break

            # TODO: Prevent start of more torrents that can fit on the drive (taking "off" files into account)
            # (restarts items that were stopped due to the "low_diskspace" schedule, and also avoids triggering it at all)

            # Only check the other conditions when we have `downloading_min` covered
            if len(downloading) < self.config.downloading_min:
                self.LOG.debug("Catching up from %d to a minimum of %d downloading item(s)" % (
                    len(downloading), self.config.downloading_min))
            else:
                # Limit to the given maximum of downloading items
                if len(downloading) >= self.config.downloading_max:
                    self.LOG.debug("Already downloading %d item(s) out of %d max, %d more could be downloading" % (
                        len(downloading), self.config.downloading_max, len(startable)-idx,))
                    break

            # If we made it here, start it!
            self.last_start = now
            downloading.append(item)
            self.LOG.info("%s '%s' [%s, #%s]" % (
                "WOULD start" if self.config.dry_run else "Starting",
                fmt.to_utf8(item.name), item.alias, item.hash))
            if not self.config.dry_run:
                item.start()
                if not self.config.quiet:
                    self.proxy.log(xmlrpc.NOHASH, "%s: Started '%s' {%s}" % (
                        self.__class__.__name__, fmt.to_utf8(item.name), item.alias,
                    ))
953658
def pauseMovie(self):
    """"""
    if self.state == self.PLAYING:
      self.sendRtspRequest(self.PAUSE)
744548
public void cancelDownload(OfflineDownloadOptions offlineDownload) {
    Intent intent = new Intent(context, OfflineDownloadService.class);
    intent.setAction(OfflineConstants.ACTION_CANCEL_DOWNLOAD);
    intent.putExtra(KEY_BUNDLE, offlineDownload);
    context.startService(intent);
  }
14558
def handle_play_pause_clicked(self):
        
        if self.__scan_hardware_source:
            if self.is_playing:
                self.__scan_hardware_source.stop_playing()
            else:
                self.__scan_hardware_source.start_playing()
93347
def toggle_service(self):
        
        self.monitoring_disabled.emit(not self.service.is_running())
        if self.service.is_running():
            self.pause_service()
        else:
            self.unpause_service()
263751
def start_download_thread(self):
		''''''
		if self._download_thread:
			return
		t = threading.Thread(target=self.downloader)
		t.daemon = True
		self._download_thread = t
		t.start()