[asterisk-dev] [Code Review]: Remove development header dependency for asterisk version
Matt Jordan
reviewboard at asterisk.org
Thu Jan 26 15:34: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
>
> Matt Jordan wrote:
> 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.
That should have been:
if (AsteriskVersion.version_str == ""):
"" do a popen, etc. """
AsteriskVersion.version_str = ...
else:
""" Use the value in AsteriskVersion.version_str """
- 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/49644e60/attachment.htm>
More information about the asterisk-dev
mailing list