Re: [openstack-dev] [keystone] Output on stderr

2015-03-04 Thread Lin Hua Cheng
Here's the link to the code review: https://review.openstack.org/#/c/147399/

On Wed, Mar 4, 2015 at 7:17 AM, Dolph Mathews dolph.math...@gmail.com
wrote:



 On Wednesday, March 4, 2015, David Stanek dsta...@dstanek.com wrote:


 On Wed, Mar 4, 2015 at 6:50 AM, Abhishek Talwar/HYD/TCS 
 abhishek.tal...@tcs.com wrote:

 While working on a bug for keystoneclient I have replaced sys.exit with
 return. However, the code reviewers want that the output should be on
 stderr(as sys.exit does). So how can we get the output on stderr.


 The print function allows you to specify a file:

  from __future__ import print_function
  import sys
  print('something to', file=sys.stderr)

 The __future__ import is needed for Python 2.6/2.7 because print was
 changed to a function in Python 3.


 I hope that answers your question. Can we have a link to the bug and/or
 code review?




 --
 David
 blog: http://www.traceback.org
 twitter: http://twitter.com/dstanek
 www: http://dstanek.com


 __
 OpenStack Development Mailing List (not for usage questions)
 Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
 http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [keystone] Output on stderr

2015-03-04 Thread David Stanek
On Wed, Mar 4, 2015 at 6:50 AM, Abhishek Talwar/HYD/TCS 
abhishek.tal...@tcs.com wrote:

 While working on a bug for keystoneclient I have replaced sys.exit with
 return. However, the code reviewers want that the output should be on
 stderr(as sys.exit does). So how can we get the output on stderr.


The print function allows you to specify a file:

 from __future__ import print_function
 import sys
 print('something to', file=sys.stderr)

The __future__ import is needed for Python 2.6/2.7 because print was
changed to a function in Python 3.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
www: http://dstanek.com
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


[openstack-dev] [keystone] Output on stderr

2015-03-04 Thread Abhishek Talwar/HYD/TCS
Hi All,

While working on a bug for keystoneclient I have replaced sys.exit with return. 
However, the code reviewers want that the output should be on stderr(as 
sys.exit does). So how can we get the output on stderr.

def do_user_password_update(kc, args):
Update user password.
user = utils.find_resource(kc.users, args.user)
new_passwd = args.passwd or utils.prompt_for_password()
if not new_passwd:
msg = (_(\nPlease specify password using the --pass option 
 or using the prompt))
print(msg)  // I have included print and return here instead of 
sys.exit
return
kc.users.update_password(user, new_passwd) 


-- 
Thanks and Regards
Abhishek Talwar
Employee ID : 770072
Assistant System Engineer
Tata Consultancy Services,Gurgaon
India
Contact Details : +918377882003
=-=-=
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev