Запишитесь на звонок Twilio с Iron.io

Я пытаюсь запланировать звонок в определенное время. Следующий код Python делает вызов:

#Download the library from twilio.com/docs/libraries
from twilio.rest import TwilioRestClient

# Get these credentials from http://twilio.com/user/account
account_sid = "myaccountsid"
auth_token = "myauthtoken"
client = TwilioRestClient(account_sid, auth_token)

# Make the call
call = client.calls.create(to="+12345789123",  # Any phone number
                           from_="+12345789123", # Must be a valid Twilio number
                           url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
print call.sid

и этот код.worker используется для Iron.io:

# define the runtime language
runtime "python"

gem 'twilio-ruby'
gem 'uber_config'

# exec is the file that will be executed:
exec "makecall.py"

Используя этот учебник.

Однако я получаю следующее исключение:

/Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:103:in `eval': undefined method `gem' for #<IronWorkerNG::Code::Base:0x007fd6c5008ec8> (NoMethodError)
    from (eval):4:in `block (2 levels) in initialize'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:103:in `eval'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:103:in `block (2 levels) in initialize'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/fetcher.rb:78:in `call'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/fetcher.rb:78:in `fetch'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:93:in `block in initialize'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:92:in `each'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:92:in `initialize'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/cli.rb:78:in `new'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/cli.rb:78:in `upload'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/bin/iron_worker:120:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/iron_worker:23:in `load'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/iron_worker:23:in `<main>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `eval'
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `<main>'

Что я делаю неправильно?

1 ответ

Решение

Похоже, вы пытаетесь использовать камни Ruby в вашем .worker файл со скриптом Python. Вы должны использовать pip для библиотек Python. Попробуйте изменить свой .worker файл к этому:

runtime 'python'

# dependencies
pip 'twilio'

# executable
exec 'mycall.py'
Другие вопросы по тегам