当前位置: 首页>>代码示例>>Python>>正文


Python Settings.instance方法代码示例

本文整理汇总了Python中settings.Settings.instance方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.instance方法的具体用法?Python Settings.instance怎么用?Python Settings.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在settings.Settings的用法示例。


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

示例1: getDeviceID

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def getDeviceID(self):
        # return 64 hex characters
        settings = Settings.instance().get(self.getRequestorID())
        dev_id = ""
        if not settings:
            dev_id = ""
        elif "DEV_ID" in settings.keys():
            dev_id = settings["DEV_ID"]

        if not dev_id:
            print "id is empty joining crap"
            dev_id = "".join(random.choice("0123456789abcdef") for _ in range(64))
            Settings.instance().store(self.getRequestorID(), "DEV_ID", dev_id)

        return dev_id
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:17,代码来源:snnow.py

示例2: getDeviceID

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def getDeviceID(self):
        #return 64 hex characters
        settings = Settings.instance().get(self.getRequestorID())
        dev_id = ''
        if not settings:
            dev_id = ''
        elif 'DEV_ID' in settings.keys():
            dev_id = settings['DEV_ID']

        if not dev_id:
            print "id is empty joining crap"
            dev_id = ''.join(random.choice('0123456789abcdef') for _ in range(64))
            Settings.instance().store(self.getRequestorID(), 'DEV_ID', dev_id)

        return dev_id
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:17,代码来源:snnow.py

示例3: preAuthorize

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def preAuthorize(self, streamProvider, resource_ids):
        """
        Pre-authroize.  This _should_ get a list of authorised channels.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param resource_ids a list of resources to preauthorise
        @return a dictionary with each resource id as a key and boolean value
                indicating if the resource could be authorised
        """
        settings = Settings.instance().get('adobe')

        values = { 'authentication_token' : settings['AUTHN_TOKEN'],
                   'requestor_id' : streamProvider.getRequestorID() }

        value_str = urllib.urlencode(values)
        for resource_id in resource_ids:
            value_str += '&' + urllib.urlencode({ 'resource_id' : resource_id })

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PREAUTHORIZE_URI, value_str)
        except urllib2.URLError, e:
            print e.args
            return False
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:31,代码来源:adobe.py

示例4: deviceShortAuthorize

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def deviceShortAuthorize(self, streamProvider, mso_id):
        """
        Authorise for a particular channel... a second time.
        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @return the session token required to authorise video the stream
        """
        settings = Settings.instance().get('adobe')

        values = { 'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   'session_guid' : uuid.uuid4(),
                   'hashed_guid' : 'false',
                   'authz_token' : settings['AUTHZ_TOKEN'],
                   'mso_id' : mso_id,
                   'device_id' : streamProvider.getDeviceID() }

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.DEVICE_SHORT_AUTHORIZE, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ''
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:30,代码来源:adobe.py

示例5: authorizeDevice

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def authorizeDevice(self, streamProvider, mso_id, channel):
        """
        Authorise the device for a particular channel.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @param channel the channel identifier
        """
        settings = Settings.instance().get('adobe')

        values = { 'resource_id' : channel,
                   'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   'mso_id' : mso_id,
                   'authentication_token' : settings['AUTHN_TOKEN'],
                   'device_id' : streamProvider.getDeviceID(),
                   'userMeta' : '1' }

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZE_URI, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return False
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:31,代码来源:adobe.py

示例6: getChannelResourceMap

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def getChannelResourceMap(self):
        """
        Get the mapping from ID to channel abbreviation
        """
        settings = Settings.instance().get(self.getRequestorID())
        chan_map = {}
        if settings and 'CHAN_MAP' in settings.keys():
            return settings['CHAN_MAP']

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.CONFIG_URI)
        except urllib2.URLError, e:
            print e.args
            return None
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:20,代码来源:snnow.py

示例7: authorize

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
    def authorize(self, username, password, msoName="Rogers"):
        """
        Authorize with the MSO credentials
        @param username the username
        @param password the password
        @param the MSO (eg: Rogers)
        """

        # Get the MSO class from the
        mso = MSOFactory.getMSO(msoName)

        # Authorize with the MSO
        mso.authorize(self, username, password)

        ap = adobe.AdobePass()
        ap.sessionDevice(self)

        settings = Settings.instance().get(self.getRequestorID())

        result = ap.preAuthorize(self, ["SNEast", "SNOne", "SNOntario", "SNWest", "SNPacific", "SN360", "SNWorld"])
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:22,代码来源:snnow.py

示例8: authorize

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import instance [as 别名]
        try:
            resp = opener.open(self.CHANNELS_URI)
        except urllib2.URLError, e:
            print e.args
            return None
        Cookies.saveCookieJar(jar)

        channels = json.loads(resp.read())
        channel_map = self.getChannelResourceMap()

        for channel in channels:
            chan_id =str(channel['id'])
            abbr = channel_map[chan_id]
            channel['abbr'] = abbr

        Settings.instance().store(self.getRequestorID(), 'CHANNELS', channels)

        return channels


    def authorize(self, username, password, msoName='Rogers'):
        """
        Authorize with the MSO credentials
        @param username the username
        @param password the password
        @param the MSO (eg: Rogers)
        """

        # Get the MSO class from the 
        mso = MSOFactory.getMSO(msoName)
        if mso == None:
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:33,代码来源:snnow.py


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