def test_pickleshare(tmpdir):
    db = PickleShareDB(tmpdir)
    db.clear()
    print("Should be empty:",db.items())
    assert len(db) == 0
    db['hello'] = 15
    assert db['hello'] == 15
    db['aku ankka'] = [1,2,313]
    assert db['aku ankka'] == [1,2,313]
    db['paths/nest/ok/keyname'] = [1,(5,46)]
    assert db['paths/nest/ok/keyname'] == [1,(5,46)]

    db.hset('hash', 'aku', 12)
    db.hset('hash', 'ankka', 313)
    assert db.hget('hash', 'aku') == 12
    assert db.hget('hash', 'ankka') == 313

    print("all hashed",db.hdict('hash'))
    print(db.keys())
    print(db.keys('paths/nest/ok/k*'))
    print(dict(db)) # snapsot of whole db
    db.uncache() # frees memory, causes re-reads later

    # shorthand for accessing deeply nested files
    lnk = db.getlink('myobjects/test')
    lnk.foo = 2
    lnk.bar = lnk.foo + 5
    assert lnk.bar == 7
Exemple #2
0
def test_pickleshare(tmpdir):
    db = PickleShareDB(tmpdir)
    db.clear()
    print("Should be empty:", db.items())
    assert len(db) == 0
    db['hello'] = 15
    assert db['hello'] == 15
    db['aku ankka'] = [1, 2, 313]
    assert db['aku ankka'] == [1, 2, 313]
    db['paths/nest/ok/keyname'] = [1, (5, 46)]
    assert db['paths/nest/ok/keyname'] == [1, (5, 46)]

    db.hset('hash', 'aku', 12)
    db.hset('hash', 'ankka', 313)
    assert db.hget('hash', 'aku') == 12
    assert db.hget('hash', 'ankka') == 313

    print("all hashed", db.hdict('hash'))
    print(db.keys())
    print(db.keys('paths/nest/ok/k*'))
    print(dict(db))  # snapsot of whole db
    db.uncache()  # frees memory, causes re-reads later

    # shorthand for accessing deeply nested files
    lnk = db.getlink('myobjects/test')
    lnk.foo = 2
    lnk.bar = lnk.foo + 5
    assert lnk.bar == 7
Exemple #3
0
config = RawConfigParser()

if not config.read("credentials.ini"):
    print("Could not find credentials. Exiting.")
    exit(1)

account_sid = config.get("twilio", "account_sid")
auth_token = config.get("twilio", "auth_token")
call_number = config.get("twilio", "number")

client = Client(account_sid, auth_token)

db = PickleShareDB('db')

for number, nextcall in db.items():

    if nextcall is not None and nextcall > time():
        continue

    sample = choice([f for f in os.listdir("samples") if f.endswith(".mp3")])

    response = VoiceResponse()
    response.play("samples/" + sample)

    # Make the call
    call = client.api.account.calls.create(to=line[0],
                                           from_=call_number,
                                           url=response)

    print(call.sid)