• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python settings.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __init__

    def __init__(self, controller):
        """Create a Frame instance."""
        wx.Frame.__init__(self, parent=None, id=-1, size=(800, 600))

        self._controller = controller

        self._debug("Gui frame initialised")

        self._updateStatus()

        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)

        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:GunioRobot,项目名称:freeems-tuner,代码行数:31,代码来源:__init__.py


示例17: get

  def get(self):
    code = self.get_argument('code','')
    req_host = self.request.headers['host']
    api_key = settings.get('disqus_public_key')
    api_secret = settings.get('disqus_secret_key')

    link = 'https://disqus.com/api/oauth/2.0/access_token/'
    data = {
      'grant_type':'authorization_code',
      'client_id':api_key,
      'client_secret':api_secret,
      'redirect_uri': 'http://%s/disqus' % req_host,
      'code' : code
    }
    try:
      account = userdb.get_user_by_screen_name(self.current_user)
      if account:
        response = urllib2.urlopen(link, urllib.urlencode(data))
        #  access_token should look like access_token=111122828977539|98f28d8b5b8ed787b585e69b.1-537252399|1bKwe6ghzXyS9vPDyeB9b1fHLRc
        user_data = json.loads(response.read())
        # refresh the user token details
        account['disqus_username'] = user_data['username']
        account['disqus_user_id'] = user_data['user_id']
        account['disqus_access_token'] = user_data['access_token']
        account['disqus_expires_in'] = user_data['expires_in']
        account['disqus_refresh_token'] = user_data['refresh_token']
        account['disqus_token_type'] = user_data['token_type']
        userdb.save_user(account)
    except:
      # trouble logging in
      data = {}
    self.redirect('/your_account?section=social_accounts')
开发者ID:cDoru,项目名称:conversation,代码行数:32,代码来源:disqus.py


示例18: __init__

 def __init__(self):
     self.username_soa = settings.get("username_soa")
     self.password_soa = settings.get("password_soa")
     self.client = Client(self.url)
     security = Security()
     security.tokens.append(UsernameToken(self.username_soa, self.password_soa))
     self.client.set_options(wsse=security)
开发者ID:UPC,项目名称:buscaticket,代码行数:7,代码来源:service.py


示例19: get_thread_details

def get_thread_details(post):
    api_link = 'https://disqus.com/api/3.0/threads/details.json'
    info = {
      'api_key': settings.get('disqus_public_key'),
      'thread:link': template_helpers.post_permalink(post),
      'forum': settings.get('disqus_short_code'),
    }
    return do_api_request(api_link, 'GET', info)
开发者ID:proteusvacuum,项目名称:theconversation,代码行数:8,代码来源:disqus.py


示例20: __init__

	def __init__(self):
		self._playlist_prefix = settings.get('playlist_prefix')
		self._video_prefix = settings.get('video_prefix')
		self.playlists = settings.get('playlists').split(',')
		self._cache_path = settings.get('cache_path')
		self._make_dirs('current')
		self.stamps = self._make_stamps('current')
		logging.info('Instantiated sync manager')
开发者ID:ekevoo,项目名称:nippl,代码行数:8,代码来源:sync.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python settings.getProperty函数代码示例发布时间:2022-05-27
下一篇:
Python settings._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap