Exemple #1
0
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
Exemple #2
0
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}
Exemple #3
0
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)
Exemple #4
0
 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)
Exemple #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)
Exemple #6
0
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)
Exemple #7
0
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
        )
 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
Exemple #9
0
 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
Exemple #10
0
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}
Exemple #11
0
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}
Exemple #12
0
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}
Exemple #13
0
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
Exemple #14
0
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)
Exemple #15
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)
Exemple #16
0
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
Exemple #17
0
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
Exemple #18
0
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)
Exemple #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)
Exemple #20
0
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)))
Exemple #21
0
 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
Exemple #22
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}
Exemple #23
0
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)))
Exemple #24
0
 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
Exemple #25
0
 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
Exemple #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
    }
Exemple #27
0
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)
Exemple #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)
Exemple #29
0
 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
Exemple #30
0
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)
Exemple #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 + ','
Exemple #32
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 + ','
Exemple #33
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)
Exemple #34
0
def _userAuthedWithGithub():
    return settings.getProperty("github", "authtoken")
Exemple #35
0
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")
Exemple #36
0
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')
Exemple #37
0
def deauthorize():
    if settings.getProperty('github', 'authtoken'):
        settings.setProperty('github', 'authtoken', '')
    if settings.getProperty('mbed', 'authtoken'):
        settings.setProperty('mbed', 'authtoken', '')
Exemple #38
0
def _userAuthedWithGithub():
    return settings.getProperty('github', 'authtoken')
Exemple #39
0
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')
Exemple #40
0
def _userAuthorized():
    return settings.getProperty('github', 'authtoken')
Exemple #41
0
def _userAuthedWithGithub():
    return settings.getProperty('github', 'authtoken')
Exemple #42
0
def defaultTarget(ignore_set_target=False):
    set_target = settings.getProperty('build', 'target')
    if set_target:
        return set_target
    else:
        return systemDefaultTarget()
Exemple #43
0
def deauthorize():
    if settings.getProperty('keys', 'private'):
        settings.setProperty('keys', 'private', '')
    if settings.getProperty('keys', 'public'):
        settings.setProperty('keys', 'public', '')
Exemple #44
0
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}
Exemple #45
0
def deauthorize():
    if settings.getProperty('github', 'authtoken'):
        settings.setProperty('github', 'authtoken', '')
Exemple #46
0
def _getPrivateKeyObject():
    privatekey_hex = settings.getProperty('keys', 'private')
    if not privatekey_hex:
        pubkey_hex, privatekey_hex = _generateAndSaveKeys()
    return RSA.importKey(binascii.unhexlify(privatekey_hex))
Exemple #47
0
def _userAuthorized():
    return settings.getProperty('github', 'authtoken')
Exemple #48
0
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}
Exemple #49
0
def deauthorize():
    if settings.getProperty('keys', 'private'):
        settings.setProperty('keys', 'private', '')
    if settings.getProperty('keys', 'public'):
        settings.setProperty('keys', 'public', '')
Exemple #50
0
def _getPrivateKeyObject():
    privatekey_hex =  settings.getProperty('keys', 'private')
    if not privatekey_hex:
        pubkey_hex, privatekey_hex = _generateAndSaveKeys()
    return RSA.importKey(binascii.unhexlify(privatekey_hex))
Exemple #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