Index: nodes/gformat.py
===================================================================
--- nodes/gformat.py	(revision 8257)
+++ nodes/gformat.py	(revision 8258)
@@ -14,4 +14,5 @@
 import yaml
 
+NODE_DIR = os.path.dirname(os.path.realpath(__file__))
 __version__ = '$Id$'
 
@@ -26,5 +27,5 @@
 
 
-def print_title():
+def print_title(nodelist):
   """ Main overview page """
   items = {'root' : os.environ['SCRIPT_NAME'] } 
@@ -236,5 +237,5 @@
 def get_yaml(item):
   """ Get configuration yaml for 'item'"""
-  gfile = item + '/wleiden.yaml'
+  gfile = NODE_DIR + '/%s/wleiden.yaml' % item
   gfile = 'test.yaml'
 
@@ -260,4 +261,5 @@
   
   # proxyX sorting based on X number
+  os.chdir(NODE_DIR)
   proxies = sorted(glob.glob("proxy*"),
               key=lambda name: int(''.join([c for c in name if c in string.digits])),
@@ -273,5 +275,6 @@
 def generate_wleiden_yaml(datadump):
   """ Special formatting to ensure it is editable"""
-  output = "# Genesis config yaml style\n" 
+  output = generate_header("#")
+  output += "# Genesis config yaml style\n" 
   output += "#\n"
   iface_keys = [elem for elem in datadump.keys() if elem.startswith('iface_')]
@@ -322,30 +325,37 @@
 
 
-#
-# Main worker
-
-# Update repository if requested
-form = cgi.FieldStorage()
-if form.getvalue("action") == "update":
-  print "Refresh: 5; url=%s" % os.environ['SCRIPT_NAME']
-  print "Content-type:text/plain\r\n\r\n",
-  print "[INFO] Updating subverion, please wait..."
-  print subprocess.Popen(['svn', 'up', '/home/rvdzwet/wleiden/genesis/nodes'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0],
-  print "[INFO] All done, redirecting in 5 seconds"
-  sys.exit(0)
-
-nodelist = glob.glob("CNode*")
-
-uri = os.environ['PATH_INFO'].strip('/').split('/')
-if not uri[0]:
-  print_title()
-elif len(uri) == 1:
-  print "Content-type:text/plain\r\n\r\n",
-  print_node(uri[0])
-elif len(uri) == 2:
-  print "Content-type:text/plain\r\n\r\n",
-  print_config(uri[0], uri[1])
-else:
-  assert False, "Invalid option"
-
-sys.exit(0)
+
+def process_cgi_request():
+  """ When calling from CGI """
+  # Update repository if requested
+  form = cgi.FieldStorage()
+  if form.getvalue("action") == "update":
+    print "Refresh: 5; url=%s" % os.environ['SCRIPT_NAME']
+    print "Content-type:text/plain\r\n\r\n",
+    print "[INFO] Updating subverion, please wait..."
+    print subprocess.Popen(['svn', 'up', NODE_DIR], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0],
+    print "[INFO] All done, redirecting in 5 seconds"
+    sys.exit(0)
+  
+  os.chdir(NODE_DIR)
+  nodelist = glob.glob("CNode*")
+  
+  uri = os.environ['PATH_INFO'].strip('/').split('/')
+  if not uri[0]:
+    print "Content-type:text/html\r\n\r\n",
+    print_title(nodelist)
+  elif len(uri) == 1:
+    print "Content-type:text/plain\r\n\r\n",
+    print_node(uri[0])
+  elif len(uri) == 2:
+    print "Content-type:text/plain\r\n\r\n",
+    print_config(uri[0], uri[1])
+  else:
+    assert False, "Invalid option"
+
+# Allow easy hacking using the CLI
+if not os.environ.has_key('PATH_INFO'):
+  os.environ['PATH_INFO'] = "/".join(sys.argv[1:])
+  os.environ['SCRIPT_NAME'] = __file__
+
+process_cgi_request()
