Return a jokes from one of the random services.
14169
def get_joke():
    """"""
    joke = None

    while joke is None:
        service_num = randint(1, NUM_SERVICES)
        joke = load_joke(service_num)
    return joke
1281032
def ask(message, options):
    """"""
    while 1:
        if os.environ.get('PIP_NO_INPUT'):
            raise Exception('No input was expected ($PIP_NO_INPUT set); question: %s' % message)
        response = raw_input(message)
        response = response.strip().lower()
        if response not in options:
            print('Your response (%r) was not one of the expected responses: %s' % (
                response, ', '.join(options)))
        else:
            return response
1312232
def emailComment(comment, obj, request):
    """"""
    if not obj.author.frog_prefs.get().json()['emailComments']:
        return

    if obj.author == request.user:
        return

    html = render_to_string('frog/comment_email.html', {
        'user': comment.user,
        'comment': comment.comment,
        'object': obj,
        'action_type': 'commented on',
        'image': isinstance(obj, Image),
        'SITE_URL': FROG_SITE_URL,
    })

    subject = '{}: Comment from {}'.format(getSiteConfig()['name'], comment.user_name)
    fromemail = comment.user_email
    to = obj.author.email
    text_content = 'This is an important message.'
    html_content = html

    send_mail(subject, text_content, fromemail, [to], html_message=html_content)
894669
def message(self, message, item, extra):
        """"""
        if item is not None:
            message += ": " + ascii(item)
        if extra is not None:
            message += " (" + str(extra) + ")"
        return message
649918
def recv(self):
        """"""
        try:
            items = self.poller.poll(self.timeout)
        except KeyboardInterrupt:
            return  # interrupted

        if items:
            # if we got a reply, process it
            msg = self.client.recv_multipart()
            self.close()
            if self.verbose:
                logging.info("I: received reply:")
                dump(msg)

            # Don't try to handle errors, just assert noisily
            assert len(msg) >= 4

            #first drop will be drop (cause empty)
            header = msg.pop(0)
            header = msg.pop(0)
            assert MDP.C_CLIENT == header

            #this one contains servicename
            #TODO: exploit this
            header = msg.pop(0)

            return msg
        else:
            logging.warn("W: permanent error, abandoning request")
1096364
def cmd(send, msg, args):
    

    req = get('http://www.imdb.com/random/title')
    html = fromstring(req.text)
    name = html.find('head/title').text.split('-')[0].strip()
    key = args['config']['api']['bitlykey']
    send("%s -- %s" % (name, get_short(req.url, key)))
1201121
def scramble_string(self, length):
        """"""
        return fake.text(length) if length > 5 else ''.join([fake.random_letter() for n in range(0, length)])
1165745
def answers(self, other):
        """"""
        if other.__class__ == self.__class__:
            return (other.service + 0x40) == self.service or \
                   (self.service == 0x7f and
                    (self.requestServiceId == other.service))
        return 0
750268
def _recv_ack(self, method_frame):
        ''''''
        if self._ack_listener:
            delivery_tag = method_frame.args.read_longlong()
            multiple = method_frame.args.read_bit()
            if multiple:
                while self._last_ack_id < delivery_tag:
                    self._last_ack_id += 1
                    self._ack_listener(self._last_ack_id)
            else:
                self._last_ack_id = delivery_tag
                self._ack_listener(self._last_ack_id)
411911
def getComics(options):
    """"""
    if options.handler:
        for name in set(options.handler):
            events.addHandler(name, options.basepath, options.baseurl, options.allowdownscale)
    events.getHandler().start()
    errors = 0
    try:
        for scraperobj in getScrapers(options.comic, options.basepath, options.adult, options.multimatch):
            jobs.put(scraperobj)
        # start threads
        num_threads = min(options.parallel, jobs.qsize())
        for i in range(num_threads):
            t = ComicGetter(options)
            threads.append(t)
            t.start()
        # wait for threads to finish
        jobs.join(1)
        for t in threads:
            errors += t.errors
    except ValueError as msg:
        out.exception(msg)
        errors += 1
    except KeyboardInterrupt:
        finish()
    finally:
        events.getHandler().end()
    return errors
663391
def services(cls):
        """"""
        return cls.json_get('%s/services' % cls.api_url, empty_key=True,
                            send_key=False)
402000
def update(request):
    """"""
    session = yield from app.ps.session.load(request)
    session['random'] = random.random()
    return session
725880
def get_jokes(language='en', category='neutral'):
    

    if language not in all_jokes:
        raise LanguageNotFoundError('No such language %s' % language)

    jokes = all_jokes[language]

    if category not in jokes:
        raise CategoryNotFoundError('No such category %s in language %s' % (category, language))

    return jokes[category]
731031
def random_string(random_length=None):
    
    choices = string.letters + ' '
    text = []
    if not random_length:
        random_length = random.randint(1, 30)
    for x in range(random_length):
        text.append(random.choice(choices))
    return "".join(text)
727164
def get_fun(fun):
    '''
    
    '''
    serv = _get_serv(ret=None)
    ret = {}
    for minion in serv.smembers('minions'):
        ind_str = '{0}:{1}'.format(minion, fun)
        try:
            jid = serv.get(ind_str)
        except Exception:
            continue
        if not jid:
            continue
        data = serv.get('{0}:{1}'.format(minion, jid))
        if data:
            ret[minion] = salt.utils.json.loads(data)
    return ret
375096
def _request(self, url, **kwargs):
        '''
        '''
        response = super(Bounces, self)._request(url, **kwargs)
        self._last_response = response
        return response
550351
function random_msg(name){
	name = filter_name(name);
	return  util.format(thanks_temp[Math.floor(Math.random()*10)%(thanks_temp.length-1)] , name);
}