Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
7c23b7de2b8d
Commit
0275b4a1
authored
Sep 11, 2015
by
Samuel Trégouët
Browse files
[py3k] print function
parent
fdaa0e4b7eaf
Changes
53
Hide whitespace changes
Inline
Side-by-side
_gcdebug.py
View file @
7c23b7de
...
...
@@ -15,6 +15,7 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
print_function
import
gc
,
types
,
weakref
...
...
@@ -68,7 +69,7 @@ def gc_info(countclasses,
except
KeyError
:
ocounters
[
key
]
=
1
if
isinstance
(
obj
,
viewreferrersclasses
):
print
' '
,
obj
,
referrers
(
obj
,
showobjs
,
maxlevel
)
print
(
' '
,
obj
,
referrers
(
obj
,
showobjs
,
maxlevel
)
)
garbage
=
[
repr
(
obj
)
for
obj
in
gc
.
garbage
]
return
counters
,
ocounters
,
garbage
...
...
cwconfig.py
View file @
7c23b7de
...
...
@@ -164,6 +164,7 @@ Here are all environment variables that may be used to configure *CubicWeb*:
Directory where pid files will be written
"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
_
=
unicode
...
...
@@ -1188,8 +1189,8 @@ the repository',
def
set_sources_mode
(
self
,
sources
):
if
not
'all'
in
sources
:
print
'warning: ignoring specified sources, requires a repository '
\
'configuration'
print
(
'warning: ignoring specified sources, requires a repository '
'configuration'
)
def
i18ncompile
(
self
,
langs
=
None
):
from
cubicweb
import
i18n
...
...
cwctl.py
View file @
7c23b7de
...
...
@@ -18,6 +18,7 @@
"""the cubicweb-ctl tool, based on logilab.common.clcommands to
provide a pluggable commands system.
"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
...
...
@@ -120,8 +121,8 @@ class InstanceCommand(Command):
_allinstances
.
remove
(
line
)
allinstances
.
append
(
line
)
except
ValueError
:
print
(
'ERROR: startorder file contains unexistant '
'instance %s'
%
line
)
print
(
'ERROR: startorder file contains unexistant '
'instance %s'
%
line
)
allinstances
+=
_allinstances
else
:
allinstances
=
_allinstances
...
...
@@ -146,7 +147,7 @@ class InstanceCommand(Command):
status
=
0
for
appid
in
args
:
if
askconfirm
:
print
'*'
*
72
print
(
'*'
*
72
)
if
not
ASK
.
confirm
(
'%s instance %r ?'
%
(
self
.
name
,
appid
)):
continue
try
:
...
...
@@ -184,13 +185,13 @@ class InstanceCommandFork(InstanceCommand):
forkcmd
=
None
for
appid
in
args
:
if
askconfirm
:
print
'*'
*
72
print
(
'*'
*
72
)
if
not
ASK
.
confirm
(
'%s instance %r ?'
%
(
self
.
name
,
appid
)):
continue
if
forkcmd
:
status
=
system
(
'%s %s'
%
(
forkcmd
,
appid
))
if
status
:
print
'%s exited with status %s'
%
(
forkcmd
,
status
)
print
(
'%s exited with status %s'
%
(
forkcmd
,
status
)
)
else
:
self
.
run_arg
(
appid
)
...
...
@@ -224,19 +225,19 @@ class ListCommand(Command):
from
cubicweb.migration
import
ConfigurationProblem
if
mode
==
'all'
:
print
'CubicWeb %s (%s mode)'
%
(
cwcfg
.
cubicweb_version
(),
cwcfg
.
mode
)
print
print
(
'CubicWeb %s (%s mode)'
%
(
cwcfg
.
cubicweb_version
(),
cwcfg
.
mode
)
)
print
()
if
mode
in
(
'all'
,
'config'
,
'configurations'
):
print
'Available configurations:'
print
(
'Available configurations:'
)
for
config
in
CONFIGURATIONS
:
print
'*'
,
config
.
name
print
(
'*'
,
config
.
name
)
for
line
in
config
.
__doc__
.
splitlines
():
line
=
line
.
strip
()
if
not
line
:
continue
print
' '
,
line
print
print
(
' '
,
line
)
print
()
if
mode
in
(
'all'
,
'cubes'
):
cfgpb
=
ConfigurationProblem
(
cwcfg
)
...
...
@@ -244,11 +245,11 @@ class ListCommand(Command):
cubesdir
=
pathsep
.
join
(
cwcfg
.
cubes_search_path
())
namesize
=
max
(
len
(
x
)
for
x
in
cwcfg
.
available_cubes
())
except
ConfigurationError
as
ex
:
print
'No cubes available:'
,
ex
print
(
'No cubes available:'
,
ex
)
except
ValueError
:
print
'No cubes available in %s'
%
cubesdir
print
(
'No cubes available in %s'
%
cubesdir
)
else
:
print
'Available cubes (%s):'
%
cubesdir
print
(
'Available cubes (%s):'
%
cubesdir
)
for
cube
in
cwcfg
.
available_cubes
():
try
:
tinfo
=
cwcfg
.
cube_pkginfo
(
cube
)
...
...
@@ -257,59 +258,59 @@ class ListCommand(Command):
except
(
ConfigurationError
,
AttributeError
)
as
ex
:
tinfo
=
None
tversion
=
'[missing cube information: %s]'
%
ex
print
'* %s %s'
%
(
cube
.
ljust
(
namesize
),
tversion
)
print
(
'* %s %s'
%
(
cube
.
ljust
(
namesize
),
tversion
)
)
if
self
.
config
.
verbose
:
if
tinfo
:
descr
=
getattr
(
tinfo
,
'description'
,
''
)
if
not
descr
:
descr
=
tinfo
.
__doc__
if
descr
:
print
' '
+
'
\n
'
.
join
(
descr
.
splitlines
())
print
(
' '
+
'
\n
'
.
join
(
descr
.
splitlines
())
)
modes
=
detect_available_modes
(
cwcfg
.
cube_dir
(
cube
))
print
' available modes: %s'
%
', '
.
join
(
modes
)
print
print
(
' available modes: %s'
%
', '
.
join
(
modes
)
)
print
()
if
mode
in
(
'all'
,
'instances'
):
try
:
regdir
=
cwcfg
.
instances_dir
()
except
ConfigurationError
as
ex
:
print
'No instance available:'
,
ex
print
print
(
'No instance available:'
,
ex
)
print
()
return
instances
=
list_instances
(
regdir
)
if
instances
:
print
'Available instances (%s):'
%
regdir
print
(
'Available instances (%s):'
%
regdir
)
for
appid
in
instances
:
modes
=
cwcfg
.
possible_configurations
(
appid
)
if
not
modes
:
print
'* %s (BROKEN instance, no configuration found)'
%
appid
print
(
'* %s (BROKEN instance, no configuration found)'
%
appid
)
continue
print
'* %s (%s)'
%
(
appid
,
', '
.
join
(
modes
))
print
(
'* %s (%s)'
%
(
appid
,
', '
.
join
(
modes
))
)
try
:
config
=
cwcfg
.
config_for
(
appid
,
modes
[
0
])
except
Exception
as
exc
:
print
' (BROKEN instance, %s)'
%
exc
print
(
' (BROKEN instance, %s)'
%
exc
)
continue
else
:
print
'No instance available in %s'
%
regdir
print
print
(
'No instance available in %s'
%
regdir
)
print
()
if
mode
==
'all'
:
# configuration management problem solving
cfgpb
.
solve
()
if
cfgpb
.
warnings
:
print
'Warnings:
\n
'
,
'
\n
'
.
join
(
'* '
+
txt
for
txt
in
cfgpb
.
warnings
)
print
(
'Warnings:
\n
'
,
'
\n
'
.
join
(
'* '
+
txt
for
txt
in
cfgpb
.
warnings
)
)
if
cfgpb
.
errors
:
print
'Errors:'
print
(
'Errors:'
)
for
op
,
cube
,
version
,
src
in
cfgpb
.
errors
:
if
op
==
'add'
:
print
'* cube'
,
cube
,
print
(
'* cube'
,
cube
,
end
=
' '
)
if
version
:
print
' version'
,
version
,
print
'is not installed, but required by %s'
%
src
print
(
' version'
,
version
,
end
=
' '
)
print
(
'is not installed, but required by %s'
%
src
)
else
:
print
'* cube %s version %s is installed, but version %s is required by %s'
%
(
cube
,
cfgpb
.
cubes
[
cube
],
version
,
src
)
print
(
'* cube %s version %s is installed, but version %s is required by %s'
%
(
cube
,
cfgpb
.
cubes
[
cube
],
version
,
src
)
)
def
check_options_consistency
(
config
):
if
config
.
automatic
and
config
.
config_level
>
0
:
...
...
@@ -380,20 +381,20 @@ class CreateInstanceCommand(Command):
templdirs
=
[
cwcfg
.
cube_dir
(
cube
)
for
cube
in
cubes
]
except
ConfigurationError
as
ex
:
print
ex
print
'
\n
available cubes:'
,
print
', '
.
join
(
cwcfg
.
available_cubes
())
print
(
ex
)
print
(
'
\n
available cubes:'
,
end
=
' '
)
print
(
', '
.
join
(
cwcfg
.
available_cubes
())
)
return
# create the registry directory for this instance
print
'
\n
'
+
underline_title
(
'Creating the instance %s'
%
appid
)
print
(
'
\n
'
+
underline_title
(
'Creating the instance %s'
%
appid
)
)
create_dir
(
config
.
apphome
)
# cubicweb-ctl configuration
if
not
self
.
config
.
automatic
:
print
'
\n
'
+
underline_title
(
'Configuring the instance (%s.conf)'
%
configname
)
print
(
'
\n
'
+
underline_title
(
'Configuring the instance (%s.conf)'
%
configname
)
)
config
.
input_config
(
'main'
,
self
.
config
.
config_level
)
# configuration'specific stuff
print
print
()
helper
.
bootstrap
(
cubes
,
self
.
config
.
automatic
,
self
.
config
.
config_level
)
# input for cubes specific options
if
not
self
.
config
.
automatic
:
...
...
@@ -402,23 +403,23 @@ class CreateInstanceCommand(Command):
and
odict
.
get
(
'level'
)
<=
self
.
config
.
config_level
)
for
section
in
sections
:
if
section
not
in
(
'main'
,
'email'
,
'web'
):
print
'
\n
'
+
underline_title
(
'%s options'
%
section
)
print
(
'
\n
'
+
underline_title
(
'%s options'
%
section
)
)
config
.
input_config
(
section
,
self
.
config
.
config_level
)
# write down configuration
config
.
save
()
self
.
_handle_win32
(
config
,
appid
)
print
'-> generated config %s'
%
config
.
main_config_file
()
print
(
'-> generated config %s'
%
config
.
main_config_file
()
)
# handle i18n files structure
# in the first cube given
from
cubicweb
import
i18n
langs
=
[
lang
for
lang
,
_
in
i18n
.
available_catalogs
(
join
(
templdirs
[
0
],
'i18n'
))]
errors
=
config
.
i18ncompile
(
langs
)
if
errors
:
print
'
\n
'
.
join
(
errors
)
print
(
'
\n
'
.
join
(
errors
)
)
if
self
.
config
.
automatic
\
or
not
ASK
.
confirm
(
'error while compiling message catalogs, '
'continue anyway ?'
):
print
'creation not completed'
print
(
'creation not completed'
)
return
# create the additional data directory for this instance
if
config
.
appdatahome
!=
config
.
apphome
:
# true in dev mode
...
...
@@ -427,9 +428,9 @@ class CreateInstanceCommand(Command):
if
config
[
'uid'
]:
from
logilab.common.shellutils
import
chown
# this directory should be owned by the uid of the server process
print
'set %s as owner of the data directory'
%
config
[
'uid'
]
print
(
'set %s as owner of the data directory'
%
config
[
'uid'
]
)
chown
(
config
.
appdatahome
,
config
[
'uid'
])
print
'
\n
-> creation done for %s
\n
'
%
repr
(
config
.
apphome
)[
1
:
-
1
]
print
(
'
\n
-> creation done for %s
\n
'
%
repr
(
config
.
apphome
)[
1
:
-
1
]
)
if
not
self
.
config
.
no_db_create
:
helper
.
postcreate
(
self
.
config
.
automatic
,
self
.
config
.
config_level
)
...
...
@@ -487,7 +488,7 @@ class DeleteInstanceCommand(Command):
if
ex
.
errno
!=
errno
.
ENOENT
:
raise
confignames
=
', '
.
join
([
config
.
name
for
config
in
configs
])
print
'-> instance %s (%s) deleted.'
%
(
appid
,
confignames
)
print
(
'-> instance %s (%s) deleted.'
%
(
appid
,
confignames
)
)
# instance commands ########################################################
...
...
@@ -551,7 +552,7 @@ running.'}),
the --force option."
raise
ExecutionError
(
msg
%
(
appid
,
pidf
))
if
helper
.
start_server
(
config
)
==
1
:
print
'instance %s started'
%
appid
print
(
'instance %s started'
%
appid
)
def
init_cmdline_log_threshold
(
config
,
loglevel
):
...
...
@@ -606,7 +607,7 @@ class StopInstanceCommand(InstanceCommand):
except
OSError
:
# already removed by twistd
pass
print
'instance %s stopped'
%
appid
print
(
'instance %s stopped'
%
appid
)
class
RestartInstanceCommand
(
StartInstanceCommand
):
...
...
@@ -630,7 +631,7 @@ class RestartInstanceCommand(StartInstanceCommand):
# get instances in startorder
for
appid
in
args
:
if
askconfirm
:
print
'*'
*
72
print
(
'*'
*
72
)
if
not
ASK
.
confirm
(
'%s instance %r ?'
%
(
self
.
name
,
appid
)):
continue
StopInstanceCommand
(
self
.
logger
).
stop_instance
(
appid
)
...
...
@@ -677,14 +678,14 @@ class StatusCommand(InstanceCommand):
status
=
0
for
mode
in
cwcfg
.
possible_configurations
(
appid
):
config
=
cwcfg
.
config_for
(
appid
,
mode
)
print
'[%s-%s]'
%
(
appid
,
mode
),
print
(
'[%s-%s]'
%
(
appid
,
mode
),
end
=
' '
)
try
:
pidf
=
config
[
'pid-file'
]
except
KeyError
:
print
'buggy instance, pid file not specified'
print
(
'buggy instance, pid file not specified'
)
continue
if
not
exists
(
pidf
):
print
"doesn't seem to be running"
print
(
"doesn't seem to be running"
)
status
=
1
continue
pid
=
int
(
open
(
pidf
).
read
().
strip
())
...
...
@@ -692,10 +693,10 @@ class StatusCommand(InstanceCommand):
try
:
getpgid
(
pid
)
except
OSError
:
print
"should be running with pid %s but the process can not be found"
%
pid
print
(
"should be running with pid %s but the process can not be found"
%
pid
)
status
=
1
continue
print
"running with pid %s"
%
(
pid
)
print
(
"running with pid %s"
%
(
pid
)
)
return
status
class
UpgradeInstanceCommand
(
InstanceCommandFork
):
...
...
@@ -756,7 +757,7 @@ given, appropriate sources for migration will be automatically selected \
)
def
upgrade_instance
(
self
,
appid
):
print
'
\n
'
+
underline_title
(
'Upgrading the instance %s'
%
appid
)
print
(
'
\n
'
+
underline_title
(
'Upgrading the instance %s'
%
appid
)
)
from
logilab.common.changelog
import
Version
config
=
cwcfg
.
config_for
(
appid
)
instance_running
=
exists
(
config
[
'pid-file'
])
...
...
@@ -797,30 +798,30 @@ given, appropriate sources for migration will be automatically selected \
# run cubicweb/componants migration scripts
if
self
.
config
.
fs_only
or
toupgrade
:
for
cube
,
fromversion
,
toversion
in
toupgrade
:
print
'-> migration needed from %s to %s for %s'
%
(
fromversion
,
toversion
,
cube
)
print
(
'-> migration needed from %s to %s for %s'
%
(
fromversion
,
toversion
,
cube
)
)
with
mih
.
cnx
:
with
mih
.
cnx
.
security_enabled
(
False
,
False
):
mih
.
migrate
(
vcconf
,
reversed
(
toupgrade
),
self
.
config
)
else
:
print
'-> no data migration needed for instance %s.'
%
appid
print
(
'-> no data migration needed for instance %s.'
%
appid
)
# rewrite main configuration file
mih
.
rewrite_configuration
()
mih
.
shutdown
()
# handle i18n upgrade
if
not
self
.
i18nupgrade
(
config
):
return
print
print
()
if
helper
:
helper
.
postupgrade
(
repo
)
print
'-> instance migrated.'
print
(
'-> instance migrated.'
)
if
instance_running
and
not
(
CWDEV
or
self
.
config
.
nostartstop
):
# restart instance through fork to get a proper environment, avoid
# uicfg pb (and probably gettext catalogs, to check...)
forkcmd
=
'%s start %s'
%
(
sys
.
argv
[
0
],
appid
)
status
=
system
(
forkcmd
)
if
status
:
print
'%s exited with status %s'
%
(
forkcmd
,
status
)
print
print
(
'%s exited with status %s'
%
(
forkcmd
,
status
)
)
print
()
def
i18nupgrade
(
self
,
config
):
# handle i18n upgrade:
...
...
@@ -832,10 +833,10 @@ given, appropriate sources for migration will be automatically selected \
langs
=
[
lang
for
lang
,
_
in
i18n
.
available_catalogs
(
join
(
templdir
,
'i18n'
))]
errors
=
config
.
i18ncompile
(
langs
)
if
errors
:
print
'
\n
'
.
join
(
errors
)
print
(
'
\n
'
.
join
(
errors
)
)
if
not
ASK
.
confirm
(
'Error while compiling message catalogs, '
'continue anyway?'
):
print
'-> migration not completed.'
print
(
'-> migration not completed.'
)
return
False
return
True
...
...
@@ -858,7 +859,7 @@ class ListVersionsInstanceCommand(InstanceCommand):
config
.
set_sources_mode
((
'migration'
,))
vcconf
=
config
.
repository
().
get_versions
()
for
key
in
sorted
(
vcconf
):
print
key
+
': %s.%s.%s'
%
vcconf
[
key
]
print
(
key
+
': %s.%s.%s'
%
vcconf
[
key
]
)
class
ShellCommand
(
Command
):
"""Run an interactive migration shell on an instance. This is a python shell
...
...
@@ -939,9 +940,9 @@ directly give URI as instance id instead',
repo
=
get_repository
(
appuri
)
cnx
=
connect
(
repo
,
login
=
login
,
password
=
pwd
,
mulcnx
=
False
)
except
AuthenticationError
as
ex
:
print
ex
print
(
ex
)
except
(
KeyboardInterrupt
,
EOFError
):
print
print
()
sys
.
exit
(
0
)
else
:
break
...
...
@@ -1002,7 +1003,7 @@ class RecompileInstanceCatalogsCommand(InstanceCommand):
config
.
init_cubes
(
repo
.
get_cubes
())
errors
=
config
.
i18ncompile
()
if
errors
:
print
'
\n
'
.
join
(
errors
)
print
(
'
\n
'
.
join
(
errors
)
)
class
ListInstancesCommand
(
Command
):
...
...
@@ -1014,7 +1015,7 @@ class ListInstancesCommand(Command):
"""run the command with its specific arguments"""
regdir
=
cwcfg
.
instances_dir
()
for
appid
in
sorted
(
listdir
(
regdir
)):
print
appid
print
(
appid
)
class
ListCubesCommand
(
Command
):
...
...
@@ -1025,7 +1026,7 @@ class ListCubesCommand(Command):
def
run
(
self
,
args
):
"""run the command with its specific arguments"""
for
cube
in
cwcfg
.
available_cubes
():
print
cube
print
(
cube
)
class
ConfigureInstanceCommand
(
InstanceCommand
):
"""Configure instance.
...
...
@@ -1144,10 +1145,10 @@ def run(args):
try
:
CWCTL
.
run
(
args
)
except
ConfigurationError
as
err
:
print
'ERROR: '
,
err
print
(
'ERROR: '
,
err
)
sys
.
exit
(
1
)
except
ExecutionError
as
err
:
print
err
print
(
err
)
sys
.
exit
(
2
)
if
__name__
==
'__main__'
:
...
...
dataimport/csv.py
View file @
7c23b7de
...
...
@@ -16,8 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Functions to help importing CSV data"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
,
print_function
import
csv
as
csvmod
import
warnings
...
...
@@ -64,7 +63,7 @@ def ucsvreader_pb(stream_or_path, encoding='utf-8', delimiter=',', quotechar='"'
yield
urow
if
withpb
:
pb
.
update
()
print
' %s rows imported'
%
rowcount
print
(
' %s rows imported'
%
rowcount
)
def
ucsvreader
(
stream
,
encoding
=
'utf-8'
,
delimiter
=
','
,
quotechar
=
'"'
,
...
...
dataimport/deprecated.py
View file @
7c23b7de
...
...
@@ -58,6 +58,7 @@ Example of use (run this with `cubicweb-ctl shell instance import-script.py`):
.. BUG file with one column are not parsable
.. TODO rollback() invocation is not possible yet
"""
from
__future__
import
print_function
import
sys
import
traceback
...
...
@@ -103,7 +104,7 @@ def lazydbtable(cu, table, headers, orderby=None):
@
deprecated
(
'[3.21] deprecated'
)
def
tell
(
msg
):
print
msg
print
(
msg
)
@
deprecated
(
'[3.21] deprecated'
)
...
...
dataimport/pgstore.py
View file @
7c23b7de
...
...
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Postgres specific store"""
from
__future__
import
print_function
import
threading
import
warnings
...
...
@@ -52,7 +53,7 @@ def _import_statements(sql_connect, statements, nb_threads=3,
for
t
in
threads
:
t
.
join
()
except
Exception
:
print
'Error in import statements'
print
(
'Error in import statements'
)
def
_execmany_thread_not_copy_from
(
cu
,
statement
,
data
,
table
=
None
,
columns
=
None
,
encoding
=
'utf-8'
):
...
...
@@ -100,7 +101,7 @@ def _execmany_thread(sql_connect, statements, dump_output_dir=None,
columns
=
list
(
data
[
0
])
execmany_func
(
cu
,
statement
,
data
,
table
,
columns
,
encoding
)
except
Exception
:
print
'unable to copy data into table %s'
%
table
print
(
'unable to copy data into table %s'
%
table
)
# Error in import statement, save data in dump_output_dir
if
dump_output_dir
is
not
None
:
pdata
=
{
'data'
:
data
,
'statement'
:
statement
,
...
...
@@ -111,7 +112,7 @@ def _execmany_thread(sql_connect, statements, dump_output_dir=None,
'%s.pickle'
%
filename
),
'w'
)
as
fobj
:
fobj
.
write
(
cPickle
.
dumps
(
pdata
))
except
IOError
:
print
'ERROR while pickling in'
,
dump_output_dir
,
filename
+
'.pickle'
print
(
'ERROR while pickling in'
,
dump_output_dir
,
filename
+
'.pickle'
)
pass
cnx
.
rollback
()
raise
...
...
@@ -335,7 +336,7 @@ class SQLGenSourceWrapper(object):
self
.
_sql
.
eid_insertdicts
=
{}
def
flush
(
self
):
print
'starting flush'
print
(
'starting flush'
)
_entities_sql
=
self
.
_sql
.
entities
_relations_sql
=
self
.
_sql
.
relations
_inlined_relations_sql
=
self
.
_sql
.
inlined_relations
...
...
devtools/__init__.py
View file @
7c23b7de
...
...
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Test tools for cubicweb"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
...
...
@@ -109,7 +110,7 @@ def turn_repo_off(repo):
try
:
repo
.
close
(
sessionid
)
except
BadConnectionId
:
#this is strange ? thread issue ?
print
'XXX unknown session'
,
sessionid
print
(
'XXX unknown session'
,
sessionid
)
for
cnxset
in
repo
.
cnxsets
:
cnxset
.
close
(
True
)
repo
.
system_source
.
shutdown
()
...
...
@@ -193,7 +194,7 @@ class TestServerConfiguration(ServerConfiguration):
def
sources_file
(
self
):
"""define in subclasses self.sourcefile if necessary"""
if
self
.
sourcefile
:
print
'Reading sources from'
,
self
.
sourcefile
print
(
'Reading sources from'
,
self
.
sourcefile
)
sourcefile
=
self
.
sourcefile
if
not
isabs
(
sourcefile
):
sourcefile
=
join
(
self
.
apphome
,
sourcefile
)
...
...
@@ -492,7 +493,7 @@ class TestDataBaseHandler(object):
if
test_db_id
is
DEFAULT_EMPTY_DB_ID
:
self
.
init_test_database
()
else
:
print
'Building %s for database %s'
%
(
test_db_id
,
self
.
dbname
)
print
(
'Building %s for database %s'
%
(
test_db_id
,
self
.
dbname
)
)
self
.
build_db_cache
(
DEFAULT_EMPTY_DB_ID
)
self
.
restore_database
(
DEFAULT_EMPTY_DB_ID
)
repo
=
self
.
get_repo
(
startup
=
True
)
...
...
devtools/devctl.py
View file @
7c23b7de
...
...
@@ -18,6 +18,7 @@
"""additional cubicweb-ctl commands and command handlers for cubicweb and
cubicweb's cubes development
"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
...
...
@@ -314,8 +315,8 @@ class UpdateCubicWebCatalogCommand(Command):
from
cubicweb.i18n
import
extract_from_tal
,
execute2
tempdir
=
tempfile
.
mkdtemp
(
prefix
=
'cw-'
)
cwi18ndir
=
WebConfiguration
.
i18n_lib_dir
()
print
'-> extract messages:'
,
print
'schema'
,
print
(
'-> extract messages:'
,
end
=
' '
)
print
(
'schema'
,
end
=
' '
)
schemapot
=
osp
.
join
(
tempdir
,
'schema.pot'
)
potfiles
=
[
schemapot
]
potfiles
.
append
(
schemapot
)
...
...
@@ -324,11 +325,11 @@ class UpdateCubicWebCatalogCommand(Command):
schemapotstream
=
file
(
schemapot
,
'w'
)
generate_schema_pot
(
schemapotstream
.
write
,
cubedir
=
None
)
schemapotstream
.
close
()
print
'TAL'
,
print
(
'TAL'
,
end
=
' '
)
tali18nfile
=
osp
.
join
(
tempdir
,
'tali18n.py'
)
extract_from_tal
(
find
(
osp
.
join
(
BASEDIR
,
'web'
),
(
'.py'
,
'.pt'
)),
tali18nfile
)
print
'-> generate .pot files.'
print
(
'-> generate .pot files.'
)
pyfiles
=
get_module_files
(
BASEDIR
)
pyfiles
+=
globfind
(
osp
.
join
(
BASEDIR
,
'misc'
,
'migration'
),
'*.py'
)
schemafiles
=
globfind
(
osp
.
join
(
BASEDIR
,
'schemas'
),
'*.py'
)
...
...
@@ -349,12 +350,12 @@ class UpdateCubicWebCatalogCommand(Command):
if
osp
.
exists
(
potfile
):
potfiles
.
append
(
potfile
)
else
:
print
'-> WARNING: %s file was not generated'
%
potfile
print
'-> merging %i .pot files'
%
len
(
potfiles
)
print
(
'-> WARNING: %s file was not generated'
%
potfile
)
print
(
'-> merging %i .pot files'
%
len
(
potfiles
)
)
cubicwebpot
=
osp
.
join
(
tempdir
,
'cubicweb.pot'
)
cmd
=
[
'msgcat'
,
'-o'
,
cubicwebpot
]
+
potfiles
execute2
(
cmd
)
print
'-> merging main pot file with existing translations.'
print
(
'-> merging main pot file with existing translations.'
)
chdir
(
cwi18ndir
)
toedit
=
[]
for
lang
in
CubicWebNoAppConfiguration
.
cw_languages
():
...
...
@@ -368,10 +369,10 @@ class UpdateCubicWebCatalogCommand(Command):
# cleanup
rm
(
tempdir
)
# instructions pour la suite
print
'-> regenerated CubicWeb
\'
s .po catalogs.'
print
'
\n
You can now edit the following files:'
print
'* '
+
'
\n
* '
.
join
(
toedit
)
print
'when you are done, run "cubicweb-ctl i18ncube yourcube".'
print
(
'-> regenerated CubicWeb
\'
s .po catalogs.'
)
print
(
'
\n
You can now edit the following files:'
)
print
(
'* '
+
'
\n
* '
.
join
(
toedit
)
)
print
(
'when you are done, run "cubicweb-ctl i18ncube yourcube".'
)