fix super-long lines
authorGreg Price <price@mit.edu>
Thu, 29 Oct 2009 05:36:41 +0000 (01:36 -0400)
committerGreg Price <price@mit.edu>
Thu, 29 Oct 2009 05:36:41 +0000 (01:36 -0400)
svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2706

code/main.py

index 786a087..f89763c 100755 (executable)
@@ -199,10 +199,16 @@ console will suffer artifacts.
     help._cp_config['tools.require_login.on'] = False
 
     def parseCreate(self, fields):
-        kws = dict([(kw, fields.get(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split() if fields.get(kw)])
-        validate = validation.Validate(cherrypy.request.login, cherrypy.request.state, strict=True, **kws)
-        return dict(contact=cherrypy.request.login, name=validate.name, description=validate.description, memory=validate.memory,
-                    disksize=validate.disksize, owner=validate.owner, machine_type=getattr(validate, 'vmtype', Defaults.type),
+        kws = dict([(kw, fields.get(kw)) for kw in
+         'name description owner memory disksize vmtype cdrom autoinstall'.split()
+                    if fields.get(kw)])
+        validate = validation.Validate(cherrypy.request.login,
+                                       cherrypy.request.state,
+                                       strict=True, **kws)
+        return dict(contact=cherrypy.request.login, name=validate.name,
+                    description=validate.description, memory=validate.memory,
+                    disksize=validate.disksize, owner=validate.owner,
+                    machine_type=getattr(validate, 'vmtype', Defaults.type),
                     cdrom=getattr(validate, 'cdrom', None),
                     autoinstall=getattr(validate, 'autoinstall', None))
 
@@ -213,7 +219,8 @@ console will suffer artifacts.
         """Handler for create requests."""
         try:
             parsed_fields = self.parseCreate(fields)
-            machine = controls.createVm(cherrypy.request.login, cherrypy.request.state, **parsed_fields)
+            machine = controls.createVm(cherrypy.request.login,
+                                        cherrypy.request.state, **parsed_fields)
         except InvalidInput, err:
             pass
         else:
@@ -257,7 +264,9 @@ console will suffer artifacts.
         @cherrypy.tools.mako(filename="/info.mako")
         def info(self, machine_id):
             """Handler for info on a single VM."""
-            machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+            machine = validation.Validate(cherrypy.request.login,
+                                          cherrypy.request.state,
+                                          machine_id=machine_id).machine
             d = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
             checkpoint.checkpoint('Got infodict')
             return d
@@ -269,15 +278,20 @@ console will suffer artifacts.
         def modify(self, machine_id, **fields):
             """Handler for modifying attributes of a machine."""
             try:
-                modify_dict = modifyDict(cherrypy.request.login, cherrypy.request.state, machine_id, fields)
+                modify_dict = modifyDict(cherrypy.request.login,
+                                         cherrypy.request.state,
+                                         machine_id, fields)
             except InvalidInput, err:
                 result = None
-                machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+                machine = validation.Validate(cherrypy.request.login,
+                                              cherrypy.request.state,
+                                              machine_id=machine_id).machine
             else:
                 machine = modify_dict['machine']
                 result = 'Success!'
                 err = None
-            info_dict = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
+            info_dict = infoDict(cherrypy.request.login,
+                                 cherrypy.request.state, machine)
             info_dict['err'] = err
             if err:
                 for field in fields.keys():
@@ -307,8 +321,9 @@ console will suffer artifacts.
             Remember to enable iptables!
             echo 1 > /proc/sys/net/ipv4/ip_forward
             """
-            machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
-
+            machine = validation.Validate(cherrypy.request.login,
+                                          cherrypy.request.state,
+                                          machine_id=machine_id).machine
             token = controls.vnctoken(machine)
             host = controls.listHost(machine)
             if host:
@@ -333,7 +348,9 @@ console will suffer artifacts.
             """Handler for running commands like boot and delete on a VM."""
             back = kwargs.get('back', None)
             try:
-                d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs)
+                d = controls.commandResult(cherrypy.request.login,
+                                           cherrypy.request.state,
+                                           command_name, machine_id, kwargs)
                 if d['command'] == 'Delete VM':
                     back = 'list'
             except InvalidInput, err:
@@ -347,9 +364,12 @@ console will suffer artifacts.
                     return d
             if back == 'list':
                 cherrypy.request.state.clear() #Changed global state
-                raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result))
+                raise cherrypy.InternalRedirect('/list?result=%s'
+                                                % urllib.quote(result))
             elif back == 'info':
-                raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303)
+                raise cherrypy.HTTPRedirect(cherrypy.request.base
+                                            + '/machine/%d/' % machine_id,
+                                            status=303)
             else:
                 raise InvalidInput('back', back, 'Not a known back page.')
 
@@ -507,7 +527,9 @@ def modifyDict(username, state, machine_id, fields):
     olddisk = {}
     session.begin()
     try:
-        kws = dict([(kw, fields.get(kw)) for kw in 'owner admin contact name description memory vmtype disksize'.split() if fields.get(kw)])
+        kws = dict([(kw, fields.get(kw)) for kw in
+         'owner admin contact name description memory vmtype disksize'.split()
+                    if fields.get(kw)])
         kws['machine_id'] = machine_id
         validate = validation.Validate(username, state, **kws)
         machine = validate.machine