Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.mac.system > #146462
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| Newsgroups | comp.sys.mac.system, alt.os.linux, comp.lang.python |
| Subject | Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB |
| Date | 2026-08-21 07:04 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <1168t9k$403a$1@dont-email.me> (permalink) |
| References | <116673g$ptq$1@nnrp.usenet.blueworldhosting.com> <11673rv$3iopn$3@dont-email.me> <20260820190640.20824006bb95f4403a2158d8@127.0.0.1> <1168jmh$1glq$1@dont-email.me> |
Cross-posted to 3 groups.
On Fri, 21 Aug 2026 04:20:33 -0000 (UTC), Chris wrote:
> Especially python where the lack of whitespace consistency completely
> breaks the code.
However:
def netstring_encode(s, as_str = False) :
"encodes a string or bytes object as a netstring. Returns the encoded" \
" format as a string or bytes object, depending on as_str."
if isinstance(s, str) :
sb = s.encode()
elif isinstance(s, (bytes, bytearray)) :
sb = s
else :
raise TypeError("input value should be str or bytes")
if len(sb) > MAX_NETSTRING_LEN :
raise ValueError("netstring length of %d exceeds %d bytes" % (len(sb), MAX_NETSTRING_LEN))
result = b"%d:%s," % (len(sb), sb)
if as_str :
result = result.decode()
return \
result
Hopeless gibberish. But:
def netstring_encode(s, as_str = False) :
"encodes a string or bytes object as a netstring. Returns the encoded" \
" format as a string or bytes object, depending on as_str."
if isinstance(s, str) :
sb = s.encode()
elif isinstance(s, (bytes, bytearray)) :
sb = s
else :
raise TypeError("input value should be str or bytes")
#end if
if len(sb) > MAX_NETSTRING_LEN :
raise ValueError("netstring length of %d exceeds %d bytes" % (len(sb), MAX_NETSTRING_LEN))
#end if
result = b"%d:%s," % (len(sb), sb)
if as_str :
result = result.decode()
#end if
return \
result
#end netstring_encode
Some chance of restoring meaning.
Back to comp.sys.mac.system | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-19 22:33 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-20 07:46 +0000
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-20 08:14 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-20 08:32 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-20 22:57 +0000
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-21 01:37 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-23 12:36 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Alan <nuh-uh@nope.com> - 2026-08-20 07:44 -0700
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB "Kerr-Mudd, John" <admin@127.0.0.1> - 2026-08-20 19:06 +0100
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Chris <ithinkiam@gmail.com> - 2026-08-21 04:20 +0000
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-21 07:04 +0000
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-20 23:05 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-21 00:30 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB "Kerr-Mudd, John" <admin@127.0.0.1> - 2026-08-21 17:42 +0100
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-23 12:05 -0800
csiph-web