~jasonodoom/dmedia/docs

« back to all changes in this revision

Viewing changes to upload.py

  • Committer: Jason Gerard DeRose
  • Date: 2011-06-07 18:42:39 UTC
  • Revision ID: jderose@novacut.com-20110607184239-s16qdrw2wovwhd00
Quick hacks to upload all the uds-o video

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import time
 
2
import dmedia
 
3
 
 
4
dmedia.configure_logging('upload')
 
5
 
 
6
from dmedia.core import Core
 
7
 
 
8
c = Core()
 
9
c.bootstrap()
 
10
 
 
11
uds_o = 'EIJ5EVPOJSO5ZBDYANRM2XT7'
 
12
 
 
13
#i = 0
 
14
#for row in c.db.view('user/video', include_docs=True):
 
15
#    i += 1
 
16
#    doc = dict(row.doc)
 
17
#    if 'proxy' not in doc:
 
18
#        print 'no proxy {_id}'.format(**doc)
 
19
#        continue
 
20
#    doc = c.db.get(doc['proxy'])
 
21
#    doc['content_type'] = 'video/webm'
 
22
#    doc['name'] = 'uds-o-%04d.webm' % i
 
23
#    print doc['name']
 
24
#    c.db.save(doc)
 
25
#
 
26
#raise SystemExit()
 
27
 
 
28
 
 
29
i = 0
 
30
for row in c.db.view('user/video', include_docs=True):
 
31
    doc = dict(row.doc)
 
32
    if 'proxy' not in doc:
 
33
        print 'no proxy {_id}'.format(**doc)
 
34
        continue
 
35
    doc = c.db.get(doc['proxy'])
 
36
    if uds_o in doc['stored']:
 
37
        print 'already in uds-o bucket {_id}'.format(**doc)
 
38
        continue
 
39
    print 'will upload {_id}'.format(**doc)
 
40
    while True:
 
41
        if len(c.manager.list_jobs()) < 3:
 
42
            c.upload(doc['_id'], uds_o)
 
43
            break
 
44
        else:
 
45
            print 'waiting for an upload to finish...'
 
46
            time.sleep(5)