forked from plivo/voicechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (20 loc) · 652 Bytes
/
utils.py
File metadata and controls
24 lines (20 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import time
import base64
import redis
import config
import plivo
def baseN(num,b,numerals="0123456789abcdefghijklmnopqrstuvwxyz"):
return ((num == 0) and "0" ) or (baseN(num // b, b).lstrip("0") + numerals[num % b])
def tinyid(size=6):
id = '%s%s' % (
baseN(abs(hash(time.time())), 36),
baseN(abs(hash(time.time())), 36))
return id[0:size]
def get_redis_connection():
redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')
rd = redis.from_url(redis_url)
return rd
def get_plivo_connection():
pl = plivo.RestAPI(config.PLIVO_AUTH_ID, config.PLIVO_AUTH_TOKEN)
return pl