I am trying to access Xero (Accounting Software) from my Google App Engine system. (Python 2.7).
The Xero example uses M2Crypto but this uses .c files which don't seem to work on App Engine. I also downloaded pycrypto from Google but this has the same problem.
At this stage I would just like my App Engine program to have a button for the user to log in to Xero. Any pointers for me?
Note: Some of these packages appear to need a visual studio or a c compiler, which I don't have.
An update. It appears that only a 'private' application needs pycrypto or m2crypto, neither of which I can install. A public application does not need these, the example I am following has both. I am continuing to work through this.
Thanks in advance
David (Windows Vista, Python 2.7, Current Google App Engine SDK)
I was able to access xero using pyzero, however there were a couple of gotchas, the most significant being the need to upgrade the version of urllib3 that comes packaged as part of the requests library.
I've created a simple project that demonstrates it in use.
https://github.com/hamish/gae_xero
The libraries that I needed to install were:
https://codeload.github.com/freakboy3742/pyxero/zip/master
http://labix.org/download/python-dateutil/python-dateutil-1.5.tar.gz
https://codeload.github.com/kennethreitz/requests/zip/master
https://codeload.github.com/requests/requests-oauthlib/zip/master
https://pypi.python.org/packages/source/o/oauthlib/oauthlib-0.6.1.tar.gz
https://pypi.python.org/packages/source/u/urllib3/urllib3-1.7.1.tar.gz (instaled into the requests/packages/ directory)
Additionally the pycrypto library must be installed and enabled:
sudo pip install pycrypto
[excerpt from app.yaml]
- name: pycrypto
version: latest
Your best bet will be to access the Xero API Endpoints via the AppEngine URL Fetch Service. You'll probably have to satisfy Xero API Authentication along the way.
Related
I'm trying to keep my Google Cloud project centered around App Engine (GAE) Standard Environment by running a UI in GAE Python 2.7 and then deploying an OpenAPI to Cloud Endpoints which also uses Python 2.7. I want my API to be able to check Google Cloud Storage (GCS) for a file, and then if it doesn't exist, fetch an Entity from Datastore, process some data with Text-
to-Speech, and then save resulting mp3 to GCS.
Under Python 2.7, I need to use the old (2015) cloudstorage client library, google-endpoints, google-endpoints-api-management and google-cloud-texttospeech modules, all in my ./lib folder.
With these modules installed, I can run the "echo" demo project without problem. This indicates that there are no dependency version conflicts. However, when trying to use texttospeech, i get this error:
ImportError: No module named grpc._cython.cygrpc
To fix this, I add the following to the libraries section of app.yaml:
- name: grpcio
version: latest
I then get this error:
from six.moves import http_client
ImportError: No module named moves
I try to fix it similarly, but the error persists
- name: six
version: latest
Other solutions didn't help. six 1.12.0 is installed in ./lib, and 1.11.0 comes with the latest gcloud cloud SDK (233.0.0).
How can I use text-to-speech with Cloud Endpoints? Even if i get this working, can I expect it to work with GCS and Datastore? So far, using Flask-RESTful under GAE seems easier.
These client libraries do not work with the first-generation Python 2.7 runtime, and there are no plans to support them.
You will need to use the new second-generation Python 3.7 runtime instead, which will let you install arbitrary dependencies. See "Python 3 Runtime Environment" for more details.
I think the answer is that Google Cloud Client Libraries aren't yet compatible with Google App Engine. The problem I had here persisted when trying to use Text To Speech in a GAE app even though it worked fine when running little tests locally outside of a GAE app.
This issue can be tracked here:
https://github.com/googleapis/google-cloud-python/issues/1893
The last few days I tried to create an App Engine Application based on DJango using PyCharm Professional 2016.3.2..
But everytime I try to create a new App Engine Application using Django as an third-party library PyCharm throws an Error and tells 'Create App Engine Application - Incorrect or corrupted App Engine SKD: cannot finde DJango installation'.
I already tried to install everything again, including Python, PyCharm, Django and the SDK, but it still doesn't work.
I would really appreciate any kind of help, because this problem drives me crazy.
You need to install extras.
gcloud components install app-engine-python-extras
And then try to create django (app engine) project again.
The legacy Appengine SDK ships with some Django versions included in its lib folder.
$ find 1.9.40/ -type d -name [Dd]jango*
1.9.40/google_appengine/lib/jinja2-2.6/examples/rwbench/django
1.9.40/google_appengine/lib/jinja2-2.6/ext/django2jinja
1.9.40/google_appengine/lib/django-1.4
1.9.40/google_appengine/lib/django-1.4/django
1.9.40/google_appengine/lib/PyAMF-0.6.1/pyamf/tests/adapters/django_app
1.9.40/google_appengine/lib/django-1.2
1.9.40/google_appengine/lib/django-1.2/django
1.9.40/google_appengine/lib/PyAMF-0.7.2/pyamf/adapters/tests/django_app
1.9.40/google_appengine/lib/django-0.96
1.9.40/google_appengine/lib/django-0.96/django
1.9.40/google_appengine/lib/django-1.5
1.9.40/google_appengine/lib/django-1.5/django
1.9.40/google_appengine/lib/django-1.3
1.9.40/google_appengine/lib/django-1.3/django
1.9.40/google_appengine/lib/django-1.9
1.9.40/google_appengine/lib/django-1.9/django
1.9.40/google_appengine/google/appengine/_internal/django
1.9.40/google_appengine/google/appengine/ext/django
1.9.40/google_appengine/google/appengine/ext/builtins/django_wsgi
1.9.40/google_appengine/google/storage/speckle/python/django
However the Google Cloud SDK does not include any Django versions in lib, only with Django utilities for its own internal use.
$ gcloud --version
Google Cloud SDK 138.0.0
app-engine-python 1.9.49
...
$ find google-cloud-sdk/ -type d -name [Dd]jango*
google-cloud-sdk/lib/third_party/oauth2client/contrib/django_util
google-cloud-sdk/lib/googlecloudsdk/third_party/appengine/ext/builtins/django_wsgi
google-cloud-sdk/platform/google_appengine/lib/jinja2-2.6/examples/rwbench/django
google-cloud-sdk/platform/google_appengine/lib/jinja2-2.6/ext/django2jinja
google-cloud-sdk/platform/google_appengine/lib/PyAMF-0.6.1/pyamf/tests/adapters/django_app
google-cloud-sdk/platform/google_appengine/lib/PyAMF-0.7.2/pyamf/adapters/tests/django_app
google-cloud-sdk/platform/google_appengine/google/appengine/_internal/django
google-cloud-sdk/platform/google_appengine/google/appengine/ext/django
google-cloud-sdk/platform/google_appengine/google/appengine/ext/builtins/django_wsgi
google-cloud-sdk/platform/google_appengine/google/storage/speckle/python/django
google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/contrib/django_util
google-cloud-sdk/.install/.backup/lib/googlecloudsdk/third_party/appengine/ext/builtins/django_wsgi
google-cloud-sdk/.install/.backup/platform/google_appengine/lib/jinja2-2.6/examples/rwbench/django
google-cloud-sdk/.install/.backup/platform/google_appengine/lib/jinja2-2.6/ext/django2jinja
google-cloud-sdk/.install/.backup/platform/google_appengine/lib/PyAMF-0.6.1/pyamf/tests/adapters/django_app
google-cloud-sdk/.install/.backup/platform/google_appengine/lib/PyAMF-0.7.2/pyamf/adapters/tests/django_app
google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/_internal/django
google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/ext/django
google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/ext/builtins/django_wsgi
google-cloud-sdk/.install/.backup/platform/google_appengine/google/storage/speckle/python/django
google-cloud-sdk/.install/.backup/platform/gsutil/third_party/oauth2client/oauth2client/contrib/django_util
The solution is to install Django according to Google's instructions for installing third party packages, that is:
Install django in your third party libs folder:pip install django -t lib
Add from google.appengine.ext import vendor;vendor.add('lib') in your appengine_config.py module
As #snakecharmerb observed the django packages are missing in the app-engine-python component (1.9.49) of the cloud SDK (138.0.0).
They are, however, present in the standalone GAE SDK (also 1.9.49):
/usr/local # diff google_appengine_1.9.49/lib google-cloud-sdk-138.0.0/platform/google_appengine/lib | grep -vi common
Only in google_appengine_1.9.49/lib: django-0.96
Only in google_appengine_1.9.49/lib: django-1.2
Only in google_appengine_1.9.49/lib: django-1.3
Only in google_appengine_1.9.49/lib: django-1.4
Only in google_appengine_1.9.49/lib: django-1.5
Only in google_appengine_1.9.49/lib: django-1.9
Only in google_appengine_1.9.49/lib: graphy
So an alternative to vendoring django into your app might be to switch to this SDK instead of the cloud SDK. See What is the relationship between Google's App Engine SDK and Cloud SDK?, including comments.
Note that it's not the recommended way these days, tho.
You could also install both and try to copy/symlink the missing packages into the cloud SDK. YMMV.
To download the GAE SDK in the Download the SDK for App Engine page click on the Optionally, you can also download the original App Engine SDK for Python. "link" - it's actually a control for the expandable download section below:
I have some entities added on datastore - made a little web app (in Python) to read and write from the datastore through endpoints. I am able to use the webapp through endpoints from javascript.
I want to access the web app from an installed application on PC. Is there a way to access endpoints from installed applications written in Python? How?
Is there any other way to access the datastore from PC installed applications written in Python?
That's one of the beauties of AppEngine's endpoints. You should use the Python Client Library for Google's APIs to communicate with your endpoints
pip install --upgrade google-api-python-client
Then you'll construct a resource object to communicate with your api using the apiclient.discovery.build function. For eg:
from apiclient.discovery import build
api_root = 'https://<APP_ID>.appspot.com/_ah/api'
api = 'api_name'
version = 'api_version'
discovery_url = '%s/discovery/v1/apis/%s/%s/rest' % (api_root, api, version)
service = build(api, version, discoveryServiceUrl=discovery_url)
You can then perform operations at service.<endpoint_method> etc
A more complete example with authentication can be found here.
EDIT:
Or as #Zig recommends, directly use the Google Cloud API
pip install googledatastore
Trivial example
I am successfully able to get BQ data from one project to another from the advice in this answer. However this only works when deployed on my development/staging instance and not my local development server on Google App Engine.
My findings are that it works in production because you include:
libraries:
- name: pycrypto
version: "latest"
in app.yaml. However these libraries are not accessible from the dev server. I have tried installing everything locally (Pycrypto, oauth2client, openSSL) after digging through some docs and tracing the error but still cannot get it to work. I have tried installing through pip and manually doing the build/install from the raw files to no avail. Any advice on getting these queries to work on the local django server? Working on Ubuntu if that matters, perhaps it's looking in the wrong spot for the libraries?
If its just the libs that are mising follow this answer https://stackoverflow.com/a/11405769/3877822 to insatll pycrypto to the root of your project
As #Udi suggests in the comment below, the following command also
installs pycrypto and can be used in virtualenv as well:
easy_install
http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win32-py2.7.exe
Notice to choose the relevant link for your setup from this list
I want to automate deploying OVA image on VSphere with python.
I looked up at some packages viz. Pysphere, psphere but didn't find direct method to do so.
is there any Library I'm missing or is there any other way to deploy OVA/OVF files/templates on VSphere with Python.
Pls help!!!
I have the same situation here and found that there is vSphere automation API here made in Python. Github clone here.
All you need to do is extract SDK and download deploy_ovf_template.py for usage here or from github clone here. This template will work with OVF, but since you want to work with OVA you'll need to do extra work and extract OVA (you'll get OVF and vmdk files).
For other scenarios, check PDF documentation here.
Be aware that this is supported 6.5>= vSphere
As far I know there are no appropriate api for deploying ovf template using python package. You can use ovftool, VMware OVF Tool is a command-line utility that allows you to import and export OVF packages to and from many VMware products.
download ovftool from vmware site https://my.vmware.com/web/vmware/details?productId=352&downloadGroup=OVFTOOL350
to install ovftool:-
sudo /bin/sh VMware-ovftool-3.5.0-1274719-lin.x86_64.bundle
to deploy ova image as template.
syntax:-
ovftool -dm=thick -ds=3par1 -n=abhi_vm /root/lab/extract/overcloud-esx-ovsvapp.ova vi://root:pwd#10.1.2**.**/datacenter/host/cluster
use os.system(ovftool_syntax) to use in your python script.