Return rTorrent condition to speed up data transfer.
507849
def pre_filter(self):
        
        if self._name in self.PRE_FILTER_FIELDS:
            val = int(self._value * self.FIELD_SCALE.get(self._name, 1))
            return '"{}=value=${},value={}"'.format(
                   self._rt_cmp, self.PRE_FILTER_FIELDS[self._name], val)
        return ''
804535
def download(url, dest):
    """"""
    path = os.path.join(dest, url.split('/')[-1])
    r = requests.get(url, stream=True)
    r.raise_for_status()
    with open(path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:
                f.write(chunk)
    return path
956723
def rw_active(self):
        """"""
        result = False
        for disk in self.disks:
            result = disk.rw_active() or result
        return result
335243
def conditions(self, full_path, environ):
        """"""
        mtime = int(time.time())
        return str(mtime), rfc822.formatdate(mtime)
1366781
def send(self, cmd, timeout, wait_for_string, password):
        """"""
        return self.target_device.send(cmd, timeout=timeout, wait_for_string=wait_for_string, password=password)
42729
def add_connection_throttle(self, loadbalancer, maxConnectionRate=None,
            maxConnections=None, minConnections=None, rateInterval=None):
        
        return loadbalancer.add_connection_throttle(
                maxConnectionRate=maxConnectionRate, maxConnections=maxConnections,
                minConnections=minConnections, rateInterval=rateInterval)
284471
def handle(self, pkt, raddress, rport):
        """"""
        log.debug("In TftpStateServerStart.handle")
        if isinstance(pkt, TftpPacketRRQ):
            log.debug("Handling an RRQ packet")
            return TftpStateServerRecvRRQ(self.context).handle(pkt,
                                                               raddress,
                                                               rport)
        elif isinstance(pkt, TftpPacketWRQ):
            log.debug("Handling a WRQ packet")
            return TftpStateServerRecvWRQ(self.context).handle(pkt,
                                                               raddress,
                                                               rport)
        else:
            self.sendError(TftpErrors.IllegalTftpOp)
            raise TftpException("Invalid packet to begin up/download: %s" % pkt)
1017199
def recv(self, mac_addr=broadcast_addr, timeout=0):
        """"""
        # recv on the broadcast address "00:..:00" will give you all packets (for promiscuous mode)
        if self.keep_listening:
            try:
                return self.inq[str(mac_addr)].get(timeout=timeout)
            except Empty:
                return ""
        else:
            self.log("is down.")
375619
public function throttle () {
        $now = $this->milliseconds ();
        $elapsed = $now - $this->lastRestRequestTimestamp;
        if ($elapsed < $this->rateLimit) {
            $delay = $this->rateLimit - $elapsed;
              usleep ((int)($delay * 1000.0));
        }
    }
484210
def recv(self, bufsize, **kws):
        
        return Recv(self, bufsize, timeout=self._timeout, **kws)
311160
def send(self):
        """"""
        self._file.write(self.as_bytes())
        self._file.write(b'\r\n')
759157
def get_open_trackers_from_remote():
    """"""

    url_base = 'https://raw.githubusercontent.com/idlesign/torrentool/master/torrentool/repo'
    url = '%s/%s' % (url_base, OPEN_TRACKERS_FILENAME)

    try:
        import requests

        response = requests.get(url, timeout=REMOTE_TIMEOUT)
        response.raise_for_status()

        open_trackers = response.text.splitlines()

    except (ImportError, requests.RequestException) as e:

        # Now trace is lost. `raise from` to consider.
        raise RemoteDownloadError('Unable to download from %s: %s' % (url, e))

    return open_trackers
1130221
def get_connection_by_dest(self, dest):
        ''''''
        with self._mutex:
            for conn in self.connections:
                if conn.has_port(self) and conn.has_port(dest):
                    return conn
            return None
326221
def _GetSubFlowNetworkLimit(self):
    """"""

    subflow_network_limit = None

    if self.runner_args.per_client_network_limit_bytes:
      subflow_network_limit = self.runner_args.per_client_network_limit_bytes

    if self.runner_args.network_bytes_limit:
      remaining_network_quota = (
          self.runner_args.network_bytes_limit -
          self.context.network_bytes_sent)
      if subflow_network_limit is None:
        subflow_network_limit = remaining_network_quota
      else:
        subflow_network_limit = min(subflow_network_limit,
                                    remaining_network_quota)

    return subflow_network_limit
421263
def _RunAndWaitForVFSFileUpdate(self, path):
    """"""

    client_id = rdf_client.GetClientURNFromPath(path)

    # If we're not actually in a directory on a client, no need to run a flow.
    if client_id is None:
      return

    flow_utils.UpdateVFSFileAndWait(
        client_id,
        token=self.token,
        vfs_file_urn=self.root.Add(path),
        timeout=self.timeout)
321698
def run_it():
    """"""
    initialize()
    parser = get_parser()
    args = None
    first_parse = True
    while(True):
        if first_parse is True:
            first_parse = False
            args = parser.parse_args()
        else:
            print(textwrap.dedent(
                '''\
                Search again like in the beginning.
                  -- You can either choose best rated or list mode.
                  -- This time, you can insert the search string without double quotes.
                  Remember the list mode options!
                    0: torrent project.
                    1: the pirate bay.
                    2: 1337x.
                    3: eztv.
                    4: limetorrents.
                    5: isohunt.
                '''))

            print('Or.. if you want to exit just write "' +
                  Colors.LRED + 'Q' + Colors.ENDC + '" or "' +
                  Colors.LRED + 'q' + Colors.ENDC + '".')
            input_parse = input('>> ').replace("'", "").replace('"', '')
            if input_parse in ['Q', 'q']:
                sys.exit(1)

            args = parser.parse_args(input_parse.split(' ', 2))

        if args.str_search.strip() == "":
            print('Please insert an appropiate non-empty string.')
        else:
            auto = AutoPy(*insert(args))
            auto.get_content()
            auto.select_torrent()
            auto.download_torrent()
456164
def _conditions(self, full_path, environ):
        """"""
        mtime = stat(full_path).st_mtime
        return str(mtime), rfc822.formatdate(mtime)