Implementing Remote Api Shell (Python) in Google App Engine - google-app-engine

Actually what I'm trying to implement is that, I have to access appengine datastore remotely using remote_api_shell.py. But the problem I'm facing is I'm able to logging in but couldn't access the entitys modules in my app. the steps for the procedure is not clear anywhere so I'm not able to proceed further.
I referred the articles
https://developers.google.com/appengine/docs/python/tools/remoteapi and
https://developers.google.com/appengine/articles/remote_api
They have used a command like
python $GAE_SDK_ROOT/remote_api_shell.py -s your_app_id.appspot.com
I dont know where to type it. I used command prompt for which i modified the above as
c:\program files(x86)\google\google_appengine\python remote_api_shell.py -s your_app_id.appspot.com
Its logging in. I'm able to save some entities in my datastore but unable to access my modules. i think there is a some kind of directories i want to specify or there are steps i have to follow before this which I might have missed. So i looking forward for Some Help to achieve it successfully.
Thanks.

First off cd to your application directory.
The run the remote shell as per the docs
python $GAE_SDK_ROOT/remote_api_shell.py -s your_app_id.appspot.com
If you use appengine_config.py to set up all your paths manually import that into the shell.
Other wise you should be able to import any modules etc that are defined at the root level of your application directory.

Related

Google App boto file stored in inappropriate directory

I installed Google Cloud SDK and it dumped a .boto file directory in to the My Documents folder (e.g. C:\Users\John) which is a wildly inappropriate location. I do see many instances of the boto file in the Python files, a couple of dozens of instances / examples:
return os.path.join(self.LegacyCredentialsDir(account), '.boto')
os.path.expanduser(os.path.join('~', '.boto')),
Where do I go to change the path to something appropriate? An appropriate path would be something such as C:\Users\John\AppData\Roaming\gcloud\.boto in example.
At the top of the file:
This file contains credentials and other configuration information needed
by the boto library, used by gsutil. You can edit this file (e.g., to add
credentials) but be careful not to mis-edit any of the variable names (like
"gs_access_key_id") or remove important markers (like the "[Credentials]" and
"[Boto]" section delimiters).
[Credentials]
Google OAuth2 credentials are managed by the Cloud SDK and
do not need to be present in this file.
To add HMAC google credentials for "gs://" URIs, edit and uncomment the
following two lines:
The latest versions of Boto don't seem to be a great fit for App Engine. I ran into this issue about a year ago, and I don't remember all of the details, but I avoided Boto3 and stuck with Boto 2.47 and that worked well for me.
For my use case, I only needed help with SES. If you need many other AWS services then YMMV.

nginX custom HTTP authorization , using scripts to decide

i want to protect some files in a folder by requiring passwords for download
however list of users that are allowed to download are on a mysql table with their passwords in md5 format (which means i cannot generate a htpasswd file)
to make it harder i also need to allow some users to download some files and others to download other files without being able to move files (separating files in multiple folders)
so i what i need is some kind of auth api , when there is a request nginx askes a Script (lets say a php script) with parameters of username/password/ip/filename and depending on script's response allow or disallow the download
is this possible?
what i've done so far:
1.looking in the 3rd party modules list http://wiki.nginx.org/3rdPartyModules
where i found a module with PAM but my server is windows
2.googling lots of terms without any results
3.looking at the module development tutorials http://www.evanmiller.org/nginx-modules-guide.html
i'm not really good at C so a pre made module for windows that bounces the request to a script (without proxy-ing the download through it) is the best if not some pointers to how should i make a module that meets my requirements is appreciated .
You can use the http_auth_request module.
p.s. Do you actually know that nginx for windows is not production ready?

Exporting a Typo3 site bit by bit

(edit: I'm leaving all the mistaken assumptions in just in case someone else makes the same mistakes)
I have an ancient Typo3 3.8.1 site on a remote server. I don't have access to that server, and the team in charge of maintaining the site doesn't know who to contact to get access to the server. I do have the admin rights on that site, though. (edit: no I don't. oops.)
This is what I see in the (not) admin menu:
I'm not sure if this version supports extensions, I can't find an extension manager anywhere. (because I'm not an admin)
I want to export the site so I can host it on a server on my own domain instead. The problem is the export file is too large, I can't download it. Will I destroy the directory structure if I export a bunch of pages at a time?
If you have admin access to the backend you can try to install Quixplorer - file manager. Using it you can try to zip folders in the main directory ie. (typo3, typo3conf, fileadmin etc) one by one and download them via browser.
It's important to download and remove typo3conf.zip from the server as soon as possible, cause it contains sensitive data.
Additionally you can also install PhpMyAdmin extension (search in repository) i you haven't other MySQL client.
Edit:
If you can't use Quixplorer the only way is... to write own extension and upload it via Extension Manager, there you'll need to try perform primitive file system operations like:
(PHP)
system('zip -R t3c.zip typo3conf/');
Sometimes the server allows more memory and execution_time that the T3D Export. So, if you can change PHP files on that server, try to change typo3/sysext/impexp/class.tx_impexp.php - search for ini_set and change that settings. If the server allows, you can then create bigger t3d-files.
And you could try some shell-extensions to get hands on that server:
http://typo3.org/extensions/repository/view/phpshell
http://typo3.org/extensions/repository/view/mw_shell
http://typo3.org/extensions/repository/view/shell
But to answer your initial question: you can crate a couple of T3D-files and import them again. Just force uid if you import them - and install all needed extensions first!

How can I script WordPress for non-GUI automated Pages/Posts-import?

This is probably a "cannot see the forest because of the trees" situation,
but how do I create a script which does the automated import of Posts/Pages, without a hook in the WP Website-GUI (e.g. in Theme's functions.php). It should be standalone triggerable by calling the script name via webserver.
via this API-call wp_insert_post()
You want to use the WordPress API (http://codex.wordpress.org/XML-RPC_wp) to connect. You can do this with almost any scripting language, but since you mention running it on the webserver, and WordPress is written in PHP, we'll go with that language for now.
Check out this tutorial:
http://life.mysiteonline.org/archives/161-Automatic-Post-Creation-with-Wordpress,-PHP,-and-XML-RPC.html
He shows example of how to create a script that will insert a post into your WordPress blog. The script can be given execute permissions and ran via the command line or a cron job.
You will have to code the logic to get the post from wherever your data is stored, though.

App Engine: Development datastore cleared each time I turn off my computer. How to avoid this?

I've been using App Engine with Python for a few months. Now that my application has a fair amount of code, I'm trying to solve a problem I've ignored so far:
Each time I turn off my computer, all my development datastore entities are removed.
I would like to keep this data until the next time I launch my development server. But I would also like to be able to turn off my computer without losing all of this data.
How should I proceed?
Thanks a lot
======== UPDATE ==========
When I set the datastore_path flag as explained by #moishe, my development server crashes as soon as it must write into the datastore.
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_file_stub.py", line 557, in __WritePickled
os.rename(tmp_filename, filename)
OSError: [Errno 13] Permission denied
Therefore, I gave this folder all UNIX permissions
chmod a+w /my_app_folder
But I have now another error which is
OSError: [Errno 21] Is a directory
Obviously the path should not be a directory. So I changed the path to:
/my_app_folder/data.datastore
And now it works! PFF...
Maybe the default data store path is in a /tmp directory that's being deleted on shutdown? You can manually set the path with the --datastore_path flag in dev_appserver.py. See the docs for details.
This clearing should not be the default behavior.
Check that this application in the Google AppEngine launcher doesn't have the --clear_datastore flag.
Select app in list and select Edit->Applications Settings...
Extra Command Line Flags should be empty.
I once set this to restart some tests and forgot to remove it.
Remove the existing application in the launcher and Create New Application. See if that helps.
Verify the OS isn't deleted the file. If you open the log for the app, then launch it, the output says where the sqlite file is being located (e.g. T:\temp\dev_appserver.rdbms)
flag when starting the dev server:
--storage_path=...
Path at which all local files (such as the Datastore, Blobstore files,
Google Cloud Storage Files, logs, etc) will be stored, unless
overridden by --datastore_path, --blobstore_path, --logs_path, etc.
found at https://developers.google.com/appengine/docs/python/tools/devserver?csw=1
I had the same problem, and installing the latest gae SDK solved it.
As in the case here: app engine datastore auto-clears every time project runs

Resources