Partial fix to #22. Laydi will require a project directory to run. If the

project directory does not exist, i.e. if a new project should be created, the
new -n switch is required. New syntax to run laydi is now
{{{
laydi [options] </path/to/project>
}}}
This commit is contained in:
2011-03-06 23:08:09 +00:00
parent b5d2e8e181
commit dc8da8823e
2 changed files with 314 additions and 142 deletions

View File

@@ -3,7 +3,7 @@
from getopt import getopt
import os
import sys
from laydi import laydi, projectview, workflow, main
from laydi import laydi, project, projectview, workflow, main
#import workflows
from laydi import cfgparse
import optparse
@@ -73,11 +73,20 @@ def parse_options():
action='store_true',
help='Generate configuration file ~/.laydi if it does not exist.')
op.add_option('-n', '--new-project',
action='store_true',
help='Create new project directory.')
for cf in conf_files:
if os.path.isfile(cf):
cp.add_file(cf)
return cp.parse(op)
options, params = cp.parse(op)
if len(params) != 1:
print "error: project directory must be specified."
sys.exit(1)
return options, params
if __name__ == '__main__':
import gtk
@@ -86,6 +95,8 @@ if __name__ == '__main__':
gnome.program_init(PROGRAM_NAME, VERSION)
options, params = parse_options()
## Workflow setup
main.options = options
for dir in main.options.workflowdir.split(';'):
@@ -112,8 +123,18 @@ if __name__ == '__main__':
main.set_options(options)
app = laydi.LaydiApp()
## Project setup
prjroot = params[0]
if not project.is_project_directory(prjroot):
if options.new_project:
project.make_project_directory(prjroot)
else:
print "error: project directory not found: %s" % prjroot
print "notice: use the -n option to make a new project"
sys.exit(2)
main.set_application(app)
main.set_projectview(projectview.ProjectView())
main.set_projectview(projectview.ProjectView(prjroot))
app.set_projectview(main.projectview)
app.show()