本文整理汇总了Python中Channel类的典型用法代码示例。如果您正苦于以下问题:Python Channel类的具体用法?Python Channel怎么用?Python Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Channel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pushMessage_to_all
def test_pushMessage_to_all(message):
c = Channel(apiKey, secretKey)
push_type = 3
optional = dict()
optional[Channel.MESSAGE_TYPE] = 1
ret = c.pushMessage(push_type, message, message_key, optional)
print ret
示例2: _manage_channels
def _manage_channels(self):
assert self.state_lock.locked()
for cid, channel in self.active_channels.items():
message = 'Location channel management removing %r from active.'
if not channel.accepting_requests():
self.debugout(message % channel, 1)
self.active_channels.pop(cid)
self.parallel_channels.decrement()
maxchannels = self.MAXPARALLELCHANNELS
numpending = len(self.pending_transactions)
numchannels = self.parallel_channels.value
if numchannels == 0:
createchannel = True
elif numchannels >= maxchannels:
createchannel = False
elif (numpending / numchannels) > self.IDEALBACKLOG:
createchannel = True
else:
createchannel = False
if createchannel:
channel = Channel(self.monitor, self.debug)
channel.setup_connection(self.host, self.port, self.protocol)
self.free_channels.append(channel)
self.parallel_channels.increment()
return
示例3: test_pushMessage_to_tag
def test_pushMessage_to_tag():
c = Channel(apiKey, secretKey)
push_type = 2
optional = dict()
optional[Channel.TAG_NAME] = tagname
optional[Channel.MESSAGE_TYPE] = 1
# print 'hi:::::', push_type, message, message_key, optional
ret = c.pushMessage(push_type, message, message_key, optional)
示例4: test_pushMessage_to_tag
def test_pushMessage_to_tag():
c = Channel(apiKey, secretKey)
push_type = 2
tag_name = 'push'
optional = dict()
optional[Channel.TAG_NAME] = tag_name
ret = c.pushMessage(push_type, message, message_key, optional)
print ret
示例5: test_pushMessage_to_user
def test_pushMessage_to_user(user_id,channel_id,phone_system,secretKey,message):
c = Channel(apiKey, secretKey)
push_type = 1
optional = dict()
optional[Channel.USER_ID] = user_id
optional[Channel.CHANNEL_ID] = channel_id
optional[Channel.MESSAGE_TYPE] = 1
ret = c.pushMessage(push_type, message, message_key, optional)
print ret
示例6: test_queryBindList
def test_queryBindList():
c = Channel(apiKey, secretKey)
#optional = dict()
#optional[Channel.CHANNEL_ID] = channel_id
c.queryBindList()
示例7: test_pushMessage_to_user
def test_pushMessage_to_user():
c = Channel(apiKey, secretKey)
push_type = 1
optional = dict()
optional[Channel.USER_ID] = user_id
optional[Channel.CHANNEL_ID] = channel_id
# 推送通知类型
optional[Channel.MESSAGE_TYPE] = 0
ret = c.pushMessage(push_type, message, message_key, optional)
print ret
示例8: push_to_user
def push_to_user(self, user, message):
channel = Channel(self.__secret.apiKey, self.__secret.secretKey)
push_type = 1
optional = dict()
optional[Channel.USER_ID] = user[0]
optional[Channel.CHANNEL_ID] = user[1]
optional[Channel.MESSAGE_TYPE] = 0
alertMessage = "{'title':'%s', 'description':'%s', 'custom_content': { 'amber_alert_id':'%s', 'from_user_id':'%s' }}" % (message[0], message[1], message[2], message[3])
#jsonMessage = json.dumps(updateMessage)
ret = channel.pushMessage(push_type, alertMessage, message_key, optional)
print (ret)
return ret
示例9: test_pushMessage_to_user
def test_pushMessage_to_user():
c = Channel(apiKey, secretKey)
c.DEFAULT_HOST=dev_host
push_type = 1
optional = dict()
optional[Channel.USER_ID] = 815730795201756090
#optional[Channel.USER_ID] = 665778416804465913
#optional[Channel.CHANNEL_ID] = 4617656892525519033
optional[Channel.CHANNEL_ID] = 4320553738754859600
#推送通知类型
optional[Channel.DEVICE_TYPE] = 4
optional[Channel.MESSAGE_TYPE] = 1
optional['phone_type'] = 'io'
ret = c.pushMessage(push_type, message, hashlib.md5(str(datetime.datetime.now())).hexdigest(), optional)
print ret
示例10: __init__
def __init__(self, serverFacade, comodo):
screen_width = 640
screen_height = 480
screen_flag = 0
screen_depht = 32
self.colors = {}
self.sprites = {}
self.channels = {}
pygame.init()
self.screen = pygame.display.set_mode((screen_width, screen_height), screen_flag, screen_depht)
self.clock = pygame.time.Clock()
self.serverFacade = serverFacade
self.comodo = comodo
self.__loadColors()
self.__loadSprites()
self.__loadChannels()
self.channel = Channel()
#self.channel = self.channels.get(str(self.comodo.getTv().getChannel()))
#self.resolution = self.channel.get_size()
print (320-320*.27, 180-180*.27)
示例11: loadFromCachedMode
def loadFromCachedMode(self):
import Channel
import Playlist
if not self._cachedMode:
raise ValueError('Cannot load from cached mode. Pages are not in cached mode')
#sourcesToUpdate = []
for page in self._pages:
if page.items:
raise ValueError('In cached mode, yet page has original videosource items')
items = []
for cachedItem in page.cacheableItems:
if cachedItem[0] == SourceType.CHANNEL:
channelId = cachedItem[1]
ytVideoSource, needsInfoUpdate = Channel.fromUserOrId(channelId=channelId)
else:
playlistId = cachedItem[1]
ytVideoSource, needsInfoUpdate = Playlist.fromPlaylistId(playlistId)
items.append(ytVideoSource)
if needsInfoUpdate: #ignored here
pass
page.items = items
self._cachedMode = False
示例12: test_pushMessage_to_user
def test_pushMessage_to_user():
c = Channel(apiKey, secretKey)
c.DEFAULT_HOST=dev_host
push_type = 1
optional = dict()
#optional[Channel.USER_ID] = 900581881515728799
optional[Channel.USER_ID] = 654406316281477917
#optional[Channel.USER_ID] = 665778416804465913
#optional[Channel.CHANNEL_ID] = 4617656892525519033
optional[Channel.CHANNEL_ID] = 3800664848253686124
#optional[Channel.CHANNEL_ID] = 3800664848253686124
#推送通知类型
optional[Channel.DEVICE_TYPE] = 4
optional[Channel.MESSAGE_TYPE] = 1
optional['phone_type'] = 'ios'
ret = c.pushMessage(push_type, message, hashlib.md5(str(datetime.datetime.now())).hexdigest(), optional)
print ret
示例13: _responseProcess
def _responseProcess(self, response):
channels = []
for item in response['items']:
channel = Channel.fromChannelsRequest(item)
channels.append(channel)
return channels
示例14: __init__
def __init__(self):
p = uuid.uuid4().int & 0xffffff
av = uuid.uuid4().int & 0xffffff
tak = uuid.uuid4().int & 0xffffff
shm = uuid.uuid4().int & 0xffffff
self.channel = chnl.getChannel(p,av,tak,shm)
self.name = uuid.uuid1()
return
示例15: _responseProcess
def _responseProcess(response):
channels = []
items = response['items']
for item in items:
channel = Channel.fromSubscriptionsRequest(item)
channels.append(channel)
return channels