Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77250 > unrolled thread
| Started by | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| First post | 2014-08-28 19:30 -0700 |
| Last post | 2014-08-29 17:51 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
python 3.4 use python-gcm can't import Frank Liou <fk26541598fk@gmail.com> - 2014-08-28 19:30 -0700
Re: python 3.4 use python-gcm can't import Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-28 22:08 -0600
Re: python 3.4 use python-gcm can't import Frank Liou <fk26541598fk@gmail.com> - 2014-08-29 01:35 -0700
Re: python 3.4 use python-gcm can't import Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-29 17:51 +0100
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-08-28 19:30 -0700 |
| Subject | python 3.4 use python-gcm can't import |
| Message-ID | <c6179d50-e8c4-43d4-896f-77d234e0f9ff@googlegroups.com> |
i just from gcm import GCM then.... Traceback (most recent call last): File "C:/Users/frank/Desktop/SinyiAPI/SinyiAPI.py", line 7, in <module> from Model.Order import Order File "C:\Users\frank\Desktop\SinyiAPI\Model\Order.py", line 7, in <module> from gcm.gcm import GCM File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible File "C:\Users\frank\untitled1\lib\site-packages\python_gcm-0.1.5-py3.4-win32.egg\gcm\__init__.py", line 4, in <module> AttributeError: 'module' object has no attribute 'GCM' it's don't let me import i try so many way ex: import gcm from gcm.gcm import GCM but still can't
[toc] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-08-28 22:08 -0600 |
| Subject | Re: python 3.4 use python-gcm can't import |
| Message-ID | <mailman.13596.1409285341.18130.python-list@python.org> |
| In reply to | #77250 |
On Thu, Aug 28, 2014 at 8:30 PM, Frank Liou <fk26541598fk@gmail.com> wrote: > i just > > from gcm import GCM > > then.... > > > Traceback (most recent call last): > File "C:/Users/frank/Desktop/SinyiAPI/SinyiAPI.py", line 7, in <module> > from Model.Order import Order > File "C:\Users\frank\Desktop\SinyiAPI\Model\Order.py", line 7, in <module> > from gcm.gcm import GCM > File "<frozen importlib._bootstrap>", line 2237, in _find_and_load > File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked > File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible > File "C:\Users\frank\untitled1\lib\site-packages\python_gcm-0.1.5-py3.4-win32.egg\gcm\__init__.py", line 4, in <module> > AttributeError: 'module' object has no attribute 'GCM' > it's don't let me import > i try so many way ex: > import gcm > from gcm.gcm import GCM > but still can't In the source at https://github.com/geeknam/python-gcm/blob/master/gcm/gcm.py I see that the second line is: import urllib2 Since urllib2 no longer exists in Python 3, that's a clear sign that this package supports Python 2 only.
[toc] | [prev] | [next] | [standalone]
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-08-29 01:35 -0700 |
| Subject | Re: python 3.4 use python-gcm can't import |
| Message-ID | <9c330850-fd0d-4190-a924-5cd99fbaccd6@googlegroups.com> |
| In reply to | #77254 |
what?
So...My 3.4 can't use this package?
now
i use http.client
reg_ids = []
reg_ids.append(GetCustomerGCMId[0])
API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
mydata = {'registration_ids': reg_ids, 'data': data}
jqs = json.dumps(mydata)
headers = {"Content-type": "application/json", "Authorization": "key="+API_KEY}
conn = http.client.HTTPConnection('android.googleapis.com')
conn.request('POST', '/gcm/send', jqs, headers)
res = conn.getresponse()
conn.close()
reason = res.reason
read = res.read().decode()
headers = res.headers
result = {'msg': res.status, 'reason': str(res.reason), 'read': str(res.read())}
i got status only 200 ok
and body is "b'" .....is empty
i'm so confused.don't know it work or not
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-08-29 17:51 +0100 |
| Subject | Re: python 3.4 use python-gcm can't import |
| Message-ID | <mailman.13613.1409331106.18130.python-list@python.org> |
| In reply to | #77266 |
On 29/08/2014 09:35, Frank Liou wrote:
> what?
>
> So...My 3.4 can't use this package?
>
> now
>
> i use http.client
>
> reg_ids = []
> reg_ids.append(GetCustomerGCMId[0])
> API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
> mydata = {'registration_ids': reg_ids, 'data': data}
> jqs = json.dumps(mydata)
> headers = {"Content-type": "application/json", "Authorization": "key="+API_KEY}
> conn = http.client.HTTPConnection('android.googleapis.com')
> conn.request('POST', '/gcm/send', jqs, headers)
> res = conn.getresponse()
> conn.close()
> reason = res.reason
> read = res.read().decode()
> headers = res.headers
> result = {'msg': res.status, 'reason': str(res.reason), 'read': str(res.read())}
>
>
> i got status only 200 ok
>
> and body is "b'" .....is empty
>
> i'm so confused.don't know it work or not
>
Thankfully I've one of my crystal balls back from the menders so I know
that you're responding to Ian Kelly. Having said that have you tried
running the code through 2to3?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web