Python:gaeproject

De Les Tutoriaux du WebMestre
Aller à : navigation, rechercher

Le Google App Engine

Installation

jpmena@jpmena-P34:~/Ateliers$ curl https://sdk.cloud.google.com | bash
……………………………………..
The following components will be installed:
    -------------------------------------------------------------------------------------------
    | BigQuery Command Line Tool                                        |     2.0.18 | < 1 MB |
    | BigQuery Command Line Tool (Platform Specific)                    |     2.0.18 | < 1 MB |
    | Cloud DNS Admin Command Line Interface                            | 2015.02.24 | < 1 MB |
    | Cloud SDK Core Command Line Tools                                 |          1 |        |
    | Cloud SDK Core Libraries (Platform Specific)                      | 2014.10.20 | < 1 MB |
    | Cloud SQL Admin Command Line Interface                            | 2015.02.24 | < 1 MB |
    | Cloud Storage Command Line Tool                                   |        4.9 | 2.0 MB |
    | Cloud Storage Command Line Tool (Platform Specific)               |        4.6 | < 1 MB |
    | Compute Engine Command Line Interface                             | 2015.02.24 | < 1 MB |
    | Compute Engine Command Line Tool (deprecated)                     |     1.16.5 | < 1 MB |
    | Compute Engine Command Line Tool (deprecated) (Platform Specific) |     1.16.5 | < 1 MB |
    -------------------------------------------------------------------------------------------
……………………………………………….
Creating backup and activating new installation...

Update done!


Modify profile to update your $PATH and enable bash completion? (Y/n)?
  Y

The Google Cloud SDK installer will now prompt you to update an rc 
file to bring the Google Cloud CLIs into your environment.

Enter path to an rc file to update, or leave blank to use 
[/home/jpmena/.bashrc]:  
Backing up [/home/jpmena/.bashrc] to [/home/jpmena/.bashrc.backup].
[/home/jpmena/.bashrc] has been updated.
Start a new shell for the changes to take effect.


For more information on how to get started, please visit:
  https://developers.google.com/cloud/sdk/gettingstarted
  • En effet nous avons :
    • et le sdk téléchargé sous ~/Ateliers
jpmena@jpmena-P34:~/Ateliers$ ll google-cloud-sdk/
total 104
drwxr-xr-x 6 jpmena jpmena  4096 janv.  4 17:59 ./
drwxr-xr-x 8 jpmena jpmena  4096 janv.  4 18:00 ../
drwxr-xr-x 3 jpmena jpmena  4096 janv.  4 18:00 bin/
-rw-r--r-- 1 jpmena jpmena  2338 déc.  17 00:36 completion.bash.inc
-rw-r--r-- 1 jpmena jpmena  1923 déc.  17 00:36 completion.zsh.inc
drwxr-xr-x 4 jpmena jpmena  4096 janv.  4 18:00 .install/
-rwxr-xr-x 1 jpmena jpmena   839 déc.  17 00:36 install.bat*
-rwxr-xr-x 1 jpmena jpmena  3374 déc.  17 00:36 install.sh*
drwxr-xr-x 4 jpmena jpmena  4096 déc.  17 00:38 lib/
-rw-r--r-- 1 jpmena jpmena   982 déc.  17 00:36 LICENSE
-rw-r--r-- 1 jpmena jpmena   308 déc.  17 00:36 path.bash.inc
-rw-r--r-- 1 jpmena jpmena    31 déc.  17 00:36 path.zsh.inc
drwxr-xr-x 4 jpmena jpmena  4096 janv.  4 18:00 platform/
-rw-rw-r-- 1 jpmena jpmena    40 janv.  4 17:58 properties
-rw-r--r-- 1 jpmena jpmena   684 déc.  17 00:36 README
-rw-r--r-- 1 jpmena jpmena 43160 déc.  17 00:36 RELEASE_NOTES
  • et le fichier ~/.basrc modifié de façon à :
    • mettre les commandes du cloud dans le //PATH//
    • permettre l'autocomplétion des commandes du cloud via des scripts fournis par le sdk:
      • (j'ai renommé le .back créé par le sdk en .backup04012016)
jpmena@jpmena-P34:~$ diff -u .bashrc.backup04012016 .bashrc
--- .bashrc.backup04012016	2016-01-04 18:02:28.117247144 +0100
+++ .bashrc	2016-01-04 19:13:18.008580412 +0100
@@ -118,3 +118,13 @@
 export PATH="$HOME/.rbenv/bin:$PATH"
 eval "$(rbenv init -)"
 export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
+
+# The next line updates PATH for the Google Cloud SDK.
+source '/home/jpmena/Ateliers/google-cloud-sdk/path.bash.inc'
+
+# The next line enables shell command completion for gcloud.
+source '/home/jpmena/Ateliers/google-cloud-sdk/completion.bash.inc'

Prise en compte du sdk

  • pour que le nouveau ~/.bashrc soit pris en compte, comme sur [1] nous recommande, on passe la commande:
jpmena@jpmena-P34:~$ exec -l $SHELL
jpmena@jpmena-P34:~$ gcloud #on appuie plusieurs fois sur la touche tab pour provoquer l'autocomplétion, ici la liste des commandes !!!!
auth                 compute              container            dns                  feedback             info                 meta                 source               topic                
components           config               deployment-manager   docker               help                 init                 preview              sql                  version
#on vérifie via la commande (qui s'autocomplète)
jpmena@jpmena-P34:~$ gcloud --help
#on quitte l'écran d'aide en tapant q
 * on teste en initialisant notre profil Google comme expliqué [notre environnement gCloud] on passe la commande
jpmena@jpmena-P34:~$ gcloud init | tee init.log
Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [default] are:
[core]
disable_usage_reporting = False
[meta]
active_config = default

Pick configuration to use:
 [1] Re-initialize this configuration [default] with new settings 
 [2] Create a new configuration
Please enter your numeric choice:  1

Your current configuration has been set to: [default]

To continue, you must login. Would you like to login (Y/n)?  Y

Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute&access_type=offline


You are now logged in as: [pythonrubylang@gmail.com]

Enter project id you would like to use:  alnayperfs
Your current project has been set to: [alnayperfs].

[compute project-info describe] has failed
Not setting default zone/region.
Make sure Compute Engine API is enabled for your project.

Could not retrieve list of repos via [gcloud alpha source repos list]
Perhaps alpha commands are not enabled or the repos list command failed.

Generally projects have a repository named [default]. Would you like 
to try clone it? (Y/n)?  n


gcloud has now been configured!
You can use [gcloud config] to change more gcloud settings.

Your current configuration is: [default]

[core]
account = pythonrubylang@gmail.com
disable_usage_reporting = False
project = alnayperfs
[meta]
active_config = default
  • les premières lignes sont relatives à une précédente initialisation, le système me laisse la possibilité de :
    • écraser la configuration précédente
    • créer une nouvelle configuration !
  • au moment de l'autentification, l'installeur lance la fenêtre d'authentification des comptes Google via le navigateur défini par défaut et une fois authentifié et d'accord avec les conditions en question ce navigateur affiche la fenêtre [2]
  • Sur l'interface en ligne de commande, j'entre //aulnayperfs// comme identifiant de projet (c'est un projet qui existe et qui correspond au **site [[3]]**

Le Python SDK

Téléchargement et installation

  • on télécharge l'archive Python SDK pour Linux
    • je décide arbitrairement de le de-zipper sous $HOME/Ateliers/google-cloud-sdk/platform, ce qui donne:
#je vérifie le téléchargement via le hash sha1
jpmena@jpmena-P34:~/Ateliers$ sha1sum google_appengine_1.9.30.zip
2067595f45e1c40d621f6221348d4d03de91fff0  google_appengine_1.9.30.zip
#je dezippe vers $HOME/Ateliers/google-cloud-sdk/platform
jpmena@jpmena-P34:~/Ateliers$ unzip -qq google_appengine_1.9.30.zip -d ~/Ateliers/google-cloud-sdk/platform
#ce qui donne:
jpmena@jpmena-P34:~/Ateliers$ ll google-cloud-sdk/platform/google_appengine/
total 136
drwxr-xr-x  8 jpmena jpmena  4096 nov.  18 10:19 ./
drwxr-xr-x  5 jpmena jpmena  4096 janv.  9 10:33 ../
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 api_server.py*
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 appcfg.py* #c'est ce programme qui va etre uttilisé par PyDev/GAE
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 backends_conversion.py*
-rw-r--r--  1 jpmena jpmena   156 nov.  18 10:19 BUGS
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 bulkload_client.py*
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 bulkloader.py*
drwxr-xr-x  4 jpmena jpmena  4096 nov.  18 10:19 demos/
-rwxr-xr-x  1 jpmena jpmena  1927 nov.  18 10:19 dev_appserver.py*
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 download_appstats.py*
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 endpointscfg.py*
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 gen_protorpc.py*
drwxr-xr-x  6 jpmena jpmena  4096 nov.  18 10:19 google/
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 google_sql.py*
drwxr-xr-x 52 jpmena jpmena  4096 nov.  18 10:19 lib/
-rw-r--r--  1 jpmena jpmena  5922 nov.  18 10:19 LICENSE
drwxr-xr-x  2 jpmena jpmena  4096 nov.  18 10:19 new_project_template/
drwxr-xr-x  4 jpmena jpmena  4096 nov.  18 10:19 php/
-rwxr-xr-x  1 jpmena jpmena  1927 nov.  18 10:19 php_cli.py*
-rwxr-xr-x  1 jpmena jpmena  1927 nov.  18 10:19 _php_runtime.py*
-rwxr-xr-x  1 jpmena jpmena  1927 nov.  18 10:19 _python_runtime.py*
-rw-r--r--  1 jpmena jpmena  8393 nov.  18 10:19 README
-rw-r--r--  1 jpmena jpmena   138 nov.  18 10:19 RELEASE_NOTES
-rwxr-xr-x  1 jpmena jpmena  3127 nov.  18 10:19 remote_api_shell.py*
-rwxr-xr-x  1 jpmena jpmena  2115 nov.  18 10:19 run_tests.py*
drwxr-xr-x  2 jpmena jpmena  4096 nov.  18 10:19 tools/
-rw-r--r--  1 jpmena jpmena   221 nov.  18 10:19 VERSION
-rwxr-xr-x  1 jpmena jpmena 11081 nov.  18 10:19 wrapper_util.py*