当前位置: 首页>>代码示例>>Python>>正文


Python settings.get函数代码示例

本文整理汇总了Python中settings.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_all_threads

def get_all_threads():
  api_link = 'https://disqus.com/api/3.0/threads/list.json'
  info = {
    'api_secret': settings.get('disqus_secret_key'),
    'forum': settings.get('disqus_short_code'),
  }
  return do_api_request(api_link, 'GET', info)
开发者ID:JDoe,项目名称:theconversation,代码行数:7,代码来源:disqus.py

示例2: conc_register

def conc_register(self, user_id, corpus_id, subc_name, subchash, query, samplesize, time_limit):
    """
    Register concordance calculation and initiate the calculation.

    arguments:
    user_id -- an identifier of the user who entered the query (used to specify subc. directory if needed)
    corpus_id -- a corpus identifier
    subc_name -- a sub-corpus identifier (None if not used)
    subchash -- a MD5 checksum of the sub-corpus data file
    query -- a query tuple
    samplesize -- a row number limit (if 0 then unlimited - see Manatee API)
    time_limit -- a time limit (in seconds) for the main conc. task

    returns:
    a dict(cachefile=..., pidfile=..., stored_pidfile=...)
    """
    reg_fn = concworker.TaskRegistration(task_id=self.request.id)
    subc_path = os.path.join(settings.get('corpora', 'users_subcpath'), str(user_id))
    pub_path = os.path.join(settings.get('corpora', 'users_subcpath'), 'published')
    initial_args = reg_fn(corpus_id, subc_name, subchash, (subc_path, pub_path), query, samplesize)
    if not initial_args['already_running']:   # we are first trying to calc this
        app.send_task('worker.conc_calculate',
                      args=(initial_args, user_id, corpus_id,
                            subc_name, subchash, query, samplesize),
                      soft_time_limit=time_limit)
    return initial_args
开发者ID:czcorpus,项目名称:kontext,代码行数:26,代码来源:worker.py

示例3: do_api_request

def do_api_request(api_link, method='GET', params={}):
    # add sendgrid user & api key
    params.update({
            'api_user': settings.get('sendgrid_user'),
            'api_key': settings.get('sendgrid_secret')
    })
    try:
        if method.upper() == 'GET':
            if len(params.keys()) > 0:
                r = requests.get(
                        api_link,
                        params=params,
                        verify=False
                )
            else:
                r = requests.get(
                        api_link,
                        verify=False
                )
        else:
            r = requests.post(
                    api_link,
                    params=params,
                    verify=False
            )
        response = r.json()
    except:
        response = {}
    if settings.get('environment') == "dev":
        logging.info("=================")
        logging.info( api_link)
        logging.info( json.dumps(params, indent=4))
        logging.info( response)
        logging.info( "=================")
    return response
开发者ID:proteusvacuum,项目名称:theconversation,代码行数:35,代码来源:emailsdb.py

示例4: send_daily_email

def send_daily_email(email):
	recipients = userdb.get_newsletter_recipients()
	recipient_usernames = [r['user']['username'] for r in recipients]
	email_sent = False
	for user in recipients:
		# send email
		if settings.get('environment') != "prod":
			print "If this were prod, we would have sent email to %s" % user['email_address']
		else:
			requests.post(
				"https://sendgrid.com/api/mail.send.json",
				data={
					"api_user":settings.get('sendgrid_user'),
					"api_key":settings.get('sendgrid_secret'),
					"from": email['from'],
					"to": user['email_address'],
					"subject": email['subject'],
					"html": email['body_html']
				},
				verify=False
			)
			email_sent = True
	# log it
	if email_sent:
		log_daily_email(email, recipient_usernames)
开发者ID:suoinguon,项目名称:theconversation,代码行数:25,代码来源:emailsdb.py

示例5: send_concordance_url

def send_concordance_url(auth, plugin_api, recipient, url):
    user_id = plugin_api.session['user']['id']
    user_info = auth.get_user_info(user_id)
    user_email = user_info['email']
    username = user_info['username']
    smtp_server = settings.get('mailing', 'smtp_server')
    sender = settings.get('mailing', 'sender')

    text = _('KonText user %s has sent a concordance link to you') % (username, ) + ':'
    text += '\n\n'
    text += url + '\n\n'
    text += '\n---------------------\n'
    text += time.strftime('%d.%m. %Y %H:%M')
    text += '\n'

    s = smtplib.SMTP(smtp_server)

    msg = MIMEText(text, 'plain', 'utf-8')
    msg['Subject'] = _('KonText concordance link')
    msg['From'] = sender
    msg['To'] = recipient
    msg.add_header('Reply-To', user_email)
    try:
        s.sendmail(sender, [recipient], msg.as_string())
        ans = True
    except Exception as ex:
        logging.getLogger(__name__).warn(
            'There were errors sending concordance link via e-mail(s): %s' % (ex,))
        ans = False
    finally:
        s.quit()
    return ans
开发者ID:anukat2015,项目名称:kontext,代码行数:32,代码来源:mailing.py

示例6: pubsub_ping

def pubsub_ping():
    """
    Ping a PubSub hub. Might be overtailored to Superfeedr docs; 
    your pubsub hub may differ.

    Also, I'd love to use requests here, but this is a bit minor.
    Trying to keep those reqs down.
    """
    hub_url = settings.get('PUBSUB_URL')
    blog_url = settings.get('BLOG_URL')
    if not hub_url or not blog_url:
        print "Need to have BLOG_URL and PUBSUB_URL set for pubsub to work."
        return

    import urllib, urllib2

    rss_url  = blog_url+'feed/rss.xml'
    atom_url = blog_url+'feed/atom.xml'

    rss_args = { 'hub.mode':'publish', 'hub.url': rss_url }
    rss_req = urllib2.Request(hub_url)
    rss_req.add_data(urllib.urlencode(rss_args))
    rss_res = urllib2.urlopen(rss_req).read()

    atom_args = { 'hub.mode':'publish', 'hub.url': atom_url }
    atom_req = urllib2.Request(hub_url)
    atom_req.add_data(urllib.urlencode(atom_args))
    atom_res = urllib2.urlopen(atom_req).read()

    return
开发者ID:mahmoud,项目名称:PythonDoesBlog,代码行数:30,代码来源:server.py

示例7: corp_freqs_cache_path

def corp_freqs_cache_path(corp, attrname):
    """
    Generates an absolute path to an 'attribute' directory/file. The path
    consists of two parts: 1) absolute path to corpus indexed data
    2) filename given by the 'attrname' argument. It is also dependent
    on whether you pass a subcorpus (files are created in user's assigned directory)
    or a regular corpus (files are created in the 'cache' directory).

    arguments:
    corp -- manatee corpus instance
    attrname -- name of an attribute

    returns:
    a path encoded as an 8-bit string (i.e. unicode paths are encoded)
    """
    if hasattr(corp, "spath"):
        ans = corp.spath.decode("utf-8")[:-4] + attrname
    else:
        if settings.contains("corpora", "freqs_cache_dir"):
            cache_dir = os.path.abspath(settings.get("corpora", "freqs_cache_dir"))
            subdirs = (corp.corpname,)
        else:
            cache_dir = os.path.abspath(settings.get("corpora", "cache_dir"))
            subdirs = (corp.corpname, "freqs")
        for d in subdirs:
            cache_dir = "%s/%s" % (cache_dir, d)
            if not os.path.exists(cache_dir):
                os.makedirs(cache_dir)
        ans = "%s/%s" % (cache_dir, attrname)
    return ans.encode("utf-8")
开发者ID:simar0at,项目名称:kontext,代码行数:30,代码来源:corplib.py

示例8: post

	def post(self):
		# Get submitted form data
		to_name = self.get_argument('to_name', '')
		to_email = self.get_argument('to_email', '')
		for_name = self.get_argument('for_name', '')
		for_email = self.get_argument('for_email', '')
		purpose = self.get_argument('purpose', '')
		intro = {'to_name': to_name, 'to_email': to_email, 'for_name': for_name, 'for_email': for_email, 'purpose': purpose}

		# TODO: Server side error handling? 

		# Save intro to database
		try:
			intro['sent_initial'] = datetime.datetime.now()
			introdb.save_intro(intro)
		except:
			return self.redirect('introbot?err=%s' % 'Failed to save file to database. Email was not sent.')

		# Send initial email
		try:
			name = settings.get('name')
			email = settings.get('email')
			subject = "Intro to %s?" % intro['for_name']
			response_url = "%s/response" % settings.get('base_url')
			if "http://" not in response_url:
				response_url = "http://" + response_url
			text_body = 'Hi %s, %s wants to meet with you to %s If you are open to the connection please email reply to [email protected] This will automatically generate an email from [email protected] to connect the two of you. Thanks! Brittany' % (intro['to_name'], intro['for_name'], intro['purpose'])
			html_body = 'Hi %s,<br><br> %s wants to meet with you to %s <br><br>If you are open to the connection please <a href="%s?id=%s">click here</a>. This will automatically generate an email from %s to connect the two of you. <br><br> Thanks! %s' % (intro['to_name'], intro['for_name'], intro['purpose'], response_url, intro['id'], email, name)
			response = self.send_email(name, intro['to_email'], subject, text_body, html_body, from_name=name)
			if response.status_code != 200:
				raise Exception 
			return self.redirect('?sent=%s (%s)' % (intro['to_name'], intro['to_email'])) # Always redirect after successful POST
		except:
			introdb.remove_intro(intro)
			return self.redirect('?err=%s' % 'Email failed to send.')
开发者ID:AlexanderPease,项目名称:IntroBot,代码行数:35,代码来源:introbot.py

示例9: __init__

    def __init__(self, parent):
        grid.Grid.__init__(self, parent)

        key = 'ui.commsdiagnostics.row.size.'
        width = []
        width.append( settings.get(key+'0', 110)    )
        width.append( settings.get(key+'1', 45)     )
        width.append( settings.get(key+'2', 75)     )
        width.append( settings.get(key+'3', 530)    )

        self.CreateGrid(        1, 4                )
        self.SetRowLabelSize(   50                  )
        self.SetColLabelValue(  0, 'Time'           )
        self.SetColSize(        0, int(width[0])    )
        self.SetColLabelValue(  1, 'Flags'          )             
        self.SetColSize(        1, int(width[1])    )
        self.SetColLabelValue(  2, 'Id'             )
        self.SetColSize(        2, int(width[2])    )
        self.SetColLabelValue(  3, 'Payload'        )
        self.SetColSize(        3, int(width[3])    )

        self.SetDefaultCellFont(wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL))

        # Get all column resizing
        self.Bind(grid.EVT_GRID_COL_SIZE, self.onResize)

        # Bind to connection
        self.conn = comms.getConnection()
        self.conn.bindSendWatcher(self.printSentPacket)
        self.conn.bindRecieveWatcher(self.printRecievedPacket)
开发者ID:karrikoivusalo,项目名称:freeems-tuner,代码行数:30,代码来源:commsDiagnostics.py

示例10: __init__

    def __init__(self, parent=None, id=-1, title=version.__title__,
                 pos=wx.DefaultPosition, size=(800,600), 
                 style=wx.DEFAULT_FRAME_STYLE):
        """Create a Frame instance."""
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        settings.loadSettings()

        self.CreateStatusBar()
        self.SetStatusText('Version %s' % self.revision)
        self._createMenus()

        self.iconized = False

        self.Bind(wx.EVT_MOVE, self.OnMove)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_ICONIZE, self.OnIconize)

        # Handle incoming comms and settings when the UI is idle
        self.Bind(wx.EVT_IDLE, self.OnIdle)

        self.BuildWindow()

        # Load saved location/size settings
        x = settings.get('win.main.pos.x', -1)
        y = settings.get('win.main.pos.y', -1)
        pos  = wx.Point(int(x), int(y))
        
        h = settings.get('win.main.size.h', -1)
        w = settings.get('win.main.size.w', -1)
        size = wx.Size(int(h), int(w))

        self.SetSize(size)
        self.Move(pos)
开发者ID:karrikoivusalo,项目名称:freeems-tuner,代码行数:34,代码来源:__init__.py

示例11: can_read_page

def can_read_page(title, user, is_admin):
    """Returns True if the user is allowed to read the specified page.

    Admins and global readers and editors are allowed to read all pages.  Other
    users are allowed to read all pages if the wiki is open or if the user is
    listed in the readers/editors page property.

    Otherwise no access."""
    if is_admin:
        return True

    is_user_reader = user and (user.email() in settings.get('readers', []) or user.email() in settings.get('editors', []))
    if is_user_reader:
        return True

    page = model.WikiContent.get_by_title(title)
    options = util.parse_page(page.body or '')

    is_open_wiki = settings.get('open-reading', 'yes') == 'yes'
    if is_open_wiki:
        if options.get('private') != 'yes':
            return True
        return user and (user.email() in options.get('readers', []) or user.email() in options.get('editors', []))
    elif settings.get('open-reading') == 'login':
        return options.get('public') == 'yes' or user
    else:
        return options.get('public') == 'yes'
开发者ID:BauweBijl,项目名称:bgaewiki,代码行数:27,代码来源:access.py

示例12: send_message

def send_message(message):
    apikey = settings.get('facebook', 'apikey')
    secretkey = settings.get('facebook', 'sessionkey')
    fb = facebook.Facebook(apikey, secretkey)
    fb.session_key = settings.get('facebook', 'sessionkey')
    fb.secret = settings.get('facebook', 'secret')
    fb.status.set([message])
开发者ID:cataska,项目名称:tweetplurk,代码行数:7,代码来源:myfacebook.py

示例13: send_message

def send_message(message):
    blog = settings.get('tumblr', 'blog')
    email = settings.get('tumblr', 'email')
    password = settings.get('tumblr', 'password')
    api = Api(blog, email, password)
    post = api.write_regular(title=None, body=message)
    print post['url']
开发者ID:cataska,项目名称:tweetplurk,代码行数:7,代码来源:mytumblr.py

示例14: generate_response

def generate_response(thumbnail_url="", width=0, height=0, format="plaintext", callback="", request=None):
    if format.lower() == "json":
        json_response = json.dumps(
            {
                "type": "photo",
                "version": "1.0",
                "provider_name": settings.get("provider_name"),
                "provider_url": settings.get("provider_url"),
                "cache_age": settings.get("suggested_cache_time"),
                "url": str(thumbnail_url),
                "height": height,
                "width": width,
            }
        )

        if callback != "":
            logging.debug("Response format is JSONP (callback: %s).\nResponse: %s" % (callback, json_response))
            json_response = "%s(%s);" % (callback, json_response)
        else:
            logging.debug("Response format is JSON.\nResponse: %s" % json_response)
        return json_response
    elif format.lower() == "plaintext":
        logging.debug("Response format is Plaintext. Response: %s" % thumbnail_url)
        return thumbnail_url
    elif format.lower() == "redirect":
        # not implemented yet
        logging.debug("Response format is a 302 redirect to URL: %s" % thumbnail_url)
        return thumbnail_url
开发者ID:jonathan3,项目名称:nxccs-thumbnailer,代码行数:28,代码来源:app.py

示例15: _get_template_filename

 def _get_template_filename():
     name = os.path.join(os.path.dirname(__file__), 'templates')
     if settings.get('theme'):
         theme = os.path.join(name, settings.get('theme'))
         if os.path.exists(theme):
             name = theme
     return os.path.join(name, template_name)
开发者ID:ilkerde,项目名称:gaewiki,代码行数:7,代码来源:view.py


注:本文中的settings.get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。