I have a site that requires the ability for a logged in admin to push a staging database to a live database. The first thing it does is dump the sql and push to the target database. This works fine, but when I go to rsync the folders containing the uploaded material, I get an error. This ONLY occurs when the script is called from within the view, not from the command line or python shell. Here is the function:
def copy_media(self, origin_folder, target_folder):
command_string = "rsync -a %s %s" % (origin_folder, target_folder)
return_code = subprocess.call(command_string, shell=True)
return return_code
The return code is "12" when it errors. My best guess is that since there's a considerable delay before the script finishes executing, the view doesn't know how to properly wait for it to end. The other guess I had was that the paths somehow get screwed up from within the view.
Check permissions of your server, it may be different user/permissions from when you use the command line and thus not be able to perform that command.