ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/PRODREQUEST/injectCFGFile.py
Revision: 1.3
Committed: Wed Mar 28 10:22:45 2007 UTC (18 years, 1 month ago) by eulisse
Content type: text/x-python
Branch: MAIN
CVS Tags: V00-08-00, V00-07-09, V00-07-08, V00-07-07, V00-07-06, V00-07-05, V00-07-04, V00-07-03, V00-07-02, V00-07-01, V00-07-00, gePreProdManagerSupport, V00-06-08, V00-06-07, V00-06-06, V00-06-05, V00-06-04, V00-06-03, V00-06-02, V00-06-01, V00-06-00, V00-05-15, V00-05-14, V00-05-13, V00-05-11, V00-05-10, V00-05-09, V00-05-08, V00-05-07, V00-05-06, V00-05-05, V00-05-04, V00-05-03, V00-05-02, V00-05-01, V00-05-00, HEAD
Changes since 1.2: +1 -1 lines
Error occurred while calculating annotation data.
Log Message:
* GUI modified to accept input dataset info.
* Schema changed to accomodate the input_dataset & pileup at the same time.
  An utility script is provided to migrate from the old schema to the new one.

File Contents

# Content
1 #!/usr/bin/env python
2
3 from getopt import getopt
4 from sys import argv
5 from os.path import exists
6 from sqlobject import *
7 conn = SQLiteConnection("prodrequest.db")
8 from Models import Payload, Workflow, WorkflowEntry
9 Payload._connection = conn
10 Workflow._connection = conn
11 WorkflowEntry._connection = conn
12
13 print argv
14 optlist, args = getopt (argv[1:], "w", ["workflow-name=","tag="])
15
16 options={}
17 print optlist
18
19 for key, value in optlist:
20 options[key] = value
21
22 if not options.has_key ("--workflow-name"):
23 print "Please specify the workflow name."
24 exit
25
26 if not options.has_key ("--tag"):
27 print "Please specify the tag to be used for this import"
28 exit
29
30 workflowName=options["--workflow-name"]
31 tag=options["--tag"]
32 workflowSelect = Workflow.select (Workflow.q.name==workflowName)
33 if not workflowSelect.count ():
34 workflowID = Workflow (name=workflowName).id
35 else:
36 workflowID = workflowSelect[0].id
37
38 for cfgfile in args:
39 if not exists (cfgfile):
40 print cfgfile + " not found."
41 pass
42
43 cfg = file (cfgfile).read ()
44 cfgname = cfgfile.rsplit ("/", 1)[1] + " - " + tag
45 payloadSelect = Payload.select (Payload.q.name==cfgname)
46 if payloadSelect.count ():
47 payloadID = payloadSelect[0].id
48 else:
49 payloadID = Payload (name=cfgname,
50 parameterset=cfg).id
51
52 entrySelect = WorkflowEntry.select (WorkflowEntry.q.payload_id==payloadID)
53
54 if entrySelect.count ():
55 print "Already in there, skipping"
56 continue
57
58 WorkflowEntry (name=cfgname,
59 workflow_id=workflowID,
60 payload_id=payloadID,
61 payloadprev_id=0,
62 payloadparent_id=0,
63 status=0,
64 primary_dataset="None",
65 output_dataset="Modify me")