Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1c5815a8
Commit
1c5815a8
authored
May 10, 2013
by
Steve Strassmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
per-file log objects
parent
a52cf85c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
i18n/execute.py
+9
-5
i18n/tests/test_validate.py
+1
-1
No files found.
i18n/execute.py
View file @
1c5815a8
...
...
@@ -4,25 +4,28 @@ from config import CONFIGURATION, BASE_DIR
LOG
=
logging
.
getLogger
(
__name__
)
def
execute
(
command
,
working_directory
=
BASE_DIR
,
log
=
LOG
):
def
execute
(
command
,
working_directory
=
BASE_DIR
,
log
=
True
):
"""
Executes shell command in a given working_directory.
Command is a string to pass to the shell.
The command is logged to log, output is ignored.
log is boolean. If true, the command's invocation string is logged.
Output is ignored.
"""
if
log
:
log
.
info
(
command
)
LOG
.
info
(
command
)
subprocess
.
call
(
command
.
split
(
' '
),
cwd
=
working_directory
)
def
call
(
command
,
working_directory
=
BASE_DIR
,
log
=
LOG
):
def
call
(
command
,
working_directory
=
BASE_DIR
,
log
=
True
):
"""
Executes shell command in a given working_directory.
Command is a string to pass to the shell.
Returns a tuple of two strings: (stdout, stderr)
log is boolean. If true, the command's invocation string is logged.
"""
if
log
:
log
.
info
(
command
)
LOG
.
info
(
command
)
p
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
cwd
=
working_directory
)
out
,
err
=
p
.
communicate
()
return
(
out
,
err
)
...
...
@@ -36,6 +39,7 @@ def create_dir_if_necessary(pathname):
def
remove_file
(
filename
,
log
=
LOG
,
verbose
=
True
):
"""
Attempt to delete filename.
log is boolean. If true, removal is logged.
Log a warning if file does not exist.
Logging filenames are releative to BASE_DIR to cut down on noise in output.
"""
...
...
i18n/tests/test_validate.py
View file @
1c5815a8
...
...
@@ -28,7 +28,7 @@ def validate_po_file(filename, log):
raise
SkipTest
()
# Use relative paths to make output less noisy.
rfile
=
os
.
path
.
relpath
(
filename
,
LOCALE_DIR
)
(
out
,
err
)
=
call
([
'msgfmt'
,
'-c'
,
rfile
],
log
=
Non
e
,
working_directory
=
LOCALE_DIR
)
(
out
,
err
)
=
call
([
'msgfmt'
,
'-c'
,
rfile
],
log
=
Fals
e
,
working_directory
=
LOCALE_DIR
)
if
err
!=
''
:
log
.
warn
(
'
\n
'
+
err
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment