I am using sphinx for documentation. and have used the make html and make latexpdf through a bash script.
when running the bash script, and when make html is run, it shows ERROR in teh rst file after the Reading sources.
make clean
+ make clean
rm -rf _build/*
make html
+ make html
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.3b3
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [100%] index
/home/sphinx/Inder.rst:12:WARNING: Bullet list ends without a blank line; unexpected unindent.
/home/sphinx/Inder.rst:12: ERROR: Document may not end with a transition.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
How can i catch this error in the bash script or send it to another variable.
i have tried grep ERROR with the make html, but it gives blank.
sphinx-build will probably print output on both stdout and stderr so you likely want to capture both streams.
You can do this like:
out=$(make html 2>&1)
if grep -q 'ERROR: ' <<< "$out"; then
# do some error handling
fi
Related
I'm trying to use the update_info command in order to add some bookmarks to an existing pdf's metadata using pdftk and powershell.
I first dump the metadata into a file as follows:
pdftk .\test.pdf dump_data > test.info
Then, I edit the test.info file by adding the bookmarks, I believe I am using the right syntax. I save the test.info file and attempt to write the metadata to a new pdf file using update_info:
pdftk test.pdf update_info test.info output out.pdf
Unfortunately, I get a warning as follows:
pdftk Warning: unexpected case 1 in LoadDataFile(); continuing
out.pdf is generated, but contains no bookmarks. Just to be sure it is not a syntax problem, I also ran it without editing the metadata file, by simply overwriting the same metadata. I still got the same warning.
Why is this warning occurring? Why are no bookmarks getting written to my resulting pdf?
using redirection in that fashion
pdftk .\test.pdf dump_data > test.info
will cause this known problem by building wrong file structure, so change to
pdftk .\test.pdf dump_data output test.info
In addition check your alterations are correctly balanced (and no unusual characters) then save the edited output file in the same encoding.
Note:- you may need to consider
Use dump_data_utf8 and update_info_utf8 in order to properly display characters in scripts other than Latin (e. g. oriental CJK)
I used pdftk --help >pdftk-help.txt to find the answer.
With credit to the previous answer, the following creates a text file of the information parameters: pdftk aaa.pdf dump_data output info.txt
Edit the info.txt file as needed.
The pdftk update_info option creates a new pdf file, leaving the original pdf untouched. Use: pdftk aaa.pdf update_info info.txt output bbb.pdf
In my CI system, I have various go scripts that I run to analyze my Go code. For example, I have a script that validates if various main files can start a long running app successfully. For this I run the go script via go run startupvalidator -pkgs=pkg1,pkg2,pk3. I am interested in using Bazel to be able to utilize the cache for this since if pkg1 has not changed startupvalidator would be able to hit the cache for pkg1 and then run a fresh run for pkg2 and pkg3.
I thought about a couple different ways to do this but none of them feel correct. Is there a "best" way to accomplish this? Is this a reasonable use case for bazel?
I thought about creating a bash script where I run something like:
go run startupvalidator $1
With a BUILD.bazel file containing
sh_binary(
name = "startupvalidator-sh",
sources = [":startupvalidator.sh"],
deps = [
"//go/path/to/startupvalidator",
],
)
I also thought about placing a similar sh_test in the BUILD.bazel file for each pkg1, pkg2, and pkg3 so that I could run bazel run //go/pkg1:startupvalidator.
However, this doesn't actually work. Does anyone have feedback on how I should go about this? Any directions or pointers are appreciated.
To take advantage of the caching for test results, you need a *_test which you run with bazel test. Maybe the only part you're missing is that bazel run simply runs a binary (even if it's a test binary), while bazel test is looking for an up-to-date test result which means it use the cache?
You also need to split up the binary so changing the code in pkg2 doesn't affect the test action in pkg1. The action's key in the cache includes the contents of all its input files, the command being run, etc. I'm not sure if your startupvalidator has the various main functions compiled into it, or if it looks for the binaries at runtime. If it compiles them in, you'll need to build separate ones. If it's loading the files at runtime, put the files it looks for in data for your test rule so they're part of the inputs to the test action.
I'd do something like this in pkg1 (assuming it's loading files at runtime; if they're compiled in then you can just make separate go_test targets):
sh_test(
name = 'startupvalidator_test',
srcs = ['startupvalidator_test.sh'],
deps = ['#bazel_tools//tools/bash/runfiles'],
data = ['//go/path/to/startupvalidator', ':package_main'],
)
with a startupvalidator_test.sh which looks like:
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
exec $(rlocation workspace/go/path/to/startupvalidator) \
-main=$(rlocation workspace/pkg1/package_main)
# --- end runfiles.bash initialization v2 ---
I'm assuming that package_main is the thing loaded by startupvalidator. Bazel is set up to pass full paths to dependencies like that to other binaries, so I'm pretending that there's a new flag that takes the full path instead of just the package name. The shell script uses runfiles.bash to locate the various files.
If you want to deduplicate this between the packages, I would write a macro that uses a genrule to generate the shell script.
I am trying to set up my custom build environment for Sublime Text 3 for competitive Programming.
My target is as follows :
Build the current source file
Run it and read inputs from a file input.in
Write output to a file output.out
diff expected output.out. expected file contains the expected output
This is how the window setup looks like
This is my json file for the build system
{
"cmd": ["g++ -std=c++11 ${file} -o ${file_path}/${file_base_name} && ${file_path}/${file_base_name}<${file_path}/input.in>${file_path}/output.out && diff output.out expected"],
"shell":true
}
So far steps 1-3 are working as expected. But for last step 4, I am not able to get the result in proper suitable format. e.g. when files match there is no output (as diff generates nothing in case of match) and in case of non-match, this build system is generating output in non human-readable format.
5a6
> f
[Finished in 0.1s with exit code 1]
Can anyone suggest a better way to output the result or is there a way to use linux's notification utility
I'm using gedit and trying to wrestle it into a real IDE. What I want is to map ctrlshift| to run my tidy tool when the file type is "text/html" and my autopep8 tool when the file type is "text/x-python".
As it turns out (and I think this is a bug), gedit doesn't care what filetype you've specified. If you have a key combo set, it will run a tool whether or not the filetype matches. Related, but maybe not a bug, I can only set the keyboard shortcut to one external tool.
So I wrote one external tool that runs on ctrlshift| and runs autopep8 if the document is Python and tidy if the document is HTML:
#!/bin/sh
# [Gedit Tool]
# Save-files=document
# Shortcut=<Primary><Shift>bar
# Output=replace-document
# Name=Tidy by Filetype
# Applicability=all
# Input=document
if [ $GEDIT_CURRENT_DOCUMENT_TYPE = "text/x-python" ]; then
autopep8 - -v -a
elif [ $GEDIT_CURRENT_DOCUMENT_TYPE = "text/html" ]; then
#-i auto indents, -w 80 wrap at 80 chars, -c replace font tags w/CSS
exec tidy -utf8 -i -w 80 -c "$GEDIT_CURRENT_DOCUMENT_NAME"
elif [ $GEDIT_CURRENT_DOCUMENT_TYPE = "text/css" ]; then
#TK CSS tidy
else
echo "This seems to be " $GEDIT_CURRENT_DOCUMENT_TYPE " I don't know how to tidy that."
fi
That second to last line is the one that is breaking my heart. If I don't define any action for that last else it just deletes my existing document. If I run ctrlshift| and the file-type isn't one that I've accounted for, I'd like it to report the file type to the shell output, not replace the document contents with
This seems to be application/x-shellscript I don't know how to tidy
that.
Is there a way to write my tool so that I write some output to the shell and some to the document?
Having no experience with trying to make gedit more usable, I did find this: https://wiki.gnome.org/Apps/Gedit/Plugins/ExternalTools?action=AttachFile&do=view&target=external-tools-manager-with-gedit-3.png
The key construct here is
echo "..." > /dev/stderr
At least that should stop you from clobbering the contents of your file if it the mime-type doesn't match, but I'm not sure where it'll print out (hopefully somewhere sane).
Edit (for a more complete answer):
You will also need to cat $GEDIT_CURRENT_DOCUMENT_NAME to replace the file contents with itself. This was pointed out by #markku-k (thanks!)
Occasionally, we receive ZIP files from our suppliers that are seemingly corrupted. Attempting to list the contents of a ZIP will trigger an error like this:
$>unzip -qql JABL_VER_20120808_165910.zip
unzip: cannot find or open JABL_VER_20120808_165910.zip, JABL_VER_20120808_165910.zip.zip or JABL_VER_20120808_165910.zip.ZIP.
I did a quick read of the unzip man page and coded that snippet to trap the above error
EXIT=`echo $?`
case $EXIT in
> 0-1) echo "Unzip Complete.";;
> *) echo "Unzip Failed.";;
> esac
$>Unzip Failed.
It seems to work. However, there are cases like this one where the error is different:
$>unzip -qql JABL_VER_20120808_175915.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of JABL_VER_20120808_175915.zip or
JABL_VER_20120808_175915.zip.zip, and cannot find JABL_VER_20120808_175915.zip.ZIP, period.
Is there a "surefire" way to trap errors like these?
PS: Not sure if matters but the ZIP files are generated on MS Windows ; We use Red Hat.
exit code 1 isn't good either,
1 one or more warning errors were encountered, but processing completed successfully anyway. This includes zipfiles
where one or more files was skipped due to unsupported compression method or encryption with an unknown password.
you should try
unzip -t zipfilename
and only accept exit code 0
why do you have so many errors? ftp'd file in text mode?