Re: [google-appengine] Re: Production SDK stuck at 1.9.48?

2017-03-03 Thread PK
Hi Kaan,

I am not sure what what is the GUI you refer to. I never used a GUI, I have 
always been using appcfg.py as a CLI tool.

PK 
www.gae123.com

> On Mar 2, 2017, at 11:51 PM, Kaan Soral  wrote:
> 
> Just checked gcloud myself, compared to appcfg, I really really like the 
> examples, as in the past, the GUI approach was spammy and insufficient, I 
> like the new CLI based approach, and the documentations seem adequate too 
> (Feedback: You seriously need to send emails when changes happen, new things 
> are added, I'm ashamed that I didn't discover the gcloud CLI and the new 
> documentations up to this point)
> 
> For some projects, I'm locked with old versions of appcfg, yet, for 
> deployments and new projects, gcloud seems nice
> 
> I think the confusion arises from this: """ Does the method you deploy with, 
> determine the version of appengine your app runs with?! """ - Because, as an 
> outsider, the assumption is that, unless you explicitly set something, the 
> apps should always run with the latest version
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Google App Engine" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/google-appengine/0s1EHuF4qDs/unsubscribe 
> .
> To unsubscribe from this group and all its topics, send an email to 
> google-appengine+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to google-appengine@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/google-appengine 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/google-appengine/9355e066-ddde-4492-9632-35030e83bf14%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/3E997334-F576-403D-8CBC-3D506EA9689C%40gae123.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] Re: Production SDK stuck at 1.9.48?

2017-03-03 Thread Kaan Soral
I guess it was "AppEngine Launcher" back in the day, on OSX, it regularly 
popped up and wanted to update itself, there was no 2-second way to get rid 
of it either, it was pretty much behaved like the old adware's

I was afraid gcloud was going to be something like that, however, having a 
CLI system replace another CLI system isn't that bad

I think the main problem is the lack of information, one email, one 
document with simple: "You did this with appcfg, now do this with gcloud" 
document would be enough, as there seem to be 1:1 replacements to appcfg 
operations simply available

On Friday, March 3, 2017 at 11:09:37 AM UTC+3, P K wrote:
>
> Hi Kaan,
>
> I am not sure what what is the GUI you refer to. I never used a GUI, I 
> have always been using appcfg.py as a CLI tool.
>
> PK 
> www.gae123.com
>
> On Mar 2, 2017, at 11:51 PM, Kaan Soral > 
> wrote:
>
> Just checked gcloud myself, compared to appcfg, I really really like the 
> examples, as in the past, the GUI approach was spammy and insufficient, I 
> like the new CLI based approach, and the documentations seem adequate too 
> (Feedback: You seriously need to send emails when changes happen, new 
> things are added, I'm ashamed that I didn't discover the gcloud CLI and the 
> new documentations up to this point)
>
> For some projects, I'm locked with old versions of appcfg, yet, for 
> deployments and new projects, gcloud seems nice
>
> I think the confusion arises from this: """ Does the method you deploy 
> with, determine the version of appengine your app runs with?! """ - 
> Because, as an outsider, the assumption is that, unless you explicitly set 
> something, the apps should always run with the latest version
>
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Google App Engine" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/google-appengine/0s1EHuF4qDs/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to 
> google-appengi...@googlegroups.com .
> To post to this group, send email to google-a...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/google-appengine.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/google-appengine/9355e066-ddde-4492-9632-35030e83bf14%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/5a025925-6971-4e65-90bc-475e2b7c33bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] MemCache and NDB

2017-03-03 Thread Ivo Bellin Salarin
Hi all,

I have two questions concerning memcache and its performances.

I was reading the page
https://cloud.google.com/appengine/articles/best-practices-for-app-engine-memcache#distribute_load_across_the_keyspace,
where I found
*The Memcache viewer in the administration console displays a list of top
keys, which can be used to identify bottlenecks*

In my administration console, this section is empty. (i.e. 'No hot keys')
But yes, I am sure that there are hot keys, since among the stackdriver
insights I can see the following messages
Slow memcache calls. Your app made 1 remote procedure calls to memcache
that took more than 50 ms and the slowest call took 66 ms. Consider
reducing the value of max_concurrent_requests for your app.
1) Thus, where can I find the hottest keys of my dedicated memcache?

In the meanwhile, according to the messages I can find in StackDriver, the
longest (thus, probably, hottest) memcache.get(s) are made by ndb.get(). In
the code of ndb.get I can see that the cache keys are **not** distributed
across the keyspace (as recommended by the page above).
I think that not using memcache (use_memcache=False) would be a worse
solution.
2) Is there a way to force a better key distribution for NDB, apart from
monkey patching
/gcloud/platform/google_appengine/google/appengine/ext/ndb/context.py::Context._memcache_prefix
with a time dependent % operation? :-)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CAPc4eF8cvOa79rwhpD26yOVkKipvii_u-tHyNbVs_YDuCzJP5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Life beyond compat

2017-03-03 Thread Vinay Chitlangia
So I started moving the code to life after beyond compat.
>From jetty9-compat to jetty9.
The transition was alright except...
the logs that are written as a part of the request come in
stderr/stdout instead of in request log. What is the trick to make them 
part of the request log.

Nothing seems to be getting traced now. What is the recommendation to hook 
up tracing?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/01ac3b46-68aa-4aa5-af70-7917264f25c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: How to download data from my datastore to the local machine

2017-03-03 Thread Delyan Spasov
I read it but I don't understand how to download my database. 

The lack of any normal way of exporting my database is making me nervous 
about using GAE in the future. What if I decide to migrate because of some 
reason? 

I will find some workaround for the current projects (I will have to). But 
I don't see myself starting a new project on GAE. 

Thanks!

On Tuesday, February 28, 2017 at 10:15:39 PM UTC+2, Alex (Cloud Platform 
Support) wrote:
>
> To add up to Nicola’s reply, you may be able to download your data to your 
> local machine by opening the local Datastore viewer as proposed on this 
> Issue Tracker thread 
> . To do 
> so, you will have to access the viewer locally at “
> http://localhost:8000/_ah/admin/datastore” and get the whole data flushed 
> to you local disk.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/51f0d4fa-1e68-4897-b8a9-f482522f1cd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Is GAE down?

2017-03-03 Thread Jeremy Hua
My GraphQL endpoint https://staging-dot-humb-app.appspot.com/graphql is 
sometimes up returning {"errors":[{"message":"Cannot read property 'split' 
of undefined"}]} as expected on browser and correct responses on my app. 
However, every alternate request is returning 

Error: Server ErrorThe server encountered a temporary error and could not 
complete your request.

Please try again in 30 seconds.

Its nodejs server on a flexible environment exposing the graphql endpoint.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/fdfa7d06-f05d-4611-a638-b86cb06c9d55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] I'm struggling to attach a file to this email

2017-03-03 Thread Guillaume France
I'm struggling with the create_message_with_attachment (the rest works, 
create_message_without_attachment works ). 

I did read google documentation. The stack thread talking about it focus on 
complicate point (while mixing up the different python version). Posting 
this in stack will be down-voted as duplicated (stack has its limit).

The script bellow only create an email attach a file to it and send it 
(well, it's suppose to do so)

This script return: 
  encoders.encode_base64(part)
NameError: name 'encoders' is not defined




import httplib2
import os
import oauth2client
from oauth2client import client, tools
import base64
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from apiclient import errors, discovery  


SCOPES = 'https://www.googleapis.com/auth/gmail.send'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Gmail API Python Send Email'




def get_credentials():
 home_dir = os.path.expanduser('~') 
 credential_dir = os.path.join(home_dir, '.credentials') 
 if not os.path.exists(credential_dir):
 os.makedirs(credential_dir)  #create folder if doesnt exist
 credential_path = os.path.join(credential_dir, 
'gmail-python-email-send.json')
 store = oauth2client.file.Storage(credential_path)
 credentials = store.get()
 if not credentials or credentials.invalid:
 flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
 flow.user_agent = APPLICATION_NAME
 credentials = tools.run_flow(flow, store)
 print('Storing credentials to ' + credential_path)
 
 return credentials
 




def SendMessage(sender, to, subject, msgHtml, msgPlain):
 credentials = get_credentials() 
 http = httplib2.Http()
 http = credentials.authorize(http) 
 service = discovery.build('gmail', 'v1', http=http)
 
 # #without attachment
 # message_without_attachment = create_message_without_attachment(sender, 
to, subject, msgHtml, msgPlain)
 # SendMessageInternal(service, "me", message_without_attachment)
 
 # #with attachement
 message_with_attach = create_message_with_attachment(sender, to, subject, 
msgHtml, msgPlain)
 SendMessageInternal(service, "me", message_with_attach)


 
def SendMessageInternal(service, user_id, message): 
 try:
 message = (service.users().messages().send(userId=user_id, body=message).
execute())  need  to get user_id before


 message_ID = message['id']
 print(f'Message Id: {message_ID}')
 return [message, message_ID] #return value as list
 except errors.HttpError as error:
 print(f'An error occurred: {error}') 
 
 
def create_message_without_attachment (sender, to, subject, msgHtml, 
msgPlain):
 msg = MIMEMultipart('alternative')
 msg['Subject'] = subject
 msg['From'] = sender
 msg['To'] = to
 msg.attach(MIMEText(msgPlain, 'plain'))
 msg.attach(MIMEText(msgHtml, 'html'))
 
 raw = base64.urlsafe_b64encode(msg.as_bytes())
 raw = raw.decode()
 body = {'raw': raw}
 return body


 
def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):
 msg = MIMEMultipart('alternative')
 msg['To'] = to
 msg['From'] = sender
 msg['Subject'] = subject
 msg.attach(MIMEText(msgPlain, 'plain'))
 msg.attach(MIMEText(msgHtml, 'html'))

 # the problem comes from this part
 part = MIMEBase('application', "octet-stream")
 part.set_payload( open(r"C:\Users\xx\Desktop\test_Attachment.txt","rb").
read() )
 encoders.encode_base64(part)
 part.add_header('Content-Disposition', 'attachment; filename="{0}"'.format(
os.path.basename(f)))
 msg.attach(part)
 
 raw = base64.urlsafe_b64encode(msg.as_bytes())
 raw = raw.decode()
 body = {'raw': raw}
 return body
 
def main():
 to = "yourem...@gmail.com"
 sender = "myem...@gmail.com"
 subject = "subject test1"
 msgHtml = r'HiHtml hello'
 msgPlain = "Hi\nPlain Email"
 message_text= "this is message text"
 SendMessage(sender, to, subject, msgHtml, msgPlain)


if __name__ == '__main__':
 main()



-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/f5e41361-c3e8-4cd2-9cb6-fe1a95928790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: Life beyond compat

2017-03-03 Thread 'George (Cloud Platform Support)' via Google App Engine


To hook up tracing by means of jetty’s Request Log module, you need to 
enable it by running the command: java -jar ../start.jar 
--add-to-startd=requestlog . 

You may find more detail in the relevant documentation page titled “Configuring 
Jetty Request Logs 
”.
 
  

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/51fb262d-ba59-4242-a5a4-79f2bcc91077%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: App Engine Flex "Error: Server Error" occurs often, how to find cause?

2017-03-03 Thread 'Nick (Cloud Platform Support)' via Google App Engine


Hey Nickolas,

This forum should be used to post general discussion threads about the 
platform, services, design patterns, etc., and a specific-issue question 
like this should be posted to Stack Overflow, although maybe we could 
gather more information before that, as in this state it seems there's not 
quite enough information for anyone to begin working on it. I have some 
lines of investigation which might lead to a better understanding:

1 .This could be a case of not inspecting the logs with the right logs 
level - are you sure you're viewing "All logs", and not just "stdout, 
stderr"? 



2. You might also want to check whether you have any logs for the resource 
"Cloud HTTP Load Balancer" as opposed to "GAE Application" 

3. A final thing to check would be the headers attached to the response - 
specifically looking to see what the "server" header says - to determine 
whether this response is generated by our machines or your own. It seems to 
look like an error that our infrastructure generates, not your app, but 
it's good to check.

Let me know what you find, and feel free to ask any further questions or 
provide any information you think may be relevant.

Cheers,

Nick
Cloud Platform Community Support

On Thursday, March 2, 2017 at 7:19:16 PM UTC-5, Nickolas Daskalou wrote:
>
> Hi,
>
> If we hit our Flexible environment service (Python 3 runtime) with a 
> relatively low concurrency level using ApacheBench, we get this returned 
> more often than not:
>
> Error: Server ErrorThe server encountered a temporary error and could not 
> complete your request.
>
> Please try again in 30 seconds.
>
> I can't seem to find any information in any of logs about why this is 
> occurring.
>
> Is there a way to get the cause of the above page being returned, whether 
> it be via the logs or otherwise?
>
> Thanks,
> Nick
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/a944a61c-c6bd-4022-841f-9fabe5ae9bf2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: How to download data from my datastore to the local machine

2017-03-03 Thread Delyan Spasov
Thanks Nicola,

>From the interactive shell I can access the remote_api. But not from my 
application. It is raising NotSupportedOnThisPlatform(). Since this is in 
Python you probably don't know about this error. I found it as an issue but 
I didn't find a solution of it. 

I don't know how to write a client to download the data. I don't know how 
to format it in a way that the local server will accept it and I also don't 
know how to import it in the local server. There is not any documentation 
about it. 

But I think this should be included. It was but they have changed it 
because of the Oauth. OK, then include it again using Oauth. It isn't 
normal to not be able to export your db. This is very low quality service. 


On Tuesday, February 28, 2017 at 9:19:18 AM UTC+2, Nicola Spreafico wrote:
>
> The appcfg client cannot be used anymore because it use a 
> username/password authentication, which has been deprecated in favor of 
> oauth2 (and not supported by the client itself).
> About 1 year ago I had a very very long ticket with google support (issue 
> number #08922843) where we analyzed all this situation, here a couple of 
> comments:
>
> We ended up writing a very simple remote API handler (both server and 
> client) in order to reproduce the same need as you.
> You need to deploy online a version with remote_api enabled and the write 
> a simple client which will download the data (for all the kinds you need) 
> from online and load it inside the local dev-server
>
> In my case the client was written in Java, but because the remote_api 
> exists in python I'm very confident that you can build a client of your own.
> The main thing to take care is (this example is for java language, i think 
> a python counterpart exists as well)
> if ( ... remote api connected to development server ...) {
> options.useDevelopmentServerCredential();
> } else {
> options.useApplicationDefaultCredential();
> }
>
> When you need to connect with the online environment, the 
> application-default is used which need to be configured using GCloud SDK
>
>
>> https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
>
>
>
>
> Il giorno lunedì 27 febbraio 2017 21:56:47 UTC+1, Delyan Spasov ha scritto:
>>
>> I've wasted lot of time trying to download the datatstore to my local 
>> machine. Nothing works!
>>
>> The appcfg download_data doesn't seem to work any more. There is nothing 
>> about it in the new docs. It's not even mentioned even as deprecation 
>> notice.
>>
>> It is still there in the appcfg. But it doesn't work. 
>> I've tried to upload some old data. It doesn't work.
>> I've tried the remote_api. Tones of errors.
>>
>> They all used to work. What happened?
>> How to work with my database on the local machine?  
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/af71a864-4b98-4687-a704-67de033d1b88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] python 3.6: struggle to send an email with a file attached to it (NameError: name 'encoders' is not defined)

2017-03-03 Thread Guillaume France
I'm struggling to send an email with a file attached to it.

Hi!

I'm struggling with the create_message_with_attachment function (the rest 
works, create_message_without_attachment works ). 

I did read google documentation. The stack threads talking about it focus 
on complex issue (while mixing up on the top of it different syntax of 
python version). Posting this in stack will be down-voted as duplicated 
(stack has its limit).

I'm just trying with the script bellow to create an email, attach a file to 
it and send it. 


*The python 3.6 script returns: *

>   encoders.encode_base64(part)
> NameError: name 'encoders' is not defined





import httplib2
import os
import oauth2client
from oauth2client import client, tools
import base64
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from apiclient import errors, discovery  

SCOPES = 'https://www.googleapis.com/auth/gmail.send'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Gmail API Python Send Email'

def get_credentials():
 home_dir = os.path.expanduser('~') 
 credential_dir = os.path.join(home_dir, '.credentials') 
 if not os.path.exists(credential_dir):
 os.makedirs(credential_dir)  #create folder if doesnt exist
 credential_path = os.path.join(credential_dir, 
'gmail-python-email-send.json')
 store = oauth2client.file.Storage(credential_path)
 credentials = store.get()
 if not credentials or credentials.invalid:
 flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
 flow.user_agent = APPLICATION_NAME
 credentials = tools.run_flow(flow, store)
 print('Storing credentials to ' + credential_path)
 return credentials
 
def SendMessage(sender, to, subject, msgHtml, msgPlain):
 credentials = get_credentials() 
 http = httplib2.Http()
 http = credentials.authorize(http) 
 service = discovery.build('gmail', 'v1', http=http)
 
 # #with attachement
 message_with_attach = create_message_with_attachment(sender, to, subject, 
msgHtml, msgPlain)
 SendMessageInternal(service, "me", message_with_attach)

 # #without attachment
 # message_without_attachment = create_message_without_attachment(sender, 
to, subject, msgHtml, msgPlain)
 # SendMessageInternal(service, "me", message_without_attachment)
 
 
def SendMessageInternal(service, user_id, message): 
 try:
 message = (service.users().messages().send(userId=user_id, body=message).
execute())  need  to get user_id before

 message_ID = message['id']
 print(f'Message Id: {message_ID}')
 return [message, message_ID] #return value as list
 except errors.HttpError as error:
 print(f'An error occurred: {error}') 
 
 
def create_message_without_attachment (sender, to, subject, msgHtml, 
msgPlain):
 msg = MIMEMultipart('alternative')
 msg['Subject'] = subject
 msg['From'] = sender
 msg['To'] = to
 msg.attach(MIMEText(msgPlain, 'plain'))
 msg.attach(MIMEText(msgHtml, 'html'))
 
 raw = base64.urlsafe_b64encode(msg.as_bytes())
 raw = raw.decode()
 body = {'raw': raw}
 return body
 
def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):
 msg = MIMEMultipart('alternative')
 msg['To'] = to
 msg['From'] = sender
 msg['Subject'] = subject
 msg.attach(MIMEText(msgPlain, 'plain'))
 msg.attach(MIMEText(msgHtml, 'html'))

 # the problem comes from this part
 part = MIMEBase('application', "octet-stream")
 part.set_payload( open(r"C:\Users\xx\Desktop\test_Attachment.txt","rb").
read() )
 encoders.encode_base64(part)
 part.add_header('Content-Disposition', 'attachment; filename="{0}"'.format(
os.path.basename(f)))
 msg.attach(part)
 
 raw = base64.urlsafe_b64encode(msg.as_bytes())
 raw = raw.decode()
 body = {'raw': raw}
 return body
 
def main():
 to = "yourem...@gmail.com"
 sender = "myem...@gmail.com"
 subject = "subject test1"
 msgHtml = r'HiHtml hello'
 msgPlain = "Hi\nPlain Email"
 message_text= "this is message text"
 SendMessage(sender, to, subject, msgHtml, msgPlain)


if __name__ == '__main__':
 main()



-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/7c6e9e54-6d62-473a-bc80-5d5c71e75be5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] python 3.6: struggle to send an email with a file attached to it (NameError: name 'encoders' is not defined)

2017-03-03 Thread 'Alex Martelli' via Google App Engine
Indeed, as the message says, you have nowhere defined the top-level name
`encoders`.

Presumably, you're missing an import for that name as per
https://docs.python.org/3/library/email.encoders.html -- `from email import
encoders` among other imports at the top of your code.


Alex

On Fri, Mar 3, 2017 at 9:08 AM, Guillaume France 
wrote:

> I'm struggling to send an email with a file attached to it.
>
> Hi!
>
> I'm struggling with the create_message_with_attachment function (the rest
> works, create_message_without_attachment works ).
>
> I did read google documentation. The stack threads talking about it focus
> on complex issue (while mixing up on the top of it different syntax of
> python version). Posting this in stack will be down-voted as duplicated
> (stack has its limit).
>
> I'm just trying with the script bellow to create an email, attach a file
> to it and send it.
>
>
> *The python 3.6 script returns: *
>
>>   encoders.encode_base64(part)
>> NameError: name 'encoders' is not defined
>
>
>
>
>
> import httplib2
> import os
> import oauth2client
> from oauth2client import client, tools
> import base64
> from email.mime.multipart import MIMEMultipart
> from email.mime.text import MIMEText
> from email.mime.base import MIMEBase
> from apiclient import errors, discovery
>
> SCOPES = 'https://www.googleapis.com/auth/gmail.send'
> CLIENT_SECRET_FILE = 'client_secret.json'
> APPLICATION_NAME = 'Gmail API Python Send Email'
>
> def get_credentials():
>  home_dir = os.path.expanduser('~')
>  credential_dir = os.path.join(home_dir, '.credentials')
>  if not os.path.exists(credential_dir):
>  os.makedirs(credential_dir)  #create folder if doesnt exist
>  credential_path = os.path.join(credential_dir,
> 'gmail-python-email-send.json')
>  store = oauth2client.file.Storage(credential_path)
>  credentials = store.get()
>  if not credentials or credentials.invalid:
>  flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
>  flow.user_agent = APPLICATION_NAME
>  credentials = tools.run_flow(flow, store)
>  print('Storing credentials to ' + credential_path)
>  return credentials
>
> def SendMessage(sender, to, subject, msgHtml, msgPlain):
>  credentials = get_credentials()
>  http = httplib2.Http()
>  http = credentials.authorize(http)
>  service = discovery.build('gmail', 'v1', http=http)
>
>  # #with attachement
>  message_with_attach = create_message_with_attachment(sender, to, subject,
> msgHtml, msgPlain)
>  SendMessageInternal(service, "me", message_with_attach)
>
>  # #without attachment
>  # message_without_attachment = create_message_without_attachment(sender,
> to, subject, msgHtml, msgPlain)
>  # SendMessageInternal(service, "me", message_without_attachment)
>
>
> def SendMessageInternal(service, user_id, message):
>  try:
>  message = (service.users().messages().send(userId=user_id, body=message).
> execute())  need  to get user_id before
>
>  message_ID = message['id']
>  print(f'Message Id: {message_ID}')
>  return [message, message_ID] #return value as list
>  except errors.HttpError as error:
>  print(f'An error occurred: {error}')
>
>
> def create_message_without_attachment (sender, to, subject, msgHtml,
> msgPlain):
>  msg = MIMEMultipart('alternative')
>  msg['Subject'] = subject
>  msg['From'] = sender
>  msg['To'] = to
>  msg.attach(MIMEText(msgPlain, 'plain'))
>  msg.attach(MIMEText(msgHtml, 'html'))
>
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>
> def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain
> ):
>  msg = MIMEMultipart('alternative')
>  msg['To'] = to
>  msg['From'] = sender
>  msg['Subject'] = subject
>  msg.attach(MIMEText(msgPlain, 'plain'))
>  msg.attach(MIMEText(msgHtml, 'html'))
>
>  # the problem comes from this part
>  part = MIMEBase('application', "octet-stream")
>  part.set_payload( open(r"C:\Users\xx\Desktop\test_Attachment.txt","rb").
> read() )
>  encoders.encode_base64(part)
>  part.add_header('Content-Disposition', 'attachment; filename="{0}"'.
> format(os.path.basename(f)))
>  msg.attach(part)
>
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>
> def main():
>  to = "yourem...@gmail.com"
>  sender = "myem...@gmail.com"
>  subject = "subject test1"
>  msgHtml = r'HiHtml hello'
>  msgPlain = "Hi\nPlain Email"
>  message_text= "this is message text"
>  SendMessage(sender, to, subject, msgHtml, msgPlain)
>
>
> if __name__ == '__main__':
>  main()
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at https://groups.google.com/group/google-appengine.
> To view this discussion on the web visit https://groups.google.com/d/
>

[google-appengine] Re: Life beyond compat

2017-03-03 Thread 'George (Cloud Platform Support)' via Google App Engine


How did you conduct the transition, step-by-step? 

One of the necessary configuration steps might have a direct influence on 
the issues you mention, namely: “Customizing the Java 8 / Jetty 9.3 
runtime” from the “The Java 8 / Jetty 9.3 Runtime” document 
. 

More details, such that you deem relevant, may prove of help as well. 

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/64b6afe7-6f43-4123-9bb5-5bc13e1511b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: Datastore String length limit of 1,500 bytes when using JDO

2017-03-03 Thread Jim
Nick,

When I'm using the Datastore Console to manually update the table it will 
throw an error related to the index if I have the indexing turned on for 
the field and try to store a large value.  When I turn indexing off I am 
able to store large strings through the console.

In my Java/JDO code I am unable to store large values under either indexing 
condition.  I have my class annotated to turn indexing off like this:

@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private String meterOptions;

Jim



On Thursday, March 2, 2017 at 5:57:41 PM UTC-6, Nick (Cloud Platform 
Support) wrote:
>
> Hey Jim,
>
> Do I understand correctly that you only see the issue when you attempt to 
> index the field - or what's the same thing - it doesn't occur when you turn 
> the field's indexing off? 
>
> Cheers,
>
> Nick
> Cloud Platform Community Support
>
> On Thursday, March 2, 2017 at 1:26:02 PM UTC-5, Jim wrote:
>>
>> When I attempt to write a Datastore string longer than 1,500 bytes via 
>> JDO I get the following error:   "String properties must be 1500 bytes or 
>> less.  Instead, use com.google.appengine.api.datastore.Text, which can 
>> store strings of any length."
>>
>> I've annotated my class to turn indexing off on this field, and I can 
>> manually insert strings (much) longer than 1,500 bytes manually via the 
>> Datastore Console.  
>>
>> Is there any way to store larger String values via JDO?  It seems like an 
>> arbitrary limitation given the fact that I can manually insert larger 
>> values into the Datastore, and Datastore doc says Strings can be up to ~1MB 
>> in size.  I know I can convert these to Text but I'd rather not do that if 
>> I can avoid it.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/323c9aee-70c0-4f8f-aa71-7e2f39fb62ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] I'm struggling to attach a file to this email

2017-03-03 Thread 'Alex Martelli' via Google App Engine
I answered on the duplicate thread you opened 2.5 hours later. To repeat:
there's a bug in your code, a missing `from email import encoders` at the
top. BTW, I think your bug has nothing to do with Google App Engine.

Alex

On Fri, Mar 3, 2017 at 7:08 AM, Guillaume France 
wrote:

> I'm struggling with the create_message_with_attachment (the rest works,
> create_message_without_attachment works ).
>
> I did read google documentation. The stack thread talking about it focus
> on complicate point (while mixing up the different python version). Posting
> this in stack will be down-voted as duplicated (stack has its limit).
>
> The script bellow only create an email attach a file to it and send it
> (well, it's suppose to do so)
>
> This script return:
>   encoders.encode_base64(part)
> NameError: name 'encoders' is not defined
>
>
>
>
> import httplib2
> import os
> import oauth2client
> from oauth2client import client, tools
> import base64
> from email.mime.multipart import MIMEMultipart
> from email.mime.text import MIMEText
> from email.mime.base import MIMEBase
> from apiclient import errors, discovery
>
>
> SCOPES = 'https://www.googleapis.com/auth/gmail.send'
> CLIENT_SECRET_FILE = 'client_secret.json'
> APPLICATION_NAME = 'Gmail API Python Send Email'
>
>
>
>
> def get_credentials():
>  home_dir = os.path.expanduser('~')
>  credential_dir = os.path.join(home_dir, '.credentials')
>  if not os.path.exists(credential_dir):
>  os.makedirs(credential_dir)  #create folder if doesnt exist
>  credential_path = os.path.join(credential_dir,
> 'gmail-python-email-send.json')
>  store = oauth2client.file.Storage(credential_path)
>  credentials = store.get()
>  if not credentials or credentials.invalid:
>  flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
>  flow.user_agent = APPLICATION_NAME
>  credentials = tools.run_flow(flow, store)
>  print('Storing credentials to ' + credential_path)
>
>  return credentials
>
>
>
>
>
> def SendMessage(sender, to, subject, msgHtml, msgPlain):
>  credentials = get_credentials()
>  http = httplib2.Http()
>  http = credentials.authorize(http)
>  service = discovery.build('gmail', 'v1', http=http)
>
>  # #without attachment
>  # message_without_attachment = create_message_without_attachment(sender,
> to, subject, msgHtml, msgPlain)
>  # SendMessageInternal(service, "me", message_without_attachment)
>
>  # #with attachement
>  message_with_attach = create_message_with_attachment(sender, to, subject,
> msgHtml, msgPlain)
>  SendMessageInternal(service, "me", message_with_attach)
>
>
>
> def SendMessageInternal(service, user_id, message):
>  try:
>  message = (service.users().messages().send(userId=user_id, body=message).
> execute())  need  to get user_id before
>
>
>  message_ID = message['id']
>  print(f'Message Id: {message_ID}')
>  return [message, message_ID] #return value as list
>  except errors.HttpError as error:
>  print(f'An error occurred: {error}')
>
>
> def create_message_without_attachment (sender, to, subject, msgHtml,
> msgPlain):
>  msg = MIMEMultipart('alternative')
>  msg['Subject'] = subject
>  msg['From'] = sender
>  msg['To'] = to
>  msg.attach(MIMEText(msgPlain, 'plain'))
>  msg.attach(MIMEText(msgHtml, 'html'))
>
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>
>
>
> def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain
> ):
>  msg = MIMEMultipart('alternative')
>  msg['To'] = to
>  msg['From'] = sender
>  msg['Subject'] = subject
>  msg.attach(MIMEText(msgPlain, 'plain'))
>  msg.attach(MIMEText(msgHtml, 'html'))
>
>  # the problem comes from this part
>  part = MIMEBase('application', "octet-stream")
>  part.set_payload( open(r"C:\Users\xx\Desktop\test_Attachment.txt","rb").
> read() )
>  encoders.encode_base64(part)
>  part.add_header('Content-Disposition', 'attachment; filename="{0}"'.
> format(os.path.basename(f)))
>  msg.attach(part)
>
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>
> def main():
>  to = "yourem...@gmail.com"
>  sender = "myem...@gmail.com"
>  subject = "subject test1"
>  msgHtml = r'HiHtml hello'
>  msgPlain = "Hi\nPlain Email"
>  message_text= "this is message text"
>  SendMessage(sender, to, subject, msgHtml, msgPlain)
>
>
> if __name__ == '__main__':
>  main()
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at https://groups.google.com/group/google-appengine.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-appengine/f5e41361-c3e8-4cd2-9cb6-
> fe1a95928790%40googlegroups.com
> 

[google-appengine] Re: python 3.6: struggle to send an email with a file attached to it (NameError: name 'encoders' is not defined)

2017-03-03 Thread Guillaume France
Thanks a lot Alex, you are right the from email import encoders was 
missing. Now it sends the email *but* without the file attached to it. 

Any idea what could go wrong in the create_message_with_attachment() ?


On Friday, March 3, 2017 at 6:08:07 PM UTC+1, Guillaume France wrote:
>
> I'm struggling to send an email with a file attached to it.
>
> Hi!
>
> I'm struggling with the create_message_with_attachment function (the rest 
> works, create_message_without_attachment works ). 
>
> I did read google documentation. The stack threads talking about it focus 
> on complex issue (while mixing up on the top of it different syntax of 
> python version). Posting this in stack will be down-voted as duplicated 
> (stack has its limit).
>
> I'm just trying with the script bellow to create an email, attach a file 
> to it and send it. 
>
>
> *The python 3.6 script returns: *
>
>>   encoders.encode_base64(part)
>> NameError: name 'encoders' is not defined
>
>
>
>
>
> import httplib2
> import os
> import oauth2client
> from oauth2client import client, tools
> import base64
> from email.mime.multipart import MIMEMultipart
> from email.mime.text import MIMEText
> from email.mime.base import MIMEBase
> from apiclient import errors, discovery  
>
> SCOPES = 'https://www.googleapis.com/auth/gmail.send'
> CLIENT_SECRET_FILE = 'client_secret.json'
> APPLICATION_NAME = 'Gmail API Python Send Email'
>
> def get_credentials():
>  home_dir = os.path.expanduser('~') 
>  credential_dir = os.path.join(home_dir, '.credentials') 
>  if not os.path.exists(credential_dir):
>  os.makedirs(credential_dir)  #create folder if doesnt exist
>  credential_path = os.path.join(credential_dir, 
> 'gmail-python-email-send.json')
>  store = oauth2client.file.Storage(credential_path)
>  credentials = store.get()
>  if not credentials or credentials.invalid:
>  flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
>  flow.user_agent = APPLICATION_NAME
>  credentials = tools.run_flow(flow, store)
>  print('Storing credentials to ' + credential_path)
>  return credentials
>  
> def SendMessage(sender, to, subject, msgHtml, msgPlain):
>  credentials = get_credentials() 
>  http = httplib2.Http()
>  http = credentials.authorize(http) 
>  service = discovery.build('gmail', 'v1', http=http)
>  
>  # #with attachement
>  message_with_attach = create_message_with_attachment(sender, to, subject, 
> msgHtml, msgPlain)
>  SendMessageInternal(service, "me", message_with_attach)
>
>  # #without attachment
>  # message_without_attachment = create_message_without_attachment(sender, 
> to, subject, msgHtml, msgPlain)
>  # SendMessageInternal(service, "me", message_without_attachment)
>  
>  
> def SendMessageInternal(service, user_id, message): 
>  try:
>  message = (service.users().messages().send(userId=user_id, body=message).
> execute())  need  to get user_id before
>
>  message_ID = message['id']
>  print(f'Message Id: {message_ID}')
>  return [message, message_ID] #return value as list
>  except errors.HttpError as error:
>  print(f'An error occurred: {error}') 
>  
>  
> def create_message_without_attachment (sender, to, subject, msgHtml, 
> msgPlain):
>  msg = MIMEMultipart('alternative')
>  msg['Subject'] = subject
>  msg['From'] = sender
>  msg['To'] = to
>  msg.attach(MIMEText(msgPlain, 'plain'))
>  msg.attach(MIMEText(msgHtml, 'html'))
>  
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>  
> def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain
> ):
>  msg = MIMEMultipart('alternative')
>  msg['To'] = to
>  msg['From'] = sender
>  msg['Subject'] = subject
>  msg.attach(MIMEText(msgPlain, 'plain'))
>  msg.attach(MIMEText(msgHtml, 'html'))
>
>  # the problem comes from this part
>  part = MIMEBase('application', "octet-stream")
>  part.set_payload( open(r"C:\Users\xx\Desktop\test_Attachment.txt","rb").
> read() )
>  encoders.encode_base64(part)
>  part.add_header('Content-Disposition', 'attachment; filename="{0}"'.
> format(os.path.basename(f)))
>  msg.attach(part)
>  
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>  
> def main():
>  to = "yourem...@gmail.com"
>  sender = "myem...@gmail.com"
>  subject = "subject test1"
>  msgHtml = r'HiHtml hello'
>  msgPlain = "Hi\nPlain Email"
>  message_text= "this is message text"
>  SendMessage(sender, to, subject, msgHtml, msgPlain)
>
>
> if __name__ == '__main__':
>  main()
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/7ca

[google-appengine] Re: python 3.6: struggle to send an email with a file attached to it (NameError: name 'encoders' is not defined)

2017-03-03 Thread Guillaume France
Thanks a lot Alex, you are right the from email import encoders was 
missing. Now it sends the email *but* without the file attached to it. 

Any idea what could go wrong with this function? (I corrected other things 
on it, I don't understand why it doesn't work)

def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):
 msg = MIMEMultipart('alternative')
 msg['To'] = to
 msg['From'] = sender
 msg['Subject'] = subject
 msg.attach(MIMEText(msgPlain, 'plain'))
 msg.attach(MIMEText(msgHtml, 'html'))
 
 
 file=r"C:\Users\xx\Desktop\test_Attachment.txt"
 part = MIMEBase('application', "octet-stream")
 part.set_payload( open(r"file","rb").read() )
 encoders.encode_base64(part)
 part.add_header('Content-Disposition', 'attachment', filename=
"test_Attachment.txt")
 msg.attach(part)
 
 
 raw = base64.urlsafe_b64encode(msg.as_bytes())
 raw = raw.decode()
 body = {'raw': raw}
 return body




-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/6189a498-f826-42f4-a1a8-ad2ec93647b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: How to download data from my datastore to the local machine

2017-03-03 Thread 'Alex (Cloud Platform Support)' via Google App Engine


In fact, current Cloud Datastore’s NoSQL implementation of relationships 
between data objects differs from traditional databases. And the observed 
feature differences in this thread can be related to what is described on 
the Google Cloud Datastore Overview documentation 
.

Nevertheless, in case you would want to migrate your data to another Google 
Cloud application, you can use the Cloud Storage backing up functionality 
to export a datastore backup into a Storage bucket (See this Backing up 
data section 

 
of the Managing Datastore guide). Note that using this method, also allows 
to export your data to other Google Cloud Platform services, such as Google 
BigQuery (See Backup and restore considerations 

).

Lastly, here is a guide 
 
about Accessing App Engine with Remote API, that may get you further 
insights on how to write a client to download the data according to your 
specifications. See step 6 of Using the Remote API in a local client section 

 
for an example on how to format and retrieve data from a Datastore instance.

Hope you’ll find this information insightful and feel free to look at 
different Cloud products as Cloud SQL  
that may more accurately suit your needs. In case you would like to see the 
previously available "appcfg.py” [download_data] available in this Cloud 
Datastore implementation, it is possible to open a Features request on this 
Issue Tracker and making sure to specify “Feature Requests” under Component.

Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/69a02536-6441-4251-afd1-782eb1c74525%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: python 3.6: struggle to send an email with a file attached to it (NameError: name 'encoders' is not defined)

2017-03-03 Thread Guillaume France

Thanks a lot Alex, you are right the from email import encoders was 
missing. Now it sends the email but without the file attached to it. 

Any idea what could go wrong with this function? (I corrected other things 
on it, it's the result of patchwork of code I took from several places)


def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):

 # Create message container - the correct MIME type is 
multipart/alternative.
 msg = MIMEMultipart('alternative')
 msg['To'] = to
 msg['From'] = sender
 msg['Subject'] = subject
 
 # Record the MIME types of both parts - text/plain and text/html
 part1 = MIMEText(msgPlain, 'plain')
 part2 = MIMEText(msgHtml, 'html')
 
 # create .txt attachment
 filename=r"C:\Users\xxx\Desktop\test_Attachment.txt"
 fp=open(filename,'rb')
 att = email.mime.application.MIMEApplication(fp.read(),_subtype="txt")
 fp.close()
 att.add_header('Content-Disposition','attachment',filename=filename)


 # Attach parts into message container.
 msg.attach(att)
 msg.attach(part1)
 msg.attach(part2)
 
 # raw = base64.urlsafe_b64encode(msg.as_bytes())
 raw= encoders.encode_base64(msg)
 raw = raw.decode()
 body = {'raw': raw}
 return body

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/3017717e-019f-47a8-96ce-4c45723e9d31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: Migrating from Endpoints v1 to v2 for AppEngine

2017-03-03 Thread 'Frank Natividad' via Google App Engine
[Solution - for given situation]

The customer was able to get passed this issue by doing the following:

   1. gcloud components update
   2. Change version for appengine-api-1.0-sdk from  1.9.30 to 1.9.49
   3. gcloud deploy openapi.json, because the sample sends metrics to the 
   endpoints service
   4. export 
   ENDPOINTS_SERVICE_NAME=echo-api-flex.endpoints.[YOUR_PROJECT_ID].cloud.goog

Others who see this issue:


   1. gcloud components update
   2. git pull (Get the latest code sample, because it's changed frequently)
   3. Follow instructions 
   here: 
https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java
 



On Tuesday, February 21, 2017 at 6:01:24 PM UTC-8, Frank Natividad wrote:
>
> Hi Paul, 
>
> Sorry to hear you had a problem trying to run our sample locally. I'm 
> looking into it now. 
>
>
>
> On Tuesday, February 21, 2017 at 1:51:47 PM UTC-8, Paul Mazzuca wrote:
>>
>> After doing a gcloud update, and mvn clean package, and running mvn 
>> appengine:run with Java 7, I receive the following error in the client 
>> response to the curl request:
>>
>>
>>
>> 
>>
>> 
>>
>> 
>>
>> Error 500 usingExperimentalRuntime
>>
>> 
>>
>> HTTP ERROR 500
>>
>> Problem accessing /_ah/api/echo/v1/echo. Reason:
>>
>> usingExperimentalRuntimeCaused 
>> by:java.lang.NoSuchFieldError: usingExperimentalRuntime
>>
>> at 
>> com.google.appengine.api.urlfetch.URLFetchServicePb$URLFetchRequest.writeTo(URLFetchServicePb.java:1928)
>>
>> at 
>> com.google.appengine.repackaged.com.google.protobuf.AbstractMessageLite.toByteArray(AbstractMessageLite.java:41)
>>
>> at 
>> com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:40)
>>
>> at 
>> com.google.api.client.extensions.appengine.http.UrlFetchRequest.execute(UrlFetchRequest.java:74)
>>
>> at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:972)
>>
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
>>
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
>>
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
>>
>> at com.google.api.control.Client.check(Client.java:188)
>>
>> at com.google.api.control.ControlFilter.doFilter(ControlFilter.java:249)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at com.google.api.control.ConfigFilter.doFilter(ConfigFilter.java:120)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> com.google.appengine.tools.development.devappserver2.RequestIdFilter.doFilter(RequestIdFilter.java:36)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:128)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>>
>> at 
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
>>
>> at 
>> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>>
>> at 
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>
>> at 
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>
>> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
>>
>> at 
>> com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:95)
>>
>> at 
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>
>> at 
>> com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:508)
>>
>> at 
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>
>> at org.mortbay.jetty.Server.handle(Server.java:326)
>>
>> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>
>> at 
>> org

[google-appengine] Re: How to download data from my datastore to the local machine

2017-03-03 Thread Delyan Spasov
Thank you Alex,

I have read the docs for the remote_api. For some reason it isn't working 
and the error isn't very useful to find our why 
- NotSupportedOnThisPlatform.
I have found bug reports about this, but nobody is giving a working 
solution. 

Fortunately I can connect the remote_api from the console and I wrote a 
simple script to download the data to a file (Good that my database was a 
small one).

Regards

On Friday, March 3, 2017 at 9:43:59 PM UTC+2, Alex (Cloud Platform Support) 
wrote:
>
> In fact, current Cloud Datastore’s NoSQL implementation of relationships 
> between data objects differs from traditional databases. And the observed 
> feature differences in this thread can be related to what is described on 
> the Google Cloud Datastore Overview documentation 
> .
>
> Nevertheless, in case you would want to migrate your data to another 
> Google Cloud application, you can use the Cloud Storage backing up 
> functionality to export a datastore backup into a Storage bucket (See this 
> Backing up data section 
> 
>  
> of the Managing Datastore guide). Note that using this method, also allows 
> to export your data to other Google Cloud Platform services, such as Google 
> BigQuery (See Backup and restore considerations 
> 
> ).
>
> Lastly, here is a guide 
>  
> about Accessing App Engine with Remote API, that may get you further 
> insights on how to write a client to download the data according to your 
> specifications. See step 6 of Using the Remote API in a local client 
> section 
> 
>  
> for an example on how to format and retrieve data from a Datastore instance.
>
> Hope you’ll find this information insightful and feel free to look at 
> different Cloud products as Cloud SQL  
> that may more accurately suit your needs. In case you would like to see the 
> previously available "appcfg.py” [download_data] available in this Cloud 
> Datastore implementation, it is possible to open a Features request on this 
> Issue Tracker and making sure to specify “Feature Requests” under Component.
>
> Regards,
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/3bc69663-dca2-4c83-bf18-eb34299a5436%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: MemCache and NDB

2017-03-03 Thread 'Nick (Cloud Platform Support)' via Google App Engine
Hey Ivo,

It seems odd that you'd see nothing for hot keys. I've emailed you to ask 
for your project ID, so feel free to reply to that email when you get a 
chance. 

In the meantime, I'm also curious about your observation of the key 
distribution. Could you possibly show some sample keys, 
sanitized/obfuscated for security, but which will still give an indication 
of what you mean by the key space not being properly distributed-into by 
NDB? If you like, you can also include the keys, without alteration, in 
your private email reply.

Of course, feel free to add any other useful information or any additional 
questions.

Cheers,

Nick
Cloud Platform Community Support

On Friday, March 3, 2017 at 6:00:20 AM UTC-5, Ivo Bellin Salarin wrote:
>
> Hi all,
>
> I have two questions concerning memcache and its performances.
>
> I was reading the page 
> https://cloud.google.com/appengine/articles/best-practices-for-app-engine-memcache#distribute_load_across_the_keyspace,
>  
> where I found
> *The Memcache viewer in the administration console displays a list of top 
> keys, which can be used to identify bottlenecks*
>
> In my administration console, this section is empty. (i.e. 'No hot keys')
> But yes, I am sure that there are hot keys, since among the stackdriver 
> insights I can see the following messages
> Slow memcache calls. Your app made 1 remote procedure calls to memcache 
> that took more than 50 ms and the slowest call took 66 ms. Consider 
> reducing the value of max_concurrent_requests for your app.
> 1) Thus, where can I find the hottest keys of my dedicated memcache?
>
> In the meanwhile, according to the messages I can find in StackDriver, the 
> longest (thus, probably, hottest) memcache.get(s) are made by ndb.get(). In 
> the code of ndb.get I can see that the cache keys are **not** distributed 
> across the keyspace (as recommended by the page above).
> I think that not using memcache (use_memcache=False) would be a worse 
> solution.
> 2) Is there a way to force a better key distribution for NDB, apart from 
> monkey patching 
> /gcloud/platform/google_appengine/google/appengine/ext/ndb/context.py::Context._memcache_prefix
>  
> with a time dependent % operation? :-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/9dabb18d-8ad8-4a2e-8c1d-9679e1aa5afe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: Endpoints not working locally (for GO)

2017-03-03 Thread Steven Kampen

>
> 1. How do you run the devserver exactly?
>
As mentioned earlier, with `dev_appserver ./` or `goapp serve ./`.
 

> 2. What's the exact output?
>
As mentioned earlier, the only "output" is the expected messages about the 
dev server starting up.
  INFO 2017-02-16 19:00:03,827 devappserver2.py:764] Skipping SDK 
update check.
  INFO 2017-02-16 19:00:03,878 api_server.py:268] Starting API server 
at: http://localhost:55881
  INFO 2017-02-16 19:00:03,881 dispatcher.py:199] Starting module 
"default" running at: http://localhost:8080
  INFO 2017-02-16 19:00:03,887 admin_server.py:116] Starting admin 
server at: http://localhost:8000

The *issue* is that the endpoints all return 404.

3. How do you send the request to the server?
>
HTTP! How do you usually do it?? No, jk, I used curl. 

The API explorer also does not "discover" the API.

4. Can this be reproduced using the endpoints example from the github repo 
> 
> ?
>
No idea. I'm not familiar with that way of using endpoints with appengine & 
go. However, it can be replicated using the example provided in the README 
here: https://github.com/GoogleCloudPlatform/go-endpoints (the greetings 
app).

On Wednesday, 22 February 2017 23:53:38 UTC+1, Nick (Cloud Platform 
Support) wrote:
>
> Hey Steven,
>
> Thanks for letting us know. This seems like something that we could take a 
> look at on the Public Issue Tracker 
> . In order to 
> produce a report there, we'll need a few more details though, for your 
> specific case:
>
> 1. How do you run the devserver exactly?
> 2. What's the exact output?
> 3. How do you send the request to the server?
> 4. Can this be reproduced using the endpoints example from the github repo 
> 
> ?
>
> With this information, we'll be able to begin work on reproducing the 
> behaviour for specialists to take a look at and correct.
>
> Cheers,
>
> Nick
> Cloud Platform Community Support
>
> On Saturday, February 18, 2017 at 7:38:48 AM UTC-5, Steven Kampen wrote:
>>
>> Looks like this is specific to OSX, judging by this report here: 
>> http://stackoverflow.com/questions/42282294/404-when-migrating-go-appengine-app-from-ubuntu-to-macos
>>
>> I tested out a bunch of GCloud SDK versions until I found that the break 
>> starts in v138.0.0, which uses Python Extensions v1.9.49. GCloud SDK 
>> v137.0.1 uses Python Extensions v1.9.40, and works fine.
>>
>>
>>
>> On Saturday, 18 February 2017 12:22:38 UTC+1, Steven Kampen wrote:
>>>
>>> Thanks for the reply Nick,
>>>
>>> There is no stacktrace. The API service just seems not to be running. If 
>>> I hit the endpoint path (verified from production) on the "main" port (8080 
>>> by default, and which I assume is the intended behaviour) I get 404s. If I 
>>> hit the endpoint path at the "API Server" host (port 55881 in the example 
>>> above), then I get a response like "{app_id: dev~myprojectname, rtok: 
>>> '0'}". I actually get this response from that host for all paths.
>>>
>>> I'm using version 1.9.48 of the SDK.
>>>
>>>
>>>
>>>
>>> On Friday, 17 February 2017 01:46:45 UTC+1, Nick (Cloud Platform 
>>> Support) wrote:

 Hey Steven,

 This kind of post - a specific-issue technical support question - would 
 be best sent to Stack Overflow, as there's a much larger user-base there 
 and their site is designed for that kind of post. This forum is meant for 
 more general discussion of the platform and services, design patterns, 
 free-form discussion not necessarily based on 1 question 1 answer. 

 But nonetheless, I'll be happy to assist here and possibly we can get 
 this question to a state where it can be posted to Stack Overflow.

 Some questions that jump out at me from reading your post:

 * What is the error that you see in development? Posting a full stack 
 trace helps to determine what went wrong
 * What version of the SDK are you using?

 I'll take a look at running the code from the tutorial you linked 
 myself and see if I can also see the error.

 Cheers,

 Nick
 Cloud Platform Community Support

 On Thursday, February 16, 2017 at 2:05:13 PM UTC-5, Steven Kampen wrote:
>
> I've previously used Python and Java SDKs (with endpoints), though 
> it's been a while.
>
> When I setup a simple Go app with a single endpoint (similar to 
> https://medium.com/google-cloud/go-cloud-endpoints-and-app-engine-64d1c78bea82#.8xz2ol18k)
>  
> I'm not able to get any response from the endpoints.
>
> I'm starting the app with both `goapp serve ./` and `dev_appserver.py 
> ./` with the same result. *When deployed, the endpoints do work.*
>
> ```
> INFO 2017-02-16 19:00:03,827 devap

[google-appengine] python 3.6: the script send message but without the attachement

2017-03-03 Thread Guillaume France
Hi!

This script send the message but does not include the attachement. I'm 
struggling with the create_message_with_attachment function . 

I did read google documentation. The stack threads talking about it focus 
on complex issue (while mixing up on the top of it different syntax of 
python version). Posting this in stack will be down-voted as duplicated 
(stack has its limit).

Thanks in advance for your help!


Here is the faulty function (full code bellow)

def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):
 
 # multipart container can contain other MIME parts.  (attachment will be 
independent of the multipart/alternative)
 msg = MIMEMultipart('alternative')
 msg['To'] = to
 msg['From'] = sender
 msg['Subject'] = subject
 
 # convert both part to a MIME compatible string
 part1 = MIMEText(msgPlain, 'plain') 
 part2 = MIMEText(msgHtml, 'html')
 
 # create .txt attachment
 filename=r"C:\Users\xxx\Desktop\test_Attachment.txt"
 fp=open(filename).read()
 att = MIMEApplication(fp)
 fp.close()
 
 #This will add a header that looks like: "Content-Disposition: attachment; 
filename="test_Attachment.txt" "
 att.add_header('content-disposition', 'attachment', filename = ('utf-8', ''
, 'test_Attachment.txt'))
 
 # Attach parts into message container.
 msg.attach(att)
 msg.attach(part1)
 msg.attach(part2)


 raw = base64.urlsafe_b64encode(msg.as_bytes())
 # raw= encoders.encode_base64(msg)
 raw = raw.decode()
 body = {'raw': raw}
 return body
 

*The whole code:*

import httplib2
import os
import oauth2client
from oauth2client import client, tools
import base64
from email import encoders
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from apiclient import errors, discovery  

SCOPES = 'https://www.googleapis.com/auth/gmail.send'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Gmail API Python Send Email'

def get_credentials():
 home_dir = os.path.expanduser('~') 
 credential_dir = os.path.join(home_dir, '.credentials') 
 if not os.path.exists(credential_dir):
 os.makedirs(credential_dir)  #create folder if doesnt exist
 credential_path = os.path.join(credential_dir, 
'gmail-python-email-send.json')
 store = oauth2client.file.Storage(credential_path)
 credentials = store.get()
 if not credentials or credentials.invalid:
 flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
 flow.user_agent = APPLICATION_NAME
 credentials = tools.run_flow(flow, store)
 print('Storing credentials to ' + credential_path)
 return credentials
 
def SendMessage(sender, to, subject, msgHtml, msgPlain):
 credentials = get_credentials() 
 http = httplib2.Http()
 http = credentials.authorize(http) 
 service = discovery.build('gmail', 'v1', http=http)
 
 # #with attachement
 message_with_attach = create_message_with_attachment(sender, to, subject, 
msgHtml, msgPlain)
 SendMessageInternal(service, "me", message_with_attach)
 
def SendMessageInternal(service, user_id, message): 
 try:
 message = (service.users().messages().send(userId=user_id, body=message).
execute())  need  to get user_id before
 message_ID = message['id']
 print(f'Message Id: {message_ID}')
 return [message, message_ID] #return value as list
 except errors.HttpError as error:
 print(f'An error occurred: {error}') 
 
 
def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):
 
 # multipart container can contain other MIME parts.  (attachment will be 
independent of the multipart/alternative)
 msg = MIMEMultipart('alternative')
 msg['To'] = to
 msg['From'] = sender
 msg['Subject'] = subject
 
 # convert both part to a MIME compatible string
 part1 = MIMEText(msgPlain, 'plain') 
 part2 = MIMEText(msgHtml, 'html')
 
 # create .txt attachment
 filename=r"C:\Users\xxx\Desktop\test_Attachment.txt"
 fp=open(filename).read()
 att = MIMEApplication(fp)
 fp.close()
 
 #This will add a header that looks like: "Content-Disposition: attachment; 
filename="test_Attachment.txt" "
 att.add_header('content-disposition', 'attachment', filename = ('utf-8', ''
, 'test_Attachment.txt'))
 
 # Attach parts into message container.
 msg.attach(att)
 msg.attach(part1)
 msg.attach(part2)

 raw = base64.urlsafe_b64encode(msg.as_bytes())
 # raw= encoders.encode_base64(msg)
 raw = raw.decode()
 body = {'raw': raw}
 return body
  
def main():
 to = "yourem...@gmail.com"
 sender = "myem...@gmail.com"
 subject = "subject test1"
 msgHtml = r'HiHtml hello'
 msgPlain = "Hi\nPlain Email"
 message_text= "this is message text"
 SendMessage(sender, to, subject, msgHtml, msgPlain)


if __name__ == '__main__':
 main()



-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view thi

[google-appengine] Re: Is GAE down?

2017-03-03 Thread 'Alex (Cloud Platform Support)' via Google App Engine


Google App Engine does not seem to be down. In case this error could 
originate from your Node.js implementation, can you provide a minimal 
working example of your code demonstrating this issue?

Alternatively, you can verify the status of the endpoint you are triggering 
by sending it a request as demonstrated in this Quickstart 
 for Cloud Endpoints Frameworks 
on App Engine.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/7a45cd89-2d65-45fb-9d78-3721ff6f0a4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Re: Are requirements.txt entries for Python Flex service installed upon deployment, or upon scaling?

2017-03-03 Thread 'Nicholas (Google Cloud Support)' via Google App Engine
As I understand it, the python runtime in the flexible environment is 
essentially using the gcr.io/google-appengine/python docker image referred 
to in the custom runtime documentation 

 
except with an ENTRYPOINT 
 specified in 
the app.yaml.  We can see in the linked Dockerfile repository that 'pip 
install -r /app/requirements.txt' is executed with RUN which occurs at 
build time, thus before the image is run as a container.

If this was otherwise done when instances were created, it would add 
significant start up time and run the risk of having inconsistent 
application containers as dependencies fetched at a later time may result 
in different packages if versions are not explicit.

On Thursday, March 2, 2017 at 7:25:09 PM UTC-5, Nickolas Daskalou wrote:
>
> Hi,
>
> For Python runtimes on App Engine flex, are the entries in 
> requirements.txt 
>  
> installed by pip during the deployment process (and then stored in a saved 
> image, whereby that image is then simply duplicated when needing to scaling 
> out), or are they installed by pip during a scale out event (i.e. when the 
> App Engine scheduler decides it needs a new instance of a service)?
>
> Thanks,
> Nick
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/aa398dae-4a4e-4d33-8416-331046158b07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] Re: python 3.6: struggle to send an email with a file attached to it (NameError: name 'encoders' is not defined)

2017-03-03 Thread 'Alex Martelli' via Google App Engine
I would recommend you post this code and question to stackoverflow.com -- a
very popular site regularly visited by many programming experts who like to
answer technical questions (me included, when I have free time). You may
want to just tag the question as python and email, since it's not really
germane to google-app-engine (if you tagged it with the latter anyway, your
question might be avoided by experts on python and email who are not also
expert on App Engine).


Alex


On Fri, Mar 3, 2017 at 12:19 PM, Guillaume France 
wrote:

>
> Thanks a lot Alex, you are right the from email import encoders was
> missing. Now it sends the email but without the file attached to it.
>
> Any idea what could go wrong with this function? (I corrected other things
> on it, it's the result of patchwork of code I took from several places)
>
>
> def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain
> ):
>
>  # Create message container - the correct MIME type is
> multipart/alternative.
>  msg = MIMEMultipart('alternative')
>  msg['To'] = to
>  msg['From'] = sender
>  msg['Subject'] = subject
>
>  # Record the MIME types of both parts - text/plain and text/html
>  part1 = MIMEText(msgPlain, 'plain')
>  part2 = MIMEText(msgHtml, 'html')
>
>  # create .txt attachment
>  filename=r"C:\Users\xxx\Desktop\test_Attachment.txt"
>  fp=open(filename,'rb')
>  att = email.mime.application.MIMEApplication(fp.read(),_subtype="txt")
>  fp.close()
>  att.add_header('Content-Disposition','attachment',filename=filename)
>
>
>  # Attach parts into message container.
>  msg.attach(att)
>  msg.attach(part1)
>  msg.attach(part2)
>
>  # raw = base64.urlsafe_b64encode(msg.as_bytes())
>  raw= encoders.encode_base64(msg)
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at https://groups.google.com/group/google-appengine.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-appengine/3017717e-019f-47a8-96ce-
> 4c45723e9d31%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CAE46Be-tAdEGj84ExamTXv5HOGptW-CanLpDxYy8t%3DnTgqmhVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] python 3.6: the script send message but without the attachement

2017-03-03 Thread 'Alex Martelli' via Google App Engine
As I posted to another one of your duplicate threads:

I would recommend you post this code and question to stackoverflow.com -- a
very popular site regularly visited by many programming experts who like to
answer technical questions (me included, when I have free time). You may
want to just tag the question as python and email, since it's not really
germane to google-app-engine (if you tagged it with the latter anyway, your
question might be avoided by experts on python and email who are not also
expert on App Engine).


Alex


On Fri, Mar 3, 2017 at 1:50 PM, Guillaume France 
wrote:

> Hi!
>
> This script send the message but does not include the attachement. I'm
> struggling with the create_message_with_attachment function .
>
> I did read google documentation. The stack threads talking about it focus
> on complex issue (while mixing up on the top of it different syntax of
> python version). Posting this in stack will be down-voted as duplicated
> (stack has its limit).
>
> Thanks in advance for your help!
>
>
> Here is the faulty function (full code bellow)
>
> def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain
> ):
>
>  # multipart container can contain other MIME parts.  (attachment will be
> independent of the multipart/alternative)
>  msg = MIMEMultipart('alternative')
>  msg['To'] = to
>  msg['From'] = sender
>  msg['Subject'] = subject
>
>  # convert both part to a MIME compatible string
>  part1 = MIMEText(msgPlain, 'plain')
>  part2 = MIMEText(msgHtml, 'html')
>
>  # create .txt attachment
>  filename=r"C:\Users\xxx\Desktop\test_Attachment.txt"
>  fp=open(filename).read()
>  att = MIMEApplication(fp)
>  fp.close()
>
>  #This will add a header that looks like: "Content-Disposition:
> attachment; filename="test_Attachment.txt" "
>  att.add_header('content-disposition', 'attachment', filename = ('utf-8',
> '', 'test_Attachment.txt'))
>
>  # Attach parts into message container.
>  msg.attach(att)
>  msg.attach(part1)
>  msg.attach(part2)
>
>
>  raw = base64.urlsafe_b64encode(msg.as_bytes())
>  # raw= encoders.encode_base64(msg)
>  raw = raw.decode()
>  body = {'raw': raw}
>  return body
>
>
> *The whole code:*
>
> import httplib2
> import os
> import oauth2client
> from oauth2client import client, tools
> import base64
> from email import encoders
> from email.mime.multipart import MIMEMultipart
> from email.mime.text import MIMEText
> from apiclient import errors, discovery
>
> SCOPES = 'https://www.googleapis.com/auth/gmail.send'
> CLIENT_SECRET_FILE = 'client_secret.json'
> APPLICATION_NAME = 'Gmail API Python Send Email'
>
> def get_credentials():
>  home_dir = os.path.expanduser('~')
>  credential_dir = os.path.join(home_dir, '.credentials')
>  if not os.path.exists(credential_dir):
>  os.makedirs(credential_dir)  #create folder if doesnt exist
>  credential_path = os.path.join(credential_dir,
> 'gmail-python-email-send.json')
>  store = oauth2client.file.Storage(credential_path)
>  credentials = store.get()
>  if not credentials or credentials.invalid:
>  flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
>  flow.user_agent = APPLICATION_NAME
>  credentials = tools.run_flow(flow, store)
>  print('Storing credentials to ' + credential_path)
>  return credentials
>
> def SendMessage(sender, to, subject, msgHtml, msgPlain):
>  credentials = get_credentials()
>  http = httplib2.Http()
>  http = credentials.authorize(http)
>  service = discovery.build('gmail', 'v1', http=http)
>
>  # #with attachement
>  message_with_attach = create_message_with_attachment(sender, to, subject,
> msgHtml, msgPlain)
>  SendMessageInternal(service, "me", message_with_attach)
>
> def SendMessageInternal(service, user_id, message):
>  try:
>  message = (service.users().messages().send(userId=user_id, body=message).
> execute())  need  to get user_id before
>  message_ID = message['id']
>  print(f'Message Id: {message_ID}')
>  return [message, message_ID] #return value as list
>  except errors.HttpError as error:
>  print(f'An error occurred: {error}')
>
>
> def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain
> ):
>
>  # multipart container can contain other MIME parts.  (attachment will be
> independent of the multipart/alternative)
>  msg = MIMEMultipart('alternative')
>  msg['To'] = to
>  msg['From'] = sender
>  msg['Subject'] = subject
>
>  # convert both part to a MIME compatible string
>  part1 = MIMEText(msgPlain, 'plain')
>  part2 = MIMEText(msgHtml, 'html')
>
>  # create .txt attachment
>  filename=r"C:\Users\xxx\Desktop\test_Attachment.txt"
>  fp=open(filename).read()
>  att = MIMEApplication(fp)
>  fp.close()
>
>  #This will add a header that looks like: "Content-Disposition:
> attachment; filename="test_Attachment.txt" "
>  att.add_header('content-disposition', 'attachment', filename = ('utf-8',
> '', 'test_Attachment.txt'))
>
>  # Attach parts into message container.
>  msg.attach(att)
>  msg.attach(part1)
>  msg.attach(part2)
>
>  raw = base64

[google-appengine] Re: Google Code issue trackers read-only

2017-03-03 Thread 'Jesse Scherer (Google Cloud Support)' via Google App Engine
The issue trackers are back online, served from 
http://issuetracker.google.com. Please check our our blog post 

 for 
more information.

On Thursday, March 2, 2017 at 12:22:43 PM UTC-5, Jesse Scherer (Google 
Cloud Support) wrote:
>
> Greetings all,
>
> We're marking the Google Code App Engine project read-only in order to 
> perform the migration to Google Issue Tracker 
> , which will replace 
>  Google Code 
> as the backend for public-facing issue trackers. While some mechanics will 
> change, all content will be preserved. When we're done, we'll set up 
> redirects so that old links to Google Code forward to to the corresponding 
> Issue Tracker issue.
>
> I'll post again when we're back!
>
> Regards,
> Jesse
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/df11c41c-dc05-4143-b723-6299b07c72c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] appengine TimeZone changed

2017-03-03 Thread Yashavanta S B
Hey,

In ServletContextListener initialization method we are setting the JVM Time 
Zone as

public void contextInitialized(ServletContextEvent event) {
TimeZone.setDefault(TimeZone.getTimeZone("GMT+00:00"));
}

But when i check the Time Zone information in servlets and filters the Time 
Zone got changed.

log.info("TimeZone : " + TimeZone.getDefault());

What might be the reason? 

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/307e4922-a885-4cc1-9751-d1e1d2dcafd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] Re: Life beyond compat

2017-03-03 Thread Vinay Chitlangia
And here is the dockerfile: (In addition to the one mentioned in the
transition doc, we also install openjdk8 in this, and ofcourse add
requestlog in the startup command).

FROM gcr.io/google-appengine/jetty9

RUN apt-get -q update && \

apt-get -y -q --no-install-recommends -t jessie-backports install
openjdk-8-jdk && \

apt-get clean && \

rm /var/lib/apt/lists/*_*

ADD backend.war $JETTY_BASE/webapps/root.war

WORKDIR $JETTY_BASE

RUN java -jar $JETTY_HOME/start.jar --approve-all-licenses \

 --add-to-startd=jmx,stats,hawtio,requestlog \

 && chown -R jetty:jetty $JETTY_BASE

On Sat, Mar 4, 2017 at 10:25 AM, Vinay Chitlangia 
wrote:

> Thanks for the response.
> Yes, I have followed the steps in the document
>  you
> have mentioned. (You mentioned one of the step has a direct influence,
> which step is that)
>
> I modified the docker file to add requestlog. However that did not seem to
> have any impact. Attached is the screenshot of the log.
> The message about memcache host and port is written in the readhandler
> (and should have been part of the request log).
>
> The app.yaml is in src/main/appengine directory and fairly vanilla.
>
> runtime: custom
>
> env: flex
>
> handlers:
>
> - url: /.*
>
>   script: this field is required, but ignored
>
>   secure: always
>
> env_variables:
>
>   USE_GAE_MEMCACHE: 1
>
> On Fri, Mar 3, 2017 at 11:23 PM, 'George (Cloud Platform Support)' via
> Google App Engine  wrote:
>
>> How did you conduct the transition, step-by-step?
>>
>> One of the necessary configuration steps might have a direct influence on
>> the issues you mention, namely: “Customizing the Java 8 / Jetty 9.3
>> runtime” from the “The Java 8 / Jetty 9.3 Runtime” document
>> .
>>
>> More details, such that you deem relevant, may prove of help as well.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Google App Engine" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/google-appengine/FfR1B38yUEo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> google-appengine+unsubscr...@googlegroups.com.
>> To post to this group, send email to google-appengine@googlegroups.com.
>> Visit this group at https://groups.google.com/group/google-appengine.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/google-appengine/64b6afe7-6f43-4123-9bb5-5bc13e1511b6%
>> 40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CADt9hj89ss%2BsjeuFd8G8u2c0S_d_ZDruXFo9PCOz96NU1G9JPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.