--- a/__init__.py Sat Jul 18 16:17:46 2009 +0200
+++ b/__init__.py Sat Jul 18 22:58:30 2009 +0200
@@ -295,3 +295,6 @@
except AttributeError:
return neg_role(obj.role)
+def underline_title(title, car='-'):
+ return title+'\n'+(car*len(title))
+
--- a/common/i18n.py Sat Jul 18 16:17:46 2009 +0200
+++ b/common/i18n.py Sat Jul 18 22:58:30 2009 +0200
@@ -63,7 +63,7 @@
"""generate .mo files for a set of languages into the `destdir` i18n directory
"""
from logilab.common.fileutils import ensure_fs_mode
- print 'compiling %s catalogs...' % destdir
+ print '-> compiling %s catalogs...' % destdir
errors = []
for lang in langs:
langdir = join(destdir, lang, 'LC_MESSAGES')
--- a/cwctl.py Sat Jul 18 16:17:46 2009 +0200
+++ b/cwctl.py Sat Jul 18 22:58:30 2009 +0200
@@ -10,7 +10,7 @@
from logilab.common.clcommands import register_commands, pop_arg
-from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage
+from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage, underline_title
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg, CONFIGURATIONS
from cubicweb.toolsutils import Command, main_run, rm, create_dir, confirm
@@ -286,20 +286,22 @@
print ', '.join(cwcfg.available_cubes())
return
# create the registry directory for this application
+ print '\n'+underline_title('Creating the application %s' % appid)
create_dir(config.apphome)
# load site_cubicweb from the cubes dir (if any)
config.load_site_cubicweb()
# cubicweb-ctl configuration
- print '** application\'s %s configuration' % configname
- print '-' * 72
+ print '\n'+underline_title('Configuring the application (%s.conf)' % configname)
config.input_config('main', self.config.config_level)
# configuration'specific stuff
print
helper.bootstrap(cubes, self.config.config_level)
# write down configuration
config.save()
+ print '-> generated %s' % config.main_config_file()
# handle i18n files structure
# in the first cube given
+ print '-> preparing i18n catalogs'
from cubicweb.common import i18n
langs = [lang for lang, _ in i18n.available_catalogs(join(templdirs[0], 'i18n'))]
errors = config.i18ncompile(langs)
@@ -317,12 +319,7 @@
# this directory should be owned by the uid of the server process
print 'set %s as owner of the data directory' % config['uid']
chown(config.appdatahome, config['uid'])
- print
- print
- print '*' * 72
- print 'application %s (%s) created in %r' % (appid, configname,
- config.apphome)
- print
+ print '\n-> creation done for %r.\n' % config.apphome
helper.postcreate()
--- a/devtools/devctl.py Sat Jul 18 16:17:46 2009 +0200
+++ b/devtools/devctl.py Sat Jul 18 22:58:30 2009 +0200
@@ -262,7 +262,7 @@
tempdir = mktemp()
mkdir(tempdir)
potfiles = [join(I18NDIR, 'entities.pot')]
- print '******** extract schema messages'
+ print '-> extract schema messages.'
schemapot = join(tempdir, 'schema.pot')
potfiles.append(schemapot)
# explicit close necessary else the file may not be yet flushed when
@@ -270,10 +270,10 @@
schemapotstream = file(schemapot, 'w')
generate_schema_pot(schemapotstream.write, cubedir=None)
schemapotstream.close()
- print '******** extract TAL messages'
+ print '-> extract TAL messages.'
tali18nfile = join(tempdir, 'tali18n.py')
extract_from_tal(find(join(BASEDIR, 'web'), ('.py', '.pt')), tali18nfile)
- print '******** .pot files generation'
+ print '-> generate .pot files.'
for id, files, lang in [('pycubicweb', get_module_files(BASEDIR) + list(globfind(join(BASEDIR, 'misc', 'migration'), '*.py')), None),
('schemadescr', globfind(join(BASEDIR, 'schemas'), '*.py'), None),
('yams', get_module_files(yams.__path__[0]), None),
@@ -288,11 +288,11 @@
if exists(potfile):
potfiles.append(potfile)
else:
- print 'WARNING: %s file not generated' % potfile
- print '******** merging .pot files'
+ print '-> WARNING: %s file was not generated' % potfile
+ print '-> merging %i .pot files' % len(potfiles)
cubicwebpot = join(tempdir, 'cubicweb.pot')
execute('msgcat %s > %s' % (' '.join(potfiles), cubicwebpot))
- print '******** merging main pot file with existing translations'
+ print '-> merging main pot file with existing translations.'
chdir(I18NDIR)
toedit = []
for lang in LANGS:
@@ -332,14 +332,14 @@
toedit = []
for cubedir in cubes:
if not isdir(cubedir):
- print 'not a directory', cubedir
+ print '-> ignoring %s that is not a directory.' % cubedir
continue
try:
toedit += update_cube_catalogs(cubedir)
except Exception:
import traceback
traceback.print_exc()
- print 'error while updating catalogs for', cubedir
+ print '-> Error while updating catalogs for cube', cubedir
# instructions pour la suite
print '*' * 72
print 'you can now edit the following files:'
@@ -357,11 +357,11 @@
tempdir = mktemp()
mkdir(tempdir)
print '*' * 72
- print 'updating %s cube...' % cube
+ print '-> updating cube %s' % cube
chdir(cubedir)
potfiles = [join('i18n', scfile) for scfile in ('entities.pot',)
if exists(join('i18n', scfile))]
- print '******** extract schema messages'
+ print '-> extract schema messages'
schemapot = join(tempdir, 'schema.pot')
potfiles.append(schemapot)
# explicit close necessary else the file may not be yet flushed when
@@ -369,10 +369,10 @@
schemapotstream = file(schemapot, 'w')
generate_schema_pot(schemapotstream.write, cubedir)
schemapotstream.close()
- print '******** extract TAL messages'
+ print '-> extract TAL messages'
tali18nfile = join(tempdir, 'tali18n.py')
extract_from_tal(find('.', ('.py', '.pt'), blacklist=STD_BLACKLIST+('test',)), tali18nfile)
- print '******** extract Javascript messages'
+ print '-> extract Javascript messages'
jsfiles = [jsfile for jsfile in find('.', '.js') if basename(jsfile).startswith('cub')]
if jsfiles:
tmppotfile = join(tempdir, 'js.pot')
@@ -381,7 +381,7 @@
# no pot file created if there are no string to translate
if exists(tmppotfile):
potfiles.append(tmppotfile)
- print '******** create cube specific catalog'
+ print '-> create cube-specific catalog'
tmppotfile = join(tempdir, 'generated.pot')
cubefiles = find('.', '.py', blacklist=STD_BLACKLIST+('test',))
cubefiles.append(tali18nfile)
@@ -390,12 +390,12 @@
if exists(tmppotfile): # doesn't exists of no translation string found
potfiles.append(tmppotfile)
potfile = join(tempdir, 'cube.pot')
- print '******** merging .pot files'
+ print '-> merging %i .pot files:' % len(potfiles)
execute('msgcat %s > %s' % (' '.join(potfiles), potfile))
- print '******** merging main pot file with existing translations'
+ print '-> merging main pot file with existing translations:'
chdir('i18n')
for lang in LANGS:
- print '****', lang
+ print '-> language', lang
cubepo = '%s.po' % lang
if not exists(cubepo):
shutil.copy(potfile, cubepo)
--- a/etwist/twctl.py Sat Jul 18 16:17:46 2009 +0200
+++ b/etwist/twctl.py Sat Jul 18 22:58:30 2009 +0200
@@ -8,6 +8,7 @@
import sys
+from cubicweb import underline_title
from cubicweb.toolsutils import CommandHandler
from cubicweb.web.webctl import WebCreateHandler
@@ -20,7 +21,7 @@
def bootstrap(self, cubes, inputlevel=0):
"""bootstrap this configuration"""
- print '** twisted configuration'
+ print '\n'+underline_title('Configuring Twisted')
mainpyfile = self.config.server_file()
mainpy = open(mainpyfile, 'w')
mainpy.write('''
@@ -28,7 +29,7 @@
application = server.main(%r, %r)
''' % (self.config.appid, self.config.name))
mainpy.close()
- print 'application\'s twisted file %s generated' % mainpyfile
+ print '-> generated %s' % mainpyfile
super(TWCreateHandler, self).bootstrap(cubes, inputlevel)
--- a/server/__init__.py Sat Jul 18 16:17:46 2009 +0200
+++ b/server/__init__.py Sat Jul 18 22:58:30 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 tables...'
source = sourcescfg['system']
driver = source['db-driver']
sqlcnx = repo.system_source.get_connection()
--- a/server/schemaserial.py Sat Jul 18 16:17:46 2009 +0200
+++ b/server/schemaserial.py Sat Jul 18 22:58:30 2009 +0200
@@ -277,7 +277,7 @@
"""synchronize schema and permissions in the database according to
current schema
"""
- print '-> storing the schema in the system source, this may take some time'
+ print '-> storing the schema in the database...'
eschemas = schema.entities()
aller = eschemas + schema.relations()
if not verbose:
--- a/server/serverctl.py Sat Jul 18 16:17:46 2009 +0200
+++ b/server/serverctl.py Sat Jul 18 22:58:30 2009 +0200
@@ -13,7 +13,7 @@
from logilab.common.configuration import Configuration
from logilab.common.clcommands import register_commands, cmd_run, pop_arg
-from cubicweb import AuthenticationError, ExecutionError, ConfigurationError
+from cubicweb import AuthenticationError, ExecutionError, ConfigurationError, underline_title
from cubicweb.toolsutils import Command, CommandHandler, confirm
from cubicweb.server import SOURCE_TYPES
from cubicweb.server.utils import ask_source_config
@@ -47,7 +47,7 @@
print special_privs
print
default_user = source.get('db-user', os.environ.get('USER', ''))
- user = raw_input('user (%r by default): ' % default_user)
+ user = raw_input('Connect as user ? [%r]: ' % default_user)
user = user or default_user
if user == source.get('db-user') and source.get('db-password'):
password = source['db-password']
@@ -121,14 +121,11 @@
asking information necessary to build required configuration files
"""
config = self.config
- print 'application\'s repository configuration'
- print '-' * 72
+ print underline_title('Configuring the repository')
config.input_config('email', inputlevel)
if config.pyro_enabled():
config.input_config('pyro-server', inputlevel)
- print
- print 'repository sources configuration'
- print '-' * 72
+ print '\n'+underline_title('Configuring the sources')
sourcesfile = config.sources_file()
sconfig = Configuration(options=SOURCE_TYPES['native'].options)
sconfig.adapter = 'native'
@@ -139,7 +136,8 @@
# source to use the cube, so add it.
if cube in SOURCE_TYPES:
sourcescfg[cube] = ask_source_config(cube, inputlevel)
- while raw_input('enter another source [y/N]: ').strip().lower() == 'y':
+ print
+ while confirm('Enter another source ?', default_is_yes=False):
available = sorted(stype for stype in SOURCE_TYPES
if not stype in cubes)
while True:
@@ -169,11 +167,12 @@
config.write_bootstrap_cubes_file(cubes)
def postcreate(self):
- if confirm('Do you want to run db-create to create repository\'s system database?'):
+ if confirm('Do you want to run db-create to create the "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 with '
+ '"cubicweb-ctl db-create %s".' % self.config.appid)
class RepositoryDeleteHandler(CommandHandler):
@@ -268,6 +267,7 @@
driver = source['db-driver']
helper = get_adv_func_helper(driver)
if create_db:
+ print '\n'+underline_title('Creating the "system database"')
# connect on the dbms system base to create our base
dbcnx = _db_sys_cnx(source, 'CREATE DATABASE and / or USER', verbose=verbose)
cursor = dbcnx.cursor()
@@ -308,10 +308,11 @@
cnx.commit()
print '-> database for application %s created and necessary extensions installed.' % appid
print
- if confirm('Do you want to run db-init 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 with '
+ '"cubicweb-ctl db-init %s".' % self.config.appid)
class InitApplicationCommand(Command):
@@ -336,6 +337,7 @@
)
def run(self, args):
+ print '\n'+underline_title('Initializing the "system database"')
from cubicweb.server import init_repository
appid = pop_arg(args, msg="No application specified !")
config = ServerConfiguration.config_for(appid)
--- a/toolsutils.py Sat Jul 18 16:17:46 2009 +0200
+++ b/toolsutils.py Sat Jul 18 22:58:30 2009 +0200
@@ -34,12 +34,12 @@
"""create a directory if it doesn't exist yet"""
try:
makedirs(directory)
- print 'created directory', directory
+ print '-> created directory %s.' % directory
except OSError, ex:
import errno
if ex.errno != errno.EEXIST:
raise
- print 'directory %s already exists' % directory
+ print '-> directory %s already exists, no need to create it.' % directory
def create_symlink(source, target):
"""create a symbolic link"""
@@ -56,7 +56,7 @@
def rm(whatever):
import shutil
shutil.rmtree(whatever)
- print 'removed %s' % whatever
+ print '-> removed %s' % whatever
def show_diffs(appl_file, ref_file, askconfirm=True):
"""interactivly replace the old file with the new file according to
@@ -133,7 +133,7 @@
if log:
log('set %s permissions to 0600', filepath)
else:
- print 'set %s permissions to 0600' % filepath
+ print '-> set %s permissions to 0600' % filepath
chmod(filepath, 0600)
def confirm(question, default_is_yes=True):
--- a/web/webctl.py Sat Jul 18 16:17:46 2009 +0200
+++ b/web/webctl.py Sat Jul 18 22:58:30 2009 +0200
@@ -8,6 +8,7 @@
"""
__docformat__ = "restructuredtext en"
+from cubicweb import underline_title
from cubicweb.toolsutils import CommandHandler, confirm
@@ -16,14 +17,12 @@
def bootstrap(self, cubes, inputlevel=0):
"""bootstrap this configuration"""
- print '** generic web configuration'
+ print '\n'+underline_title('Generic web configuration')
config = self.config
if config.repo_method == 'pyro':
- print
- print '** repository server configuration'
- print '-' * 72
+ print '\n'+underline_title('Repository server configuration')
config.input_config('pyro-client', inputlevel)
- if confirm('allow anonymous access', False):
+ if confirm('Allow anonymous access ?', False):
config.global_set_option('anonymous-user', 'anon')
config.global_set_option('anonymous-password', 'anon')