2006-04-27 12:06:30 +02:00
|
|
|
#!/usr/bin/python2.4
|
2006-04-25 14:19:25 +02:00
|
|
|
|
|
|
|
from getopt import getopt
|
2007-02-28 15:07:33 +01:00
|
|
|
import os
|
2006-04-25 14:19:25 +02:00
|
|
|
import sys
|
2006-10-17 16:42:27 +02:00
|
|
|
from fluents import fluents, project, workflow
|
2006-04-25 14:19:25 +02:00
|
|
|
import workflows
|
2007-02-27 17:08:22 +01:00
|
|
|
import cfgparse, optparse
|
2006-04-25 14:19:25 +02:00
|
|
|
|
|
|
|
PROGRAM_NAME = 'fluents'
|
|
|
|
VERSION = '0.1.0'
|
|
|
|
|
|
|
|
def list_workflows():
|
2007-02-27 17:25:48 +01:00
|
|
|
print 'fluents %s' % VERSION
|
2006-04-25 14:19:25 +02:00
|
|
|
print
|
2007-02-27 17:25:48 +01:00
|
|
|
print 'Available workflows:'
|
2006-04-25 14:19:25 +02:00
|
|
|
|
|
|
|
wfs = workflow.workflow_list()
|
2006-04-25 14:36:38 +02:00
|
|
|
for wf in wfs:
|
|
|
|
print ' %s (%s)' % (wf.ident, wf.name)
|
|
|
|
print
|
2006-04-25 14:19:25 +02:00
|
|
|
|
|
|
|
def parse_options():
|
2007-02-28 15:07:33 +01:00
|
|
|
conf_files = ['/etc/fluentsrc',
|
|
|
|
os.path.join(os.environ['HOME'], '.fluents')]
|
|
|
|
|
2007-02-27 17:08:22 +01:00
|
|
|
cp = cfgparse.ConfigParser()
|
2007-02-28 15:07:33 +01:00
|
|
|
|
|
|
|
cp.add_option('home', type='string',
|
|
|
|
default=os.environ['HOME'])
|
|
|
|
|
|
|
|
cp.add_option('datadir', type='string',
|
|
|
|
default=os.environ['HOME'])
|
|
|
|
cp.parse()
|
2007-02-27 17:08:22 +01:00
|
|
|
op = optparse.OptionParser()
|
2006-04-25 14:19:25 +02:00
|
|
|
|
2007-02-27 17:08:22 +01:00
|
|
|
op.add_option('-l', '--list-workflows',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='List available workflows.')
|
2006-04-25 14:19:25 +02:00
|
|
|
|
2007-02-27 17:08:22 +01:00
|
|
|
op.add_option('-w', '--workflow',
|
|
|
|
default='emptyview',
|
|
|
|
help='Start with selected workflow')
|
2006-04-25 14:19:25 +02:00
|
|
|
|
2007-02-28 15:07:33 +01:00
|
|
|
for cf in conf_files:
|
|
|
|
if os.path.isfile(cf):
|
|
|
|
cp.add_file(cf)
|
|
|
|
|
2007-02-27 17:08:22 +01:00
|
|
|
return cp.parse(op)
|
|
|
|
|
2006-04-25 14:19:25 +02:00
|
|
|
if __name__ == '__main__':
|
2007-02-27 17:08:22 +01:00
|
|
|
options, params = parse_options()
|
2006-04-25 14:19:25 +02:00
|
|
|
|
2007-02-27 17:08:22 +01:00
|
|
|
if options.list_workflows:
|
|
|
|
list_workflows()
|
|
|
|
sys.exit(0)
|
|
|
|
|
2006-04-25 14:19:25 +02:00
|
|
|
import gtk
|
|
|
|
import gnome
|
|
|
|
|
|
|
|
gnome.program_init(PROGRAM_NAME, VERSION)
|
2007-02-27 17:08:22 +01:00
|
|
|
|
|
|
|
selected_wf = workflow.EmptyWorkflow
|
|
|
|
|
|
|
|
workflow_list = workflow.workflow_list()
|
|
|
|
for wf in workflow_list:
|
|
|
|
if wf.ident == options.workflow:
|
|
|
|
selected_wf = wf
|
|
|
|
|
|
|
|
app = fluents.FluentApp(selected_wf)
|
2007-02-28 15:07:33 +01:00
|
|
|
app.options = options
|
2006-10-16 21:57:40 +02:00
|
|
|
fluents.app = app
|
2007-02-27 17:08:22 +01:00
|
|
|
|
2006-04-25 14:19:25 +02:00
|
|
|
app.set_project(project.Project())
|
|
|
|
app.show()
|
|
|
|
gtk.main()
|
2007-02-27 17:08:22 +01:00
|
|
|
|