bernieke / python-magento Goto Github PK
View Code? Open in Web Editor NEWA Python interface to Magento's XMLRPC API.
License: MIT License
A Python interface to Magento's XMLRPC API.
License: MIT License
from magento import MagentoAPI
D:\Work\Coding\AmCa\MagentoAPI>showProducts.py
Traceback (most recent call last):
File "D:\Work\Coding\AmCa\MagentoAPI\showProducts.py", line 17, in
from magento import MagentoAPI
ImportError: cannot import name 'MagentoAPI' from 'magento' (C:\Program Files\Python37\lib\site-packages\magento_init_.py)
Occasionally when trying to initiate an API call / or the API (not sure which at present) I get the following:
Traceback (most recent call last):
File "sales_note_add.py", line 109, in <module>
main()
File "sales_note_add.py", line 87, in main
orderStatus = get_order(orderId)
File "sales_note_add.py", line 56, in get_order
order = mage.sales_order.info(order_id)
File "/Users/mmuser/Documents/magento19-api/magento/__init__.py", line 142, in call_method
return self._client.call(self._session_id, path, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1240, in __call__
return self.__send(self.__name, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1599, in __request
verbose=self.__verbose
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1280, in request
return self.single_request(host, handler, request_body, verbose)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1308, in single_request
self.send_content(h, request_body)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1456, in send_content
connection.endheaders(request_body)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1049, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 893, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 855, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1266, in connect
HTTPConnection.connect(self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 832, in connect
self.timeout, self.source_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 557, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
I believe this is where our web server has an issue processing the request and throws an error.
It would be good to build into the magento code some form of error handling for broken connections / calls so they are always handled with a retry(?) so its all rolled up in the API call rather than writing it into the functions calling the API (one place for the connection and error handling)
I will try to fix this in the near future but if anyone has noticed this issue and fixed it already then superb!
I had been working with version 0.3.4
and upgraded to 1.0.1
. After upgrade I cannot establish a connection.
Tried a fresh virtualenv with only this package in order to rule out any dependency issues that might exist, and got the same result.
Using 1.0.0
now and am not experiencing the issue.
Traceback (most recent call last):
File "mage.py", line 9, in <module>
mag = MagentoAPI('www.MYDOMAIN.com', 80, 'MYAPIUSER', 'MYAPIKEY', verbose=False)
File "C:\Users\Chris\.virtualenvs\analytics1\lib\site-packages\magento\magento_api.py", line 61, in __init__
self.login()
File "C:\Users\Chris\.virtualenvs\analytics1\lib\site-packages\magento\magento_api.py", line 108, in login
self._session_id = self._client.login(self._api_user, self._api_key)
File "C:\Python27\Lib\xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "C:\Python27\Lib\xmlrpclib.py", line 1591, in __request
verbose=self.__verbose
File "C:\Python27\Lib\xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\Lib\xmlrpclib.py", line 1293, in single_request
h = self.make_connection(host)
File "C:\Python27\Lib\xmlrpclib.py", line 1373, in make_connection
if self._connection and host == self._connection[0]:
How can I connect to the server over https?
I was previously installing python-magento from this repo since PyPI didn't have the official release yet, but I saw the official PyPI page showed the current version as 1.0.0, so I tried installing it from PyPI with pip. The latest version that pip could find, though, was 0.3.3 -- I did a little debugging and it looks like the package's simple index hasn't been updated with the distribution for 1.0.0:
https://pypi.python.org/simple/python-magento/
Some not-very-extensive Googling seems to suggest that a project maintainer needs to upload a distribution for 1.0.0 either from a web form or via the setup.py script: https://docs.python.org/3.4/distutils/packageindex.html#package-index
is this library working for magento 2 ?
I am getting the following error during library installation:
Exception:
Traceback (most recent call last):
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/wheel.py", line 492, in move_wheel_files
maker.make_multiple(['%s = %s' % kv for kv in console.items()])
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/_vendor/distlib/scripts.py", line 383, in make_multiple
filenames.extend(self.make(specification, options))
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/_vendor/distlib/scripts.py", line 368, in make
entry = get_export_entry(specification)
File "/Users/rohit.rawat/.virtualenvs/re_inv/lib/python3.5/site-packages/pip/_vendor/distlib/util.py", line 590, in get_export_entry
"'%s'" % specification)
pip._vendor.distlib.DistlibException: Invalid specification 'magento-ipython-shell = magento.magento_ipython_shell:main [interactive-shell]'
Discussion rather than issue:
Do we want to put any effort or thought into adding in magento2 compatibility or for that matter Rest / Soap compatibility ?
If we were to build in Rest Capability to this now, we would be putting the ground work in for the magento 2 release ?
Thoughts ?
Alex
I am trying to create an order. The steps to create a quote and set a customer work well, but I cannot set customer addresses. I have send the params as suggested in http://devdocs.magento.com/guides/m1x/api/soap/checkout/cartCustomer/cart_customer.addresses.html and below is error stack
Traceback (most recent call last):
File "D:\mage_connect\mage_connect\mageapp\addons\magento_bridge\models\mob_synchronization.py", line 1168, in _export_specific_order
mage_resultCustomerAddresses = magento.cart_customer.addresses(mage_shoppingCartId, customer_address_data)
File "C:\Program Files\Anaconda2\lib\site-packages\magento\magento_api.py", line 206, in call_method
return self._client.call(self._session_id, path, args)
File "C:\Program Files\Anaconda2\lib\xmlrpclib.py", line 1243, in call
return self.__send(self.__name, args)
File "C:\Program Files\Anaconda2\lib\xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "C:\Program Files\Anaconda2\lib\xmlrpclib.py", line 1283, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Program Files\Anaconda2\lib\xmlrpclib.py", line 1331, in single_request
response.msg,
ProtocolError: <ProtocolError for magento-odoo.mage_connect.com:80/api/xmlrpc: 500 Internal Server Error>
and
customer_address_data = [ { 'city': u'test', 'fax': u'', 'telephone ': u'', 'firstname': u'patrik', 'lastname': u'test', 'region': False, 'country_id': u'DE', 'is_default_shipping': 0, 'street': u'test', 'is_default_billing': 1, 'postcode': u'43332', 'email': u'[email protected]', 'mode': 'billing' }, { 'city': u'test', 'fax': False, 'telephone ': False, 'firstname': u'patrik', 'lastname': u'test', 'region': False, 'country_id': u'DE', 'is_default_shipping': 1, 'street': u'test', 'is_default_billing': 0, 'postcode': u'43332', 'email': u'[email protected]', 'mode': 'shipping' } ]
any hints of how to resolve the issue?
Thanks in advance
Hello, I have a problem with updating the quantity of products at the SKU.
in IPython:
magento.cataloginventory_stock_item.update({'sku': 'OTTest'}, {'qty': '332'})
gives me:
Fault: <Fault 101: 'Product not exists.'>
but
In [107]: magento.cataloginventory_stock_item.update({'product_id': '8372'}, {'qty': '332'})
Out[107]: True
OTTest id=8372
What is the reason that you can not update the amount of the "SKU"
To distinguish from soap and rest api clients (or other magento interfacing py software), it might make sense to add '-xmlrpc' while you're at it.
Sadly magento2 won't have an xmlrpc api any longer it seems.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.