Module workCmdlineFrontEnd
[hide private]
[frames] | no frames]

Source Code for Module workCmdlineFrontEnd

 1  #!/bin/env python 
 2  ''' 
 3  A convenience class for building agenda-based Qube jobs where each agenda item is a completely different command. 
 4  ''' 
 5  #====================================== 
 6  #  $Revision: #2 $ 
 7  #  $Change: 12198 $ 
 8  #====================================== 
 9   
10  import sys 
11  import os 
12   
13  try: 
14      import qb 
15  except: 
16      if 'QBDIR' in os.environ: 
17          QBDIR = os.environ['QBDIR'] 
18      else: 
19          if os.name == 'posix': 
20              if os.uname()[0] == 'Darwin': 
21                  QBDIR = '/Applications/pfx/qube' 
22              else: 
23                  QBDIR = '/usr/local/pfx/qube' 
24   
25      sys.path.append('%s/api/python' % QBDIR) 
26      import qb 
27           
28  import qb.frontend 
29   
30   
31 -class WorkCmdlineJob(qb.frontend.QubeJob):
32 - def __init__(self, agenda, dev=False, ):
33 ''' 34 Function to initialize members of the class 35 36 @param dev: Set the 'dev' value for the Qube job, enables debug output on the farm. 37 @type dev: bool 38 ''' 39 super(WorkCmdlineJob, self).__init__(dev=dev) 40 41 self['prototype'] = 'pyWorkCmdline' 42 self['agenda'] = agenda 43 44 pkg = {'smartAgenda': True} 45 self['package'].update(pkg)
46 47 48
49 -def buildAgenda():
50 ''' 51 An example of building an agenda where item (the "work") is a distinct command. 52 53 This example builds a list of mp4 jobs that take a different audio file and applies it to the video. 54 ''' 55 agenda = [] 56 langList = ['FRA', 'ENG', 'DEU'] 57 58 for lang in langList: 59 work = { 60 'name': lang, 61 'package': {} 62 } 63 64 work['package']['cmdline'] = 'mp4 -audio %s -video /foo/bar/test/mov' % lang 65 66 agenda.append(work) 67 68 return agenda
69 70 71 if __name__ == '__main__': 72 ''' 73 A "hello world", meant to show how to build and submit a pyCmdrange job. 74 ''' 75 import sys, os 76 import qb 77 78 # It's only neccessary to setsupervisor() if you have multiple supervisors in your environment 79 #qb.setsupervisor('build01') 80 81 agenda = buildAgenda() 82 83 job = WorkCmdlineJob(agenda) 84 job['name'] = 'my test job' 85 86 submitted = qb.submit(job) 87 for i in submitted: 88 print '%(id)8s: %(name)s' % i 89