Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197890 > unrolled thread

Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB

Started byLawrence D’Oliveiro <ldo@nz.invalid>
First post2026-08-21 07:04 +0000
Last post2026-08-21 07:04 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#197890 — Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-08-21 07:04 +0000
SubjectRe: PSA: A python script to clone your phone exactly, over Wi-Fi or USB
Message-ID<1168t9k$403a$1@dont-email.me>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web