Hi Noel,

> >>> foo=collections.OrderedDict(strongswan.list_sas())

> ValueError: need more than 1 value to unpack

list_sas() returns a generator over SA dictionaries, an iterable over a
list. Creating a dictionary from that does not make much sense, as there
in no key for the value. Instead, you could try:

> foo=list(strongswan.list_sas())
> for item in foo:
>   print item

But the good thing about the generator is that you don't have to hold
the whole list in memory, but process it directly:

> for item in strongswan.list_sas():
>   print item


> >>> bar.next()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> StopIteration

> >>> bar=strongswan.list_sas()
> >>> bar.next()
> vici.exception.SessionException: Unexpected response type 1, expected '5' 
> (EVENT_CONFIRM)

Usually you don't want to iterate the generator by hand using next(),
but use for loops or other constructs working with iterable. If you do,
make sure to close() the generator after you are done to terminate the
underlying vici stream request. This is most likely a result from
incomplete iteration. You may have only one generator alive for a single
vici connection, as objects get streamed on demand over the socket.

Regards
Martin

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users

Reply via email to