server/serverctl.py
branchtls-sprint
changeset 1469 ba9759972b52
parent 1263 01152fffd593
child 1682 36bd5cba09de
--- a/server/serverctl.py	Fri Apr 24 09:20:36 2009 +0200
+++ b/server/serverctl.py	Fri Apr 24 09:20:43 2009 +0200
@@ -89,7 +89,7 @@
         # set_isolation_level() is psycopg specific
         pass
     return cnx
-    
+
 def generate_sources_file(sourcesfile, sourcescfg, keys=None):
     """serialize repository'sources configuration into a INI like file
 
@@ -109,7 +109,7 @@
             # get a Configuration object
             _sconfig = Configuration(options=SOURCE_TYPES[sconfig['adapter']].options)
             for attr, val in sconfig.items():
-                if attr == 'uri': 
+                if attr == 'uri':
                     continue
                 if attr == 'adapter':
                     _sconfig.adapter = val
@@ -140,7 +140,7 @@
         except AuthenticationError:
             print 'wrong user/password'
         login, pwd = manager_userpasswd()
-    
+
 # repository specific command handlers ########################################
 
 class RepositoryCreateHandler(CommandHandler):
@@ -187,14 +187,14 @@
         restrict_perms_to_user(sourcesfile)
         # remember selected cubes for later initialization of the database
         config.write_bootstrap_cubes_file(cubes)
-        
+
     def postcreate(self):
         if confirm('do you want to create repository\'s system database?'):
             verbosity = (self.config.mode == 'installed') and 'y' or 'n'
             cmd_run('db-create', self.config.appid, '--verbose=%s' % verbosity)
         else:
             print 'nevermind, you can do it later using the db-create command'
-            
+
 USER_OPTIONS =  (
     ('login', {'type' : 'string',
                'default': REQUIRED,
@@ -236,7 +236,7 @@
                 cnx.rollback()
                 raise
 
-    
+
 class RepositoryStartHandler(CommandHandler):
     cmdname = 'start'
     cfgname = 'repository'
@@ -247,7 +247,7 @@
             command.append('--debug')
         command.append(self.config.appid)
         return ' '.join(command)
-        
+
 
 class RepositoryStopHandler(CommandHandler):
     cmdname = 'stop'
@@ -260,12 +260,12 @@
         if self.config.pyro_enabled():
             from cubicweb.server.repository import pyro_unregister
             pyro_unregister(self.config)
-    
+
 
 # repository specific commands ################################################
 class CreateApplicationDBCommand(Command):
     """Create the system database of an application (run after 'create').
-    
+
     You will be prompted for a login / password to use to connect to
     the system database.  The given user should have almost all rights
     on the database (ie a super user on the dbms allowed to create
@@ -276,7 +276,7 @@
     """
     name = 'db-create'
     arguments = '<application>'
-    
+
     options = (
         ("create-db",
          {'short': 'c', 'type': "yn", 'metavar': '<y or n>',
@@ -328,11 +328,11 @@
             except:
                 dbcnx.rollback()
                 raise
-        cnx = system_source_cnx(source, special_privs='LANGUAGE C', verbose=verbose) 
+        cnx = system_source_cnx(source, special_privs='LANGUAGE C', verbose=verbose)
         cursor = cnx.cursor()
         indexer = get_indexer(driver)
         indexer.init_extensions(cursor)
-        # postgres specific stuff        
+        # postgres specific stuff
         if driver == 'postgres':
             # install plpythonu/plpgsql language if not installed by the cube
             for extlang in ('plpythonu', 'plpgsql'):
@@ -346,10 +346,10 @@
         else:
             print 'nevermind, you can do it later using the db-init command'
 
-    
+
 class InitApplicationCommand(Command):
     """Initialize the system database of an application (run after 'db-create').
-    
+
     You will be prompted for a login / password to use to connect to
     the system database.  The given user should have the create tables,
     and grant permissions.
@@ -359,7 +359,7 @@
     """
     name = 'db-init'
     arguments = '<application>'
-    
+
     options = (
         ("drop",
          {'short': 'd', 'action': 'store_true',
@@ -377,7 +377,7 @@
 
 class GrantUserOnApplicationCommand(Command):
     """Grant a database user on a repository system database.
-    
+
     <application>
       the identifier of the application
     <user>
@@ -388,7 +388,7 @@
 
     options = (
         ("set-owner",
-         {'short': 'o', 'type' : "yn", 'metavar' : '<yes or no>', 
+         {'short': 'o', 'type' : "yn", 'metavar' : '<yes or no>',
           'default' : False,
           'help': 'Set the user as tables owner if yes (no by default).'}
          ),
@@ -417,10 +417,10 @@
             print 'grants given to %s on application %s' % (appid, user)
 
 
-    
+
 class StartRepositoryCommand(Command):
     """Start an CubicWeb RQL server for a given application.
-    
+
     The server will be accessible through pyro
 
     <application>
@@ -428,7 +428,7 @@
     """
     name = 'start-repository'
     arguments = '<application>'
-    
+
     options = (
         ("debug",
          {'short': 'D', 'action' : 'store_true',
@@ -534,7 +534,7 @@
             applversion = vcconf[cube]
         except KeyError:
             print "no cube version information for %s in version configuration" % cube
-            continue            
+            continue
         if softversion == applversion:
             continue
         if softversion > applversion:
@@ -542,11 +542,11 @@
         elif softversion < applversion:
             return 'needapplupgrade'
     return None
-    
+
 
 class DBDumpCommand(Command):
     """Backup the system database of an application.
-    
+
     <application>
       the identifier of the application to backup
       format [[user@]host:]appname
@@ -556,7 +556,7 @@
 
     options = (
         ("output",
-         {'short': 'o', 'type' : "string", 'metavar' : '<file>', 
+         {'short': 'o', 'type' : "string", 'metavar' : '<file>',
           'default' : None,
           'help': 'Specify the backup file where the backup will be stored.'}
          ),
@@ -578,7 +578,7 @@
 
 class DBRestoreCommand(Command):
     """Restore the system database of an application.
-    
+
     <application>
       the identifier of the application to restore
     """
@@ -587,7 +587,7 @@
 
     options = (
         ("no-drop",
-         {'short': 'n', 'action' : 'store_true', 
+         {'short': 'n', 'action' : 'store_true',
           'default' : False,
           'help': 'for some reason the database doesn\'t exist and so '
           'should not be dropped.'}
@@ -602,7 +602,7 @@
 
 class DBCopyCommand(Command):
     """Copy the system database of an application (backup and restore).
-    
+
     <src-application>
       the identifier of the application to backup
       format [[user@]host:]appname
@@ -615,7 +615,7 @@
 
     options = (
         ("no-drop",
-         {'short': 'n', 'action' : 'store_true', 
+         {'short': 'n', 'action' : 'store_true',
           'default' : False,
           'help': 'For some reason the database doesn\'t exist and so '
           'should not be dropped.'}
@@ -648,10 +648,10 @@
         else:
             os.remove(output)
 
-        
+
 class CheckRepositoryCommand(Command):
     """Check integrity of the system database of an application.
-    
+
     <application>
       the identifier of the application to check
     """
@@ -660,25 +660,25 @@
 
     options = (
         ("checks",
-         {'short': 'c', 'type' : "csv", 'metavar' : '<check list>', 
+         {'short': 'c', 'type' : "csv", 'metavar' : '<check list>',
           'default' : ('entities', 'relations', 'metadata', 'schema', 'text_index'),
           'help': 'Comma separated list of check to run. By default run all \
 checks, i.e. entities, relations, text_index and metadata.'}
          ),
-        
+
         ("autofix",
-         {'short': 'a', 'type' : "yn", 'metavar' : '<yes or no>', 
+         {'short': 'a', 'type' : "yn", 'metavar' : '<yes or no>',
           'default' : False,
           'help': 'Automatically correct integrity problems if this option \
 is set to "y" or "yes", else only display them'}
          ),
         ("reindex",
-         {'short': 'r', 'type' : "yn", 'metavar' : '<yes or no>', 
+         {'short': 'r', 'type' : "yn", 'metavar' : '<yes or no>',
           'default' : False,
           'help': 're-indexes the database for full text search if this \
 option is set to "y" or "yes" (may be long for large database).'}
          ),
-        
+
         )
 
     def run(self, args):
@@ -692,7 +692,7 @@
 
 class RebuildFTICommand(Command):
     """Rebuild the full-text index of the system database of an application.
-    
+
     <application>
       the identifier of the application to rebuild
     """
@@ -710,10 +710,10 @@
         reindex_entities(repo.schema, session)
         cnx.commit()
 
-    
+
 class SynchronizeApplicationSchemaCommand(Command):
     """Synchronize persistent schema with cube schema.
-        
+
     Will synchronize common stuff between the cube schema and the
     actual persistent schema, but will not add/remove any entity or relation.
 
@@ -730,7 +730,7 @@
         mih.cmd_synchronize_schema()
 
 
-register_commands( (CreateApplicationDBCommand,                   
+register_commands( (CreateApplicationDBCommand,
                     InitApplicationCommand,
                     GrantUserOnApplicationCommand,
                     StartRepositoryCommand,