ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/PRODREQUEST/injectCFGFile.py
Revision: 1.2
Committed: Fri Dec 15 10:59:11 2006 UTC (18 years, 4 months ago) by eulisse
Content type: text/x-python
Branch: MAIN
CVS Tags: V00-04-22, V00-04-21, V00-04-20, V00-04-19, V00-04-18, V00-04-17, V00-04-16, V00-04-15, V00-04-14, V00-04-13, V00-04-12, V00-04-11, V00-04-10, V00-04-09, V00-04-08, V00-04-07, V00-04-06, V00-04-05, V00-04-04, V00-04-03, V00-04-02, V00-04-01, V00-04-00, V00-03-14, V00-03-13, V00-03-12, V00-03-11, V00-03-10, V00-03-09, V00-03-08, V00-03-07, V00-03-06, V00-03-05, V00-03-04, V00-03-03, V00-03-02, V00-03-01, V00-03-00, V00-02-00, V00-01-00, V00-00-05
Changes since 1.1: +4 -4 lines
Log Message:
On par with current svn repository. New features introduced:

- dbs integration for the selection of input and output dataset
- more heavily based on YUI
- test suite for the YUI widget
- input_dataset and output dataset now belong to WorkflowEntry, rather than
  to the payload
- ability to remove items from a workflow added.
- ability to inject workflows via web, rather than writing directly to the
  DB
- CMS specific entry window.

File Contents

# User Rev Content
1 eulisse 1.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 eulisse 1.2 parameterset=cfg).id
51 eulisse 1.1
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 eulisse 1.2 status=0,
64     input_dataset="None",
65     output_dataset="Modify me")