Re: GCP Copy Files - Data Export
On 2022-02-10 17:20, BmoreIT wrote: I did a data export from Google to export all company data - Google Data Export It shows the root folder and to download, I run this command (it automatically enters this command) gsutil -m cp -r \ "gs://takeout-export-myUniqueID" \. But I have no idea where it would save it being I am not a GCP customer, only Google Workspace. Workspace won't help because they say it's a GCP product but I am exporting from Workspace. Can someone let me know the proper command to run on my local machine with Google's SDK to download this folder? I was able to start the download yesterday but it said there was an invalid character in the file names so it killed the export. Appreciate any help! On this page: https://cloud.google.com/storage/docs/gsutil/commands/cp I think the problem might be that you have an surplus backslash. Does this work? gsutil cp -r gs://takeout-export-myUniqueID . This should copy recursively from gs://takeout-export-myUniqueID to the current folder. -- https://mail.python.org/mailman/listinfo/python-list
GCP Copy Files - Data Export
I did a data export from Google to export all company data - Google Data Export It shows the root folder and to download, I run this command (it automatically enters this command) gsutil -m cp -r \ "gs://takeout-export-myUniqueID" \. But I have no idea where it would save it being I am not a GCP customer, only Google Workspace. Workspace won't help because they say it's a GCP product but I am exporting from Workspace. Can someone let me know the proper command to run on my local machine with Google's SDK to download this folder? I was able to start the download yesterday but it said there was an invalid character in the file names so it killed the export. Appreciate any help! -- https://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On 6/18/2011 1:13 PM, Michael Hrivnak wrote: Python is great for automating sysadmin tasks, but perhaps you should just use rsync for this. It comes with the benefit of only copying the changes instead of every file every time. "rsync -a C:\source E:\destination" and you're done. Perhaps 'synctree' would be a candidate for addition to shutil. If copytree did not prohibit an existing directory as destination, it could be used for synching with an 'ignore' function. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
Python is great for automating sysadmin tasks, but perhaps you should just use rsync for this. It comes with the benefit of only copying the changes instead of every file every time. "rsync -a C:\source E:\destination" and you're done. Michael On Fri, Jun 17, 2011 at 1:06 AM, John Salerno wrote: > Based on what I've read, it seems os.rename is the proper function to > use, but I'm a little confused about the syntax. Basically I just want > to write a simple script that will back up my saved game files when I > run it. So I want it to copy a set of files/directories from a > location on my C:\ drive to another directory on my E:\ drive. I don't > want to rename or delete the originals, just move them. I also want > them to automatically overwrite whatever already happens to be in the > location on the E:\ drive. > > Is os.rename the proper function for this? Mainly I was because the > Module Index says this: > > "On Windows, if dst already exists, OSError will be raised even if it > is a file.." > > so it sounds like I can't move the files to a location where those > file names already exist. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On Jun 17, 5:15 pm, Ethan Furman wrote: > John Salerno wrote: > > On Jun 17, 2:23 pm, Terry Reedy wrote: > > >> If you follow the second part of Greg's suggestion 'or one of the other > >> related function in the shutil module', you will find copytree() > >> "Recursively copy an entire directory tree rooted at src. " > > > Yeah, but shutil.copytree says: > > > "The destination directory, named by dst, must not already exist" > > > which again brings me back to the original problem. All I'm looking > > for is a simple way to copy files from one location to another, > > overwriting as necessary, but there doesn't seem to be a single > > function that does just that. > > If you don't mind deleting what's already there: > > shutil.rmtree(...) > shutil.copytree(...) > > If you do mind, roll your own (or borrow ;): > > 8<--- > #stripped down and modified version from 2.7 shutil (not tested) > def copytree(src, dst): > names = os.listdir(src) > if not os.path.exists(dst): # no error if already exists > os.makedirs(dst) > errors = [] > for name in names: > srcname = os.path.join(src, name) > dstname = os.path.join(dst, name) > try: > if os.path.isdir(srcname): > copytree(srcname, dstname, symlinks, ignore) > else: > copy2(srcname, dstname) > except (IOError, os.error), why: > errors.append((srcname, dstname, str(why))) > # catch the Error from the recursive copytree so that we can > # continue with other files > except Error, err: > errors.extend(err.args[0]) > if errors: > raise Error(errors) > 8<--- > > ~Ethan~ Thanks. Deleting what is already there is not a problem, I was just hoping to have it overwritten without any extra steps, but that's no big deal. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
John Salerno wrote: On Jun 17, 2:23 pm, Terry Reedy wrote: If you follow the second part of Greg's suggestion 'or one of the other related function in the shutil module', you will find copytree() "Recursively copy an entire directory tree rooted at src. " Yeah, but shutil.copytree says: "The destination directory, named by dst, must not already exist" which again brings me back to the original problem. All I'm looking for is a simple way to copy files from one location to another, overwriting as necessary, but there doesn't seem to be a single function that does just that. If you don't mind deleting what's already there: shutil.rmtree(...) shutil.copytree(...) If you do mind, roll your own (or borrow ;): 8<--- #stripped down and modified version from 2.7 shutil (not tested) def copytree(src, dst): names = os.listdir(src) if not os.path.exists(dst): # no error if already exists os.makedirs(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if os.path.isdir(srcname): copytree(srcname, dstname, symlinks, ignore) else: copy2(srcname, dstname) except (IOError, os.error), why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files except Error, err: errors.extend(err.args[0]) if errors: raise Error(errors) 8<--- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On Jun 17, 2:23 pm, Terry Reedy wrote: > If you follow the second part of Greg's suggestion 'or one of the other > related function in the shutil module', you will find copytree() > "Recursively copy an entire directory tree rooted at src. " Yeah, but shutil.copytree says: "The destination directory, named by dst, must not already exist" which again brings me back to the original problem. All I'm looking for is a simple way to copy files from one location to another, overwriting as necessary, but there doesn't seem to be a single function that does just that. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On 6/17/2011 12:17 PM, John Salerno wrote: On Jun 17, 2:25 am, Gregory Ewing wrote: It sounds like shutil.copy() is what you want, or one of the other related functions in the shutil module. This looks promising! But can src be a directory, or does it have to be a file? For my purposes (copying a saved games folder), I don't really need to specify particular files to copy, I just need to copy the entire Saved Games directory, so that's what would be my src argument if allowed. If you follow the second part of Greg's suggestion 'or one of the other related function in the shutil module', you will find copytree() "Recursively copy an entire directory tree rooted at src. " Also, the directory I want to copy also contains a directory. Will the contents of that directory also be copied, or do I have to do some kind of walk-through of the directory manually? If you want more control of which files to copy, between 1 and all, look as os.walk and the glob module. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On 01/-10/-28163 02:59 PM, John Salerno wrote: Based on what I've read, it seems os.rename is the proper function to use, but I'm a little confused about the syntax. Basically I just want to write a simple script that will back up my saved game files when I run it. So I want it to copy a set of files/directories from a location on my C:\ drive to another directory on my E:\ drive. I don't want to rename or delete the originals, just move them. I also want them to automatically overwrite whatever already happens to be in the location on the E:\ drive. Is os.rename the proper function for this? Mainly I was because the Module Index says this: "On Windows, if dst already exists, OSError will be raised even if it is a file.." so it sounds like I can't move the files to a location where those file names already exist. You keep saying 'move' when you want 'copy.' Even if os.rename would work across drives (it doesn't, on Windows), it still would be removing the original. Similarly with move. As Greg mentioned, you want shutil.copy(), not move nor rename. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On Jun 17, 2:25 am, Gregory Ewing wrote: > John Salerno wrote: > > I want it to copy a set of files/directories from a > > location on my C:\ drive to another directory on my E:\ drive. I don't > > want to rename or delete the originals, > > It sounds like shutil.copy() is what you want, or one of the > other related functions in the shutil module. > > -- > Greg shutil.copy(src, dst) Copy the file src to the file or directory dst. If dst is a directory, a file with the same basename as src is created (or overwritten) in the directory specified. Permission bits are copied. src and dst are path names given as strings. This looks promising! But can src be a directory, or does it have to be a file? For my purposes (copying a saved games folder), I don't really need to specify particular files to copy, I just need to copy the entire Saved Games directory, so that's what would be my src argument if allowed. Also, the directory I want to copy also contains a directory. Will the contents of that directory also be copied, or do I have to do some kind of walk-through of the directory manually? -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On 17/06/2011 06:06, John Salerno wrote: Based on what I've read, it seems os.rename is the proper function to use, but I'm a little confused about the syntax. Basically I just want to write a simple script that will back up my saved game files when I run it. So I want it to copy a set of files/directories from a location on my C:\ drive to another directory on my E:\ drive. I don't want to rename or delete the originals, just move them. I also want them to automatically overwrite whatever already happens to be in the location on the E:\ drive. Is os.rename the proper function for this? Mainly I was because the Module Index says this: "On Windows, if dst already exists, OSError will be raised even if it is a file.." so it sounds like I can't move the files to a location where those file names already exist. For a Windows-only Q&D, you could use the pywin32 win32file module which exposes the MoveFileEx[W] API: import win32file win32file.MoveFileExW ( "c:/temp/blah.txt", "c:/temp/blah2.txt", win32file.MOVEFILE_REPLACE_EXISTING ) TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
John Salerno wrote: I want it to copy a set of files/directories from a location on my C:\ drive to another directory on my E:\ drive. I don't want to rename or delete the originals, It sounds like shutil.copy() is what you want, or one of the other related functions in the shutil module. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you copy files from one location to another?
On 2011.06.17 12:06 AM, John Salerno wrote: > "On Windows, if dst already exists, OSError will be raised even if it > is a file.." If you try to create a file or directory that already exists on Windows, you'll get a WindowsError with error code 183: >>> os.mkdir('C:\\common\\games') Traceback (most recent call last): File "", line 1, in WindowsError: [Error 183] Cannot create a file when that file already exists: 'C:\\common\\games' I'm pretty sure you have to delete the existing file before you can "overwrite" it. You can try to write the file and delete the file and try again in an except OSError block (this will catch WindowsError as well since it's a subclass of OSError, and it will catch similar errors on other platforms). -- http://mail.python.org/mailman/listinfo/python-list
How do you copy files from one location to another?
Based on what I've read, it seems os.rename is the proper function to use, but I'm a little confused about the syntax. Basically I just want to write a simple script that will back up my saved game files when I run it. So I want it to copy a set of files/directories from a location on my C:\ drive to another directory on my E:\ drive. I don't want to rename or delete the originals, just move them. I also want them to automatically overwrite whatever already happens to be in the location on the E:\ drive. Is os.rename the proper function for this? Mainly I was because the Module Index says this: "On Windows, if dst already exists, OSError will be raised even if it is a file.." so it sounds like I can't move the files to a location where those file names already exist. -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy files
I haven't tested this, but i maybe think it works? import shutil try: copy("your_file.txt", "your_subfolder") print "Done!" except: print "Failed!" -- http://mail.python.org/mailman/listinfo/python-list
Copy files
How can I copy a file from one folder to another(subfolder) without change and property. I work on zope. -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy files to Linux server through ssh tunnel
You might want to install copy of Cygwin on your Windows box. Then you can use scp or maybe rsync over ssh to do the copying. Works great for me. -Larry Bates [EMAIL PROTECTED] wrote: > Hi ! > > I have some backup files on a server farm. > I want to store these local backup files on a backup file server for > "safety's snake". > > These files are compressed zip files with 12 character length password. > But my system admin asked me, how can I improve the safety of the copy > operation, and the storing (now I use Samba share to store these files. I > map the SMB share on the client, copy these files, and unmap SMB). > > Then I thinking to ssh protocol to improve protection. > > The backup script is a py script. I see that Winscp can copy files through > ssh tunnel. Can I do it too ? > How ? How to I do it in pythonic way ? > > Please help me with some examples or urls or other infos ! > > Thanks * 1000: > dd > > > > > > > > -- > 1 Gbyte Ingyenes E-Mail Tárhely a MailPont-tól > http://www.mailpont.hu/ > -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy files to Linux server through ssh tunnel
[EMAIL PROTECTED] wrote: > Hi ! > > I have some backup files on a server farm. > I want to store these local backup files on a backup file server for > "safety's snake". > > These files are compressed zip files with 12 character length password. > But my system admin asked me, how can I improve the safety of the copy > operation, and the storing (now I use Samba share to store these files. I > map the SMB share on the client, copy these files, and unmap SMB). > > Then I thinking to ssh protocol to improve protection. > > The backup script is a py script. I see that Winscp can copy files through > ssh tunnel. Can I do it too ? > How ? How to I do it in pythonic way ? > > Please help me with some examples or urls or other infos ! > > Thanks * 1000: > dd > > > > > > > > -- > 1 Gbyte Ingyenes E-Mail Tárhely a MailPont-tól > http://www.mailpont.hu/ > See this: http://www.lag.net/paramiko/ with this library you can use sftp to transfer you files. -- http://mail.python.org/mailman/listinfo/python-list
Copy files to Linux server through ssh tunnel
Hi ! I have some backup files on a server farm. I want to store these local backup files on a backup file server for "safety's snake". These files are compressed zip files with 12 character length password. But my system admin asked me, how can I improve the safety of the copy operation, and the storing (now I use Samba share to store these files. I map the SMB share on the client, copy these files, and unmap SMB). Then I thinking to ssh protocol to improve protection. The backup script is a py script. I see that Winscp can copy files through ssh tunnel. Can I do it too ? How ? How to I do it in pythonic way ? Please help me with some examples or urls or other infos ! Thanks * 1000: dd -- 1 Gbyte Ingyenes E-Mail Tárhely a MailPont-tól http://www.mailpont.hu/ -- http://mail.python.org/mailman/listinfo/python-list
Copy files to Linux server through ssh tunnel
Hi ! I have some backup files on a server farm. I want to store these local backup files on a backup file server for "safety's snake". These files are compressed zip files with 12 character length password. But my system admin asked me, how can I improve the safety of the copy operation, and the storing (now I use Samba share to store these files. I map the SMB share on the client, copy these files, and unmap SMB). Then I thinking to ssh protocol to improve protection. The backup script is a py script. I see that Winscp can copy files through ssh tunnel. Can I do it too ? How ? How to I do it in pythonic way ? Please help me with some examples or urls or other infos ! Thanks * 1000: dd -- 1 Gbyte Ingyenes E-Mail Tárhely a MailPont-tól http://www.mailpont.hu/ -- http://mail.python.org/mailman/listinfo/python-list
Copy files to Linux server through ssh tunnel
Hi ! I have some backup files on a server farm. I want to store these local backup files on a backup file server for "safety's snake". These files are compressed zip files with 12 character length password. But my system admin asked me, how can I improve the safety of the copy operation, and the storing (now I use Samba share to store these files. I map the SMB share on the client, copy these files, and unmap SMB). Then I thinking to ssh protocol to improve protection. The backup script is a py script. I see that Winscp can copy files through ssh tunnel. Can I do it too ? How ? How to I do it in pythonic way ? Please help me with some examples or urls or other infos ! Thanks * 1000: dd -- 1 Gbyte Ingyenes E-Mail Tárhely a MailPont-tól http://www.mailpont.hu/ -- http://mail.python.org/mailman/listinfo/python-list