pytolino 1.4__tar.gz → 1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytolino-1.4/src/pytolino.egg-info → pytolino-1.6}/PKG-INFO +3 -2
- {pytolino-1.4 → pytolino-1.6}/pyproject.toml +1 -1
- {pytolino-1.4 → pytolino-1.6}/src/pytolino/tolino_cloud.py +15 -1
- {pytolino-1.4 → pytolino-1.6/src/pytolino.egg-info}/PKG-INFO +3 -2
- {pytolino-1.4 → pytolino-1.6}/tests/test_tolino_cloud.py +34 -11
- {pytolino-1.4 → pytolino-1.6}/LICENSE +0 -0
- {pytolino-1.4 → pytolino-1.6}/MANIFEST.in +0 -0
- {pytolino-1.4 → pytolino-1.6}/README.rst +0 -0
- {pytolino-1.4 → pytolino-1.6}/setup.cfg +0 -0
- {pytolino-1.4 → pytolino-1.6}/src/pytolino/__init__.py +0 -0
- {pytolino-1.4 → pytolino-1.6}/src/pytolino/servers_settings.ini +0 -0
- {pytolino-1.4 → pytolino-1.6}/src/pytolino.egg-info/SOURCES.txt +0 -0
- {pytolino-1.4 → pytolino-1.6}/src/pytolino.egg-info/dependency_links.txt +0 -0
- {pytolino-1.4 → pytolino-1.6}/src/pytolino.egg-info/requires.txt +0 -0
- {pytolino-1.4 → pytolino-1.6}/src/pytolino.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pytolino
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6
|
|
4
4
|
Summary: client for tolino cloud
|
|
5
5
|
Author: Imam Usmani
|
|
6
6
|
Project-URL: Source Code, https://github.com/ImamAzim/pytolino
|
|
@@ -23,6 +23,7 @@ Requires-Dist: sphinx; extra == "dev"
|
|
|
23
23
|
Requires-Dist: build; extra == "dev"
|
|
24
24
|
Requires-Dist: twine; extra == "dev"
|
|
25
25
|
Requires-Dist: sphinx-rtd-theme; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
26
27
|
|
|
27
28
|
pytolino
|
|
28
29
|
===================
|
|
@@ -6,11 +6,13 @@ import configparser
|
|
|
6
6
|
import platform
|
|
7
7
|
import logging
|
|
8
8
|
from urllib.parse import urlparse, parse_qs
|
|
9
|
+
from urllib3.util import Retry
|
|
9
10
|
import json
|
|
10
11
|
import time
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
import requests
|
|
15
|
+
from requests.adapters import HTTPAdapter
|
|
14
16
|
import mechanize
|
|
15
17
|
|
|
16
18
|
|
|
@@ -27,6 +29,8 @@ servers_settings = configparser.ConfigParser()
|
|
|
27
29
|
servers_settings.read(SERVERS_SETTINGS_FILE_PATH)
|
|
28
30
|
|
|
29
31
|
PARTNERS = servers_settings.sections()
|
|
32
|
+
TOTAL_RETRY =5
|
|
33
|
+
STATUS_FORCELIST = [404]
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
def main():
|
|
@@ -124,8 +128,17 @@ class Client(object):
|
|
|
124
128
|
self.token_expires = None
|
|
125
129
|
|
|
126
130
|
self.server_settings = servers_settings[server_name]
|
|
127
|
-
self.session = requests.
|
|
131
|
+
self.session = requests.Session()
|
|
132
|
+
retry_strategy = Retry(
|
|
133
|
+
total=TOTAL_RETRY,
|
|
134
|
+
status_forcelist=STATUS_FORCELIST,
|
|
135
|
+
backoff_factor=2,
|
|
136
|
+
allowed_methods=frozenset(['GET', 'POST']))
|
|
137
|
+
adapter = HTTPAdapter(max_retries=retry_strategy)
|
|
138
|
+
self.session.mount('http://', adapter)
|
|
139
|
+
self.session.mount('https://', adapter)
|
|
128
140
|
self.browser = mechanize.Browser()
|
|
141
|
+
self.browser.set_handle_robots(False)
|
|
129
142
|
self.server_name = server_name
|
|
130
143
|
|
|
131
144
|
def login(self, username, password):
|
|
@@ -195,6 +208,7 @@ class Client(object):
|
|
|
195
208
|
allow_redirects=False,
|
|
196
209
|
)
|
|
197
210
|
self._log_requests(host_response)
|
|
211
|
+
|
|
198
212
|
try:
|
|
199
213
|
j = host_response.json()
|
|
200
214
|
self.access_token = j['access_token']
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pytolino
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6
|
|
4
4
|
Summary: client for tolino cloud
|
|
5
5
|
Author: Imam Usmani
|
|
6
6
|
Project-URL: Source Code, https://github.com/ImamAzim/pytolino
|
|
@@ -23,6 +23,7 @@ Requires-Dist: sphinx; extra == "dev"
|
|
|
23
23
|
Requires-Dist: build; extra == "dev"
|
|
24
24
|
Requires-Dist: twine; extra == "dev"
|
|
25
25
|
Requires-Dist: sphinx-rtd-theme; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
26
27
|
|
|
27
28
|
pytolino
|
|
28
29
|
===================
|
|
@@ -9,12 +9,14 @@ import os
|
|
|
9
9
|
import unittest
|
|
10
10
|
import configparser
|
|
11
11
|
import logging
|
|
12
|
+
import time
|
|
13
|
+
import logging
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
from pytolino.tolino_cloud import Client, PytolinoException
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
logging.basicConfig(level=logging.INFO)
|
|
19
|
+
# logging.basicConfig(level=logging.INFO)
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
class TestClient(unittest.TestCase):
|
|
@@ -130,11 +132,12 @@ def upload_test():
|
|
|
130
132
|
username, password = get_credentials()
|
|
131
133
|
client = Client()
|
|
132
134
|
client.login(username, password)
|
|
135
|
+
client.register()
|
|
133
136
|
ebook_id = client.upload(EPUB_PATH)
|
|
134
137
|
print(ebook_id)
|
|
135
138
|
with open(EPUB_ID_PATH, 'w') as myfile:
|
|
136
139
|
myfile.write(ebook_id)
|
|
137
|
-
|
|
140
|
+
client.unregister()
|
|
138
141
|
client.logout()
|
|
139
142
|
|
|
140
143
|
def collection_test():
|
|
@@ -165,12 +168,15 @@ def inventory_test():
|
|
|
165
168
|
username, password = get_credentials()
|
|
166
169
|
client = Client()
|
|
167
170
|
client.login(username, password)
|
|
171
|
+
client.register()
|
|
168
172
|
inventory = client.get_inventory()
|
|
173
|
+
client.unregister()
|
|
169
174
|
client.logout()
|
|
170
175
|
print(inventory[0].keys())
|
|
171
176
|
for item in inventory:
|
|
172
177
|
metadata = item['epubMetaData']
|
|
173
|
-
print(metadata
|
|
178
|
+
print(metadata['title'])
|
|
179
|
+
# print(metadata.keys())
|
|
174
180
|
|
|
175
181
|
|
|
176
182
|
def delete_test():
|
|
@@ -186,20 +192,32 @@ def delete_test():
|
|
|
186
192
|
|
|
187
193
|
|
|
188
194
|
def metadata_test():
|
|
189
|
-
|
|
195
|
+
|
|
196
|
+
metadata = dict(
|
|
197
|
+
title='mytitle',
|
|
198
|
+
isbn='myisbn',
|
|
199
|
+
language='mylanguage',
|
|
200
|
+
author='myauthor',
|
|
201
|
+
publisher='mypublisher',
|
|
202
|
+
issued=time.time(),
|
|
203
|
+
)
|
|
190
204
|
with open(EPUB_ID_PATH, 'r') as myfile:
|
|
191
205
|
epub_id = myfile.read()
|
|
192
206
|
|
|
193
207
|
username, password = get_credentials()
|
|
194
208
|
client = Client()
|
|
195
209
|
client.login(username, password)
|
|
196
|
-
client.
|
|
210
|
+
client.register()
|
|
211
|
+
|
|
212
|
+
client.upload_metadata(epub_id, **metadata)
|
|
213
|
+
|
|
197
214
|
inventory = client.get_inventory()
|
|
198
|
-
for
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
215
|
+
book = [el for el in inventory if el['epubMetaData']['identifier']==epub_id][0]
|
|
216
|
+
online_metadata = book['epubMetaData']
|
|
217
|
+
for key in metadata:
|
|
218
|
+
print(key, online_metadata[key])
|
|
219
|
+
|
|
220
|
+
client.unregister()
|
|
203
221
|
client.logout()
|
|
204
222
|
|
|
205
223
|
def add_cover_test():
|
|
@@ -220,7 +238,12 @@ def add_cover_test():
|
|
|
220
238
|
|
|
221
239
|
|
|
222
240
|
if __name__ == '__main__':
|
|
241
|
+
logging.basicConfig(level=logging.INFO)
|
|
242
|
+
# register_test()
|
|
243
|
+
# unregister_test()
|
|
244
|
+
client_method_tests()
|
|
223
245
|
# upload_test()
|
|
224
|
-
|
|
246
|
+
# delete_test()
|
|
247
|
+
# add_cover_test()
|
|
225
248
|
# metadata_test()
|
|
226
249
|
# inventory_test()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|