[cw-ctl] improve dialog messages stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Sat, 18 Jul 2009 16:17:46 +0200
branchstable
changeset 2394 92bba46b853f
parent 2393 6190852af97f
child 2395 e3093fc12a00
[cw-ctl] improve dialog messages
server/__init__.py
server/schemaserial.py
server/serverctl.py
--- a/server/__init__.py	Sat Jul 18 16:00:14 2009 +0200
+++ b/server/__init__.py	Sat Jul 18 16:17:46 2009 +0200
@@ -45,7 +45,7 @@
     assert len(repo.sources) == 1, repo.sources
     schema = repo.schema
     sourcescfg = config.sources()
-    print 'creating necessary tables into the system source'
+    print '-> creating necessary tables into the system source.'
     source = sourcescfg['system']
     driver = source['db-driver']
     sqlcnx = repo.system_source.get_connection()
@@ -56,7 +56,7 @@
         try:
             sqlexec(dropsql, execute)
         except Exception, ex:
-            print 'drop failed, skipped (%s)' % ex
+            print '-> drop failed, skipped (%s).' % ex
             sqlcnx.rollback()
     # schema entities and relations tables
     # can't skip entities table even if system source doesn't support them,
@@ -71,11 +71,11 @@
     sqlexec(schemasql, execute)
     # install additional driver specific sql files
     for fpath in glob(join(config.schemas_lib_dir(), '*.sql.%s' % driver)):
-        print 'install', fpath
+        print '-> installing', fpath
         sqlexec(open(fpath).read(), execute, False, delimiter=';;')
     for directory in config.cubes_path():
         for fpath in glob(join(directory, 'schema', '*.sql.%s' % driver)):
-            print 'install', fpath
+            print '-> installing', fpath
             sqlexec(open(fpath).read(), execute, False, delimiter=';;')
     sqlcursor.close()
     sqlcnx.commit()
@@ -90,7 +90,7 @@
             login, pwd = manager_userpasswd(msg=msg, confirm=True)
         else:
             login, pwd = unicode(source['db-user']), source['db-password']
-    print 'inserting default user and groups'
+    print '-> inserting default user and default groups.'
     needisfix = []
     for group in BASEGROUPS:
         rset = session.execute('INSERT CWGroup X: X name %(name)s',
@@ -140,7 +140,7 @@
     config.bootstrap_schema = bootstrap_schema
     config.consider_user_state = True
     config.set_language = True
-    print 'application %s initialized' % config.appid
+    print '-> application %s initialized.' % config.appid
 
 
 def initialize_schema(config, schema, mhandler, event='create'):
--- a/server/schemaserial.py	Sat Jul 18 16:00:14 2009 +0200
+++ b/server/schemaserial.py	Sat Jul 18 16:17:46 2009 +0200
@@ -277,7 +277,7 @@
     """synchronize schema and permissions in the database according to
     current schema
     """
-    print 'serializing the schema, this may take some time'
+    print '-> storing the schema in the system source, this may take some time'
     eschemas = schema.entities()
     aller = eschemas + schema.relations()
     if not verbose:
--- a/server/serverctl.py	Sat Jul 18 16:00:14 2009 +0200
+++ b/server/serverctl.py	Sat Jul 18 16:17:46 2009 +0200
@@ -19,7 +19,6 @@
 from cubicweb.server.utils import ask_source_config
 from cubicweb.server.serverconfig import USER_OPTIONS, ServerConfiguration
 
-
 # utility functions ###########################################################
 
 def source_cnx(source, dbname=None, special_privs=False, verbose=True):
@@ -32,7 +31,7 @@
     if dbname is None:
         dbname = source['db-name']
     driver = source['db-driver']
-    print '**** connecting to %s database %s@%s' % (driver, dbname, dbhost),
+    print '-> connecting to %s database %s@%s' % (driver, dbname, dbhost or 'localhost'),
     if not verbose or (not special_privs and source.get('db-user')):
         user = source['db-user']
         print 'as', user
@@ -106,7 +105,7 @@
         try:
             return in_memory_cnx(config, login, pwd)
         except AuthenticationError:
-            print 'wrong user/password'
+            print '-> Error: wrong user/password.'
             # reset cubes else we'll have an assertion error on next retry
             config._cubes = None
         login, pwd = manager_userpasswd()
@@ -147,12 +146,12 @@
                 sourcetype = raw_input('source type (%s): ' % ', '.join(available))
                 if sourcetype in available:
                     break
-                print 'unknown source type, use one of the available type'
+                print '-> unknown source type, use one of the available types.'
             while True:
                 sourceuri = raw_input('source uri: ').strip()
                 if sourceuri != 'admin' and sourceuri not in sourcescfg:
                     break
-                print 'uri already used, choose another one'
+                print '-> uri already used, choose another one.'
             sourcescfg[sourceuri] = ask_source_config(sourcetype)
             sourcemodule = SOURCE_TYPES[sourcetype].module
             if not sourcemodule.startswith('cubicweb.'):
@@ -170,11 +169,11 @@
         config.write_bootstrap_cubes_file(cubes)
 
     def postcreate(self):
-        if confirm('do you want to create repository\'s system database?'):
+        if confirm('Do you want to run db-create 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'
+            print '-> nevermind, you can do it later using the db-create command.'
 
 
 class RepositoryDeleteHandler(CommandHandler):
@@ -187,18 +186,18 @@
         source = self.config.sources()['system']
         dbname = source['db-name']
         helper = get_adv_func_helper(source['db-driver'])
-        if confirm('delete database %s ?' % dbname):
+        if confirm('Delete database %s ?' % dbname):
             user = source['db-user'] or None
             cnx = _db_sys_cnx(source, 'DROP DATABASE', user=user)
             cursor = cnx.cursor()
             try:
                 cursor.execute('DROP DATABASE %s' % dbname)
-                print 'database %s dropped' % dbname
+                print '-> database %s dropped.' % dbname
                 # XXX should check we are not connected as user
                 if user and helper.users_support and \
-                       confirm('delete user %s ?' % user, default_is_yes=False):
+                       confirm('Delete user %s ?' % user, default_is_yes=False):
                     cursor.execute('DROP USER %s' % user)
-                    print 'user %s dropped' % user
+                    print '-> user %s dropped.' % user
                 cnx.commit()
             except:
                 cnx.rollback()
@@ -276,12 +275,12 @@
                 if helper.users_support:
                     user = source['db-user']
                     if not helper.user_exists(cursor, user) and \
-                           confirm('create db user %s ?' % user, default_is_yes=False):
+                           confirm('Create db user %s ?' % user, default_is_yes=False):
                         helper.create_user(source['db-user'], source['db-password'])
-                        print 'user %s created' % user
+                        print '-> user %s created.' % user
                 dbname = source['db-name']
                 if dbname in helper.list_databases(cursor):
-                    if confirm('DB %s already exists -- do you want to drop it ?' % dbname):
+                    if confirm('Database %s already exists -- do you want to drop it ?' % dbname):
                         cursor.execute('DROP DATABASE %s' % dbname)
                     else:
                         return
@@ -292,7 +291,7 @@
                     helper.create_database(cursor, dbname,
                                            encoding=source['db-encoding'])
                 dbcnx.commit()
-                print 'database %s created' % source['db-name']
+                print '-> database %s created.' % source['db-name']
             except:
                 dbcnx.rollback()
                 raise
@@ -307,12 +306,12 @@
                 helper.create_language(cursor, extlang)
         cursor.close()
         cnx.commit()
-        print 'database for application %s created and necessary extensions installed' % appid
+        print '-> database for application %s created and necessary extensions installed.' % appid
         print
-        if confirm('do you want to initialize the system database?'):
+        if confirm('Do you want to run db-init to initialize the system database?'):
             cmd_run('db-init', config.appid)
         else:
-            print 'nevermind, you can do it later using the db-init command'
+            print '-> nevermind, you can do it later using the db-init command.'
 
 
 class InitApplicationCommand(Command):
@@ -379,10 +378,10 @@
             cnx.rollback()
             import traceback
             traceback.print_exc()
-            print 'An error occured:', ex
+            print '-> an error occured:', ex
         else:
             cnx.commit()
-            print 'grants given to %s on application %s' % (appid, user)
+            print '-> rights granted to %s on application %s.' % (appid, user)
 
 class ResetAdminPasswordCommand(Command):
     """Reset the administrator password.
@@ -403,7 +402,7 @@
         try:
             adminlogin = sourcescfg['admin']['login']
         except KeyError:
-            print 'could not get cubicweb administrator login'
+            print '-> Error: could not get cubicweb administrator login.'
             sys.exit(1)
         cnx = source_cnx(sourcescfg['system'])
         cursor = cnx.cursor()
@@ -423,10 +422,10 @@
             cnx.rollback()
             import traceback
             traceback.print_exc()
-            print 'An error occured:', ex
+            print '-> an error occured:', ex
         else:
             cnx.commit()
-            print 'password reset, sources file regenerated'
+            print '-> password reset, sources file regenerated.'
 
 
 class StartRepositoryCommand(Command):
@@ -488,7 +487,7 @@
     rmcmd = 'ssh -t %s "rm -f /tmp/%s.dump"' % (host, appid)
     print rmcmd
     if os.system(rmcmd) and not confirm(
-        'an error occured while deleting remote dump. Continue anyway?'):
+        'An error occured while deleting remote dump. Continue anyway?'):
         raise ExecutionError('Error while deleting remote dump')
 
 def _local_dump(appid, output):
@@ -539,12 +538,12 @@
         try:
             softversion = config.cube_version(cube)
         except ConfigurationError:
-            print "no cube version information for %s, is the cube installed?" % cube
+            print "-> Error: no cube version information for %s, please check that the cube is installed." % cube
             continue
         try:
             applversion = vcconf[cube]
         except KeyError:
-            print "no cube version information for %s in version configuration" % cube
+            print "-> Error: no cube version information for %s in version configuration." % cube
             continue
         if softversion == applversion:
             continue
@@ -655,7 +654,7 @@
             _local_dump(srcappid, output)
         _local_restore(destappid, output, not self.config.no_drop)
         if self.config.keep_dump:
-            print 'you can get the dump file at', output
+            print '-> you can get the dump file at', output
         else:
             os.remove(output)