billrobo / gdatacopier

Automatically exported from code.google.com/p/gdatacopier
0 stars 0 forks source link

Enhancement : Enter the password with a file #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to be able to enter the password with a file. It would
allow to do some scripting without passing it on the command line.

Ex : gcp --passwordfile thefilecontainingthepassword.txt  ...

Below is a sample patch against 2.0.2 for gcp.

Thanks a lot for gdatacopier.

--- gcp.py.dist 2010-01-06 11:47:17.000000000 +0100
+++ gcp.py      2010-01-06 11:51:27.000000000 +0100
@@ -399,6 +399,8 @@
                                                help = 'copies documents to
a sub-directory by owner name, if the directory doesn\'t exist it will be
created')
        parser.add_option('-p', '--password', dest = 'password', 
                                                help = 'password to login
to Google document servers, use with extreme caution, may be logged')
+       parser.add_option('', '--passwordfile', dest = 'passwordfile', 
+                                               help = 'name of file
containing password to login to Google document servers, this file should
obvisouly be read only by user')
        parser.add_option('-f', '--format', default = 'oo',
                                                help = 'file format to
export documents to, ensure to use default if exporting mixed types
(download only option)')

@@ -428,6 +430,9 @@
                to enter the password on the command line
        """

+       if options.passwordfile != None:
+               options.password = open(options.passwordfile,
'r').read().strip()
+
        if options.password == None: 
                options.password = getpass.getpass()

Original issue reported on code.google.com by remi.pey...@gmail.com on 6 Jan 2010 at 4:16

GoogleCodeExporter commented 9 years ago
Thanks for the suggestion and the patch remi. I will accept this for the 2.1 
release.

Original comment by devraj on 6 Jan 2010 at 9:04

GoogleCodeExporter commented 9 years ago
Incorporated modified version of the patch, with exception handling if the file 
isn't found or can't be read. 
Commited to subversion will be released as 2.1

Thanks again Remi.

Original comment by devraj on 7 Jan 2010 at 3:49