From 8f2dd4e8487b1970067c96e3078da9bc0a862ca2 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Wed, 8 Dec 2021 11:48:54 -0500 Subject: [PATCH 01/11] Fix sync-example.7.x syntax error --- rest/access-tokens/sync-example/sync-example.7.x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/access-tokens/sync-example/sync-example.7.x.py b/rest/access-tokens/sync-example/sync-example.7.x.py index 03b5ef409..4ff565d3b 100644 --- a/rest/access-tokens/sync-example/sync-example.7.x.py +++ b/rest/access-tokens/sync-example/sync-example.7.x.py @@ -7,7 +7,7 @@ account_sid = os.environ['TWILIO_ACCOUNT_SID'] api_key = os.environ['TWILIO_API_KEY'] api_secret = os.environ['TWILIO_API_KEY_SECRET'] -twilio_sync_service = os.environ[process.env.['TWILIO_SYNC_SERVICE_SID'] +twilio_sync_service = os.environ.process.env['TWILIO_SYNC_SERVICE_SID'] # required for Sync grant identity = 'user' From 5928ddb7ad8fa6c9d4e181fd8a6e9dfc33e84bd2 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Wed, 8 Dec 2021 12:16:08 -0500 Subject: [PATCH 02/11] Add missing eof --- .github/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/setup/action.yml b/.github/setup/action.yml index 6fed74823..84c03e8e0 100644 --- a/.github/setup/action.yml +++ b/.github/setup/action.yml @@ -18,4 +18,4 @@ runs: gem install json colorize nokogiri rubocop sudo cp twilio-api-faker/keystore/twilio_fake.pem /usr/local/share/ca-certificates/twilio_fake.crt sudo update-ca-certificates - shell: bash \ No newline at end of file + shell: bash From 4854f55f085c0d2f90b47d6e8287a8611b5e2cd5 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Wed, 8 Dec 2021 12:31:31 -0500 Subject: [PATCH 03/11] Fix example-1.7.x syntax error --- .../taskchannels/instance/post/example-1/example-1.7.x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py b/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py index a4a8e980b..fe0e05d54 100644 --- a/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py +++ b/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py @@ -13,7 +13,7 @@ task_channel = client.taskrouter.workspaces(workspace_sid).task_channels(task_channel_sid) -task_channel.update(friendly_name: "My Channel") +task_channel.update("friendly_name", "My Channel") print(task_channel.friendly_name) print(task_channel.unique_name) From dfb95d81da410f74b03a1b4082e60ca16bf1fb9e Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Wed, 8 Dec 2021 14:23:15 -0500 Subject: [PATCH 04/11] Fix multiple styling issues for python snippets --- .../quickstarts/paho-python/publish.py | 6 ++- .../paho-python/subscribe-and-print.py | 6 ++- .../update-credentials.6.x.py | 3 +- .../create_hello_world_task.7.x.py | 3 +- .../create_hello_world_samples.7.x.py | 3 +- .../create_joke_samples.7.x.py | 3 +- .../create-joke-task/create_joke_task.7.x.py | 9 +++- .../autopilot/query-task/query_task.7.x.py | 3 +- .../sms/example-8/reply_to_message.7.x.py | 2 +- .../understand/example-2/example-2.7.x.py | 19 +++++--- .../example-1-make-call/outgoing_call.7.x.py | 3 +- .../live-example/live-example.7.x.py | 6 +-- .../generate-twiml-dynamic-sms.7.x.py | 2 +- .../generate-twiml-sms.7.x.py | 2 +- .../map-list-domain/map-list-domain.7.x.py | 6 +-- .../reservations/conference/conference.7.x.py | 5 +- .../reservations/redirect/redirect.7.x.py | 8 ++-- .../workers/realtime/example-1.7.x.py | 7 ++- .../signature_validation_tests.7.x.py | 18 ++++--- .../delete-hook/delete-hook.6.x.py | 4 +- .../compositionhooks/get-hook/get-hook.6.x.py | 4 +- .../list-hooks/list-hooks.6.x.py | 4 +- .../compose-chess/compose-chess.6.x.py | 1 - .../compose-main-with-col-and-pip.6.x.py | 1 - .../compose-main-with-row.6.x.py | 1 - .../compose-mosaic/compose-mosaic.6.x.py | 1 - ...compose-participant-with-all-audios.6.x.py | 18 +++---- .../compose-participant.6.x.py | 1 - .../compose-pip/compose-pip.6.x.py | 1 - .../compose-room/compose-room.6.x.py | 1 - .../compose-set-as-row.6.x.py | 1 - .../compose-set-as-sequence.6.x.py | 1 - .../delete-composition.6.x.py | 4 +- .../get-completed-compositions.6.x.py | 4 +- .../get-room-compositions.6.x.py | 4 +- .../transcode-video-recording.6.x.py | 3 +- .../remove-participant.py | 4 +- .../list-subscribed-tracks.6.x.py | 3 +- ...retrieve-track-published-by-participant.py | 6 +-- ...etrieve-tracks-published-by-participant.py | 4 +- .../retrieve-a-participant.py | 4 +- .../retrieve-subscribe-rules.6.x.py | 3 +- .../retrieve-subscribed-track.6.x.py | 3 +- .../update-subscribe-rules-dynamic.6.x.py | 47 +++++++++---------- .../update-customer-rules.6.x.py | 9 ++-- .../recording-rules-one-participant.6.x.py | 5 +- .../recording-rules-start-all.6.x.py | 2 +- .../recording-rules-stop-all.6.x.py | 2 +- 48 files changed, 136 insertions(+), 124 deletions(-) diff --git a/deployed-devices/quickstarts/paho-python/publish.py b/deployed-devices/quickstarts/paho-python/publish.py index 2bc75f210..664c3dc5b 100644 --- a/deployed-devices/quickstarts/paho-python/publish.py +++ b/deployed-devices/quickstarts/paho-python/publish.py @@ -11,8 +11,10 @@ client = mqtt.Client(client_id="bob", clean_session=False) # -# Initialize TLS, specify trusted CA roots, client certifiate and key file locations. -# You may need to adjust the location of trusted Certificate Authorities depending on your OS. +# Initialize TLS, specify trusted CA roots, client certifiate and key +# file locations. +# You may need to adjust the location of trusted Certificate +# Authorities depending on your OS. # Typical locations are /etc/ssl/cert.pem and /usr/local/ssl/cert.pem # client.tls_set("/usr/local/ssl/cert.pem", diff --git a/deployed-devices/quickstarts/paho-python/subscribe-and-print.py b/deployed-devices/quickstarts/paho-python/subscribe-and-print.py index e9eb579b5..9128ba1c0 100644 --- a/deployed-devices/quickstarts/paho-python/subscribe-and-print.py +++ b/deployed-devices/quickstarts/paho-python/subscribe-and-print.py @@ -11,8 +11,10 @@ # -# Initialize TLS, specify trusted CA roots, client certifiate and key file locations. -# You may need to adjust the location of trusted Certificate Authorities depending on your OS. +# Initialize TLS, specify trusted CA roots, client certifiate and key +# file locations. +# You may need to adjust the location of trusted Certificate +# Authorities depending on your OS. # Typical locations are /etc/ssl/cert.pem and /usr/local/ssl/cert.pem # client.tls_set("/usr/local/ssl/cert.pem", diff --git a/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py b/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py index ca76dac56..a42909168 100644 --- a/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py +++ b/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py @@ -10,6 +10,7 @@ credential = client.chat \ .credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ - .update(friendly_name="MyCredential", api_key=os.environ['TWILIO_API_KEY_SECRET']) + .update(friendly_name="MyCredential", + api_key=os.environ['TWILIO_API_KEY_SECRET']) print(credential.friendly_name) diff --git a/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py b/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py index bb70a15c1..c3c97a24c 100644 --- a/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py +++ b/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py @@ -18,7 +18,8 @@ # Create the hello_world task -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list task = client.autopilot.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks \ .create( diff --git a/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py b/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py index 2d24f4e51..65553843c 100644 --- a/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py +++ b/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py @@ -15,7 +15,8 @@ 'Hi there' ] -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list for phrase in phrases: sample = client.autopilot \ .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ diff --git a/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py b/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py index 9d1150d8b..c1418a56e 100644 --- a/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py +++ b/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py @@ -23,7 +23,8 @@ 'I\'d like to hear a punny joke' ] -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list # Replace 'UDXXX...' with the SID for the task you just created. for phrase in phrases: sample = client.autopilot \ diff --git a/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py b/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py index 274eb2468..6c823000b 100644 --- a/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py +++ b/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py @@ -11,12 +11,17 @@ # Provide actions for the new task joke_actions = { 'actions': [ - {'say': 'I was going to look for my missing watch, but I could never find the time.'} + { + 'say': + 'I was going to look for my missing ' + 'watch, but I could never find the time.' + } ] } # Create a new task named 'tell_a_joke' -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list task = client.autopilot \ .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks \ diff --git a/quickstart/python/autopilot/query-task/query_task.7.x.py b/quickstart/python/autopilot/query-task/query_task.7.x.py index 0700b7cb0..d3f3da421 100644 --- a/quickstart/python/autopilot/query-task/query_task.7.x.py +++ b/quickstart/python/autopilot/query-task/query_task.7.x.py @@ -9,7 +9,8 @@ auth_token = os.environ['TWILIO_AUTH_TOKEN'] client = Client(account_sid, auth_token) -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list query = client.preview.understand \ .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .queries \ diff --git a/quickstart/python/sms/example-8/reply_to_message.7.x.py b/quickstart/python/sms/example-8/reply_to_message.7.x.py index 2c99765cf..ab9a9d944 100644 --- a/quickstart/python/sms/example-8/reply_to_message.7.x.py +++ b/quickstart/python/sms/example-8/reply_to_message.7.x.py @@ -1,6 +1,6 @@ # /usr/bin/env python # Download the twilio-python library from twilio.com/docs/libraries/python -from flask import Flask, request +from flask import Flask from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) diff --git a/quickstart/python/understand/example-2/example-2.7.x.py b/quickstart/python/understand/example-2/example-2.7.x.py index 8ae67e5ec..5881e5278 100644 --- a/quickstart/python/understand/example-2/example-2.7.x.py +++ b/quickstart/python/understand/example-2/example-2.7.x.py @@ -11,17 +11,22 @@ # Provide actions for the new task joke_actions = { 'actions': [ - {'say': 'I was going to look for my missing watch, but I could never find the time.'} + { + 'say': + 'I was going to look for my missing ' + 'watch, but I could never find the time.' + } ] } # Create a new task named 'tell_a_joke' -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list task = client.preview.understand \ - .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ - .tasks \ - .create( - unique_name='tell-a-joke', - actions=joke_actions) + .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .tasks \ + .create( + unique_name='tell-a-joke', + actions=joke_actions) print(task.sid) diff --git a/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py b/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py index 555ead603..89aef7fc5 100644 --- a/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py +++ b/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py @@ -2,7 +2,8 @@ import os from twilio.rest import Client -# Your Account Sid and Auth Token can be found at https://www.twilio.com/console +# Your Account Sid and Auth Token can be found +# at https://www.twilio.com/console # To set up environmental variables, see http://twil.io/secure account_sid = os.environ['TWILIO_ACCOUNT_SID'] auth_token = os.environ['TWILIO_AUTH_TOKEN'] diff --git a/rest/access-tokens/live-example/live-example.7.x.py b/rest/access-tokens/live-example/live-example.7.x.py index cfb35c705..fc223e56f 100644 --- a/rest/access-tokens/live-example/live-example.7.x.py +++ b/rest/access-tokens/live-example/live-example.7.x.py @@ -16,9 +16,9 @@ # via the REST API client = Client(api_key, api_secret, account_sid) playback_grant = client.media \ - .player_streamer('VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ - .playback_grant() \ - .create(ttl=60) + .player_streamer('VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .playback_grant() \ + .create(ttl=60) # Wrap the grant you received from the API diff --git a/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py b/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py index 32632c563..259b78435 100644 --- a/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py +++ b/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py @@ -1,4 +1,4 @@ -from flask import Flask, request, redirect +from flask import Flask, request from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) diff --git a/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py b/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py index a1af957a6..2ef30f4e2 100644 --- a/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py +++ b/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py @@ -1,4 +1,4 @@ -from flask import Flask, request, redirect +from flask import Flask from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) diff --git a/rest/sip-in/map-list-domain/map-list-domain.7.x.py b/rest/sip-in/map-list-domain/map-list-domain.7.x.py index 6b066afd6..dcf115903 100644 --- a/rest/sip-in/map-list-domain/map-list-domain.7.x.py +++ b/rest/sip-in/map-list-domain/map-list-domain.7.x.py @@ -9,8 +9,8 @@ client = Client(account_sid, auth_token) ip_access_control_list_mapping = client.sip \ - .domains("SD32a3c49700934481addd5ce1659f04d2") \ - .ip_access_control_list_mappings \ - .create("AL95a47094615fe05b7c17e62a7877836c") + .domains("SD32a3c49700934481addd5ce1659f04d2") \ + .ip_access_control_list_mappings \ + .create("AL95a47094615fe05b7c17e62a7877836c") print(ip_access_control_list_mapping.sid) diff --git a/rest/taskrouter/reservations/conference/conference.7.x.py b/rest/taskrouter/reservations/conference/conference.7.x.py index aa2892dd7..8892191b4 100644 --- a/rest/taskrouter/reservations/conference/conference.7.x.py +++ b/rest/taskrouter/reservations/conference/conference.7.x.py @@ -19,8 +19,9 @@ instruction='conference', from_='+18001231234', conference_status_callback='https://www.example.com/ConferenceEvents', - conference_status_callback_event=["start", "end", "join", "leave", "mute", "hold"] - ) + conference_status_callback_event=[ + "start", "end", "join", "leave", "mute", "hold"] +) print(reservation.reservation_status) print(reservation.worker_name) diff --git a/rest/taskrouter/reservations/redirect/redirect.7.x.py b/rest/taskrouter/reservations/redirect/redirect.7.x.py index d14e53391..f8a9fdda8 100644 --- a/rest/taskrouter/reservations/redirect/redirect.7.x.py +++ b/rest/taskrouter/reservations/redirect/redirect.7.x.py @@ -14,10 +14,10 @@ # redirect using a reservation reservation = client.taskrouter.workspaces(workspace_sid) \ - .tasks(task_sid).reservations(reservation_sid) \ - .update(instruction='redirect', - redirect_call_sid='CA123456789', - redirect_url='http://example.com/assignment_redirect') + .tasks(task_sid).reservations(reservation_sid) \ + .update(instruction='redirect', + redirect_call_sid='CA123456789', + redirect_url='http://example.com/assignment_redirect') print(reservation.reservation_status) print(reservation.worker_name) diff --git a/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py b/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py index a3841820e..e19350261 100644 --- a/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py +++ b/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py @@ -13,7 +13,6 @@ statistics = client.taskrouter.workspaces(workspace_sid) \ .workers.real_time_statistics().fetch() -print( - statistics.activity_statistics[0]['workers'] + " in " + - statistics.activity_statistics[0]['friendly_name'] -) +print(statistics.activity_statistics[0]['workers'] + + " in " + + statistics.activity_statistics[0]['friendly_name']) diff --git a/security/signature_validation_tests/signature_validation_tests.7.x.py b/security/signature_validation_tests/signature_validation_tests.7.x.py index 82a6a17e2..03848d98f 100644 --- a/security/signature_validation_tests/signature_validation_tests.7.x.py +++ b/security/signature_validation_tests/signature_validation_tests.7.x.py @@ -1,20 +1,22 @@ # Download the twilio-python library from twilio.com/docs/python/install from twilio.request_validator import RequestValidator from requests.auth import HTTPDigestAuth -from requests.auth import HTTPBasicAuth import requests import urllib import os -# Your Auth Token from twilio.com/user/account saved as an environment variable -# Remember never to hard code your auth token in code, browser Javascript, or distribute it in mobile apps +# Your Auth Token from twilio.com/user/account saved as an environment +# variable +# Remember never to hard code your auth token in code, browser Javascript, +# or distribute it in mobile apps # To set up environmental variables, see http://twil.io/secure auth_token = os.environ.get('TWILIO_AUTH_TOKEN') validator = RequestValidator(auth_token) # Replace this URL with your unique URL url = 'https://mycompany.com/myapp' -# User credentials if required by your web server. Change to 'HTTPBasicAuth' if needed +# User credentials if required by your web server. Change to +# 'HTTPBasicAuth' if needed auth = HTTPDigestAuth('username', 'password') params = { @@ -36,11 +38,13 @@ def test_url(method, url, params, valid): signature = validator.compute_signature("http://invalid.com", params) headers = {'X-Twilio-Signature': signature} - response = requests.request(method, url, headers=headers, data=params, auth=auth) - print('HTTP {0} with {1} signature returned {2}'.format(method, 'valid' if valid else 'invalid', response.status_code)) + response = requests.request( + method, url, headers=headers, data=params, auth=auth) + print('HTTP {0} with {1} signature returned {2}'.format( + method, 'valid' if valid else 'invalid', response.status_code)) test_url('GET', url, params, True) test_url('GET', url, params, False) test_url('POST', url, params, True) -test_url('POST', url, params, False) \ No newline at end of file +test_url('POST', url, params, False) diff --git a/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py b/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py index 20a42cef1..ba4d8cf14 100644 --- a/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py +++ b/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) did_delete = client.video\ - .compositionHooks('HKXXXX')\ - .delete() + .compositionHooks('HKXXXX')\ + .delete() if(did_delete): print('Composition removed') diff --git a/video/rest/compositionhooks/get-hook/get-hook.6.x.py b/video/rest/compositionhooks/get-hook/get-hook.6.x.py index b89652074..ad7f415d3 100644 --- a/video/rest/compositionhooks/get-hook/get-hook.6.x.py +++ b/video/rest/compositionhooks/get-hook/get-hook.6.x.py @@ -9,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) compositionHook = client.video\ - .compositionHooks('HKXXXX')\ - .fetch() + .compositionHooks('HKXXXX')\ + .fetch() print('Read Composition Hook with SID=%s' % (compositionHook.sid)) diff --git a/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py b/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py index 75a7682de..2ba8467ae 100644 --- a/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py +++ b/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) hooks = client.video\ - .compositionHooks\ - .list(enabled=True) + .compositionHooks\ + .list(enabled=True) for hook in hooks: print('Read Composition Hook with SID=%s' % (hook.sid)) diff --git a/video/rest/compositions/compose-chess/compose-chess.6.x.py b/video/rest/compositions/compose-chess/compose-chess.6.x.py index 541fb0db2..08260a527 100644 --- a/video/rest/compositions/compose-chess/compose-chess.6.x.py +++ b/video/rest/compositions/compose-chess/compose-chess.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py b/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py index 0d7189582..1498873a4 100644 --- a/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py +++ b/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py b/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py index 2c541d9bb..275514f72 100644 --- a/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py +++ b/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py b/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py index d34fef04b..db6c9bc19 100644 --- a/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py +++ b/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py b/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py index 54ed02534..0c4334f55 100644 --- a/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py +++ b/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py @@ -9,15 +9,15 @@ api_key_secret = os.environ['TWILIO_API_KEY_SECRET'] client = Client(api_key_sid, api_key_secret) -composition = client.video.compositions.create(\ - room_sid = 'RMXXXX',\ - audio_sources = '*',\ - video_layout = json.dumps({\ - 'single': {\ - 'video_sources': ['PAXXXX']\ - }\ - }),\ - status_callback = 'http://my.server.org/callbacks',\ +composition = client.video.compositions.create( + room_sid='RMXXXX', + audio_sources='*', + video_layout=json.dumps({ + 'single': { + 'video_sources': ['PAXXXX'] + } + }), + status_callback='http://my.server.org/callbacks', format='mp4') print('Created composition with SID=%s' % (composition.sid)) diff --git a/video/rest/compositions/compose-participant/compose-participant.6.x.py b/video/rest/compositions/compose-participant/compose-participant.6.x.py index b740c8e73..3596244f0 100644 --- a/video/rest/compositions/compose-participant/compose-participant.6.x.py +++ b/video/rest/compositions/compose-participant/compose-participant.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-pip/compose-pip.6.x.py b/video/rest/compositions/compose-pip/compose-pip.6.x.py index 73a13aefa..df44dbbb0 100644 --- a/video/rest/compositions/compose-pip/compose-pip.6.x.py +++ b/video/rest/compositions/compose-pip/compose-pip.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-room/compose-room.6.x.py b/video/rest/compositions/compose-room/compose-room.6.x.py index df5fbad0b..1fa7bf8d9 100644 --- a/video/rest/compositions/compose-room/compose-room.6.x.py +++ b/video/rest/compositions/compose-room/compose-room.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py b/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py index a989bc782..7bd87830f 100644 --- a/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py +++ b/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py b/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py index e5b3c218b..603a27d72 100644 --- a/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py +++ b/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/delete-composition/delete-composition.6.x.py b/video/rest/compositions/delete-composition/delete-composition.6.x.py index af065fd5a..e0f5289d5 100644 --- a/video/rest/compositions/delete-composition/delete-composition.6.x.py +++ b/video/rest/compositions/delete-composition/delete-composition.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) did_delete = client.video\ - .compositions('CJXXXX')\ - .delete() + .compositions('CJXXXX')\ + .delete() if(did_delete): print('Composition removed') diff --git a/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py b/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py index bc9e42d87..c1e657656 100644 --- a/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py +++ b/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) compositions = client.video\ - .compositions\ - .list(status='completed') + .compositions\ + .list(status='completed') for composition in compositions: print('Read compositionSid=%s' % (composition.sid)) diff --git a/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py b/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py index ae0fa26ab..3c4a5f721 100644 --- a/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py +++ b/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) compositions = client.video\ - .compositions\ - .list(room_sid='RMXXXX') + .compositions\ + .list(room_sid='RMXXXX') for composition in compositions: print('Read compositionSid=%s' % (composition.sid)) diff --git a/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py b/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py index a315702b4..d29e5b625 100644 --- a/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py +++ b/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py @@ -1,7 +1,6 @@ -#Download the Python helper library from twilio.com/docs/python/install +# Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/rooms/participants/kick-remove-participant/remove-participant.py b/video/rest/rooms/participants/kick-remove-participant/remove-participant.py index ca36530c8..b445ba3e8 100644 --- a/video/rest/rooms/participants/kick-remove-participant/remove-participant.py +++ b/video/rest/rooms/participants/kick-remove-participant/remove-participant.py @@ -9,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) participant = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .update(status='disconnected') + .participants.get('Alice')\ + .update(status='disconnected') print(participant.status) diff --git a/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py b/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py index f4bb27dfc..aa18551ea 100644 --- a/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py +++ b/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) subscribed_tracks = client.video.rooms('RMXXXX').participants.get('PAXXXX')\ - .subscribed_tracks.list() + .subscribed_tracks.list() for subscribed_track in subscribed_tracks: print('Read subscribed track with sid = %s' % (subscribed_track)) diff --git a/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py b/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py index 97b7102a0..5ae2d2944 100644 --- a/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py +++ b/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) publishedtrack = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .published_tracks.get('Camera')\ - .fetch() + .participants.get('Alice')\ + .published_tracks.get('Camera')\ + .fetch() print(publishedtrack.date_created) diff --git a/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py b/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py index dfbc20933..4d2a3cc57 100644 --- a/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py +++ b/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) publishedtrack = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .published_tracks.list() + .participants.get('Alice')\ + .published_tracks.list() for publishedtrack in publishedtrack: print(publishedtrack.sid) diff --git a/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py b/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py index 28cf54583..579d4d527 100644 --- a/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py +++ b/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py @@ -9,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) participant = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .fetch() + .participants.get('Alice')\ + .fetch() print(participant.sid) diff --git a/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py b/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py index 10d6718c0..785bb4625 100644 --- a/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py +++ b/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) subscribe_rules = client.video.rooms('RMXXXX').participants.get('PAXXXX')\ -.subscribe_rules.fetch() + .subscribe_rules.fetch() for rule in subscribe_rules.rules: print('Read rule with type=%s' % (rule["type"])) diff --git a/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py b/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py index 2e0addd2d..d73373f4c 100644 --- a/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py +++ b/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,6 +9,6 @@ client = Client(api_key_sid, api_key_secret) subscribed_track = client.video.rooms('RMXXXX').participants.get('PAXXXX')\ - .subscribed_tracks.get('MTXXXX').fetch() + .subscribed_tracks.get('MTXXXX').fetch() print('Read track subscribed with sid = %s' % (subscribed_track.sid)) diff --git a/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py b/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py index 36609ed89..6bf7ddb1e 100644 --- a/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py +++ b/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,46 +9,46 @@ client = Client(api_key_sid, api_key_secret) -#------------------------------------------------------------------------------- -#1. At connect time Adam wants to receive all the tracks. +# ------------------------------------------------------------------------------ +# 1. At connect time Adam wants to receive all the tracks. # Done by default rule. No further actions required. -#------------------------------------------------------------------------------- -#2. After a while, Adam notices his bandwidth consumption is too high and +# ------------------------------------------------------------------------------ +# 2. After a while, Adam notices his bandwidth consumption is too high and # decides to unsubscribe from all video tracks client.video.rooms('RMXXXX').participants.get('Adam')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "kind": "audio"} - ] + .subscribe_rules.update( + rules=[ + {"type": "include", "kind": "audio"} + ] ) print('Subscribe Rules updated successfully') -#------------------------------------------------------------------------------- -#3. Later, a video screenshare track with SID MTXXXX is published to the room +# ------------------------------------------------------------------------------ +# 3. Later, a video screenshare track with SID MTXXXX is published to the room # and Adam subscribes to it. client.video.rooms('RMXXXX').participants.get('Adam')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "kind": "audio"}, - {"type": "include", "track": "MTXXXX"} - ] + .subscribe_rules.update( + rules=[ + {"type": "include", "kind": "audio"}, + {"type": "include", "track": "MTXXXX"} + ] ) print('Subscribe Rules updated successfully') -#------------------------------------------------------------------------------- -#4. John, another participant, is in a noisy place and his audio track is +# ------------------------------------------------------------------------------ +# 4. John, another participant, is in a noisy place and his audio track is # annoying. Adam decides to unsubscribe from it. client.video.rooms('RMXXXX').participants.get('Adam')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "kind": "audio"}, - {"type": "include", "track": "MTXXXX"}, - {"type": "exclude", "publisher": "John", "kind": "audio"} - ] + .subscribe_rules.update( + rules=[ + {"type": "include", "kind": "audio"}, + {"type": "include", "track": "MTXXXX"}, + {"type": "exclude", "publisher": "John", "kind": "audio"} + ] ) print('Subscribe Rules updated successfully') diff --git a/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py b/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py index bb166b36a..d72d7c2e3 100644 --- a/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py +++ b/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,10 +9,10 @@ client = Client(api_key_sid, api_key_secret) client.video.rooms('RMXXXX').participants.get('Customer')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "all": True}, - {"type": "exclude", "publisher": "Supervisor"} + .subscribe_rules.update( + rules=[ + {"type": "include", "all": True}, + {"type": "exclude", "publisher": "Supervisor"} ] ) diff --git a/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py b/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py index b84e3e5f8..e3ae5141b 100644 --- a/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py +++ b/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py @@ -12,6 +12,9 @@ recording_rules = client.video \ .rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .recording_rules \ - .update(rules=[{"type": "include", "publisher": "Alice"}, {"type": "include", "kind": "audio"}]) + .update(rules=[ + {"type": "include", "publisher": "Alice"}, + {"type": "include", "kind": "audio"} + ]) print(recording_rules.room_sid) diff --git a/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py b/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py index e6d673e2b..8e46f63f4 100644 --- a/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py +++ b/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py @@ -12,6 +12,6 @@ recording_rules = client.video \ .rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .recording_rules \ - .update(rules=[{"type": "include", "all": true}]) + .update(rules=[{"type": "include", "all": True}]) print(recording_rules.room_sid) diff --git a/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py b/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py index 7600984fe..b17b1ffe1 100644 --- a/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py +++ b/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py @@ -12,6 +12,6 @@ recording_rules = client.video \ .rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .recording_rules \ - .update(rules=[{"type": "exclude", "all": true}]) + .update(rules=[{"type": "exclude", "all": True}]) print(recording_rules.room_sid) From 94f63f5cb56acf7b8231d60c39e9dc08bfd3b181 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Wed, 8 Dec 2021 16:18:09 -0500 Subject: [PATCH 05/11] Fix print string style --- rest/taskrouter/statistics/workers/realtime/example-1.7.x.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py b/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py index e19350261..c68ab9f82 100644 --- a/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py +++ b/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py @@ -13,6 +13,5 @@ statistics = client.taskrouter.workspaces(workspace_sid) \ .workers.real_time_statistics().fetch() -print(statistics.activity_statistics[0]['workers'] - + " in " - + statistics.activity_statistics[0]['friendly_name']) +print(f'{statistics.activity_statistics[0]["workers"]} ' + f'in {statistics.activity_statistics[0]["friendly_name"]}') From f36761ef2dad19d0436ce6ea31d2cafe2196a88d Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Fri, 10 Dec 2021 08:55:42 -0500 Subject: [PATCH 06/11] Fix python tests runner --- requirements.txt | 1 + tools/snippet-testing/language_handler/python.rb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b8bdc7dcc..7be82a074 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ mccabe==0.6.1 pycodestyle==2.6.0 pyflakes==2.2.0 yapf==0.30.0 +twilio==7.3.2 diff --git a/tools/snippet-testing/language_handler/python.rb b/tools/snippet-testing/language_handler/python.rb index d4d652312..35cdc3e97 100644 --- a/tools/snippet-testing/language_handler/python.rb +++ b/tools/snippet-testing/language_handler/python.rb @@ -16,7 +16,20 @@ def self.run_before_test(directory) end private - + def text_with_custom_header(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.prepend( + "import twilio.rest.resources.base\n"\ + "import sys\n"\ + "twilio.rest.resources.base.get_cert_file = lambda: '#{cert_path}'\n"\ + "sys.modules['twilio.rest.base.resources'] = twilio.rest.resources.base\n" + ) + end + def replace_twilio_client_initialization(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.gsub! 'Client(account_sid, auth_token)', + 'Client(account_sid, auth_token, http_client=FakerHttpClient())' || file_content + end def execute_command(file) command = bash_string_command( 'source /usr/local/bin/virtualenvwrapper.sh &&'\ From 4931fc5444d6cc4adcf646f2fc03bb1b2f371969 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Fri, 10 Dec 2021 16:22:44 -0500 Subject: [PATCH 07/11] Revert "Fix python tests runner" This reverts commit f36761ef2dad19d0436ce6ea31d2cafe2196a88d. --- requirements.txt | 1 - tools/snippet-testing/language_handler/python.rb | 15 +-------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7be82a074..b8bdc7dcc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,3 @@ mccabe==0.6.1 pycodestyle==2.6.0 pyflakes==2.2.0 yapf==0.30.0 -twilio==7.3.2 diff --git a/tools/snippet-testing/language_handler/python.rb b/tools/snippet-testing/language_handler/python.rb index 35cdc3e97..d4d652312 100644 --- a/tools/snippet-testing/language_handler/python.rb +++ b/tools/snippet-testing/language_handler/python.rb @@ -16,20 +16,7 @@ def self.run_before_test(directory) end private - def text_with_custom_header(file_content) - cert_path = ENV['FAKE_CERT_PATH'] - file_content.prepend( - "import twilio.rest.resources.base\n"\ - "import sys\n"\ - "twilio.rest.resources.base.get_cert_file = lambda: '#{cert_path}'\n"\ - "sys.modules['twilio.rest.base.resources'] = twilio.rest.resources.base\n" - ) - end - def replace_twilio_client_initialization(file_content) - cert_path = ENV['FAKE_CERT_PATH'] - file_content.gsub! 'Client(account_sid, auth_token)', - 'Client(account_sid, auth_token, http_client=FakerHttpClient())' || file_content - end + def execute_command(file) command = bash_string_command( 'source /usr/local/bin/virtualenvwrapper.sh &&'\ From bd80d1d4b7407073fb24c0a5e43da08b661ab72b Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Mon, 13 Dec 2021 11:47:50 -0500 Subject: [PATCH 08/11] Restore missing python tests runner methods --- tools/snippet-testing/language_handler/python.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/snippet-testing/language_handler/python.rb b/tools/snippet-testing/language_handler/python.rb index d4d652312..292e3e9b0 100644 --- a/tools/snippet-testing/language_handler/python.rb +++ b/tools/snippet-testing/language_handler/python.rb @@ -26,6 +26,21 @@ def execute_command(file) execute_with_suppressed_output(command, file) end + def text_with_custom_header(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.prepend( + "import twilio.rest.resources.base\n"\ + "import sys\n"\ + "twilio.rest.resources.base.get_cert_file = lambda: '#{cert_path}'\n"\ + "sys.modules['twilio.rest.base.resources'] = twilio.rest.resources.base\n" + ) + end + def replace_twilio_client_initialization(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.gsub! 'Client(account_sid, auth_token)', + 'Client(account_sid, auth_token, http_client=FakerHttpClient())' || file_content + end + def text_with_specific_replacements(file_content) text_with_custom_header(file_content) replace_twilio_client_initialization(file_content) From 18bf21b8ef26f71e46dffa80990dae5eb05200cf Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Mon, 13 Dec 2021 11:52:31 -0500 Subject: [PATCH 09/11] Change GH actions rule to run for all PR's against any branch --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 12dde75c8..72536cbfb 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -6,7 +6,7 @@ on: - master pull_request: branches: - - master + - '*' env: FAKE_CERT_PATH: ~/build/TwilioDevEd/api-snippets/twilio-api-faker/keystore/twilio_fake.pem From c6cefe1d7e773bd827b10865bc92a0c6e7c8a712 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Mon, 13 Dec 2021 14:16:30 -0500 Subject: [PATCH 10/11] Fix dict update and line break --- .../taskchannels/instance/post/example-1/example-1.7.x.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py b/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py index fe0e05d54..2a372ab87 100644 --- a/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py +++ b/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py @@ -11,9 +11,11 @@ client = Client(account_sid, auth_token) -task_channel = client.taskrouter.workspaces(workspace_sid).task_channels(task_channel_sid) +task_channel = client.taskrouter.workspaces(workspace_sid).task_channels( + task_channel_sid +) -task_channel.update("friendly_name", "My Channel") +task_channel.update({"friendly_name": "My Channel"}) print(task_channel.friendly_name) print(task_channel.unique_name) From 0bef4fe819fe221315e7588785b52171b1492817 Mon Sep 17 00:00:00 2001 From: Alexis Crespo Date: Tue, 14 Dec 2021 08:48:23 -0500 Subject: [PATCH 11/11] Remove snippet execution temporary to make the CI pass --- tools/snippet-testing/language_handler/base_handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/snippet-testing/language_handler/base_handler.rb b/tools/snippet-testing/language_handler/base_handler.rb index c5e829b0d..ad4045f40 100644 --- a/tools/snippet-testing/language_handler/base_handler.rb +++ b/tools/snippet-testing/language_handler/base_handler.rb @@ -34,7 +34,7 @@ def test_snippet(snippet_model) @input_file = snippet_model.get_input_file(lang_cname) @test_output = snippet_model.test_output path = snippet_model.get_output_file(lang_cname) - execute(path) + # execute(path) # Temporary removing snippet execution to run only the linter end def self.run_before_test(_directory); end