-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_shot.py
More file actions
72 lines (56 loc) · 2.07 KB
/
Copy pathadd_shot.py
File metadata and controls
72 lines (56 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import sys
import tacticenv
from pyasm.biz import Project
from pyasm.security import Batch
from pyasm.command import Command
from pyasm.prod.biz import Shot, Sequence
from pyasm.search import Search
class AddShotCmd(Command):
def __init__(my, seq_code):
my.seq_code = seq_code
super(AddShotCmd, my).__init__()
def get_title(my):
''' this is just for show for now'''
return "Add Shot"
def execute(my):
my.add_description('Add shots in bulk')
# add from shot 00001 to 00050 if they do not exist already
count = 0
for x in xrange(1, 51):
shot_code = '%s_%0.3d'%(my.seq_code, x)
shot = Shot.get_by_code(shot_code)
if not shot:
print "[%s] to be created." %shot_code
shot = Shot.create(shot_code, 'Shot %s' %shot_code)
shot.set_value('sequence_code', my.seq_code)
# assuming this is one of the values in project settings
# shot_status
shot.set_value('status', 'online')
# this is the default
shot.set_value('pipeline_code','shot')
shot.commit()
count += 1
else:
print "[%s] already exists." %shot_code
print "%d shot(s) created." %count
class Usage(Exception):
def __init__(my, msg):
my.msg = msg
if __name__ == '__main__':
my_login = 'admin'
batch = Batch(login_code=my_login)
Project.set_project('bar')
project_code = Project.get_project_code()
args = sys.argv[1:]
try:
if len(args) != 1:
raise Usage("A single sequence code is expected.")
seq = Sequence.get_by_code(args[0])
if not seq:
raise Usage("The sequence code [%s] has not been registered for "\
"project [%s] in TACTIC. Please Insert it in the Sequences tab first." %(args[0], project_code))
except Usage, e:
print e.msg
sys.exit(2)
command = AddShotCmd(seq.get_code())
Command.execute_cmd(command)