Permalink
Browse files

Tronfig tweaks, deleted unneeded files, extra error catching

  • Loading branch information...
1 parent 4fab68a commit 6952652370b9272ca6c5aa5b1e6eb11042338bf8 @mtytel mtytel committed Aug 24, 2010
Showing with 34 additions and 142 deletions.
  1. +2 −2 bin/trond
  2. +23 −8 bin/tronfig
  3. +1 −1 docs/sample_config_large.yaml
  4. +7 −0 tron/job.py
  5. +1 −0 tron/www.py
  6. +0 −7 web/static/js/g.line.js
  7. +0 −7 web/static/js/g.raphael.js
  8. +0 −117 web/static/js/raphael.js
View
@@ -10,7 +10,7 @@ from twisted.python import log
from twisted.internet import reactor, defer
from twisted.web import server
-from tron import mcp, job, resource, node, scheduler, www, monitor, emailer
+from tron import mcp, job, resource, node, scheduler, www, monitor, emailer, config
def parse_options():
parser = optparse.OptionParser()
@@ -65,7 +65,7 @@ def main():
master_control = mcp.MasterControlProgram(options.working_dir, options.config_file)
try:
master_control.load_config()
- except mcp.ConfigError, e:
+ except config.ConfigError, e:
print >>sys.stderr, "Error in configuration file:", e
sys.exit()
View
@@ -3,8 +3,9 @@ import os
import tempfile
import optparse
import sys
+import yaml
-from tron import cmd
+from tron import cmd, config
def parse_options():
parser = optparse.OptionParser("usage: %prog [options] [-]")
@@ -20,23 +21,36 @@ def parse_options():
def upload_config(options, contents):
status, content = cmd.request(options.server, "/config", {'config': contents})
- if status != cmd.OK:
- print >>sys.stderr, "Error in configuration: %r" % (content,)
- sys.exit(1)
+ if 'error' in content:
+ print >>sys.stderr, "Configuration uploaded but errors occurred. Please fix: %s" % content['error']
+ sys.exit(1)
else:
print "Configuration uploaded successfully"
+def test_config(file_name):
+ file = open(file_name)
+ try:
+ config.load_config(file)
+ file.close()
+ return True
+ except (yaml.YAMLError, config.ConfigError), e:
+ print >>sys.stderr, "Error in configuration: %s" % str(e)
+ file.close()
+ return False
+
def edit_config(options, contents):
fi = tempfile.NamedTemporaryFile(suffix='.yaml')
fi.write(contents)
fi.flush()
editor = os.getenv('EDITOR') or os.getenv('VISUAL') or 'vim'
- if not os.system("%s %s" % (editor, fi.name)):
- upload = file(fi.name, 'r')
- upload_config(options, upload.read())
- upload.close()
+ while not os.system("%s %s" % (editor, fi.name)) and not test_config(fi.name):
+ if raw_input("There are errors in your configuration. Continue editing? (y/n): ")[:1].lower() == 'n':
+ return
+ upload = open(fi.name)
+ upload_config(options, upload.read())
+ upload.close()
fi.close()
if __name__ == '__main__':
@@ -63,3 +77,4 @@ if __name__ == '__main__':
print content['config']
cmd.save_config(options)
+
@@ -29,7 +29,7 @@ jobs:
command: "sleep 3; echo 4"
requires: *intAction0
- &jobFoo !Job
- name: "interval0v"
+ name: "interval0b"
node: *nodeBatch00
schedule: !IntervalScheduler
interval: 20s
View
@@ -297,3 +297,10 @@ def restore_run(self, data):
assert not run.is_running
return run
+class Service(Job):
+ def __init__(self, *args, **kwargs):
+ super(Service, self).__init__(*args, **kwargs)
+ enable_cmd = None
+ disable_cmd = None
+
+
View
@@ -346,6 +346,7 @@ def render_POST(self, request):
response['error'] = str(e)
return respond(request, response)
+
class RootResource(resource.Resource):
def __init__(self, master_control):
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 6952652

Please sign in to comment.