Question

I've been trying to trouble this for days now, and would appreciate some help --

Basically, I wrote the following Python script

import os, sys

# =__=__=__=__=__=__=__ START MAIN =__=__=__=__=__=__=__
if __name__ == '__main__':

# initialize variables
all_files = []

# directory to download data siphon files to
dDir = '/path/to/download/directory/'

# my S3 bucket
s3bucket = "com.mybucket/"

foldername = "test"

# get a list of available feeds
feeds = <huge JSON object with URLs to feeds>

for item in range(feeds['count']):
    # ...check if the directory exists, and if not, create the directory...
    if not os.path.exists(folderName):
        os.makedirs(folderName)

    ... ... ...

    # Loop through all the splits
    for s in dsSplits:
        ... ... ...
        location = requestFeedLocation(name, timestamp)

        ... ... ...
        downloadFeed(location[0], folderName, nameNotGZ)

    # THIS IS WHERE I AM HAVING PROBLEMS!!!!!!!!!!!
    cmd = 's3cmd sync 'dDir+folderName+'/ s3://'+s3bucket+'/'
    os.system(cmd)

Everything in my code works...when I run this straight from the command line, everything runs as expected...however, when I have it executed via cron -- the following DOES NOT execute (everything else does)

# THIS IS WHERE I AM HAVING PROBLEMS!!!!!!!!!!!
cmd = 's3cmd sync 'dDir+folderName+'/ s3://'+s3bucket+'/'
os.system(cmd)

To answer a few questions, I am running the cron as root, s3cmd is configured for the root user, OS is Ubuntu 12.04, python version is 2.7, all of the necessary directories have Read / Write permissions...

What am I missing?

Was it helpful?

Solution

  1. First check variable 'foldername' in command you have used N in variable.
  2. In command syntax you need to add plus (+) sign in prefix like +dDir+folderName+

So I hope command would be like below..

cmd = 's3cmd sync '+dDir+foldername+'/ s3://'+s3bucket+'/'

os.system(cmd)

Here I found some more s3cmd sync help: http://tecadmin.net/s3cmd-file-sync-with-s3bucket/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top