[ovs-dev] [PATCH] timeval: Import ctypes Python library within a try statement.

Alex Wang alexw at nicira.com
Sat May 31 00:38:21 UTC 2014


Applied, thx!


On Fri, May 30, 2014 at 5:30 PM, Alex Wang <alexw at nicira.com> wrote:

> LGTM,
>
> Acked-by: Alex Wang <alexw at nicira.com>
>
>
> On Fri, May 30, 2014 at 4:59 PM, Ryan Wilson <wryan at nicira.com> wrote:
>
>> Older versions of Python do not have ctypes as a default installed
>> package. This patch puts the 'import ctypes' statement inside a try
>> statement.
>>
>> This fixes a bug introduced by commit 8396f (timeval: Use monotonic
>> time in OVS Python timeval library).
>>
>> Signed-off-by: Ryan Wilson <wryan at nicira.com>
>> ---
>>  python/ovs/timeval.py |   16 ++++++++--------
>>  1 file changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/python/ovs/timeval.py b/python/ovs/timeval.py
>> index f2681ac..4463e87 100644
>> --- a/python/ovs/timeval.py
>> +++ b/python/ovs/timeval.py
>> @@ -12,20 +12,20 @@
>>  # See the License for the specific language governing permissions and
>>  # limitations under the License.
>>
>> -import ctypes
>> -import sys
>>  import time
>>
>>  LIBRT = 'librt.so.1'
>>  CLOCK_MONOTONIC = 1
>>
>> -class timespec(ctypes.Structure):
>> -    _fields_ = [
>> -        ('tv_sec', ctypes.c_long),
>> -        ('tv_nsec', ctypes.c_long),
>> -    ]
>> -
>>  try:
>> +    import ctypes
>> +
>> +    class timespec(ctypes.Structure):
>> +        _fields_ = [
>> +            ('tv_sec', ctypes.c_long),
>> +            ('tv_nsec', ctypes.c_long),
>> +        ]
>> +
>>      librt = ctypes.CDLL(LIBRT)
>>      clock_gettime = librt.clock_gettime
>>      clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)]
>> --
>> 1.7.9.5
>>
>> _______________________________________________
>> dev mailing list
>> dev at openvswitch.org
>> http://openvswitch.org/mailman/listinfo/dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20140530/9bb11da4/attachment-0005.html>


More information about the dev mailing list