Skip to content

Commit 1081545

Browse files
committed
flake8: sample-code
1 parent 4450ead commit 1081545

File tree

7 files changed

+38
-42
lines changed

7 files changed

+38
-42
lines changed

sample-code/start_custom_hls.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
3-
43
import json
54
import os.path
65
import sys
@@ -22,8 +21,8 @@
2221
STREAM = qencode.stream()
2322
DESTINATION = qencode.destination()
2423

25-
# set your S3 access credentials here
26-
# for more storage types see Destination object description: https://docs.qencode.com/#010_050
24+
# Set your S3 access credentials here. For more storage types see Destination object
25+
# description: https://docs.qencode.com/#010_050
2726
DESTINATION.url = "s3://s3-eu-west-2.amazonaws.com/qencode-test"
2827
DESTINATION.key = "your-s3-key"
2928
DESTINATION.secret = "your-s3-secret"
@@ -45,20 +44,19 @@
4544

4645

4746
def start_encode():
48-
4947
"""
5048
Create client object
5149
:param api_key: string. required
5250
:param api_url: string. not required
5351
:param api_version: int. not required. default 'v1'
5452
:return: task object
55-
"""
53+
"""
5654

5755
client = qencode.client(API_KEY)
5856
if client.error:
5957
raise QencodeClientException(client.message)
6058

61-
print 'The client created. Expire date: %s' % client.expire
59+
print('The client created. Expire date: {}'.format(client.expire))
6260

6361
task = client.create_task()
6462

@@ -70,12 +68,12 @@ def start_encode():
7068
if task.error:
7169
raise QencodeTaskException(task.message)
7270

73-
print 'Start encode. Task: %s' % task.task_token
71+
print('Start encode. Task: %s' % task.task_token)
7472

7573
while True:
7674
status = task.status()
7775
# print status
78-
print json.dumps(status, indent=2, sort_keys=True)
76+
print(json.dumps(status, indent=2, sort_keys=True))
7977
if status['error'] or status['status'] == 'completed':
8078
break
8179
time.sleep(5)

sample-code/start_custom_mp4.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
FORMAT = qencode.format()
2222
DESTINATION = qencode.destination()
2323

24-
# set your S3 access credentials here
25-
# for more storage types see Destination object description: https://docs.qencode.com/#010_050
24+
# set your S3 access credentials here for more storage types see Destination object
25+
# description: https://docs.qencode.com/#010_050
2626
DESTINATION.url = "s3://s3-eu-west-2.amazonaws.com/qencode-test"
2727
DESTINATION.key = "your-s3-key"
2828
DESTINATION.secret = "your-s3-secret"
@@ -38,20 +38,19 @@
3838

3939

4040
def start_encode():
41-
4241
"""
4342
Create client object
4443
:param api_key: string. required
4544
:param api_url: string. not required
4645
:param api_version: int. not required. default 'v1'
4746
:return: task object
48-
"""
47+
"""
4948

5049
client = qencode.client(API_KEY)
5150
if client.error:
5251
raise QencodeClientException(client.message)
5352

54-
print 'The client created. Expire date: %s' % client.expire
53+
print('The client created. Expire date: %s' % client.expire)
5554

5655
task = client.create_task()
5756

@@ -63,12 +62,12 @@ def start_encode():
6362
if task.error:
6463
raise QencodeTaskException(task.message)
6564

66-
print 'Start encode. Task: %s' % task.task_token
65+
print('Start encode. Task: %s' % task.task_token)
6766

6867
while True:
6968
status = task.status()
7069
# print status
71-
print json.dumps(status, indent=2, sort_keys=True)
70+
print(json.dumps(status, indent=2, sort_keys=True))
7271
if status['error'] or status['status'] == 'completed':
7372
break
7473
time.sleep(5)

sample-code/start_custom_with_dict.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,19 @@
3232

3333

3434
def start_encode():
35-
3635
"""
3736
Create client object
3837
:param api_key: string. required
3938
:param api_url: string. not required
4039
:param api_version: int. not required. default 'v1'
4140
:return: task object
42-
"""
41+
"""
4342

4443
client = qencode.client(API_KEY)
4544
if client.error:
4645
raise QencodeClientException(client.message)
4746

48-
print 'The client created. Expire date: %s' % client.expire
47+
print('The client created. Expire date: {}'.format(client.expire))
4948

5049
task = client.create_task()
5150

@@ -57,12 +56,12 @@ def start_encode():
5756
if task.error:
5857
raise QencodeTaskException(task.message)
5958

60-
print 'Start encode. Task: %s' % task.task_token
59+
print('Start encode. Task: {}'.format(task.task_token))
6160

6261
while True:
6362
status = task.status()
6463
# print status
65-
print json.dumps(status, indent=2, sort_keys=True)
64+
print(json.dumps(status, indent=2, sort_keys=True))
6665
if status['error'] or status['status'] == 'completed':
6766
break
6867
time.sleep(5)

sample-code/start_custom_with_file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def get_query_template():
2626
file_data = json.load(data)
2727
return json.dumps(file_data)
2828
except ValueError as e:
29-
print e
29+
print(e)
3030
except IOError as e:
31-
print e
31+
print(e)
3232

3333

3434
params = get_query_template()
@@ -48,7 +48,7 @@ def start_encode():
4848
if client.error:
4949
raise QencodeClientException(client.message)
5050

51-
print 'The client created. Expire date: %s' % client.expire
51+
print('The client created. Expire date: %s' % client.expire)
5252

5353
task = client.create_task()
5454

@@ -60,12 +60,12 @@ def start_encode():
6060
if task.error:
6161
raise QencodeTaskException(task.message)
6262

63-
print 'Start encode. Task: %s' % task.task_token
63+
print('Start encode. Task: %s' % task.task_token)
6464

6565
while True:
6666
status = task.status()
6767
# print status
68-
print json.dumps(status, indent=2, sort_keys=True)
68+
print(json.dumps(status, indent=2, sort_keys=True))
6969
if status['error'] or status['status'] == 'completed':
7070
break
7171
time.sleep(5)

sample-code/start_custom_with_json.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,19 @@
3232

3333

3434
def start_encode():
35-
3635
"""
3736
Create client object
3837
:param api_key: string. required
3938
:param api_url: string. not required
4039
:param api_version: int. not required. default 'v1'
4140
:return: task object
42-
"""
41+
"""
4342

4443
client = qencode.client(API_KEY)
4544
if client.error:
4645
raise QencodeClientException(client.message)
4746

48-
print 'The client created. Expire date: %s' % client.expire
47+
print('The client created. Expire date: %s' % client.expire)
4948

5049
task = client.create_task()
5150

@@ -57,12 +56,12 @@ def start_encode():
5756
if task.error:
5857
raise QencodeTaskException(task.message)
5958

60-
print 'Start encode. Task: %s' % task.task_token
59+
print('Start encode. Task: %s' % task.task_token)
6160

6261
while True:
6362
status = task.status()
6463
# print status
65-
print json.dumps(status, indent=2, sort_keys=True)
64+
print(json.dumps(status, indent=2, sort_keys=True))
6665
if status['error'] or status['status'] == 'completed':
6766
break
6867
time.sleep(5)

sample-code/start_encode.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
# replace with your API KEY (can be found in your Project settings on Qencode portal)
1818
API_KEY = 'your-api-qencode-key'
1919

20-
# replace with your Transcoding Profile ID (can be found in your Project settings on Qencode portal)
20+
# replace with your Transcoding Profile ID (can be found in your Project settings on
21+
# Qencode portal)
2122
TRANSCODING_PROFILEID = 'your-qencode-profile-id'
2223

2324
# replace with a link to your input video
@@ -39,7 +40,7 @@ def start_encode():
3940
if client.error:
4041
raise QencodeClientException(client.message)
4142

42-
print 'The client created. Expire date: %s' % client.expire
43+
print('The client created. Expire date: %s' % client.expire)
4344

4445
task = client.create_task()
4546
task.start_time = 0.0
@@ -55,11 +56,11 @@ def start_encode():
5556
if task.error:
5657
raise QencodeTaskException(task.message)
5758

58-
print 'Start encode. Task: %s' % task.task_token
59+
print('Start encode. Task: %s' % task.task_token)
5960

6061
while True:
6162
status = task.status()
62-
print json.dumps(status, indent=2, sort_keys=True)
63+
print(json.dumps(status, indent=2, sort_keys=True))
6364
# print status
6465
if status['error'] or status['status'] == 'completed':
6566
break

sample-code/start_with_callback.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import json
55
import os.path
66
import sys
7-
import time
87

98
import qencode
109
from qencode import QencodeClientException, QencodeTaskException
@@ -17,7 +16,8 @@
1716
# replace with your API KEY (can be found in your Project settings on Qencode portal)
1817
API_KEY = 'your-api-qencode-key'
1918

20-
# replace with your Transcoding Profile ID (can be found in your Project settings on Qencode portal)
19+
# replace with your Transcoding Profile ID (can be found in your Project settings on
20+
# Qencode portal)
2121
TRANSCODING_PROFILEID = 'your-qencode-profile-id'
2222

2323
# replace with a link to your input video
@@ -26,12 +26,12 @@
2626

2727
def progress_changed_handler(status):
2828
if status['status'] != 'completed':
29-
print json.dumps(status, indent=2, sort_keys=True)
29+
print(json.dumps(status, indent=2, sort_keys=True))
3030

3131

3232
def task_completed_handler(status, task_token):
33-
print 'Completed task: %s' % task_token
34-
print json.dumps(status, indent=2, sort_keys=True)
33+
print('Completed task: %s' % task_token)
34+
print(json.dumps(status, indent=2, sort_keys=True))
3535

3636

3737
def start_encode():
@@ -41,13 +41,13 @@ def start_encode():
4141
:param api_url: string. not required
4242
:param api_version: int. not required. default 'v1'
4343
:return: task object
44-
"""
44+
"""
4545

4646
client = qencode.client(API_KEY)
4747
if client.error:
4848
raise QencodeClientException(client.message)
4949

50-
print 'The client created. Expire date: %s' % client.expire
50+
print('The client created. Expire date: %s' % client.expire)
5151

5252
task = client.create_task()
5353
task.start_time = 0.0
@@ -61,7 +61,7 @@ def start_encode():
6161
if task.error:
6262
raise QencodeTaskException(task.message)
6363

64-
print 'Start encode. Task: %s' % task.task_token
64+
print('Start encode. Task: %s' % task.task_token)
6565

6666
# using callback methods
6767
task.progress_changed(progress_changed_handler)

0 commit comments

Comments
 (0)