Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with Python3 #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ as "say". In some cases, you'll want to build a class object directly such as in

## Note on Python versions

This module is for python 2.x and requires python 2.5 or higher.
There is a separate version available for python 3.x at:

http://github.com/tropo/python-webapi/tree/python3
This module is for Python 3 and 2.5 or higher.

## License

Expand Down
2 changes: 2 additions & 0 deletions build/lib/tropo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

"""

from __future__ import print_function

try:
import cjson as jsonlib
jsonlib.dumps = jsonlib.encode
Expand Down
4 changes: 3 additions & 1 deletion samples/gh-12-test_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session, TropoAction, Choices

Expand Down Expand Up @@ -35,7 +37,7 @@ def index(request):


json = t.RenderJson()
print json
print(json)
return json


Expand Down
4 changes: 3 additions & 1 deletion samples/gh-14.test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session

Expand All @@ -23,7 +25,7 @@ def index(request):
t.call(to='tel:+' + TO_NUMBER, _from='tel:+' + FROM_NUMBER)
t.say('This is your mother. Did you brush your teeth today?')
json = t.RenderJson()
print json
print(json)
return json


Expand Down
8 changes: 5 additions & 3 deletions samples/gh-14.test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session

Expand All @@ -20,9 +22,9 @@
def index(request):
t = Tropo()
t.message("Hello World", TO_NUMBER, channel='VOICE', _from='tel:+' + FROM_NUMBER)
json = t.RenderJson()
print json
return json
json = t.RenderJson()
print(json)
return json
#retest


Expand Down
4 changes: 3 additions & 1 deletion samples/gh-14.test_say.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session

Expand All @@ -17,7 +19,7 @@ def index(request):
t = Tropo()
t.say('12345', _as='DIGITS', voice='dave')
json = t.RenderJson()
print json
print(json)
return json


Expand Down
4 changes: 3 additions & 1 deletion samples/gh-14.test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session

Expand All @@ -25,7 +27,7 @@ def index(request):
t.transfer(TO_NUMBER, _from="tel:+" + FROM_NUMBER)
t.say("Hi. I am a robot")
json = t.RenderJson()
print json
print(json)
return json


Expand Down
4 changes: 3 additions & 1 deletion samples/gh-14_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session

Expand All @@ -14,7 +16,7 @@ def index(request):
t = Tropo()
t.say('12345', _as='DIGITS', voice='allison')
json = t.RenderJson()
print json
print(json)
return json

run_itty()
8 changes: 5 additions & 3 deletions samples/gh-17.test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

from itty import *
from tropo import Tropo, Result

Expand All @@ -11,7 +13,7 @@ def index(request):
t.on(event = "continue", next ="/continue")
t.on(event = "incomplete", next ="/incomplete")
json = t.RenderJson()
print json
print(json)
return json

@post("/continue")
Expand All @@ -29,15 +31,15 @@ def index(request):
t.say("What are you waiting for?")

json = t.RenderJson()
print json
print(json)
return json

@post("/incomplete")
def index(request):
t = Tropo()
t.say("Sorry, that wasn't on of the options.")
json = t.RenderJson()
print json
print(json)
return json

run_itty()
12 changes: 7 additions & 5 deletions samples/gh-20-test_ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session, Result

Expand All @@ -19,16 +21,16 @@ def index(request):

t.on(event = "continue", next ="/continue")

json = t.RenderJson()
json = t.RenderJson()

print json
print(json)
return json

@post("/continue")
def index(request):

r = Result(request.body)
print "Result : %s" % r
print("Result : %s" % r)

t = Tropo()

Expand All @@ -37,8 +39,8 @@ def index(request):

t.say("You said " + answer + ", which is a " + value)

json = t.RenderJson()
print json
json = t.RenderJson()
print(json)
return json

run_itty()
14 changes: 8 additions & 6 deletions samples/gh-21.choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session, Result, Choices

Expand All @@ -20,21 +22,21 @@ def index(request):

t = Tropo()

choices = Choices("[4-5 DIGITS]", mode="dtmf", terminator = "#")
choices = Choices("[4-5 DIGITS]", mode="dtmf", terminator = "#")
t.ask(choices, timeout=15, name="digit", say = "What's your four or five digit pin? Press pound when finished.")

t.on(event = "continue", next ="/continue")

json = t.RenderJson()
json = t.RenderJson()

print json
print(json)
return json

@post("/continue")
def index(request):

r = Result(request.body)
print "Result : %s" % r
print("Result : %s" % r)
# dump(r)
t = Tropo()

Expand All @@ -43,8 +45,8 @@ def index(request):
t.say("You said ")
t.say (answer, _as="DIGITS")

json = t.RenderJson()
print json
json = t.RenderJson()
print(json)
return json

run_itty()
Expand Down
3 changes: 2 additions & 1 deletion samples/gh-22.transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo-webapi-python/tropo import Tropo, Session
Expand All @@ -30,7 +31,7 @@ def index(request):
t.transfer(TO_NUMBER, headers={"x-callername":"Kevin Bond"})

json = t.RenderJson()
print json
print(json)
return json


Expand Down
5 changes: 3 additions & 2 deletions samples/gh-23.ask_timeout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# tests example clarifying gh-23 . How to use timeout, and nomatch parameters
# in "say" within "ask"

from __future__ import print_function

from itty import *
from tropo import Tropo, Session, Result
Expand All @@ -25,7 +26,7 @@ def index (request):
])

json = t.RenderJson()
print json
print(json)
return json


Expand Down Expand Up @@ -67,7 +68,7 @@ def index_straight_json (request):

}
"""
print json
print(json)
return json


Expand Down
10 changes: 6 additions & 4 deletions samples/gh-5.hello_cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@
# 3. Place this file in examples folder and chmod it executable
# 4. Dial up Tropo app, and hear "Hello, World ..."

from __future__ import print_function

import cgi
from tropo import Tropo

def hello():
t = Tropo()
t.say(['hello world! I am a C G I script.'])
json = t.RenderJson()
print json
print(json)
return json



print "Content-type: text/json"
print
print
print("Content-type: text/json")
print()
print()

hello()

2 changes: 2 additions & 0 deletions samples/itty_hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session

Expand Down
2 changes: 2 additions & 0 deletions samples/itty_session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# Sample application using the itty-bitty python web framework from:
# http://github.com/toastdriven/itty

from __future__ import print_function

from itty import *
from tropo import Tropo, Session
from urllib import urlencode
Expand Down
4 changes: 3 additions & 1 deletion samples/record_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

from itty import *
from tropo import Tropo, Session, Result

Expand All @@ -11,4 +13,4 @@ def index(request):

return t.RenderJson()

run_itty(server='wsgiref', port=8888)
run_itty(server='wsgiref', port=8888)
Loading