diff options
author | Stefan Metzmacher <metze@samba.org> | 2016-01-28 13:44:33 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2016-02-05 10:03:34 +0100 |
commit | ffd18e18d6b2e88399784754aa2eb33b0e82fe45 (patch) | |
tree | 1b21111e49952a20c489ca16f20991d010fbb6f9 | |
parent | b4225105debb1915771b545e4cf783bda9985f85 (diff) | |
download | samba-ffd18e18d6b2e88399784754aa2eb33b0e82fe45.tar.gz |
python:samba: add a generic string_to_byte_array() helper function
We should avoid implementing this again and again.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 65127d16744763d0865ca9ce4d039866785e3fc7)
-rw-r--r-- | python/samba/__init__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python/samba/__init__.py b/python/samba/__init__.py index 84b0b1fb2d5..6adc412948d 100644 --- a/python/samba/__init__.py +++ b/python/samba/__init__.py @@ -362,6 +362,14 @@ def dn_from_dns_name(dnsdomain): def current_unix_time(): return int(time.time()) +def string_to_byte_array(string): + blob = [0] * len(string) + + for i in range(len(string)): + blob[i] = ord(string[i]) + + return blob + import _glue version = _glue.version interface_ips = _glue.interface_ips |