[asterisk-dev] [Code Review]: Remove development header dependency for asterisk version
Matt Jordan
reviewboard at asterisk.org
Thu Jan 26 15:27:03 CST 2012
> On Jan. 26, 2012, 1:38 p.m., Matt Jordan wrote:
> > asterisk/trunk/lib/python/asterisk/version.py, lines 54-70
> > <https://reviewboard.asterisk.org/r/1695/diff/1/?file=23659#file23659line54>
> >
> > The version_str should probably be a static to the AsteriskVersion class:
> > 1. Once it is set within a process, we wouldn't expect the Asterisk version to change
> > 2. Every subsequent creation of an AsteriskVersion object could check to see if the version number was assigned - if so, it wouldn't need to spawn a process
> >
> > Otherwise, the asterisk wrapper class will be spawning a lot of children processes to wait on.
>
> Paul Belanger wrote:
> I think it is going to be more complicated adding the version string to a static variable right now, since we have object compare functions. Or maybe my brains is not working today.
>
> Either way, do you have an example of how you would like to see it?
>
> FWIW: We do a good job of passing the ast_version object round within runtests.py
Static in python would be a variable declared outside of the __init__ method but within the class. Initially, set it to blank.
version_str = ""
def __init__(self, [other params]):
if (AsteriskVersion.version_str != "")
""" do a popen, set it, etc.
else:
""" Do your version comparisons """
version_str would no longer be a member variable, but rather static to the class, i.e., don't refer to it as "self.version_str". This would let external entities not have to pass around the object once they've calculated the version once, and you'd only have to calculate the version once within a process.
> On Jan. 26, 2012, 1:38 p.m., Matt Jordan wrote:
> > asterisk/trunk/runtests.py, lines 345-357
> > <https://reviewboard.asterisk.org/r/1695/diff/1/?file=23660#file23660line345>
> >
> > You can't remove this yet. We still check buildoptions for some tests.
> >
> > When a run-time mechanism for that is available, then this can be removed.
>
> wdoekes wrote:
> Or you could adapt those tests to fetch the source path from the binary, e.g.:
>
> $ nm `which asterisk` | sed -e '/ t main$/!d;s/ .*//' | addr2line -e `which asterisk`
> /home/walter/src/asterisk-1.8.x-WRITE/main/asterisk.c:3255
>
>
> Paul Belanger wrote:
> boo!
>
> Let me see what I can come up with.
>
> Paul Belanger wrote:
> @wdoekes: Another options is to add the build info to the asterisk -V command. I'll do a quick google to see what other project do this.
If needed, that can be done on a separate review. Right now trunk can't be tested - so if this takes longer then a few hours, its probably worth deferring.
- Matt
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1695/#review5309
-----------------------------------------------------------
On Jan. 26, 2012, 10:39 a.m., Paul Belanger wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1695/
> -----------------------------------------------------------
>
> (Updated Jan. 26, 2012, 10:39 a.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Summary
> -------
>
> Like the title says, we'll now use the asterisk binary over the development headers to figure out which version of asterisk is installed.
>
>
> Diffs
> -----
>
> asterisk/trunk/lib/python/asterisk/version.py 3015
> asterisk/trunk/runtests.py 3015
>
> Diff: https://reviewboard.asterisk.org/r/1695/diff
>
>
> Testing
> -------
>
> local development box
>
>
> Thanks,
>
> Paul
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120126/bc7e60c1/attachment-0001.htm>
More information about the asterisk-dev
mailing list