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

Python messages.Messages类代码示例

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

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



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

示例1: delete

 def delete(self, key):
     if auth.user_is_admin():
         Idea.get(key).delete()
     else:
         Messages.add('Only and administrator may delete submitted ideas. ' +
                      'This incident has been logged.')
     return self.redirect('/ideas')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:7,代码来源:back.main.py


示例2: signup

 def signup(self):
     user = auth.User(auth.current_user())
     if user.in_group():
         Messages.add('You are already in a group')
         return self.redirect('/groups')
     else:
         return self.render('groups_signup')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:7,代码来源:back.main.py


示例3: create

    def create(self):
        """Handles the POST data for creating a group.

        Form Variables:
            name:   the name of the new group
            public: true if the group should be joinable by the public
        """
        if auth.logged_in():
            name = self.request.get('name')
            public = self.request.get('public') == 'public'
            owner = auth.current_user()

            if Group.exists(name):
                Messages.add('A group with that name already exists')
                return self.redirect('/groups/signup')

            Group(name=name,
                  public=public,
                  owner=owner,
                  members=[owner]).put()

            return self.redirect('/groups')
        else:
            Messages.add('You must be logged in to create a group')
            return self.redirect('/groups/signup')
开发者ID:ryleyherrington,项目名称:app_hackathon,代码行数:25,代码来源:main.py


示例4: get

    def get(self):
        
        generate_nml_out = subprocess.check_output('do_generate_collection_nml', shell=True, stderr=subprocess.STDOUT)
        Messages.add_message(generate_nml_out, 'success')
        install = 'install -m 0775 -g traktor output.nml /mnt/disk_array/traktor/TraktorProRootDirectory/new-collection.nml'
        subprocess.call(install, shell=True, stderr=subprocess.STDOUT)

        current_route.CURRENT_ROUTE = 'push'
开发者ID:am0ry,项目名称:chirpradio-importer,代码行数:8,代码来源:generate.py


示例5: EventHandler

class EventHandler(object):
    def __init__(self):
        self.dict = OrderedDict()
        self.dict['a'] = False
        self.dict['b'] = False
        self.dict['c'] = False
        self.dict['d'] = False
        self.dict['e'] = False
        self.dict['f'] = False
        self.messages = Messages()
        
#     向服务器发送item
    def send(self):
        for key in self.dict:
            value = self.dict[key]
            if not value:
                self.item = key
                break
        if self.dict[key]:
            return
        host = self.messages.getValue("socket1", "host")
        port = int(self.messages.getValue("socket1", "port"))
        params = (("deliverItem", self.item), self.sendCallBack)
#         检查当前item在服务器的状态,7次
        Thread(target=TCPClient(host, port).send, args=params).start()
        self.check(self.item)
        
    def sendCallBack(self, params):
        if params[1]:
            print("Send", params[0], "成功")
        elif len(params) == 3:
            print("Send", params[0], "出现异常", params[2])
    
#     轮询检查服务器端item的还行状况,7次
    def check(self, item):
        totalTimes = 7
        times = 0
        while times < totalTimes:
            time.sleep(1)
            if self.dict[item]:
                return
            host = self.messages.getValue("socket2", "host")
            port = int(self.messages.getValue("socket2", "port"))
            params = (("checkItemStatus", item), self.checkCallBack)
            Thread(target=TCPClient(host, port).send, args=params).start()
            times += 1
        else:
            print("已经对", item, "发起", totalTimes, "次校验,没有结果. 任务终止.")
        
    def checkCallBack(self, params):
        if params[1]:
            self.dict[params[0]] = params[1]
            print("Check", params[0], "成功。当前队列状态为:", self.dict.items())
            self.send()
        elif len(params) == 3:
            print("Check", params[0], "出现异常:", params[2])
        else:
            print("Check", params[0], "未得到结果")
开发者ID:weijingwei,项目名称:py_sendAndCheck,代码行数:58,代码来源:eventHandler.py


示例6: do_push_artists

    def do_push_artists(self):
        # patch credentials
        if not request.headers.get('Authorization'):
            abort(401)
        else:
            auth = request.headers['Authorization'].lstrip('Basic ')
            username, password = base64.b64decode(auth).split(':')
            if username and password:
                conf.CHIRPRADIO_AUTH = '%s %s' % (username, password)
                chirpradio.connect()
            else:
                abort(401)

        dry_run = False

        # reload artists from file
        artists._init()

        # Find all of the library artists
        all_library_artists = set(artists.all())

        # Find all of the artists in the cloud.
        all_chirpradio_artists = set()
        mapped = 0
        t1 = time.time()
        for art in models.Artist.fetch_all():
            if art.revoked:
                continue
            std_name = artists.standardize(art.name)
            if std_name != art.name:
                #print "Mapping %d: %s => %s" % (mapped, art.name, std_name)
                mapped += 1
                art.name = std_name
                idx = search.Indexer()
                idx._transaction = art.parent_key()
                idx.add_artist(art)
                if not dry_run:
                    idx.save()
            all_chirpradio_artists.add(art.name)

        to_push = list(all_library_artists.difference(all_chirpradio_artists))

        Messages.add_message("Pushing %d artists" % len(to_push), 'warning')
        while to_push:
            # Push the artists in batches of 50
            this_push = to_push[:50]
            to_push = to_push[50:]
            idx = search.Indexer()
            for name in this_push:
                #print name
                art = models.Artist.create(parent=idx.transaction, name=name)
                idx.add_artist(art)
            if not dry_run:
                idx.save()
            #print "+++++ Indexer saved"

        Messages.add_message("Artist push complete. OK!", 'success')
开发者ID:am0ry,项目名称:chirpradio-importer,代码行数:57,代码来源:do_push.py


示例7: update_group

    def update_group(self, key):
        if not auth.logged_in():
            return self.redirect('/groups')
        
        user = auth.current_user()
        group = Group.get(key)
        if group.owner.user_id() != user.user_id() and not auth.user_is_admin():
            Messages.add('Only the owner of the group owner may modify it')
            return self.redirect('/groups')
        
        name = self.request.get('name')
        public = self.request.get('public') == 'public'
        abandon = self.request.get('abandon-project')
        sub_text = self.request.get('submission-text')
        sub_url = self.request.get('submission-url')
        remove_submission = self.request.get_all('remove-submission')
        remove = self.request.get_all('remove')
        owner = self.request.get('owner')
        delete = self.request.get('delete')
        
        if delete:
            group.delete()
            return self.redirect('/groups')
        
        group.name = name
        group.public = public
        
        if abandon:
            group.project = None
        
        if sub_text and sub_url:
            Submission(text=sub_text, url=sub_url, group=group).put()

        for sub in Submission.get(remove_submission):
            sub.delete()

        pending  = list(group.pending_users)
        for user in pending:
            approve = self.request.get("approve-%s" % user)
            if approve == "approve":
                group.members.append(user)
                group.pending_users.remove(user)
            elif approve == "refuse":
                group.pending_users.remove(user)
        
        group.owner = auth.user_from_email(owner)
        
        for user in remove:
            if auth.user_from_email(user) == group.owner:
                Messages.add('Cannot remove the group owner')
                return self.redirect('/groups/%s/edit' % key)
            else:
                group.members.remove(auth.user_from_email(user))
        
        group.put()
        return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:56,代码来源:back.main.py


示例8: edit

 def edit(self, key):
     if not auth.logged_in():
         return self.redirect('/groups')
     
     user = auth.current_user()
     group = Group.get(key)
     if group.owner.user_id() == user.user_id() or auth.user_is_admin():
         return self.render('groups_edit', { 'group': group })
     else:
         Messages.add('Only the owner of this group may edit it')
         return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:11,代码来源:back.main.py


示例9: leave

 def leave(self, key):
     group = Group.get(key)
     user = auth.User(auth.current_user())
     
     if user.group != group:
         Messages.add('You cannot leave a group you are not in')
         return self.redirect('/groups/%s' % key)
     
     group.members.remove(user.gae_user)
     group.put()
     return self.redirect('/groups')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:11,代码来源:back.main.py


示例10: claim

 def claim(self, key):
     user = auth.User(auth.current_user())
     group = user.group
     if group.owner.user_id() == auth.current_user().user_id():
         project = Project.get(key)
         group.project = project
         group.put()
         return self.redirect('/groups/%s' % group.key())
     else:
         Messages.add('You are not the owner of your group. Only the ' +
                      'owner of the group may select a project.')
         return self.redirect('/projects')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:12,代码来源:back.main.py


示例11: approve

 def approve(self, key):
     if auth.user_is_admin():
         idea = Idea.get(key)
         Project(name=idea.name,
                 description=idea.description,
                 author=idea.author,
                 post_time=idea.post_time).put()
         idea.delete()
         return self.redirect('/projects')
     else:
         Messages.add('Only and administrator may approve submitted ' +
                      'ideas. This incident has been logged.')
         return self.redirect('/ideas')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:13,代码来源:back.main.py


示例12: render

    def render(self, template_name, data={}):
        """Renders the template in the site wide manner.

        Retrieves the template data needed for the base template (login URL and
        text, user information, etc.) and merges it with the data passed to the
        method. Templates are retrieved from the template directory specified
        in the settings and appended with the suffix ".html"

        Arguments:
        template_name: the name of the template. this is the file name of the
                       template without the .html extension.

        data: a dictionary containing data to be passed to the template.
        """
        (login_text, login_url) = auth.login_logout(self.request)

        if auth.logged_in():
            data['user'] = auth.User(auth.current_user())

        data['admin'] = auth.user_is_admin()
        data['login_url'] = login_url
        data['login_text'] = login_text
        data['messages'] = Messages.get()

        path = os.path.join(settings.BASE_DIR, settings.TEMPLATE_DIR,
                        "%s.html" % template_name)

        return self.response.out.write(template.render(path, data))
开发者ID:ryleyherrington,项目名称:app_hackathon,代码行数:28,代码来源:main.py


示例13: restart

def restart():  # this really could be health
    lock = None
    try:
        lock = LockFile('json/health.json', 'r')
        lock.acquire()
        with open('json/health.json', 'r') as json_file:

            data = json.load(json_file, encoding='utf-8')

            if request.method == 'POST':
                status = request.args.get('status', type=str)

                if status is None:
                    print 'no status given, defaults to true'
                    status = 'true'

                data['restart'] = status

                with open('json/health.json', 'w') as json_file:
                    json_file.write(json.dumps(data))
                    lock.release()
                    return 'restart set to %s' % status
            if request.method == 'GET':
                lock.release()
                return data['restart']

    except IOError:
        if lock is not None:
            lock.release()
        return Messages.inventoryNotFound()
开发者ID:uml-ubicomp-2016-spring,项目名称:ubicomp16-SmartKitchen,代码行数:30,代码来源:rest_api.py


示例14: dump_dropbox

    def dump_dropbox(self):

        drop = chirp.library.dropbox.Dropbox()
        result = []
        for path in sorted(drop._dirs):
            try:
                chirp_albums = chirp.library.album.from_directory(path, fast=True)
            except (IOError, chirp.library.album.AlbumError), e:
                Messages.add_message('There was an error at %s.' % path, 'error')
                # propagate error to ui so the album may be removed
                result.append({'path': path, 'title': 'There was an error at %s' % path, 'error': True})
                continue

            # build albums
            for album in chirp_albums:
                json = album_to_json(album, path)
                result.append(json)
开发者ID:am0ry,项目名称:chirpradio-importer,代码行数:17,代码来源:pre_import_dropbox_scan.py


示例15: __init__

 def __init__(self):
     self.dict = OrderedDict()
     self.dict['a'] = False
     self.dict['b'] = False
     self.dict['c'] = False
     self.dict['d'] = False
     self.dict['e'] = False
     self.dict['f'] = False
     self.messages = Messages()
开发者ID:weijingwei,项目名称:py_sendAndCheck,代码行数:9,代码来源:eventHandler.py


示例16: __init__

	def __init__(self, newclass=False, ismessages=False, comments=False, configure=None,\
		construct=None):
		self.configure = None
		if configure != None:
			self.configure = self._load_configure(configure)
		else:
			self.newclass = newclass
			self.comments = comments
			self.messages = Messages(ismessages)
			self.construct = construct
开发者ID:saromanov,项目名称:pygentesto,代码行数:10,代码来源:tdd.py


示例17: get_user_or_auto_register

 def get_user_or_auto_register(user_dict):
     try:
         username = user_dict.get("username", None)
         phone = user_dict.get("phone", None)
         if not username:
             return Users.get_none()
         user = Users.get_user(username)
         if not user:
             user = Users.add(user_dict)
             if not user:
                 return Users.get_none()
             else:
                 data_list = [phone]
                 Messages.send_notification(phone, data_list)
                 return user
         return user
     except Exception as ex:
         Logs.print_current_function_name_and_line_number(ex)
         return Users.get_none()
开发者ID:appleface2050,项目名称:WorkCode_Bakup,代码行数:19,代码来源:users.py


示例18: Messages_Test

class Messages_Test(unittest.TestCase):
    def setUp(self):
        self.mutation_matrix = np.array([[ 0.96,  0.02,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.02],
                                         [ 0.02,  0.96,  0.02,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
                                         [ 0.  ,  0.02,  0.96,  0.02,  0.  ,  0.  ,  0.  ,  0.  ],
                                         [ 0.  ,  0.  ,  0.02,  0.96,  0.02,  0.  ,  0.  ,  0.  ],
                                         [ 0.  ,  0.  ,  0.  ,  0.02,  0.96,  0.02,  0.  ,  0.  ],
                                         [ 0.  ,  0.  ,  0.  ,  0.  ,  0.02,  0.96,  0.02,  0.  ],
                                         [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.02,  0.96,  0.02],
                                         [ 0.02,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.02,  0.96]])

        pchem_vals = [0.05,0.15,0.24,0.41,0.44,0.51,0.54,0.79,0.83,0.92]
        site_ids = range(10)
        aa_ids = range(10)
        self.site_types = Ring_Site_Types(.25, zip(aa_ids, pchem_vals), zip(site_ids, pchem_vals), [1] * 10)
        
        self.code_matrix = np.ones((8,10)) / 10

        self.fitness_contributions = None
        self.message = Messages(self.code_matrix, self.site_types.fitness_matrix, self.mutation_matrix)

    def test_mutation_selection_matrix(self):
        mutation_selection_matrices = [self.message._mutation_selection_matrix(i) for i in xrange(10)]

        for i in xrange(10):
            self.assertTrue(np.allclose(mutation_selection_matrices[i],
                                        correct_mutation_selection_matrices[i]),
                            msg="Mutation Selection matrix did not match for site index {}.".format(i))
    
    def test_equilibrium_codon_usage(self):
        self.assertTrue(np.allclose(self.message.codon_usage, # Should default to calculating codon usage
                                    correct_equilibrium_codon_usage)) # at equilibrium

    def test_equilibrium_fitness_contributions(self):
        self.assertTrue(np.allclose(self.message.fitness_contributions, # Should also default to at equilibrium 
                                    correct_equilibrium_fitness_contributions))

    def test_nonequilibrium_fitness_contributions(self):
        self.message.calculate_at_codon_usage(nonequilibrium_codon_usage)
        fitness_contributions = self.message.fitness_contributions

        self.assertAlmostEqual(correct_nonequilibrium_fitness, np.prod(fitness_contributions))
开发者ID:kkauffman,项目名称:tRNAModel,代码行数:42,代码来源:messages_test.py


示例19: _code_fitness

    def _code_fitness(self, code, codon_usage = None):
        """ Gets the overall fitness of a code at the given codon usage,
            if no codon usage is given the codon usage of the 
            currently fixed code at equilibrium is used. """
        
        fitness_contributions = None

        if codon_usage is None:
            if self._last_messages is None:
                if code == self._current_code:
                    msgs = Messages(self._current_code.effective_code_matrix,
                                    self._fitness_matrix,
                                    self._message_mutation_matrix)
                    msgs.calculate_at_equilibrium()
                    self._last_messages = msgs
                    fitness_contributions = msgs.fitness_contributions
                else:
                    self._code_fitness(self._current_code)

        if fitness_contributions is None:
            msgs = Messages(code.effective_code_matrix,
                            self._fitness_matrix,
                            self._message_mutation_matrix)
            msgs.calculate_at_codon_usage(self._last_messages.codon_usage)
            fitness_contributions = msgs.fitness_contributions

        overall_fitness = self._overall_fitness(fitness_contributions)

        if codon_usage is None and code == self._current_code:
            self._current_code_fitness = overall_fitness

        return overall_fitness
开发者ID:kkauffman,项目名称:tRNAModel,代码行数:32,代码来源:evolver.py


示例20: push_to_github

    def push_to_github(self):
        """ Push changes to the artist-whitelist to CHIRP Github

        git-dir and work-tree must be specified because we are operating outside
        of the repo directory.

        TODO: remove abs paths
        """
        git_dir = '/home/musiclib/chirpradio-machine/.git'
        work_tree = '/home/musiclib/chirpradio-machine'

        # commit changes
        commit_command = 'git --git-dir=%s --work-tree=%s commit %s -m "Adding new artists"' % (
            git_dir, work_tree, artists._WHITELIST_FILE,
        )
        commit_output = subprocess.check_output(commit_command, shell=True, stderr=subprocess.STDOUT)
        Messages.add_message(commit_output, 'success')

        # push changes
        push_command = 'git --git-dir=%s --work-tree=%s push' % (git_dir, work_tree)
        push_output = subprocess.check_output(push_command, shell=True, stderr=subprocess.STDOUT)
        Messages.add_message(push_output, 'success')
开发者ID:am0ry,项目名称:chirpradio-importer,代码行数:22,代码来源:do_periodic_import.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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