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

Python models.Channel类代码示例

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

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



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

示例1: fetchDataset

  def fetchDataset (self):
    """Fetch a dataset to the list of cacheable datasets"""

    token = self.dataset_name.split('-')[0]
    
    try:
      json_info = json.loads(getURL('http://{}/ocpca/{}/info/'.format(settings.SERVER, token)))
    except Exception as e:
      logger.error("Token {} doesn not exist on the backend {}".format(token, settings.SERVER))
      raise NDTILECACHEError("Token {} doesn not exist on the backend {}".format(token, settings.SERVER))
    
    ximagesize, yimagesize, zimagesize = json_info['dataset']['imagesize']['0']
    xoffset, yoffset, zoffset = json_info['dataset']['offset']['0']
    xvoxelres, yvoxelres, zvoxelres = json_info['dataset']['voxelres']['0']
    scalinglevels = json_info['dataset']['scalinglevels']
    scalingoption = ND_scalingtoint[json_info['dataset']['scaling']]
    starttime, endtime = json_info['dataset']['timerange']
    project_name = json_info['project']['name']
    s3backend = json_info['project']['s3backend']
    
    self.ds = Dataset(dataset_name=self.dataset_name, ximagesize=ximagesize, yimagesize=yimagesize, zimagesize=zimagesize, xoffset=xoffset, yoffset=yoffset, zoffset=zoffset, xvoxelres=xvoxelres, yvoxelres=yvoxelres, zvoxelres=zvoxelres, scalingoption=scalingoption, scalinglevels=scalinglevels, starttime=starttime, endtime=endtime, project_name=project_name, s3backend=s3backend)
    self.ds.save()

    for channel_name in json_info['channels'].keys():
      channel_name = channel_name
      dataset_id = self.dataset_name
      channel_type = json_info['channels'][channel_name]['channel_type']
      channel_datatype = json_info['channels'][channel_name]['datatype']
      startwindow, endwindow = json_info['channels'][channel_name]['windowrange']
      propagate = json_info['channels'][channel_name]['propagate'] 
      readonly = json_info['channels'][channel_name]['readonly']
      ch = Channel(channel_name=channel_name, dataset=self.ds, channel_type=channel_type, channel_datatype=channel_datatype, startwindow=startwindow, endwindow=endwindow, propagate=propagate, readonly=readonly)
      ch.save()
开发者ID:neurodata,项目名称:ndtilecache,代码行数:33,代码来源:nddataset.py


示例2: index

def index(request):
	# Validate token from Slack.
	token = request.GET['token']
	if (token != 'RNmcnBKCdOZBfs3S7habfT85'):
		return JsonResponse({'text': 'ERROR: Invalid token %s' % token})
	
	# Fetch channel if it exists, else create a new Channel object.
	channel_id = request.GET['channel_id']
	try:
		channel = Channel.objects.get(channel_id=channel_id)
	except Channel.DoesNotExist:
		channel = Channel(channel_id=channel_id)
		channel.save() 

	# Parse command from user.
	command = request.GET['text']	
	args = command.split(' ')
	if (len(args) < 1 or args[0] == 'help'):
		return showHelp()
	elif (args[0] == 'startGame'):
		return startGame(args, request.GET['user_name'], channel)
	elif (args[0] == 'makeMove'):
		return makeMove(args, request.GET['user_name'], channel)
	elif (args[0] == 'showBoard'):
		return showBoard(channel)
	else:
		return showHelp()
开发者ID:stephanieychou,项目名称:tictactoe,代码行数:27,代码来源:views.py


示例3: initChannel

def initChannel(userid):
    #Refreshes the channel api
    chan = Channel.get_by_key_name(userid)
    if not chan:
        chan = Channel(key_name = userid)
    chan.token = channel.create_channel(userid, duration_minutes=5)
    chan.put()
    return chan.token
开发者ID:dillongrove,项目名称:TheHackers,代码行数:8,代码来源:main.py


示例4: channel_add

def channel_add():
    j = request.get_json()
    c = Channel(j)
    c.save()
    responseData = {
        'channel_name': c.name,
        'channel_id': c.id,
    }
    return json.dumps(responseData, indent=2)
开发者ID:RachelQ1103,项目名称:Forum-Gua,代码行数:9,代码来源:app.py


示例5: get

 def get(self):
     outlets = Outlet.all().filter('target =', self.account).fetch(100)
     if len(self.request.path.split('/')) > 2:
         source = Account.get_by_hash(self.request.path.split('/')[-1])
         channel = Channel.get_by_source_and_target(source, self.account)
         self.render('templates/source.html', locals())
     else:
         enabled_channels = Channel.get_all_by_target(self.account).order('-count').filter('status =', 'enabled')
         self.render('templates/sources.html', locals())
开发者ID:dcparker,项目名称:notify-io,代码行数:9,代码来源:main.py


示例6: get

 def get(self):
     global is_modified
     is_modified = True
     for ch in Channel.all():
         ch.delete()
     for c in CHANNELS_LIST:
         channel = Channel(img_url=c["img_url"], name=c["name"])
         channel.put()
         taskqueue.add(url="/tvfeed/update", method="POST", params={"key": channel.key(), "gogo_id": c["c_id"]})
     self.response.out.write("Started")
开发者ID:erdenezul,项目名称:tv-feeder,代码行数:10,代码来源:tv.py


示例7: admin

def admin():
    user = current_user()
    is_admin = is_administrator(user)
    log('Is admin?', is_admin)
    if is_admin:
        option_json = request.json
        Channel.update_roles(option_json)
        response_data = cid_rid_for_cookie()
        return json.dumps(response_data, indent=2)
    else:
        abort(401)
开发者ID:eason-lee,项目名称:Forum-Gua,代码行数:11,代码来源:app.py


示例8: channel_add

def channel_add():
    user = current_user()
    is_admin = is_administrator(user)
    log('Is admin? ', is_admin)
    if is_admin:
        j = request.json
        c = Channel(j)
        c.save()
        responseData = {
            'channel_name': c.name,
            'channel_id': c.id,
        }
        return json.dumps(responseData, indent=2)
    else:
        abort(401)
开发者ID:eason-lee,项目名称:Forum-Gua,代码行数:15,代码来源:app.py


示例9: add_bot

 def add_bot(self, channel, name):
     channel = channel.lower()
     name = name.lower()
     try:
         Bot.get(Bot.name == name)
     except peewee.DoesNotExist:
         pass  # this seems really unpythonic somehow
     else:
         raise KeyError('Bot already exists')
     try:
         chan_o = Channel.get(Channel.name == channel)
     except peewee.DoesNotExist:
         chan_o = Channel.create(name=channel)
     Bot.create(name=name,
                channel=chan_o)
开发者ID:Bevinsky,项目名称:packlist-assembler,代码行数:15,代码来源:assembler.py


示例10: list_command

 def list_command(self, msg):
   """Handle /list commands."""
   lines = []
   q = Channel.all().order('-num_members').filter('num_members >', 0)
   channels = q.fetch(self._LIST_LIMIT + 1)
   if not len(channels):
     msg.reply('* No channels exist!')
     return
   if len(channels) <= self._LIST_LIMIT:
     # Show all, sorted by channel name.
     channels.sort(key=lambda c: c.name)
     lines.append('* All channels:')
   else:
     # Show the top N channels, sorted by num_members.
     channels.pop()
     lines.append('* More than %d channels; here are the most popular:' %
                  self._LIST_LIMIT)
   for c in channels:
     if c.num_members == 1:
       count = '1 person'
     else:
       count = '%d people' % c.num_members
     s = '* - %s (%s)' % (c, count)
     lines.append(s)
   msg.reply('\n'.join(lines))
开发者ID:hasantayyar,项目名称:robot-talk,代码行数:25,代码来源:xmpp.py


示例11: decorated_view

 def decorated_view(*args, **kwargs):
     channel=kwargs['channel']
     channel=Channel.gql("WHERE id = :1", channel).get()
     if channel:
         kwargs['channel']=channel
         return func(*args, **kwargs)
     return redirect(url_for('qq.list_channels'))
开发者ID:motord,项目名称:banter,代码行数:7,代码来源:decorators.py


示例12: newchan

def newchan(request):
	if request.method == 'POST':
		uc = NewChanForm(request.POST)
		if uc.is_valid():
			cname = uc.cleaned_data['cname']
			chan = Channel(name=cname, description=uc.cleaned_data['desc'], publish=[request.user.username,], subscribe=[request.user.username,], creator=request.user)
			#request.user.publish.append(cname)
			#request.user.subscribe.append(cname)
			chan.save()
			#request.user.save()
			return render_to_response('chancreated.html', {'cname': cname}, context_instance=RequestContext(request))
		else:
			return render_to_response('chancreate.html', {'form': uc}, context_instance=RequestContext(request))
		
	uc = NewChanForm()
	return render_to_response('chancreate.html', {'form': uc}, context_instance=RequestContext(request))
开发者ID:Oriumpor,项目名称:hpfeeds,代码行数:16,代码来源:views.py


示例13: populate

def populate():
    q=Channel.gql("WHERE id=:1", 'koan')
    channel=q.get()
    code="""
__author__ = 'peter'

from application import settings
import logging

MSG_TYPE_TEXT = u'text'
MSG_TYPE_LOCATION = u'location'
MSG_TYPE_IMAGE = u'image'

def process_text(remark, retort):
    if remark['content']:
        retort['content']='Bot Spawned!'
        retort['msgType']=MSG_TYPE_TEXT
        retort['funcFlag']=0
    return retort

def process_location(remark, retort):
    return retort

def process_image(remark, retort):
    return retort
    """
    bot=Bot(name=u'spawn', code=code, channel=channel.key)
    bot.put()
    return 'populated.'
开发者ID:motord,项目名称:banter,代码行数:29,代码来源:__init__.py


示例14: list_command

 def list_command(self, msg):
   """Handle /list commands."""
   lines = []
   q = Channel.all().order('-num_members').filter('num_members >', 0)
   channels = q.fetch(self._LIST_LIMIT + 1)
   if not len(channels):
     msg.reply(u'* 沒有任何頻道!')
     return
   if len(channels) <= self._LIST_LIMIT:
     # Show all, sorted by channel name.
     channels.sort(key=lambda c: c.name)
     lines.append('* 所有頻道清單如下:')
   else:
     # Show the top N channels, sorted by num_members.
     channels.pop()
     lines.append('* 頻道數超過 %d; 底下是最受歡迎的清單:' %
                  self._LIST_LIMIT)
   for c in channels:
     if c.num_members == 1:
       count = '1 個人'
     else:
       count = '%d 個人' % c.num_members
     s = '* - %s (%s)' % (c, count)
     lines.append(s)
   msg.reply(u'\n'.join(lines))
开发者ID:wade-fs,项目名称:mud-fs,代码行数:25,代码来源:xmpp.py


示例15: post

  def post(self, channelid):
    """Handles a POST to the /channel/{id}/subscriber/ resource
    which is to add a subscriber to the channel
    """
#   Get channel first
    channel = Channel.get_by_id(int(channelid))
    if channel is None:
      self.response.out.write("Channel %s not found" % (channelid, ))
      self.response.set_status(404)
      return

#   Add subscriber
    name = self.request.get('name').rstrip('\n')
    resource = self.request.get('resource').rstrip('\n')
    subscriber = Subscriber()
    subscriber.channel = channel
    subscriber.name = name
    subscriber.resource = resource
    subscriber.put()
#   Not sure I like this ... re-put()ing
    if len(subscriber.name) == 0:
      subscriber.name = 'subscriber-' + str(subscriber.key().id())
      subscriber.put()

#   If we've got here from a web form, redirect the user to the 
#   channel subscriber resource, otherwise return the 201
    if self.request.get('subscribersubmissionform'):
      self.redirect(self.request.path_info)
    else:
      self.response.headers['Location'] = self.request.url + str(subscriber.key().id()) + '/'
      self.response.set_status(201)
开发者ID:qmacro,项目名称:coffeeshop,代码行数:31,代码来源:coffeeshop.py


示例16: get

 def get(self):
     outlets = Outlet.all().filter("target =", self.account).fetch(100)
     if len(self.request.path.split("/")) > 2:
         source = Account.get_by_hash(self.request.path.split("/")[-1])
         channel = Channel.get_by_source_and_target(source, self.account)
         self.render("templates/source.html", locals())
     else:
         enabled_channels = Channel.get_all_by_target(self.account).order("-count").filter("status =", "enabled")
         # TODO: remove me after a while. this is to fix my poor reference management
         for c in enabled_channels:
             try:
                 c.outlet
             except:
                 c.outlet = None
                 c.put()
         self.render("templates/sources.html", locals())
开发者ID:Mondego,项目名称:pyreco,代码行数:16,代码来源:allPythonContent.py


示例17: send

def send(event, message):
    from models import Channel
    for channel in Channel.query():
        channel.send({
            'event': event,
            'data': message
        })
开发者ID:armonge,项目名称:geek_feed,代码行数:7,代码来源:utils.py


示例18: open

 def open(self, channel):
     #logging.info("opened connection")
     self.board_name = 'board:' + channel
     publisher.subscribe(self.board_name, self.on_new_board_message)
     self.channel = Channel(self.board_name)
     # when client connects send all commands written
     for cmd in iter(self.channel.get_commands()):
        self.write_message(cmd)
开发者ID:GunioRobot,项目名称:whitebrd.me,代码行数:8,代码来源:app.py


示例19: _initialize_channels_and_users

 def _initialize_channels_and_users(self):
   self.info('Loading channels and users...')
   channel_id_to_name_map, channel_name_to_id_map = \
       self.slack.channel_id_name_maps()
   with self.database_manager.transaction():
     for k, v in channel_id_to_name_map.items():
       is_direct = True if k.startswith('D0') else False
       try:
         channel = Channel.get(
             Channel.slack_id == k
         )
         channel.slack_name = v
         channel.is_direct = is_direct
         channel.save()
       except Channel.DoesNotExist:
         channel = Channel.create(
             slack_name=v,
             slack_id=k,
             is_direct=is_direct
         )
       except Exception as e:
         self.error(e)
       channel_members = self.slack.channel_members(channel.slack_name)
       for channel_member in channel_members:
         is_slackbot = True if channel_member[1] == 'USLACKBOT' else False
         try:
           user = User.get(
               User.slack_name == channel_member[1],
               User.slack_id == channel_member[0],
               User.is_slackbot == is_slackbot
           )
         except User.DoesNotExist:
           user = User.create(
               slack_name=channel_member[1],
               slack_id=channel_member[0],
               is_slackbot=is_slackbot
           )
         except Exception as e:
           self.error(e)
         try:
           ChannelUserRelationship.create(
               channel=channel,
               user=user
           )
         except:
           pass
开发者ID:gabeos,项目名称:slackotron,代码行数:46,代码来源:slackotron.py


示例20: list_channels

def list_channels():
    """List all channels"""
    channels = Channel.query()
    form = ChannelForm()
    if form.validate_on_submit():
        channel = Channel(
            id = form.id.data,
            name = form.name.data,
            token = form.token.data,
        )
        try:
            channel.put()
            flash(u'Channel %s successfully saved.' % channel.id, 'success')
            return redirect(url_for('qq.list_channels'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('qq.list_channels'))
    return render_template('list_channels.html', channels=channels, form=form)
开发者ID:motord,项目名称:banter,代码行数:18,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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