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

Python models.Config类代码示例

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

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



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

示例1: dash

    def dash(self, **params):
        config = Config.readconfig()
        # Attempts to read the config.
        if config == 0:
            # Else it uses the Arguements to create a config.
            # organises make config data
            data = {str(key):str(value) for key,value in params.items()}
            url = []
            for i, v in data.items():
                url.append(v)

            # makes config
            Config.mkconfig(url)
        else:
            # If True it saves the data to a variable
            URLS = config["URLS"]
            refresh = config["refresh"]

        # Runs the script in the Parsing Model. Parses the XML Files from URL
        parse = Parsing.system()
        refresh = config["refresh"]


        # Returns the template with Parsed XML Data and The Refresh Integer from the Config.
        return self.render_template('home/dash.html', template_vars={'data': parse, 'refresh': refresh})
开发者ID:desgyz,项目名称:MultiMonit,代码行数:25,代码来源:home.py


示例2: set_config

def set_config(name, value):
    config = Config.query.filter(Config.name==name).first()
    if config is None:
        config = Config(name = name, value=value)
    else:
        config.value = value
    db.session.commit()
    return config.value
开发者ID:kafeinnet,项目名称:kafeinnet-blog,代码行数:8,代码来源:hooks.py


示例3: is_open_or_close

def is_open_or_close():
    c = Config.query().get()
    if not c:
        c = Config()
        c.is_open = False
        c.put()
        return False
    return c.is_open
开发者ID:esseti,项目名称:fantacalcio-mercato-libero,代码行数:8,代码来源:main.py


示例4: set_auth_secret

def set_auth_secret(secret):
    """
    Sets the auth secret.
    """
    from models import Config
    secret_config = Config()
    secret_config.key = "auth_secret"
    secret_config.value = secret
    secret_config.put()
    return secret_config
开发者ID:dothiv,项目名称:clickcounter-backend,代码行数:10,代码来源:settings.py


示例5: config_list

def config_list(user):
    if request.method == "GET":
        configs = [c.json() for c in user.configs]
        return _json_response(configs)
    elif request.method == "POST":
        if request.json is None:
            return Response(status=400)
        c = Config(user, request.json)
        db.session.add(c)
        db.session.commit()
        return _json_response(c.json())
开发者ID:deciob,项目名称:data-story-world-bank-project,代码行数:11,代码来源:datastory.py


示例6: load_instagram

def load_instagram():
    access_token = Config.query(Config.name == 'instagram_access_token').order(-Config.date_added).get()

    if access_token is None:
        return Response(json.dumps({ 'error': 'instagram_access_token configuration was not found.' }), status=500, mimetype='application/json');

    client_secret = Config.query(Config.name == 'instagram_client_secret').order(-Config.date_added).get()

    if client_secret is None:
        return Response(json.dumps({ 'error': 'instagram_client_secret configuration was not found.' }), status=500, mimetype='application/json');

    return instagram_import.import_media(access_token.value, client_secret.value)
开发者ID:spiermar,项目名称:yakin-tracker,代码行数:12,代码来源:views.py


示例7: addclusterconfig

def addclusterconfig():
    print request
    if request.method == 'POST':
        # save a new config
        nc = Config()
        nc.cluster_name = request.form['cluster_name']
        nc.cluster_etcd_locator_url = request.form['cluster_etcd_locator_url']
        nc.private_key = request.form['primary_key']
        db.session.add(nc)
        db.session.commit()
        return json.dumps({'status': 'OK', 'cluster': {'id': nc.id, 'cluster_name': nc.cluster_name,
                                                       'cluster_etcd_locator_url': nc.cluster_etcd_locator_url}})
    else:
        print request
开发者ID:drichner,项目名称:docklr,代码行数:14,代码来源:views.py


示例8: load_tracker

def load_tracker():
    tracker_url = Config.query(Config.name == 'tracker_url').order(-Config.date_added).get()
    if tracker_url is None:
        return Response(json.dumps({ 'error': 'tracker_url configuration was not found.' }), status=500, mimetype='application/json');

    tracker_type = Config.query(Config.name == 'tracker_type').order(-Config.date_added).get()
    if tracker_type is None:
        return Response(json.dumps({ 'error': 'tracker_type configuration was not found.' }), status=500, mimetype='application/json');

    if tracker_type.value == 'delorme':
        return delorme.load_data(tracker_url.value)
    elif tracker_type.value == 'spot':
        return Response(json.dumps({ 'error': 'tracker not supported.' }), status=400, mimetype='application/json');
    else:
        return Response(json.dumps({ 'error': 'tracker not supported.' }), status=400, mimetype='application/json');
开发者ID:jmangi13,项目名称:yakin-tracker,代码行数:15,代码来源:views.py


示例9: api_edit_config

def api_edit_config():
    config = Config.get()
    # update all fields, no checks (TODO)
    config_fields = config.fields_set(exclude_fields=['id', 'password'])
    fields = config_fields & set(request.json.keys())
    for field in fields:
        setattr(config, field, request.json[field])
    # change password if the "pw" field isnt empty
    pw = request.json.get('pw')
    if pw:
        Config.change_password(pw)
    db.session.merge(config)
    db.session.commit()
    Config.refresh_instance()  # not necessary ?
    return jsonify({'msg': 'Success !'})
开发者ID:fspot,项目名称:zenfeed,代码行数:15,代码来源:views.py


示例10: confirmed

    def confirmed(self, **params):
        url = []
        # setup update config data
        for k, v in params.items():
            if k != "refresh" and k != "time":
                url.append(v)
            elif k == "refresh":
                refresh = v
            elif k == "time":
                time = v

        # update config
        Config.updateconfig(url, refresh, time)

        # redirect to dashboard
        raise cherrypy.HTTPRedirect("dash")
开发者ID:desgyz,项目名称:MultiMonit,代码行数:16,代码来源:home.py


示例11: admin_settings_update

def admin_settings_update():
	params = utils.flat_multi(request.form)
	params.pop("csrf_token")
	with app.app_context():
		for key in params:
			config = Config.query.filter_by(key=key).first()
			if config is None:
				config = Config(key, params[key])
			else:
				new = params[key]
				if config.value != new:
					config.value = params[key]
			db.session.add(config)
		db.session.commit()

	return { "success": 1, "message": "Success!" }
开发者ID:EasyCTF,项目名称:openctf-docker,代码行数:16,代码来源:admin.py


示例12: new_feed_worker

def new_feed_worker(url, favicon_dir, answer_box, manager_box):
    logger.info("Fetching feed... [%s]", url)
    try:
        fetched = fetch_and_parse_feed(url)
        feed_dict, real_url = fetched['feed'], fetched['real_url']
    except FetchingException:
        return answer_box.put(Exception("Error with feed: " + url))

    feed = FeedFromDict(feed_dict, Config.get())
    feed.url = sanitize_url(real_url) # set the real feed url
    logger.info("Fetching favicon... [%s]", feed.url)
    feed.favicon_path = save_favicon(fetch_favicon(feed.url), favicon_dir)
    db.session.add(feed)
    for e in feed_dict['entries'][::-1]:
        entry = EntryFromDict(e, feed.url)
        entry.feed = feed # set the corresponding feed
        db.session.add(entry)
    db.session.commit()

    most_recent_entry = feed.entries.order_by(Entry.updated.desc()).first()
    feed.updated = most_recent_entry.updated
    db.session.commit()

    answer_box.put(feed)
    manager_box.put({'type': 'new-deadline-worker', 'feed_id': feed.id})
    manager_box.put({'type': 'refresh-cache', 'feed_id': feed.id})
开发者ID:fspot,项目名称:zenfeed,代码行数:26,代码来源:workers.py


示例13: logall

    def logall():
        config = Config.readconfig()
        while config != 0:
            url = config["URLS"]

            if os.path.exists("logs"):
                pass
            else:
                os.mkdir("logs")

            thread_list = []

            for m in url:
                # Instantiates the thread
                # (i) does not make a sequence, so (i,)
                t = threading.Thread(target=logs.log, args=(m,))
                # Sticks the thread in a list so that it remains accessible
                thread_list.append(t)

            # Starts threads
            for thread in thread_list:
                thread.start()

            # This blocks the calling thread until the thread whose join() method is called is terminated.
            # From http://docs.python.org/2/library/threading.html#thread-objects
            for thread in thread_list:
                thread.join()
开发者ID:desgyz,项目名称:MultiMonit,代码行数:27,代码来源:logger.py


示例14: index

 def index(self):
     config = Config.readconfig()
     # Check if there is a config.
     if config != 0:
         # Else redirect the User to the Dashboard
         raise cherrypy.HTTPRedirect("Home/dash")
     else:
         # If True Return the template
         return self.render_template('home/index.html')
开发者ID:desgyz,项目名称:MultiMonit,代码行数:9,代码来源:home.py


示例15: register

def register(request):
	if request.method == "GET":
		template = get_template('registration/register.html')
		context = RequestContext(request, {})
		return HttpResponse(template.render(context))
	elif request.method == "POST":
		username = strip_tags(request.POST.get('username'))
		password = make_password(request.POST.get('password'))
		title = "Pagina de " + username
		user = User(username=username, password=password)
		user.save()
		user = User.objects.get(username=username)
		config = Config(user=user, title=title, color='#D7C4B7', size=14)
		config.save()
		return HttpResponseRedirect("/")
	else:
		template = get_template('notfound.html')
		return HttpResponseNotFound(template.render())
开发者ID:agvergara,项目名称:HotelDiscover,代码行数:18,代码来源:views.py


示例16: settings

    def settings(self):
        # get config data
        config = Config.readconfig()
        URLS = config["URLS"]
        refresh = config["refresh"]
        times = config["time"]

        # Return the template
        return self.render_template('home/settings.html', template_vars={'refresh': refresh, 'urls': URLS, 'time': times})
开发者ID:desgyz,项目名称:MultiMonit,代码行数:9,代码来源:home.py


示例17: config

 def config(self):
     if not hasattr(self, '_config'):
         path = config_path()
         if os.path.exists(path):
             self._config = Config.load(path)
         else:
             self._config = Config()
             self._config.path = path
     return self._config
开发者ID:no2key,项目名称:PyF5,代码行数:9,代码来源:server.py


示例18: set_working_tree

 def set_working_tree(self, working_tree):
     self.unset_current_working_tree()
     new_working_tree, created = Config.get_or_create(**{
         'type': 'working_tree',
         'status': 0,
         'data': working_tree.replace('%', '*')
     })
     new_working_tree.status = 1
     new_working_tree.save()
开发者ID:palestamp,项目名称:owl,代码行数:9,代码来源:service.py


示例19: lists

def lists(candidate_studies, user, annotation_class = None):
    from models import Config

    study_list = (hasattr(user, 'study_list') and user.study_list) or Config.get_solo().default_study_list
    # if no lists are configured, just pass thru
    if not study_list:
        return candidate_studies

    studies = study_list.studies.exclude(radiologystudyreview__user_id = user.id)
    return studies
开发者ID:chop-dbhi,项目名称:django-dicom-review,代码行数:10,代码来源:prioritizers.py


示例20: post

    def post(self):
        pivotal_project_id = self.request.get('pivotal_project_id')
        pivotal_auth_token = self.request.get('pivotal_auth_token')

        config = Config.get_app_config()
        config.pivotal_project_id = pivotal_project_id
        config.pivotal_auth_token = pivotal_auth_token
        config.put()
        
        self.render_template(config)
开发者ID:jakrapong,项目名称:android_crash_reports,代码行数:10,代码来源:admin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Contact类代码示例发布时间:2022-05-27
下一篇:
Python models.ConferenceForm类代码示例发布时间: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