Initial config parser support.
This commit is contained in:
parent
686a1fdcd1
commit
1ba4bf5f82
50
bin/fluents
50
bin/fluents
|
@ -4,12 +4,11 @@ from getopt import getopt
|
|||
import sys
|
||||
from fluents import fluents, project, workflow
|
||||
import workflows
|
||||
import cfgparse, optparse
|
||||
|
||||
PROGRAM_NAME = 'fluents'
|
||||
VERSION = '0.1.0'
|
||||
|
||||
parameters = {'workflow': workflow.EmptyWorkflow}
|
||||
|
||||
def show_help():
|
||||
print 'fluent %s' % VERSION
|
||||
print 'This software is released under the GNU General Public Licence'
|
||||
|
@ -36,34 +35,43 @@ def list_workflows():
|
|||
print
|
||||
|
||||
def parse_options():
|
||||
short_opts = 'hlw:'
|
||||
long_opts = ['help', 'list-workflows', 'workflow=']
|
||||
cp = cfgparse.ConfigParser()
|
||||
op = optparse.OptionParser()
|
||||
|
||||
options, params = getopt(sys.argv[1:], short_opts, long_opts)
|
||||
op.add_option('-l', '--list-workflows',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='List available workflows.')
|
||||
|
||||
for opt, val in options:
|
||||
if opt in ['-h', '--help']:
|
||||
show_help()
|
||||
sys.exit(0)
|
||||
elif opt in ['-l', '--list-workflows']:
|
||||
list_workflows()
|
||||
sys.exit(0)
|
||||
elif opt in ['-w', '--workflow']:
|
||||
wfs = workflow.workflow_list()
|
||||
for wf in wfs:
|
||||
if wf.ident == val:
|
||||
parameters['workflow'] = wf
|
||||
parameters['workflow']
|
||||
op.add_option('-w', '--workflow',
|
||||
default='emptyview',
|
||||
help='Start with selected workflow')
|
||||
|
||||
if __name__ == '__main__':
|
||||
parse_options()
|
||||
return cp.parse(op)
|
||||
|
||||
if __name__ == '__main__':
|
||||
options, params = parse_options()
|
||||
|
||||
if options.list_workflows:
|
||||
list_workflows()
|
||||
sys.exit(0)
|
||||
|
||||
import gtk
|
||||
import gnome
|
||||
|
||||
gnome.program_init(PROGRAM_NAME, VERSION)
|
||||
app = fluents.FluentApp(parameters['workflow'])
|
||||
|
||||
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)
|
||||
fluents.app = app
|
||||
|
||||
app.set_project(project.Project())
|
||||
app.show()
|
||||
gtk.main()
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue