├── LICENSE
├── pyacd
├── status.py
├── types.py
├── exception.py
├── multipart.py
├── __init__.py
├── auth.py
├── connection.py
├── apiresponse.py
└── api.py
├── setup.py
├── README
├── bin
├── acdcat
├── acdmkdir
├── acdrecycle
├── acdget
├── acdlist
└── acdput
└── test.py
/LICENSE:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2011 anatanokeitai.com(sakurai_youhei)
2 | #
3 | # Permission is hereby granted, free of charge, to any person obtaining a
4 | # copy of this software and associated documentation files (the
5 | # "Software"), to deal in the Software without restriction, including
6 | # without limitation the rights to use, copy, modify, merge, publish, dis-
7 | # tribute, sublicense, and/or sell copies of the Software, and to permit
8 | # persons to whom the Software is furnished to do so, subject to the fol-
9 | # lowing conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included
12 | # in all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | # IN THE SOFTWARE.
21 | #
22 | # The Software shall be used for *YOUNGER* than you, not *OLDER*.
23 | #
24 |
--------------------------------------------------------------------------------
/pyacd/status.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2011 anatanokeitai.com(sakurai_youhei)
2 | #
3 | # Permission is hereby granted, free of charge, to any person obtaining a
4 | # copy of this software and associated documentation files (the
5 | # "Software"), to deal in the Software without restriction, including
6 | # without limitation the rights to use, copy, modify, merge, publish, dis-
7 | # tribute, sublicense, and/or sell copies of the Software, and to permit
8 | # persons to whom the Software is furnished to do so, subject to the fol-
9 | # lowing conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included
12 | # in all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | # IN THE SOFTWARE.
21 | #
22 | # The Software shall be used for Younger than you, not Older.
23 | #
24 |
25 | """Entity statuses in Amazon Cloud Drive
26 |
27 | AVIABLE means normal status
28 | PENDING means that file was created but have not been finished.
29 | """
30 |
31 | AVIABLE="AVIABLE"
32 | PENDING="PENDING"
33 |
--------------------------------------------------------------------------------
/pyacd/types.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2011 anatanokeitai.com(sakurai_youhei)
2 | #
3 | # Permission is hereby granted, free of charge, to any person obtaining a
4 | # copy of this software and associated documentation files (the
5 | # "Software"), to deal in the Software without restriction, including
6 | # without limitation the rights to use, copy, modify, merge, publish, dis-
7 | # tribute, sublicense, and/or sell copies of the Software, and to permit
8 | # persons to whom the Software is furnished to do so, subject to the fol-
9 | # lowing conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included
12 | # in all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | # IN THE SOFTWARE.
21 | #
22 | # The Software shall be used for Younger than you, not Older.
23 | #
24 |
25 | """Entity types in Amazon Cloud Drive
26 |
27 | ROOT means "/".
28 | RECYCLE means "/RecycleBin".
29 | FOLDER means folder.
30 | FILE means file.
31 | """
32 |
33 | ROOT="ROOT"
34 | RECYCLE="RECYCLE"
35 | FOLDER="FOLDER"
36 | FILE="FILE"
37 |
38 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # Copyright (c) 2012 Matt Luongo http://mattluongo.com
4 | # All rights reserved.
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a
7 | # copy of this software and associated documentation files (the
8 | # "Software"), to deal in the Software without restriction, including
9 | # without limitation the rights to use, copy, modify, merge, publish, dis-
10 | # tribute, sublicense, and/or sell copies of the Software, and to permit
11 | # persons to whom the Software is furnished to do so, subject to the fol-
12 | # lowing conditions:
13 | #
14 | # The above copyright notice and this permission notice shall be included
15 | # in all copies or substantial portions of the Software.
16 | #
17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
19 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
20 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 | # IN THE SOFTWARE.
24 |
25 | from setuptools import setup
26 |
27 | setup(name = "amazon-cloud-drive",
28 | version = '0.0.6',
29 | description = "A maintained fork of PyAmazonCloudDrive (pyacd), a "\
30 | "3rd-party Python library for accessing Amazon Cloud "\
31 | "Drives.",
32 | author = "Sakurai Youhei",
33 | maintainer = "Matt Luongo",
34 | maintainer_email = "mhluongo@gmail.com",
35 | scripts = ["bin/acdcat", "bin/acdget", "bin/acdlist", "bin/acdmkdir",
36 | "bin/acdput", "bin/acdrecycle"],
37 | url = "https://github.com/mhluongo/amazon-cloud-drive",
38 | packages = ["pyacd"],
39 | license = "MIT",
40 | classifiers = ["Development Status :: 4 - Beta",
41 | "Intended Audience :: Developers",
42 | "License :: OSI Approved :: MIT License",
43 | "Operating System :: POSIX"]
44 | )
45 |
--------------------------------------------------------------------------------
/pyacd/exception.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2011 anatanokeitai.com(sakurai_youhei)
2 | #
3 | # Permission is hereby granted, free of charge, to any person obtaining a
4 | # copy of this software and associated documentation files (the
5 | # "Software"), to deal in the Software without restriction, including
6 | # without limitation the rights to use, copy, modify, merge, publish, dis-
7 | # tribute, sublicense, and/or sell copies of the Software, and to permit
8 | # persons to whom the Software is furnished to do so, subject to the fol-
9 | # lowing conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included
12 | # in all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | # IN THE SOFTWARE.
21 | #
22 | # The Software shall be used for Younger than you, not Older.
23 | #
24 |
25 |
26 | class PyAmazonCloudDriveError(StandardError):
27 | """General error"""
28 |
29 | def __init__(self, reason):
30 | StandardError.__init__(self)
31 | self.reason = reason
32 |
33 | def __repr__(self):
34 | return 'PyAmazonCloudDriveError: %s' % self.reason
35 |
36 | def __str__(self):
37 | return 'PyAmazonCloudDriveError: %s' % self.reason
38 |
39 | class PyAmazonCloudDriveApiException(PyAmazonCloudDriveError):
40 | """server returns error code and message"""
41 |
42 | def __init__(self,error_obj):
43 | if not isinstance(error_obj,dict):
44 | PyAmazonCloudDriveError.__init__(self,error_obj)
45 | else:
46 | self.message=error_obj.get("Message")
47 | self.code=error_obj.get("Code")
48 | self._type=error_obj.get("Type")
49 | PyAmazonCloudDriveError.__init__(self,"%s:%s"%(self.code,self.message))
50 |
--------------------------------------------------------------------------------
/pyacd/multipart.py:
--------------------------------------------------------------------------------
1 | # Original code is following URL
2 | # http://stackoverflow.com/questions/1254270/multipart-form-post-to-google-app-engine-not-working
3 |
4 |
5 | import mimetypes
6 | import urllib2
7 | import httplib
8 | import sys
9 |
10 | import pyacd
11 | from pyacd.exception import PyAmazonCloudDriveError
12 | from pyacd.connection import gen_httplib_conn
13 |
14 | def post_multipart(url, fields, files):
15 | method="POST"
16 | content_type, body = encode_multipart_formdata(fields, files)
17 | #print body
18 |
19 | # Issue 1
20 | # http://code.google.com/p/pyamazonclouddrive/issues/detail?id=1
21 | hs={'content-type': content_type,'content-length': str(len(body))}
22 |
23 | scheme,host = urllib2.urlparse.urlparse(url)[:2]
24 |
25 | conn=gen_httplib_conn(scheme,host)
26 |
27 | path = url.split(host,1)[1]
28 | conn.request(method,path,body,hs)
29 |
30 | if pyacd.debug_level:
31 | sys.stderr.write(method)
32 |
33 | resp = conn.getresponse()
34 | #print "code->",resp.status
35 | if 400< resp.status <599:
36 | sys.stderr.write(resp.read())
37 | raise PyAmazonCloudDriveError("response code is %d"%resp.status)
38 |
39 | if pyacd.debug_level:
40 | sys.stderr.write("->")
41 |
42 | #if resp.getheader("Location"):
43 | # return pyacd.conn.do_get(resp.getheader("Location"))
44 |
45 | resp_body=resp.read()
46 | conn.close()
47 | return resp_body
48 |
49 | def encode_multipart_formdata(fields, files):
50 | """
51 | fields is a dict of (name, value) elements for regular form fields.
52 | files is a dict of (filename, filedata) elements for data to be uploaded as files
53 | Return (content_type, body) ready for httplib.HTTP instance
54 | """
55 | BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
56 | CRLF = '\r\n'
57 | L = []
58 | for key, value in fields.items():
59 | L.append('--' + BOUNDARY)
60 | L.append('Content-Disposition: form-data; name="%s"' % key)
61 | L.append('')
62 | L.append(value)
63 | for filename, filedata in files.items():
64 | L.append('--' + BOUNDARY)
65 | L.append('Content-Disposition: form-data; name="file"; filename="%s"' % (filename))
66 | L.append('Content-Type: %s' % 'application/octet-stream')
67 | L.append('')
68 | L.append(filedata)
69 | L.append('--' + BOUNDARY + '--')
70 | L.append('')
71 |
72 | # Issue 1
73 | # http://code.google.com/p/pyamazonclouddrive/issues/detail?id=1
74 | body = CRLF.join([x if type(x)==str else str(x) for x in L])
75 |
76 | content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
77 | return content_type, body
78 |
79 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | *NOTE*: This is a fork of the PyAmazonCloudDrive project located at http://code.google.com/p/pyamazonclouddrive/. All credit goes to the original author, whose name I believe to be Sakurai Youhei