I'm trying to get autofoo to test for a maximum version of Python rather than a minimum. Example:
AC_REQUIRE([AM_PATH_PYTHON([2.7])])
... will test for Python >= 2.7, and will probably turn up with /usr/bin/python3. I want it to return nothing greater than python2.7, however.
Is there a straightforward way to do this? I asked around, and so far the best response I've gotten is, "rewrite the macro."
Thanks in advance!
1). Add to acinclude.m4
`# my_CHECK_MAJOR_VERSION(VARIABLE, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])`
`# ---------------------------------------------------------------------------`
`# Run ACTION-IF-TRUE if the VAR has a major version >= VERSION.`
`# Run ACTION-IF-FALSE otherwise.`
AC_DEFUN([my_CHECK_MAJOR_VERSION],
[AC_MSG_CHECKING([whether $1 $$1 major version == $2])
case $$1 in
$2*)
AC_MSG_RESULT([yes])
ifelse([$3], [$3], [:])
;;
*)
AC_MSG_RESULT([no])
ifelse([$4], , [AC_MSG_ERROR([$$1 differs from $2])], [$4])
;;
esac])
2.) Add to zconfigure.inz
my_CHECK_MAJOR_VERSION([PYTHON_VERSION], [2])
3.) aclocal, automake, autoconf
That's it.
The version argument to AM_PATH_PYTHON is optional. If python is required, call it like this:
AM_PATH_PYTHON
If it's not required, call it like this:
AM_PATH_PYTHON(,, [:])
Now, AM_PATH_PYTHON sets the shell variable $PYTHON_VERSION to the value of sys.version[:3], which you can test yourself.
An alternative solution can be setting the default for _AM_PYTHON_INTERPRETER_LIST, to include only Python 2 binaries.
Related
For some time my old project used gmock_gen.py to generate automatically mocked classes (this is an old project from http://code.google.com/p/cppclean/ that it seems inactive and it depends on python2 that we don't want)
My question:
Is there anything on gtest environment that does the same as gmock_gen.py and supports python3, or what is the alternative to gmock_gen.py if we don't have or don't want to use python2?
Best regards,
Nuno
It seems that the conversion to python3 is very simple.
You only need to do two things and only one is required (step 2.):
you can use the python tool 2to3 to convert the code from python 2 code into python 3 code (optional)
change only one line to prevent an exception on the execution of the scrip:
gmock_gtest/generator/cpp/ast.py:908
change from:
def _GetNextToken(self):
if self.token_queue:
return self.token_queue.pop()
return next(self.tokens)
to
def _GetNextToken(self):
if self.token_queue:
return self.token_queue.pop()
return next(self.tokens, None)
and that will work.
I'm fairly new to dtrace. I'm using it on Oracle Linux 7.
I want the following probe only to fire when the execname equals a defined string. I've tried different ways without success. The way described in most tutorials didn't work
syscall::write*:entry
/execname=="dtrace"/
{
...
This doesn't work.
But the other way around works
syscall::write*:entry
/execname!="dtrace"/
{
...
Now the probe fires for every execname except "dtrace"
What's my mistake?
I don’t know how but a reboot fixed the problem...
I'm new to python, and while it's a pretty simple language, I'm having a hard time finding a solid and easy to read language reference that lists all the supported build-in methods and libraries that come with the installation. The main documentation site is confusing. There's more info about what's deprecated than what's recommended. I tried using pydoc to find method usage. For example, I want to see a simple list of all the methods that are part of the string class (e.g. replace(), toupper(), etc). But I'm not sure how to use it to list the methods, or to list a method and its usage. What do people use for a quick reference that works?
When I do something like 'pydoc string', I see a message that says "Warning: most of the code you see here isn't normally used nowadays.
Beginning with Python 1.6, many of these functions are implemented as
methods on the standard string object. They used to be implemented by
a built-in module called strop, but strop is now obsolete itself."
So while there's info about the method replace() there, I'm worried that it's not the right info based on that warning. How can I see the methods of the standard string object?
Documentation about standard functions:
https://docs.python.org/2/library/functions.html
Documentation about standard libraries:
https://docs.python.org/2/library/
You could use dir() and help(). i.e. :
From python shell :
>>> import math
>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
>>> help(math.tan)
Will print :
Help on built-in function tan in module math:
tan(...)
tan(x)
Return the tangent of x (measured in radians).
(press "q" to exit the help page)
Hope it helps.
EDIT
Another solution from the shell :
$ python -m pydoc sys
Then press "q" to exit.
I find the documentation on Eunit lacking, with regards to how to test a multi-node application. I found this example, but sadly when I run:
cluster_test_() ->
{node, foo,
fun (Node) ->
[?_assertEqual(pong, net_adm:ping(Node))]
end
}.
I get:
undefined
*** context setup failed ***
** in function slave:start/5 (slave.erl, line 197)
**exit:not_alive
Am I doing something wrong here?
As a sidenote, I also looked at gproc's distributed test here, but it's manually starting a number of slave nodes rather than using the built-in Eunit functionality.
Can someone give me some examples of how to use use the node test fixture?
Thanks,
Common Test was written especially for testing bigger systems.
Other that official documentation you can find very good introduction to theme here. And chapter evens ends with small snippet howto integrate existing eunit tests into Common Test.
Hm, I never got the slave node functionality to work properly, so it shouldn't be a documented feature. I guess it ended up in the docs while I still thought it was working. I'll probably have to fix the docs.
If you are going with multi-node tests and eunit keep in mind then eunit ifdefs in modules will change it's checksums, and if you say have one module compiled with ifdef eunit and another is not you will have errors if try to call remote functions.
My suggestion is that you run your master node with disabled distribution. Enable it with -sname key (I assume, your example code is located in module node_test):
> erl -sname master
(master#hostname)1> c(node_test).
> node_test:test().
But it is not all. To run this code in new versions of erlang, you should make a little changes:
cluster_test_() ->
{node, foo,
fun ({Node, StopNet}) ->
?debugFmt("Node ~p", [Node]),
?debugFmt("StopNet ~p", [StopNet]),
[?_assertEqual(pong, net_adm:ping(Node))]
end
}.
Note, function argument now contains not node name, but tuple with two elements. First element is remote node name, second - is boolean flag which always false (at least for now). For more detail refer to eunit sources
I'm looking for a way to register somthing like an end-build callback in scons. For example, I'm doing something like this right now:
def print_build_summary():
failures = SCons.Script.GetBuildFailures()
notifyExe = 'notify-send '
if len(failures) > 0:
notifyExe = notifyExe + ' --urgency=critical Build Failed'
else:
notifyExe = notifyExe + ' --urgency=normal Build Succeed'
os.system(notifyExe)
atexit.register(print_build_summary)
This only works in non-interactive mode. I'd like to be able to pop up something like this at the end of every build, specifically, when running multiple 'build' commands in an interactive scons session.
The only suggestions I've found, looking around, seem to be to use the dependency system or the AddPostAction call to glom this on. It doesn't seem quite right to me to do it that way, since it's not really a dependency (it's not even really a part of the build, strictly speaking) - it's just a static bit of code that needs to be run at the end of every build.
Thanks!
I don't think there's anything wrong with using the dependency system to resolve this. This is how I normally do it:
def finish( target, source, env ):
raise Exception( 'DO IT' )
finish_command = Command( 'finish', [], finish )
Depends( finish_command, DEFAULT_TARGETS )
Default( finish_command )
This creates a command that depends on the default targets for it's execution (so you know it'll always run last - see DEFAULT_TARGETS in scons manual). Hope this helps.
Ive been looking into this and havent found that SCons offers anything that would help. This seems like quite a usefull feature, maybe the SCons developers are watching these threads and will take the suggestion...
I looked at the source code and figured out how to do it. I'll try to suggest this change to the SCons developers on scons.org.
If you're interested, the file is engine/SCons/Script/Main.py, and the function is _build_targets(). At the end of this funcion, you would simply need to add a call to a user supplied callback. Of course this solution would not be very useful if you build on several different machines in your network, since you would have to port the change everywhere its needed, but if you're only building on one machine, then maybe you could make the change until/if SCons officially provides a solution.
Let me know if you need help implementing the change, and I'll see what I can do.
Another option would be to wrap the call to SCons, and have the wrapper script perform the desired actions, but that wouldnt help in SCons interactive mode.
Hope this helps,
Brady
EDIT:
I create a feature request for this: http://scons.tigris.org/issues/show_bug.cgi?id=2834