Johannes Graumann wrote:
> Dear all,
>
> I'm trying to convert
> '00:08:9b:ce:f5:d4'
> to
> '\x00\x08\x9b\xce\xf5\xd4'
> for use in magic packet construction for WakeOnLan like so:
> wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>wolsocket.setsockopt(socket.SOL_SOCKET, sock
Paul Rubin wrote:
> Johannes Graumann writes:
>> '00:08:9b:ce:f5:d4'
>> ...
>> hexcall = "\\x".join(hexcall).decode('string_escape')
>
> I think it's best not to mess with stuff like that. Convert to integers
> then convert back:
>
> mac = '00:08:9b:ce:f5:d4'
> hexcall = ''.join(chr(int(c,
MRAB wrote:
> On 2012-10-07 20:44, Johannes Graumann wrote:
>> Dear all,
>>
>> I'm trying to convert
>> '00:08:9b:ce:f5:d4'
>> to
>> '\x00\x08\x9b\xce\xf5\xd4'
>> for use in magic packet construction for WakeOnLan like so:
>> wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>
On 2012-10-07 20:44, Johannes Graumann wrote:
Dear all,
I'm trying to convert
'00:08:9b:ce:f5:d4'
to
'\x00\x08\x9b\xce\xf5\xd4'
for use in magic packet construction for WakeOnLan like so:
wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
wolsock
Johannes Graumann writes:
> '00:08:9b:ce:f5:d4'
> ...
> hexcall = "\\x".join(hexcall).decode('string_escape')
I think it's best not to mess with stuff like that. Convert to integers
then convert back:
mac = '00:08:9b:ce:f5:d4'
hexcall = ''.join(chr(int(c,16)) for c in mac.split(':'))