├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── README.rst ├── akamai ├── __init__.py └── netstorage │ ├── __init__.py │ └── netstorage.py ├── cms_netstorage.py ├── requirements.txt ├── setup.cfg ├── setup.py ├── test ├── secret_sample.py └── test_netstorage.py └── tox.ini /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | MANIFEST 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | 56 | # Sphinx documentation 57 | docs/_build/ 58 | 59 | # PyBuilder 60 | target/ 61 | 62 | #Ipython Notebook 63 | .ipynb_checkpoints 64 | 65 | # others 66 | .DS_Store 67 | test/secret.py 68 | spike/ 69 | 70 | 71 | upload-test-dir/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.6" 4 | - "2.7" 5 | - "3.3" 6 | - "3.4" 7 | - "3.5" 8 | - "3.6-dev" 9 | - "pypy" 10 | - "pypy3" 11 | 12 | install: 13 | - pip install -r requirements.txt 14 | 15 | script: 16 | - export TEST_MODE=TRAVIS 17 | - export NS_HOSTNAME=$NS_HOSTNAME 18 | - export NS_KEYNAME=$NS_KEYNAME 19 | - export NS_KEY=$NS_KEY 20 | - export NS_CPCODE=$NS_CPCODE 21 | - python test/test_netstorage.py -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2016 Akamai Technologies http://developer.akamai.com. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst requirements.txt setup.py -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | NetstorageAPI: Akamai Netstorage API for Python 2 | =============================================== 3 | 4 | .. image:: https://img.shields.io/pypi/v/netstorageapi.svg 5 | :target: https://pypi.python.org/pypi/netstorageapi 6 | 7 | .. image:: https://travis-ci.org/akamai/NetStorageKit-Python.svg?branch=master 8 | :target: https://travis-ci.org/akamai/NetStorageKit-Python 9 | 10 | .. image:: http://img.shields.io/:license-apache-blue.svg 11 | :target: https://github.com/akamai/NetStorageKit-Python/blob/master/LICENSE 12 | 13 | 14 | NetstorageAPI is Akamai Netstorage (File/Object Store) API for Python and uses `requests `_. 15 | NetstorageAPI supports Python 2.6–2.7 & 3.3–3.6, and runs great on PyPy as `requests `_. 16 | 17 | Important 18 | ------------ 19 | 20 | Akamai does not maintain or regulate this package. While it can be incorporated to assist you in API use, Akamai Technical Support will not offer assistance and Akamai cannot be held liable if issues arise from its use. 21 | 22 | Installation 23 | ------------ 24 | 25 | To install Netstorage API for Python: 26 | 27 | .. code-block:: bash 28 | 29 | $ pip install netstorageapi 30 | 31 | 32 | Example 33 | ------- 34 | 35 | .. code-block:: python 36 | 37 | from akamai.netstorage import Netstorage, NetstorageError 38 | 39 | NS_HOSTNAME = 'astin-nsu.akamaihd.net' 40 | NS_KEYNAME = 'astinapi' 41 | NS_KEY = 'xxxxxxxxxx' # Don't expose NS_KEY on public repository. 42 | NS_CPCODE = '360949' 43 | 44 | ns = Netstorage(NS_HOSTNAME, NS_KEYNAME, NS_KEY, ssl=False) # ssl is optional (default: False) 45 | local_source = 'hello.txt' 46 | netstorage_destination = '/{0}/hello.txt'.format(NS_CPCODE) # or '/{0}/'.format(NS_CPCODE) is same. 47 | ok, response = ns.upload(local_source, netstorage_destination) 48 | # "ok": True means 200 OK; If False, it's not 200 OK 49 | # "response": # Response object from requests.get|post|put 50 | print(response.text) 51 | # 'Request Processed' 52 | 53 | Methods 54 | ------- 55 | 56 | .. code-block:: python 57 | 58 | >>> ns.delete(NETSTORAGE_PATH) 59 | >>> dir_option = { 60 | ... 'max_entries': INTEGER, 61 | ... 'start': 'STRING', 62 | ... 'end': 'STRING', 63 | ... 'prefix': 'object-prefix', 64 | ... 'slash': 'both', 65 | ... 'encoding': 'utf-8' 66 | ... } 67 | >>> ns.dir(NETSTORAGE_PATH, dir_option) 68 | >>> ns.download(NETSTORAGE_SOURCE, LOCAL_DESTINATION) 69 | >>> ns.du(NETSTORAGE_PATH) 70 | >>> list_option = { 71 | ... 'max_entries': INTEGER, 72 | ... 'end': '/CPCODE/path', 73 | ... 'encoding': 'utf-8' 74 | ... } 75 | >>> ns.list(NETSTORAGE_PATH, list_option) 76 | >>> ns.mkdir(NETSTORAGE_PATH + DIRECTORY_NAME) 77 | >>> ns.mtime(NETSTORAGE_PATH, TIME) # ex) TIME: int(time.time()) 78 | >>> ns.quick_delete(NETSTORAGE_DIR) # needs to be enabled on the CP Code 79 | >>> ns.rename(NETSTORAGE_TARGET, NETSTORAGE_DESTINATION) 80 | >>> ns.rmdir(NETSTORAGE_DIR) 81 | >>> ns.stat(NETSTORAGE_PATH) 82 | >>> ns.stream_download(NETSTORAGE_SOURCE) 83 | >>> ns.stream_upload(DATA, NETSTORAGE_DESTINATION) 84 | >>> ns.symlink(NETSTORAGE_TARGET, NETSTORAGE_DESTINATION) 85 | >>> ns.upload(LOCAL_SOURCE_PATH, NETSTORAGE_DESTINATION, INDEX_ZIP=False) 86 | >>> 87 | >>> 88 | >>> # INFO: Return (True/False, Response Object from requests.get|post|put) 89 | >>> # True means 200 OK. 90 | >>> # INFO: Can "upload" Only a single file, not a directory. 91 | >>> # To use 'INDEX_ZIP=True', 92 | >>> # Must turn on index_zip on your Netstorage configuration 93 | >>> # WARN: Can raise NetstorageError at all methods. 94 | >>> 95 | 96 | 97 | Test 98 | ---- 99 | 100 | You can test all above methods with `unittest script `_ 101 | (NOTE: You should input NS_HOSTNAME, NS_KEYNAME, NS_KEY and NS_CPCODE in the script): 102 | 103 | .. code-block:: bash 104 | 105 | $ python test/test_netstorage.py 106 | [TEST] dir /360949 done 107 | [TEST] mkdir /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0 done 108 | [TEST] upload 2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done 109 | [TEST] stream_upload /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/stream_2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done 110 | [TEST] stream_download /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/stream_2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done 111 | [TEST] du done 112 | [TEST] mtime /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to 1508482349 done 113 | [TEST] stat done 114 | [TEST] symlink /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_lnk done 115 | [TEST] rename /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename done 116 | [TEST] download /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename done 117 | [TEST] delete /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/stream_2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done 118 | [TEST] delete /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename done 119 | [TEST] delete /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_lnk done 120 | [TEST] rmdir /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0 done 121 | [TEARDOWN] remove 2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt from local done 122 | [TEARDOWN] remove 2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename from local done 123 | . 124 | 125 | [TEST] Invalid ns path NetstorageError test done 126 | [TEST] Invalid local path NetstorageError test done 127 | [TEST] Download directory path NetstorageError test done 128 | . 129 | ---------------------------------------------------------------------- 130 | Ran 2 tests in x.xxxs 131 | 132 | OK 133 | 134 | 135 | Command 136 | ------- 137 | 138 | You can run the `script `_ with command line parameters. 139 | 140 | .. code-block:: bash 141 | 142 | $ python cms_netstorage.py -H astin-nsu.akamaihd.net -k astinapi -K xxxxxxxxxx -a dir /360949 143 | 144 | Use -h or --help option for more detail. 145 | 146 | 147 | Author 148 | ------ 149 | 150 | Astin Choi (achoi@akamai.com) 151 | 152 | 153 | License 154 | ------- 155 | 156 | Copyright 2016 Akamai Technologies, Inc. All rights reserved. 157 | 158 | Licensed under the Apache License, Version 2.0 (the "License"); 159 | you may not use this file except in compliance with the License. 160 | You may obtain a copy of the License at ``_. 161 | 162 | Unless required by applicable law or agreed to in writing, software 163 | distributed under the License is distributed on an "AS IS" BASIS, 164 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 165 | See the License for the specific language governing permissions and 166 | limitations under the License. 167 | -------------------------------------------------------------------------------- /akamai/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __import__('pkg_resources').declare_namespace(__name__) -------------------------------------------------------------------------------- /akamai/netstorage/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .netstorage import Netstorage, NetstorageError 4 | 5 | 6 | __all__ = ['Netstorage', 'NetstorageError'] -------------------------------------------------------------------------------- /akamai/netstorage/netstorage.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Original author: Astin Choi 4 | 5 | # Copyright 2016 Akamai Technologies http://developer.akamai.com. 6 | 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | 20 | import base64 21 | import hashlib 22 | import hmac 23 | import mmap 24 | import ntpath 25 | import os 26 | import random 27 | import sys 28 | import time 29 | if sys.version_info[0] >= 3: 30 | from urllib.parse import quote_plus, quote, urlencode 31 | else: 32 | from urllib import quote_plus, quote, urlencode 33 | 34 | import requests 35 | 36 | 37 | class NetstorageError(Exception): 38 | """Base-class for all exceptions raised by Netstorage Class""" 39 | 40 | 41 | class Netstorage: 42 | def __init__(self, hostname, keyname, key, ssl=False): 43 | if not (hostname and keyname and key): 44 | raise NetstorageError('[NetstorageError] You should input netstorage hostname, keyname and key all') 45 | 46 | self.hostname = hostname 47 | self.keyname = keyname 48 | self.key = key 49 | self.ssl = 's' if ssl else '' 50 | self.http_client = requests.Session() 51 | 52 | 53 | def _download_data_from_response(self, response, ns_path, local_destination, chunk_size=16*1024): 54 | if not local_destination: 55 | local_destination = ntpath.basename(ns_path) 56 | elif os.path.isdir(local_destination): 57 | local_destination = os.path.join(local_destination, ntpath.basename(ns_path)) 58 | 59 | if response.status_code == 200: 60 | try: 61 | with open(local_destination, 'wb') as f: 62 | for chunk in response.iter_content(chunk_size): 63 | if chunk: 64 | f.write(chunk) 65 | except Exception as e: 66 | raise NetstorageError(e) 67 | 68 | def _upload_data_to_request(self, source): 69 | mmapped_data = None 70 | try: 71 | with open(source, 'rb') as f: 72 | if os.fstat(f.fileno()).st_size == 0: 73 | mmapped_data = '' 74 | else: 75 | mmapped_data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) 76 | except Exception as e: 77 | if mmapped_data: mmapped_data.close() 78 | raise NetstorageError(e) 79 | 80 | return mmapped_data 81 | 82 | def _request(self, **kwargs): 83 | path = kwargs['path'] 84 | if not path.startswith('/'): 85 | raise NetstorageError('[NetstorageError] Invalid netstorage path') 86 | 87 | path = quote(path) 88 | acs_action = "version=1&action={0}".format(kwargs['action']) 89 | acs_auth_data = "5, 0.0.0.0, 0.0.0.0, {0}, {1}, {2}".format( 90 | int(time.time()), 91 | str(random.getrandbits(32)), 92 | self.keyname) 93 | sign_string = "{0}\nx-akamai-acs-action:{1}\n".format(path, acs_action) 94 | message = acs_auth_data + sign_string 95 | hash_ = hmac.new(self.key.encode(), message.encode(), hashlib.sha256).digest() 96 | 97 | acs_auth_sign = base64.b64encode(hash_) 98 | 99 | request_url = "http{0}://{1}{2}".format(self.ssl, self.hostname, path) 100 | 101 | headers = { 102 | 'X-Akamai-ACS-Action': acs_action, 103 | 'X-Akamai-ACS-Auth-Data': acs_auth_data, 104 | 'X-Akamai-ACS-Auth-Sign': acs_auth_sign, 105 | 'Accept-Encoding': 'identity', 106 | 'User-Agent': 'NetStorageKit-Python' 107 | } 108 | 109 | response = None 110 | if kwargs['method'] == 'GET': 111 | if kwargs['action'] == 'download': 112 | response = self.http_client.get(request_url, headers=headers, stream=True) 113 | if 'stream' not in kwargs.keys(): 114 | self._download_data_from_response(response, kwargs['path'], kwargs['destination']) 115 | else: 116 | response = self.http_client.get(request_url, headers=headers) 117 | 118 | elif kwargs['method'] == 'POST': 119 | response = self.http_client.post(request_url, headers=headers) 120 | 121 | elif kwargs['method'] == 'PUT': # Use only upload 122 | if 'stream' in kwargs.keys(): 123 | response = self.http_client.put(request_url, headers=headers, data=kwargs['stream']) 124 | elif kwargs['action'].startswith('upload'): 125 | mmapped_data = self._upload_data_to_request(kwargs['source']) 126 | response = self.http_client.put(request_url, headers=headers, data=mmapped_data) 127 | if not isinstance(mmapped_data, str): 128 | mmapped_data.close() 129 | 130 | return response.status_code == 200, response 131 | 132 | def dir(self, ns_path, option={}): 133 | option = "dir&format=xml&{0}".format(urlencode(option)) 134 | return self._request(action=option, 135 | method='GET', 136 | path=ns_path) 137 | 138 | def list(self, ns_path, option={}): 139 | option = "list&format=xml&{0}".format(urlencode(option)) 140 | return self._request(action=option, 141 | method='GET', 142 | path=ns_path) 143 | 144 | def download(self, ns_source, local_destination=''): 145 | if ns_source.endswith('/'): 146 | raise NetstorageError("[NetstorageError] Nestorage download path shouldn't be a directory: {0}".format(ns_source)) 147 | return self._request(action='download', 148 | method='GET', 149 | path=ns_source, 150 | destination=local_destination) 151 | 152 | def stream_download(self, ns_source): 153 | return self._request(action='download', 154 | method='GET', 155 | path=ns_source, 156 | stream=True) 157 | 158 | def du(self, ns_path): 159 | return self._request(action='du&format=xml', 160 | method='GET', 161 | path=ns_path) 162 | 163 | def stat(self, ns_path): 164 | return self._request(action='stat&format=xml', 165 | method='GET', 166 | path=ns_path) 167 | 168 | def mkdir(self, ns_path): 169 | return self._request(action='mkdir', 170 | method='POST', 171 | path=ns_path) 172 | 173 | def rmdir(self, ns_path): 174 | return self._request(action='rmdir', 175 | method='POST', 176 | path=ns_path) 177 | 178 | def mtime(self, ns_path, mtime): 179 | return self._request(action='mtime&format=xml&mtime={0}'.format(mtime), 180 | method='POST', 181 | path=ns_path) 182 | 183 | def delete(self, ns_path): 184 | return self._request(action='delete', 185 | method='POST', 186 | path=ns_path) 187 | 188 | def quick_delete(self, ns_path): 189 | return self._request(action='quick-delete&quick-delete=imreallyreallysure', 190 | method='POST', 191 | path=ns_path) 192 | 193 | def rename(self, ns_target, ns_destination): 194 | return self._request(action='rename&destination={0}'.format(quote_plus(ns_destination)), 195 | method='POST', 196 | path=ns_target) 197 | 198 | def symlink(self, ns_target, ns_destination): 199 | return self._request(action='symlink&target={0}'.format(quote_plus(ns_target)), 200 | method='POST', 201 | path=ns_destination) 202 | 203 | def upload(self, local_source, ns_destination, index_zip=False): 204 | if os.path.isfile(local_source): 205 | if ns_destination.endswith('/'): 206 | ns_destination = "{0}{1}".format(ns_destination, ntpath.basename(local_source)) 207 | else: 208 | raise NetstorageError("[NetstorageError] {0} doesn't exist or is directory".format(local_source)) 209 | 210 | action = 'upload' 211 | if index_zip is True or str(index_zip).lower() == 'true': 212 | action = action + '&index-zip=1' 213 | 214 | return self._request(action=action, 215 | method='PUT', 216 | source=local_source, 217 | path=ns_destination) 218 | 219 | def stream_upload(self, data, ns_destination): 220 | return self._request(action='upload', 221 | method='PUT', 222 | stream=data, 223 | path=ns_destination) 224 | -------------------------------------------------------------------------------- /cms_netstorage.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Original author: Astin Choi 4 | 5 | # Copyright 2016 Akamai Technologies http://developer.akamai.com. 6 | 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | #adding folderUpload support 19 | import os 20 | import ast 21 | import optparse, sys 22 | from akamai.netstorage import Netstorage 23 | 24 | class NetstorageParser(optparse.OptionParser): 25 | def format_epilog(self, formatter): 26 | return self.epilog 27 | 28 | def print_result(response, action): 29 | print("=== Request Header ===") 30 | print(response.request.headers) 31 | print("=== Response Code ===") 32 | print(response.status_code) 33 | print("=== Response Header ===") 34 | print(response.headers) 35 | if action != 'download': 36 | print("=== Response Content ===") 37 | print(response.text) 38 | 39 | # Uploads a single file to NetStorage 40 | def upload_file(ns, local_file, remote_file): 41 | print(f"Uploading {local_file} to {remote_file}") 42 | 43 | # If the upload method requires three arguments 44 | ok, res = ns.upload(local_file, remote_file) 45 | 46 | # Check if the upload was successful 47 | if ok: 48 | print(f"Upload successful: {local_file} -> {remote_file}") 49 | else: 50 | print(f"Upload failed: {local_file} -> {remote_file}") 51 | 52 | return ok, res 53 | 54 | # Recursively upload directory contents 55 | def upload_directory(ns, local_dir, remote_dir): 56 | for root, dirs, files in os.walk(local_dir): 57 | for file in files: 58 | local_file_path = os.path.join(root, file) 59 | relative_path = os.path.relpath(local_file_path, local_dir) # Preserve directory structure 60 | remote_file_path = os.path.join(remote_dir, relative_path).replace("\\", "/") # Ensure remote path uses forward slashes 61 | ok, response = upload_file(ns, local_file_path, remote_file_path) 62 | print_result(response, 'upload') 63 | 64 | if __name__ == '__main__': 65 | action_list = '''\ 66 | dir: to list the contents of the directory /123456 67 | dir /123456 68 | upload: to upload file.txt or a folder to /123456 directory 69 | upload file.txt /123456/ or 70 | upload uploaddir /123456/uploaddir 71 | stat: to display status of /123456/file.txt 72 | stat /123456/file.txt 73 | du: to display disk usage on directory /123456 74 | du /123456 75 | download: To download /123456/file.txt 76 | download /123456/file.txt or 77 | download /123456/file.txt LOCAL_PATH 78 | mtime: to set the timestamp of /123456/file.txt to 1463042904 in epoch format) 79 | mtime /123456/file.txt 1463042904 80 | quick-delete: to delete /123456/dir1 recursively (quick-delete needs to be enabled on the CP Code): 81 | quick-delete /123456/dir1 82 | rename: to rename /123456/file.txt to /123456/newfile.txt 83 | rename /123456/file.txt /123456/newfile.txt 84 | symlink: to create a symlink /123456/file.txt_symlink pointing to /123456/file.txt 85 | symlink /123456/file.txt /123456/file.txt_symlink 86 | delete: to delete /123456/file.txt 87 | delete /123456/file.txt 88 | mkdir: to create /123456/dir1 89 | mkdir /123456/dir1 90 | rmdir: to delete /123456/dir1 (directory needs to be empty) 91 | rmdir /123456/dir1 92 | ''' 93 | usage = 'Usage: python cms_netstorage.py -H [hostname] -k [keyname] -K [key] -a [action_options] ..' 94 | parser = NetstorageParser(usage=usage, epilog=action_list) 95 | 96 | parser.add_option( 97 | '-H', '--host', dest='hostname', 98 | help='Netstorage API hostname ex) xxx-nsu.akamaihd.net') 99 | parser.add_option( 100 | '-k', '--keyname', dest='keyname', 101 | help='Netstorage API keyname ex) xxxxx') 102 | parser.add_option( 103 | '-K', '--key', dest='key', 104 | help='Netstorage API key ex) xxxxxxxxxxxxx') 105 | parser.add_option( 106 | '-a', '--action', dest='action') 107 | 108 | (options, args) = parser.parse_args() 109 | 110 | if options.hostname and options.keyname and options.key and options.action: 111 | ns = Netstorage(options.hostname, options.keyname, options.key) 112 | 113 | try: 114 | skipFinalLog = False 115 | res = None 116 | if options.action == 'delete': 117 | ok, res = ns.delete(args[0]) 118 | elif options.action == 'dir': 119 | if len(args) >= 2: 120 | ok, res = ns.dir(args[0], ast.literal_eval(args[1])) 121 | else: 122 | ok, res = ns.dir(args[0]) 123 | elif options.action == 'list': 124 | if len(args) >= 2: 125 | ok, res = ns.list(args[0], ast.literal_eval(args[1])) 126 | else: 127 | ok, res = ns.list(args[0]) 128 | elif options.action == 'download': 129 | ok, res = ns.download(args[0], args[1]) 130 | elif options.action == 'du': 131 | ok, res = ns.du(args[0]) 132 | elif options.action == 'mkdir': 133 | ok, res = ns.mkdir(args[0]) 134 | elif options.action == 'mtime': 135 | ok, res = ns.mtime(args[0], args[1]) 136 | elif options.action == 'quick-delete': 137 | ok, res = ns.quick_delete(args[0]) 138 | elif options.action == 'rmdir': 139 | ok, res = ns.rmdir(args[0]) 140 | elif options.action == 'stat': 141 | ok, res = ns.stat(args[0]) 142 | elif options.action == 'symlink': 143 | ok, res = ns.symlink(args[0], args[1]) 144 | elif options.action == 'upload': 145 | local_path = args[0] 146 | remote_path = args[1] 147 | 148 | if os.path.isdir(local_path): 149 | # Upload directory recursively 150 | skipFinalLog = True 151 | upload_directory(ns, local_path, remote_path) 152 | elif os.path.isfile(local_path): 153 | # Upload single file 154 | ok, res = upload_file(ns, local_path, remote_path) 155 | 156 | else: 157 | print(f"Invalid path: {local_path}. Must be a file or directory.") 158 | elif options.action == 'rename': 159 | ok, res = ns.rename(args[0], args[1]) 160 | else: 161 | print("Invalid action.\nUse option -h or --help") 162 | exit() 163 | if not skipFinalLog: 164 | print_result(res, options.action) 165 | 166 | except IndexError as e: 167 | if options.action == 'download' and args[0]: 168 | ok, res = ns.download(args[0]) 169 | print_result(res, options.action) 170 | else: 171 | print("Invalid argument.\n") 172 | parser.print_help() 173 | else: 174 | print("You should input hostname, keyname, key and action.\n") 175 | parser.print_help() 176 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from setuptools import setup, find_packages 4 | 5 | 6 | with open('README.rst', 'r') as f: 7 | readme = f.read() 8 | 9 | setup ( 10 | name = 'netstorageapi', 11 | version = '1.2.13', 12 | description = 'Akamai Netstorage API for Python', 13 | long_description = readme, 14 | namespace_packages=['akamai'], 15 | packages=find_packages(exclude=['spike', 'test']), 16 | install_requires = [ 17 | 'requests' 18 | ], 19 | author = 'Astin Choi', 20 | author_email = 'asciineo@gmail.com', 21 | url = 'https://github.com/akamai/NetStorageKit-Python', 22 | license='Apache 2.0', 23 | keywords='netstorage akamai open api', 24 | classifiers=[ 25 | 'Intended Audience :: Developers', 26 | 'Programming Language :: Python', 27 | 'Programming Language :: Python :: 2.6', 28 | 'Programming Language :: Python :: 2.7', 29 | 'Programming Language :: Python :: 3', 30 | 'Programming Language :: Python :: 3.3', 31 | 'Programming Language :: Python :: 3.4', 32 | 'Programming Language :: Python :: 3.5', 33 | 'Programming Language :: Python :: 3.6', 34 | 'Programming Language :: Python :: Implementation :: CPython', 35 | 'Programming Language :: Python :: Implementation :: PyPy' 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /test/secret_sample.py: -------------------------------------------------------------------------------- 1 | NS_HOSTNAME = "YOUR_HOSTNAME" 2 | NS_KEYNAME = "YOUR_KEYNAME" 3 | NS_KEY = "YOUR_KEY" 4 | NS_CPCODE = "YOUR_CPCODE" -------------------------------------------------------------------------------- /test/test_netstorage.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Original author: Astin Choi 4 | 5 | # Copyright 2016 Akamai Technologies http://developer.akamai.com. 6 | 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | 20 | import os 21 | import sys 22 | import time 23 | import unittest 24 | import uuid 25 | import xml.etree.ElementTree as ET 26 | 27 | sys.path.append("akamai/netstorage"); sys.path.append("../akamai/netstorage") 28 | from netstorage import Netstorage, NetstorageError 29 | 30 | if os.environ.get('TEST_MODE') == 'TRAVIS': 31 | NS_HOSTNAME = os.environ['NS_HOSTNAME'] 32 | NS_KEYNAME = os.environ['NS_KEYNAME'] 33 | NS_KEY = os.environ['NS_KEY'] 34 | NS_CPCODE = os.environ['NS_CPCODE'] 35 | else: 36 | import secret 37 | NS_HOSTNAME = secret.NS_HOSTNAME 38 | NS_KEYNAME = secret.NS_KEYNAME 39 | NS_KEY = secret.NS_KEY 40 | NS_CPCODE = secret.NS_CPCODE 41 | 42 | 43 | class TestNetstorage(unittest.TestCase): 44 | 45 | def setUp(self): 46 | self.cpcode_path = NS_CPCODE 47 | self.temp_ns_dir = "/{0}/{1}".format(self.cpcode_path, str(uuid.uuid4())) 48 | self.temp_file = "{0}.txt".format(str(uuid.uuid4())) 49 | self.temp_ns_file = "{0}/{1}".format(self.temp_ns_dir, self.temp_file) 50 | self.temp_ns_stream_file = "{0}/stream_{1}".format(self.temp_ns_dir, self.temp_file) 51 | 52 | self.ns = Netstorage(NS_HOSTNAME, NS_KEYNAME, NS_KEY) 53 | 54 | def tearDown(self): 55 | # delete temp files for local 56 | if os.path.exists(self.temp_file): 57 | os.remove(self.temp_file) 58 | print("[TEARDOWN] remove {0} from local done".format(self.temp_file)) 59 | 60 | if os.path.exists(self.temp_file + '_rename'): 61 | os.remove(self.temp_file + '_rename') 62 | print("[TEARDOWN] remove {0} from local done".format(self.temp_file + '_rename')) 63 | 64 | # delete temp files for netstorage 65 | ok, _ = self.ns.delete(self.temp_ns_file) 66 | if ok: 67 | print("[TEARDOWN] delete {0} done".format(self.temp_ns_file)) 68 | ok, _ = self.ns.delete(self.temp_ns_file + '_lnk') 69 | if ok: 70 | print("[TEARDOWN] delete {0} done".format(self.temp_ns_file + '_lnk')) 71 | ok, _ = self.ns.delete(self.temp_ns_file + '_rename') 72 | if ok: 73 | print("[TEARDOWN] delete {0} done".format(self.temp_ns_file + '_rename')) 74 | ok, _ = self.ns.rmdir(self.temp_ns_dir) 75 | if ok: 76 | print("[TEARDOWN] rmdir {0} done".format(self.temp_ns_dir)) 77 | 78 | def test_netstorage(self): 79 | # dir 80 | ok, _ = self.ns.dir("/" + self.cpcode_path) 81 | self.assertEqual(True, ok, "dir fail.") 82 | print("[TEST] dir {0} done".format("/" + self.cpcode_path)) 83 | 84 | # mkdir 85 | ok, _ = self.ns.mkdir(self.temp_ns_dir) 86 | self.assertEqual(True, ok, "mkdir fail.") 87 | print("[TEST] mkdir {0} done".format(self.temp_ns_dir)) 88 | 89 | # upload 90 | with open(self.temp_file, 'wt') as f: 91 | f.write("Hello, Netstorage API World!") 92 | ok, res = self.ns.upload(self.temp_file, self.temp_ns_file) 93 | self.assertEqual(True, ok, "upload fail.") 94 | print("[TEST] upload {0} to {1} done".format(self.temp_file, self.temp_ns_file)) 95 | 96 | # stream_upload 97 | stream_upload_text = 'Stream Upload!' 98 | ok, res = self.ns.stream_upload(stream_upload_text, self.temp_ns_stream_file) 99 | self.assertEqual(True, ok, "stream upload fail") 100 | print("[TEST] stream_upload {0} done".format(self.temp_ns_stream_file)) 101 | 102 | # stream_download 103 | ok, res = self.ns.stream_download(self.temp_ns_stream_file) 104 | self.assertEqual(True, ok, "stream download fail") 105 | self.assertEqual(stream_upload_text, res.text, "stream download fail") 106 | print("[TEST] stream_download {0} done".format(self.temp_ns_stream_file)) 107 | 108 | # list 109 | ok, _ = self.ns.list("/" + self.cpcode_path, { 110 | 'max_entries': 1, 111 | 'end': self.temp_ns_dir, 112 | 'encoding': 'utf-8' 113 | } 114 | ) 115 | self.assertEqual(True, ok, "dir fail.") 116 | print("[TEST] dir {0} done".format("/" + self.cpcode_path)) 117 | 118 | # du 119 | ok, res = self.ns.du(self.temp_ns_dir) 120 | self.assertEqual(True, ok) 121 | # xml_tree = ET.fromstring(res.text) 122 | # self.assertEqual(str(os.stat(self.temp_file).st_size), xml_tree[0].get('bytes'), "du fail.") 123 | print("[TEST] du done") 124 | 125 | # mtime 126 | current_time = int(time.time()) 127 | ok, _ = self.ns.mtime(self.temp_ns_file, current_time) 128 | self.assertEqual(True, ok, "mtime fail.") 129 | print("[TEST] mtime {0} to {1} done".format(self.temp_ns_file, current_time)) 130 | 131 | # stat 132 | ok, res = self.ns.stat(self.temp_ns_file) 133 | self.assertEqual(True, ok, "stat fail.") 134 | xml_tree = ET.fromstring(res.text) 135 | self.assertEqual(str(current_time), xml_tree[0].get('mtime')) 136 | print("[TEST] stat done") 137 | 138 | # symlink 139 | ok, _ = self.ns.symlink(self.temp_ns_file, self.temp_ns_file + "_lnk") 140 | self.assertEqual(True, ok, "symlink fail.") 141 | print("[TEST] symlink {0} to {1} done".format(self.temp_ns_file, self.temp_ns_file + "_lnk")) 142 | 143 | # rename 144 | ok, _ = self.ns.rename(self.temp_ns_file, self.temp_ns_file + "_rename") 145 | self.assertEqual(True, ok, "rename fail.") 146 | print("[TEST] rename {0} to {1} done".format(self.temp_ns_file, self.temp_ns_file + "_rename")) 147 | 148 | # download 149 | ok, _ = self.ns.download(self.temp_ns_file + "_rename") 150 | self.assertEqual(True, ok, "download fail.") 151 | print("[TEST] download {0} done".format(self.temp_ns_file + "_rename")) 152 | 153 | # delete 154 | ok, _ = self.ns.delete(self.temp_ns_stream_file) 155 | self.assertEqual(True, ok, "delete fail.") 156 | print("[TEST] delete {0} done".format(self.temp_ns_stream_file)) 157 | ok, _ = self.ns.delete(self.temp_ns_file + "_rename") 158 | self.assertEqual(True, ok, "delete fail.") 159 | print("[TEST] delete {0} done".format(self.temp_ns_file + "_rename")) 160 | ok, _ = self.ns.delete(self.temp_ns_file + "_lnk") 161 | self.assertEqual(True, ok, "delete fail.") 162 | print("[TEST] delete {0} done".format(self.temp_ns_file + "_lnk")) 163 | 164 | # rmdir 165 | ok, _ = self.ns.rmdir(self.temp_ns_dir) 166 | self.assertEqual(True, ok, "rmdir fail.") 167 | print("[TEST] rmdir {0} done".format(self.temp_ns_dir)) 168 | 169 | def test_netstorage_exception(self): 170 | print(os.linesep) 171 | if not (sys.version_info[0] == 2 and sys.version_info[1] <= 6): 172 | with self.assertRaises(NetstorageError): 173 | self.ns.dir("Invalid ns path") 174 | print("[TEST] Invalid ns path NetstorageError test done") 175 | 176 | with self.assertRaises(NetstorageError): 177 | self.ns.upload("Invalid local path", self.temp_ns_file) 178 | print("[TEST] Invalid local path NetstorageError test done") 179 | 180 | with self.assertRaises(NetstorageError): 181 | self.ns.download("/123456/directory/", self.temp_file) 182 | print("[TEST] Download directory path NetstorageError test done") 183 | 184 | 185 | if __name__ == '__main__': 186 | unittest.main() -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py26,py27,py33,py34,py35,py36,pypy,pypy3 3 | 4 | [testenv] 5 | passenv = * 6 | 7 | commands = 8 | python test_netstorage.py --------------------------------------------------------------------------------