コード例 #1
0
ファイル: microsoft_api.py プロジェクト: arch1904/MediBot
def get_tts(accessToken, filename, text):
    ssmlPayload = "<speak version='1.0' xml:lang='en-us'><voice xml:lang='en-US' xml:gender='Male' name='Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS)'>" + text + "</voice></speak>"

    url = 'https://speech.platform.bing.com/synthesize'
    body = ssmlPayload
    headers = {
        'Authorization': 'Bearer ' + accessToken,
        'content-type': 'application/ssml+xml',
        #   // 'X-Microsoft-OutputFormat' : 'riff-8khz-8bit-mono-mulaw', uses mulaw encoding format
        'X-Microsoft-OutputFormat': 'raw-16khz-16bit-mono-pcm',
        'X-Search-AppId': settings.getProperty('X-Search-AppId'),
        'X-Search-ClientID': settings.getProperty('X-Search-ClientID'),
        'User-Agent': 'Chat Robot',
        'cache-control': "no-cache",
        'postman-token': "955d09e1-9815-5753-38ee-97f97bf92733"
    }

    #response = requests.request("POST", url, data=payload,headers=headers)
    request = Request(url, data=body, headers=headers)
    response = urlopen(request)
    wav_data = response.read()

    #wav_data = response.text
    with io.BytesIO() as myfile:
        wav_writer = wave.open(filename, "wb")
        try:
            wav_writer.setframerate(16000)
            wav_writer.setsampwidth(2)
            wav_writer.setnchannels(1)
            wav_writer.writeframes(wav_data)
            #wav_data = filename.getvalue()
        finally:
            wav_writer.close()
    #print wav_data
    return
コード例 #2
0
ファイル: github_access.py プロジェクト: parisk/yotta
def _getTags(repo):
    ''' return a dictionary of {tag: tarball_url}'''
    g = Github(settings.getProperty('github', 'authtoken'))
    logger.info('get versions for ' + repo)
    repo = g.get_repo(repo)
    tags = repo.get_tags()
    return {t.name: t.tarball_url for t in tags}
コード例 #3
0
ファイル: registry_access.py プロジェクト: xingdl2007/yotta
def getPublicKey(registry=None):
    ''' Return the user's public key (generating and saving a new key pair if necessary) '''
    registry = registry or Registry_Base_URL
    pubkey_pem = None
    if _isPublicRegistry(registry):
        pubkey_pem = settings.getProperty('keys', 'public')
    else:
        for s in _getSources():
            if _sourceMatches(s, registry):
                if 'keys' in s and s['keys'] and 'public' in s['keys']:
                    pubkey_pem = s['keys']['public']
                    break
    if not pubkey_pem:
        pubkey_pem, privatekey_pem = _generateAndSaveKeys()
    else:
        # settings are unicode, we should be able to safely decode to ascii for
        # the key though, as it will either be hex or PEM encoded:
        pubkey_pem = pubkey_pem.encode('ascii')
    # if the key doesn't look like PEM, it might be hex-encided-DER (which we
    # used historically), so try loading that:
    if b'-----BEGIN PUBLIC KEY-----' in pubkey_pem:
        pubkey = serialization.load_pem_public_key(pubkey_pem, default_backend())
    else:
        pubkey_der = binascii.unhexlify(pubkey_pem)
        pubkey = serialization.load_der_public_key(pubkey_der, default_backend())
    return _pubkeyWireFormat(pubkey)
コード例 #4
0
ファイル: registry_access.py プロジェクト: parisk/yotta
 def wrapped(*args, **kwargs):
     try:
         return fn(*args, **kwargs)
     except restkit_errors.Unauthorized as e:
         github_access.authorizeUser()
         logger.debug('trying with authtoken:', settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
コード例 #5
0
def _getTarball(url, into_directory, cache_key):
    '''unpack the specified tarball url into the specified directory'''

    try:
        access_common.unpackFromCache(cache_key, into_directory)
    except KeyError as e:
        tok = settings.getProperty('github', 'authtoken')
        headers = {}
        if tok is not None:
            headers['Authorization'] = 'token ' + str(tok)

        logger.debug('GET %s', url)
        response = requests.get(url,
                                allow_redirects=True,
                                stream=True,
                                headers=headers)
        response.raise_for_status()

        logger.debug('getting file: %s', url)
        logger.debug('headers: %s', response.headers)
        response.raise_for_status()

        # github doesn't exposes hashes of the archives being downloaded as far
        # as I can tell :(
        access_common.unpackTarballStream(stream=response,
                                          into_directory=into_directory,
                                          hash={},
                                          cache_key=cache_key)
コード例 #6
0
ファイル: registry_access.py プロジェクト: ntoll/yotta
def getPublicKey(registry=None):
    ''' Return the user's public key (generating and saving a new key pair if necessary) '''
    registry = registry or Registry_Base_URL
    pubkey_pem = None
    if _isPublicRegistry(registry):
        pubkey_pem = settings.getProperty('keys', 'public')
    else:
        for s in _getSources():
            if _sourceMatches(s, registry):
                if 'keys' in s and s['keys'] and 'public' in s['keys']:
                    pubkey_pem = s['keys']['public']
                    break
    if not pubkey_pem:
        pubkey_pem, privatekey_pem = _generateAndSaveKeys()
    else:
        # settings are unicode, we should be able to safely decode to ascii for
        # the key though, as it will either be hex or PEM encoded:
        pubkey_pem = pubkey_pem.encode('ascii')
    # if the key doesn't look like PEM, it might be hex-encided-DER (which we
    # used historically), so try loading that:
    if b'-----BEGIN PUBLIC KEY-----' in pubkey_pem:
        pubkey = serialization.load_pem_public_key(pubkey_pem,
                                                   default_backend())
    else:
        pubkey_der = binascii.unhexlify(pubkey_pem)
        pubkey = serialization.load_der_public_key(pubkey_der,
                                                   default_backend())
    return _pubkeyWireFormat(pubkey)
コード例 #7
0
ファイル: github_access.py プロジェクト: xcdl/yotta
def _getTarball(url, into_directory, cache_key, origin_info=None):
    '''unpack the specified tarball url into the specified directory'''

    try:
        access_common.unpackFromCache(cache_key, into_directory)
    except KeyError as e:
        tok = settings.getProperty('github', 'authtoken')
        headers = {}
        if tok is not None:
            headers['Authorization'] = 'token ' + str(tok)

        logger.debug('GET %s', url)
        response = requests.get(url, allow_redirects=True, stream=True, headers=headers)
        response.raise_for_status()

        logger.debug('getting file: %s', url)
        logger.debug('headers: %s', response.headers)
        response.raise_for_status()

        # github doesn't exposes hashes of the archives being downloaded as far
        # as I can tell :(
        access_common.unpackTarballStream(
                    stream = response,
            into_directory = into_directory,
                      hash = {},
                 cache_key = cache_key,
               origin_info = origin_info
        )
コード例 #8
0
ファイル: github_access.py プロジェクト: MarceloSalazar/yotta
 def wrapped(*args, **kwargs):
     try:
         return fn(*args, **kwargs)
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == 401:
             authorizeUser()
             return fn(*args, **kwargs)
         else:
             raise
     except github.BadCredentialsException:
         logger.debug("github: bad credentials")
         authorizeUser()
         logger.debug('trying with authtoken:', settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
     except github.UnknownObjectException:
         logger.debug("github: unknown object")
         # some endpoints return 404 if the user doesn't have access, maybe
         # it would be better to prompt for another username and password,
         # and store multiple tokens that we can try for each request....
         # but for now we assume that if the user is logged in then a 404
         # really is a 404
         if not _userAuthorized():
             logger.info('failed to fetch Github object, re-trying with authentication...')
             authorizeUser()
             return fn(*args, **kwargs)
         else:
             raise
コード例 #9
0
ファイル: github_access.py プロジェクト: ntoll/yotta
 def wrapped(*args, **kwargs):
     try:
         return fn(*args, **kwargs)
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == 401:
             authorizeUser()
             return fn(*args, **kwargs)
         else:
             raise
     except github.BadCredentialsException:
         logger.debug("github: bad credentials")
         authorizeUser()
         logger.debug('trying with authtoken:',
                      settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
     except github.UnknownObjectException:
         logger.debug("github: unknown object")
         # some endpoints return 404 if the user doesn't have access, maybe
         # it would be better to prompt for another username and password,
         # and store multiple tokens that we can try for each request....
         # but for now we assume that if the user is logged in then a 404
         # really is a 404
         if not _userAuthorized():
             logger.info(
                 'failed to fetch Github object, re-trying with authentication...'
             )
             authorizeUser()
             return fn(*args, **kwargs)
         else:
             raise
コード例 #10
0
ファイル: github_access.py プロジェクト: ntoll/yotta
def _getTags(repo):
    ''' return a dictionary of {tag: tarball_url}'''
    logger.debug('get tags for %s', repo)
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    tags = repo.get_tags()
    logger.debug('tags for %s: %s', repo, [t.name for t in tags])
    return {t.name: t.tarball_url for t in tags}
コード例 #11
0
ファイル: github_access.py プロジェクト: kylemanna/yotta
def _getTags(repo):
    """ return a dictionary of {tag: tarball_url}"""
    logger.debug("get tags for %s", repo)
    g = Github(settings.getProperty("github", "authtoken"))
    repo = g.get_repo(repo)
    tags = repo.get_tags()
    logger.debug("tags for %s: %s", repo, [t.name for t in tags])
    return {t.name: t.tarball_url for t in tags}
コード例 #12
0
ファイル: github_access.py プロジェクト: xcdl/yotta
def _getTags(repo):
    ''' return a dictionary of {tag: tarball_url}'''
    logger.debug('get tags for %s', repo)
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    tags = repo.get_tags()
    logger.debug('tags for %s: %s', repo, [t.name for t in tags])
    return {t.name: _ensureDomainPrefixed(t.tarball_url) for t in tags}
コード例 #13
0
ファイル: registry_access.py プロジェクト: ntoll/yotta
def _getPrivateKey(registry):
    if _isPublicRegistry(registry):
        return settings.getProperty('keys', 'private')
    else:
        for s in _getSources():
            if _sourceMatches(s, registry):
                if 'keys' in s and s['keys'] and 'private' in s['keys']:
                    return s['keys']['private']
        return None
コード例 #14
0
ファイル: github_access.py プロジェクト: parisk/yotta
def _getTarball(url, into_directory):
    '''unpack the specified tarball url into the specified directory'''
    resource = Resource(url, pool=connection_pool.getPool(), follow_redirect=True)
    response = resource.get(
        headers = {'Authorization': 'token ' + settings.getProperty('github', 'authtoken')}, 
    )
    logger.debug('getting file: %s', url)
    # TODO: there's an MD5 in the response headers, verify it
    access_common.unpackTarballStream(response.body_stream(), into_directory)
コード例 #15
0
ファイル: github_access.py プロジェクト: xcdl/yotta
 def retryWithAuthOrRaise(original_exception):
     # in all cases ask for auth, so that in non-interactive mode a
     # login URL is displayed
     auth.authorizeUser(provider='github', interactive=interactive)
     if not interactive:
         raise original_exception
     else:
         logger.debug('trying with authtoken: %s', settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
コード例 #16
0
ファイル: registry_access.py プロジェクト: xingdl2007/yotta
def _getPrivateKey(registry):
    if _isPublicRegistry(registry):
        return settings.getProperty('keys', 'private')
    else:
        for s in _getSources():
            if _sourceMatches(s, registry):
                if 'keys' in s and s['keys'] and 'private' in s['keys']:
                    return s['keys']['private']
        return None
コード例 #17
0
ファイル: registry_access.py プロジェクト: stevenewey/yotta
def _getPrivateKey(registry):
    if _isPublicRegistry(registry):
        return settings.getProperty("keys", "private")
    else:
        for s in _getSources():
            if _sourceMatches(s, registry):
                if "keys" in s and s["keys"] and "private" in s["keys"]:
                    return s["keys"]["private"]
        return None
コード例 #18
0
ファイル: github_access.py プロジェクト: iriark01/yotta
def _getTarball(url, into_directory):
    '''unpack the specified tarball url into the specified directory'''
    headers = {'Authorization': 'token ' + str(settings.getProperty('github', 'authtoken'))}

    response = requests.get(url, allow_redirects=True, stream=True, headers=headers)

    logger.debug('getting file: %s', url)
    # TODO: there's an MD5 in the response headers, verify it

    access_common.unpackTarballStream(response, into_directory)
コード例 #19
0
 def retryWithAuthOrRaise(original_exception):
     # in all cases ask for auth, so that in non-interactive mode a
     # login URL is displayed
     auth.authorizeUser(provider='github', interactive=interactive)
     if not interactive:
         raise original_exception
     else:
         logger.debug('trying with authtoken: %s',
                      settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
コード例 #20
0
ファイル: registry_access.py プロジェクト: parisk/yotta
def getPublicKey():
    ''' Return the user's public key (generating and saving a new key pair if necessary) '''
    pubkey_hex = settings.getProperty('keys', 'public')
    if not pubkey_hex:
        k = RSA.generate(2048)
        settings.setProperty('keys', 'private', binascii.hexlify(k.exportKey('DER')))
        pubkey_hex = binascii.hexlify(k.publickey().exportKey('DER'))
        settings.setProperty('keys', 'public', pubkey_hex)
        pubkey_hex, privatekey_hex = _generateAndSaveKeys()
    return _pubkeyWireFormat(RSA.importKey(binascii.unhexlify(pubkey_hex)))
コード例 #21
0
ファイル: registry_access.py プロジェクト: iriark01/yotta
 def wrapped(*args, **kwargs):
     try:
         return fn(*args, **kwargs)
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == requests.codes.unauthorized:
             logger.debug('%s unauthorised', fn)
             github_access.authorizeUser()
             logger.debug('trying with authtoken: %s', settings.getProperty('github', 'authtoken'))
             return fn(*args, **kwargs)
         else:
             raise
コード例 #22
0
ファイル: github_access.py プロジェクト: theotherjimmy/yotta
def _getBranchHeads(repo):
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    branches = repo.get_branches()

    # branch tarball URLs aren't supported by the API, so have to munge the
    # master tarball URL. Fetch the master tarball URL once (since that
    # involves a network request), then mumge it for each branch we want:
    master_tarball_url = repo.get_archive_link('tarball')

    return {b.name:_tarballUrlForBranch(master_tarball_url, b.name) for b in branches}
コード例 #23
0
ファイル: registry_access.py プロジェクト: bridadan/yotta
def getPublicKey():
    ''' Return the user's public key (generating and saving a new key pair if necessary) '''
    pubkey_hex = settings.getProperty('keys', 'public')
    if not pubkey_hex:
        k = RSA.generate(2048)
        settings.setProperty('keys', 'private',
                             binascii.hexlify(k.exportKey('DER')))
        pubkey_hex = binascii.hexlify(k.publickey().exportKey('DER'))
        settings.setProperty('keys', 'public', pubkey_hex)
        pubkey_hex, privatekey_hex = _generateAndSaveKeys()
    return _pubkeyWireFormat(RSA.importKey(binascii.unhexlify(pubkey_hex)))
コード例 #24
0
ファイル: registry_access.py プロジェクト: bridadan/yotta
 def wrapped(*args, **kwargs):
     try:
         return fn(*args, **kwargs)
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == requests.codes.unauthorized:
             github_access.authorizeUser()
             logger.debug('trying with authtoken:',
                          settings.getProperty('github', 'authtoken'))
             return fn(*args, **kwargs)
         else:
             raise
コード例 #25
0
ファイル: github_access.py プロジェクト: aewp2/yotta
 def wrapped(*args, **kwargs):
     # if yotta is being run noninteractively, then we never retry, but we
     # do call auth.authorizeUser, so that a login URL can be displayed:
     interactive = globalconf.get('interactive')
     if not interactive:
         try:
             return fn(*args, **kwargs)
         except requests.exceptions.HTTPError as e:
             if e.response.status_code == 401:
                 auth.authorizeUser(provider='github', interactive=False)
             raise
         except github.BadCredentialsException:
             logger.debug("github: bad credentials")
             auth.authorizeUser(provider='github', interactive=False)
             raise
         except github.UnknownObjectException:
             logger.debug("github: unknown object")
             # some endpoints return 404 if the user doesn't have access:
             if not _userAuthedWithGithub():
                 logger.info(
                     'failed to fetch Github object, try re-authing...')
                 auth.authorizeUser(provider='github', interactive=False)
             raise
     else:
         try:
             return fn(*args, **kwargs)
         except requests.exceptions.HTTPError as e:
             if e.response.status_code == 401:
                 auth.authorizeUser(provider='github')
                 return fn(*args, **kwargs)
             raise
         except github.BadCredentialsException:
             logger.debug("github: bad credentials")
             auth.authorizeUser(provider='github')
             logger.debug('trying with authtoken:',
                          settings.getProperty('github', 'authtoken'))
             return fn(*args, **kwargs)
         except github.UnknownObjectException:
             logger.debug("github: unknown object")
             # some endpoints return 404 if the user doesn't have access, maybe
             # it would be better to prompt for another username and password,
             # and store multiple tokens that we can try for each request....
             # but for now we assume that if the user is logged in then a 404
             # really is a 404
             if not _userAuthedWithGithub():
                 logger.info(
                     'failed to fetch Github object, re-trying with authentication...'
                 )
                 auth.authorizeUser(provider='github')
                 return fn(*args, **kwargs)
             raise
コード例 #26
0
def _getBranchHeads(repo):
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    branches = repo.get_branches()

    # branch tarball URLs aren't supported by the API, so have to munge the
    # master tarball URL. Fetch the master tarball URL once (since that
    # involves a network request), then mumge it for each branch we want:
    master_tarball_url = repo.get_archive_link('tarball')

    return {
        b.name: _tarballUrlForBranch(master_tarball_url, b.name)
        for b in branches
    }
コード例 #27
0
ファイル: github_access.py プロジェクト: MarceloSalazar/yotta
def _getTarball(url, into_directory):
    '''unpack the specified tarball url into the specified directory'''
    tok = settings.getProperty('github', 'authtoken')
    headers = {}
    if tok is not None:
        headers['Authorization'] = 'token ' + str(tok)

    logger.debug('GET %s', url)
    response = requests.get(url, allow_redirects=True, stream=True, headers=headers)
    response.raise_for_status()

    logger.debug('getting file: %s', url)
    # TODO: there's an MD5 in the response headers, verify it

    access_common.unpackTarballStream(response, into_directory)
コード例 #28
0
def _getTarball(url, into_directory):
    '''unpack the specified tarball url into the specified directory'''
    headers = {
        'Authorization':
        'token ' + settings.getProperty('github', 'authtoken')
    }

    response = requests.get(url,
                            allow_redirects=True,
                            stream=True,
                            headers=headers)

    logger.debug('getting file: %s', url)
    # TODO: there's an MD5 in the response headers, verify it

    access_common.unpackTarballStream(response, into_directory)
コード例 #29
0
ファイル: github_access.py プロジェクト: stevenewey/yotta
 def wrapped(*args, **kwargs):
     # if yotta is being run noninteractively, then we never retry, but we
     # do call auth.authorizeUser, so that a login URL can be displayed:
     interactive = globalconf.get('interactive')
     if not interactive:
         try:
             return fn(*args, **kwargs)
         except requests.exceptions.HTTPError as e:
             if e.response.status_code == 401:
                 auth.authorizeUser(provider='github', interactive=False)
             raise
         except github.BadCredentialsException:
             logger.debug("github: bad credentials")
             auth.authorizeUser(provider='github', interactive=False)
             raise
         except github.UnknownObjectException:
             logger.debug("github: unknown object")
             # some endpoints return 404 if the user doesn't have access:
             if not _userAuthedWithGithub():
                 logger.info('failed to fetch Github object, try re-authing...')
                 auth.authorizeUser(provider='github', interactive=False)
             raise
     else:
         try:
             return fn(*args, **kwargs)
         except requests.exceptions.HTTPError as e:
             if e.response.status_code == 401:
                 auth.authorizeUser(provider='github')
                 return fn(*args, **kwargs)
             raise
         except github.BadCredentialsException:
             logger.debug("github: bad credentials")
             auth.authorizeUser(provider='github')
             logger.debug('trying with authtoken:', settings.getProperty('github', 'authtoken'))
             return fn(*args, **kwargs)
         except github.UnknownObjectException:
             logger.debug("github: unknown object")
             # some endpoints return 404 if the user doesn't have access, maybe
             # it would be better to prompt for another username and password,
             # and store multiple tokens that we can try for each request....
             # but for now we assume that if the user is logged in then a 404
             # really is a 404
             if not _userAuthedWithGithub():
                 logger.info('failed to fetch Github object, re-trying with authentication...')
                 auth.authorizeUser(provider='github')
                 return fn(*args, **kwargs)
             raise
コード例 #30
0
ファイル: github_access.py プロジェクト: ntoll/yotta
def _getTarball(url, into_directory):
    '''unpack the specified tarball url into the specified directory'''
    tok = settings.getProperty('github', 'authtoken')
    headers = {}
    if tok is not None:
        headers['Authorization'] = 'token ' + str(tok)

    logger.debug('GET %s', url)
    response = requests.get(url,
                            allow_redirects=True,
                            stream=True,
                            headers=headers)
    response.raise_for_status()

    logger.debug('getting file: %s', url)
    # TODO: there's an MD5 in the response headers, verify it

    access_common.unpackTarballStream(response, into_directory)
コード例 #31
0
def defaultTarget():
    set_target = settings.getProperty('build', 'target')
    if set_target:
        return set_target

    machine = platform.machine()

    x86 = machine.find('86') != -1
    arm = machine.find('arm') != -1 or machine.find('aarch') != -1

    prefix = "x86-" if x86 else "arm-" if arm else ""
    platf = 'unknown'

    if sys.platform.startswith('linux'):
        platf = 'linux-native'
    elif sys.platform == 'darwin':
        platf = 'osx-native'
    elif sys.platform.find('win') != -1:
        platf = 'win'
    return prefix + platf + ','
コード例 #32
0
ファイル: detect.py プロジェクト: danros/yotta
def defaultTarget():
    set_target = settings.getProperty('build', 'target')
    if set_target:
        return set_target

    machine = platform.machine()

    x86 = machine.find('86') != -1
    arm = machine.find('arm') != -1 or machine.find('aarch') != -1

    prefix = "x86-" if x86 else "arm-" if arm else ""
    platf = 'unknown'

    if sys.platform.startswith('linux'):
        platf = 'linux-native'
    elif sys.platform == 'darwin':
        platf = 'osx-native'
    elif sys.platform.find('win') != -1:
        platf = 'win'
    return prefix + platf + ','
コード例 #33
0
ファイル: github_access.py プロジェクト: kylemanna/yotta
def _getTarball(url, into_directory, cache_key):
    """unpack the specified tarball url into the specified directory"""

    try:
        access_common.unpackFromCache(cache_key, into_directory)
    except KeyError as e:
        tok = settings.getProperty("github", "authtoken")
        headers = {}
        if tok is not None:
            headers["Authorization"] = "token " + str(tok)

        logger.debug("GET %s", url)
        response = requests.get(url, allow_redirects=True, stream=True, headers=headers)
        response.raise_for_status()

        logger.debug("getting file: %s", url)
        logger.debug("headers: %s", response.headers)
        response.raise_for_status()

        # github doesn't exposes hashes of the archives being downloaded as far
        # as I can tell :(
        access_common.unpackTarballStream(stream=response, into_directory=into_directory, hash={}, cache_key=cache_key)
コード例 #34
0
ファイル: github_access.py プロジェクト: kylemanna/yotta
def _userAuthedWithGithub():
    return settings.getProperty("github", "authtoken")
コード例 #35
0
ファイル: github_access.py プロジェクト: kylemanna/yotta
def _getTipArchiveURL(repo):
    """ return a string containing a tarball url """
    g = Github(settings.getProperty("github", "authtoken"))
    repo = g.get_repo(repo)
    return repo.get_archive_link("tarball")
コード例 #36
0
ファイル: github_access.py プロジェクト: ntoll/yotta
def _getTipArchiveURL(repo):
    ''' return a string containing a tarball url '''
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    return repo.get_archive_link('tarball')
コード例 #37
0
ファイル: auth.py プロジェクト: jason790/yotta
def deauthorize():
    if settings.getProperty('github', 'authtoken'):
        settings.setProperty('github', 'authtoken', '')
    if settings.getProperty('mbed', 'authtoken'):
        settings.setProperty('mbed', 'authtoken', '')
コード例 #38
0
ファイル: github_access.py プロジェクト: xcdl/yotta
def _userAuthedWithGithub():
    return settings.getProperty('github', 'authtoken')
コード例 #39
0
ファイル: github_access.py プロジェクト: xcdl/yotta
def _getTipArchiveURL(repo):
    ''' return a string containing a tarball url '''
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    return repo.get_archive_link('tarball')
コード例 #40
0
ファイル: github_access.py プロジェクト: ntoll/yotta
def _userAuthorized():
    return settings.getProperty('github', 'authtoken')
コード例 #41
0
ファイル: github_access.py プロジェクト: aewp2/yotta
def _userAuthedWithGithub():
    return settings.getProperty('github', 'authtoken')
コード例 #42
0
def defaultTarget(ignore_set_target=False):
    set_target = settings.getProperty('build', 'target')
    if set_target:
        return set_target
    else:
        return systemDefaultTarget()
コード例 #43
0
ファイル: registry_access.py プロジェクト: bridadan/yotta
def deauthorize():
    if settings.getProperty('keys', 'private'):
        settings.setProperty('keys', 'private', '')
    if settings.getProperty('keys', 'public'):
        settings.setProperty('keys', 'public', '')
コード例 #44
0
ファイル: github_access.py プロジェクト: xcdl/yotta
def _getBranchHeads(repo):
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    branches = repo.get_branches()

    return {b.name:_tarballUrlForBranch(repo, b.name) for b in branches}
コード例 #45
0
ファイル: github_access.py プロジェクト: theotherjimmy/yotta
def deauthorize():
    if settings.getProperty('github', 'authtoken'):
        settings.setProperty('github', 'authtoken', '')
コード例 #46
0
ファイル: registry_access.py プロジェクト: bridadan/yotta
def _getPrivateKeyObject():
    privatekey_hex = settings.getProperty('keys', 'private')
    if not privatekey_hex:
        pubkey_hex, privatekey_hex = _generateAndSaveKeys()
    return RSA.importKey(binascii.unhexlify(privatekey_hex))
コード例 #47
0
ファイル: github_access.py プロジェクト: theotherjimmy/yotta
def _userAuthorized():
    return settings.getProperty('github', 'authtoken')
コード例 #48
0
ファイル: github_access.py プロジェクト: ntoll/yotta
def _getBranchHeads(repo):
    g = Github(settings.getProperty('github', 'authtoken'))
    repo = g.get_repo(repo)
    branches = repo.get_branches()

    return {b.name: _tarballUrlForBranch(repo, b.name) for b in branches}
コード例 #49
0
ファイル: registry_access.py プロジェクト: parisk/yotta
def deauthorize():
    if settings.getProperty('keys', 'private'):
        settings.setProperty('keys', 'private', '')
    if settings.getProperty('keys', 'public'):
        settings.setProperty('keys', 'public', '')
コード例 #50
0
ファイル: registry_access.py プロジェクト: parisk/yotta
def _getPrivateKeyObject():
    privatekey_hex =  settings.getProperty('keys', 'private')
    if not privatekey_hex:
        pubkey_hex, privatekey_hex = _generateAndSaveKeys()
    return RSA.importKey(binascii.unhexlify(privatekey_hex))
コード例 #51
0
import settings
import sys
import time
import wave
import enchant
from termcolor import colored, cprint

url = "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"

payload = ""
headers = {
    'content-type':
    "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    'content-length': "0",
    'ocp-apim-subscription-key':
    settings.getProperty('ocp-apim-subscription-key'),
    'cache-control': "no-cache",
    'postman-token': "955d09e1-9815-5753-38ee-97f97bf92733"
}

response = requests.request("POST", url, data=payload, headers=headers)

ACCESS_TOKEN = response.text

LANG_CODE = 'en-US'  # Language to use

d = enchant.Dict("en_US")

# Microphone stream config.
CHUNK = 1024  # CHUNKS of bytes to read each time from mic
FORMAT = pyaudio.paInt16