Example #1
0
def swift_move(filename, credentials, container='videos', content_type='video'):
    """ Moves a given file to a swift specified by the credentials
    dictionary. The container and container type are by default the ones we
    use across the entire project, but they can be easily changed.
    """
    print 'Moving', filename, 'to swift'
    swift = create_swift_client(credentials)

    # Creates the container we need to use if it doesn't already exist
    swift.put_container(container)
    with open(filename, 'rb') as f:
        swift.put_object(container, filename, contents=f,
                         content_type=content_type)
Example #2
0
def place_thread():
    """ Defines the place thread, which has an infinite loop in it that keeps
    listening and placing items from the place queue
    """
    global placeQ, num_processed, num_total

    print 'PLACE THREAD: Loading credentials'
    credentials = json.load(open('config/local.json'))

    print 'PLACE THREAD: Spawning swift client'
    sw_client = create_swift_client(credentials)

    while True:
        print 'PLACE THREAD: Listening on place queue'
        filename = placeQ.get()

        print 'PLACE THREAD: Placing ' + filename + ' back in swift'
        place(sw_client, filename)
        num_processed += 1
Example #3
0
def grab_thread():
    """ Defines the grab thread, which has an infinite loop in it that keeps
    listening and grabbing items from the grab queue
    """
    global grabQ, convertQ

    print 'GRAB THREAD: Loading credentials'
    credentials = json.load(open('config/local.json'))

    print 'GRAB THREAD: Spawning swift client'
    sw_client = create_swift_client(credentials)

    while True:
        print 'GRAB THREAD: Listening in grab queue...'
        filename = grabQ.get()

        print 'GRAB THREAD: Grabbing ' + filename + ' from swift'
        grab(sw_client, filename)

        print 'GRAB THREAD: Putting ' + filename + ' in convert queue'
        convertQ.put(filename)