Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197883
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
| Newsgroups | comp.sys.mac.system, alt.os.linux, alt.comp.os.windows-11, comp.lang.python |
| Subject | Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB |
| Date | Thu, 20 Aug 2026 07:46:26 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 69 |
| Message-ID | <1166bch$39qqm$2@dont-email.me> (permalink) |
| References | <116673g$ptq$1@nnrp.usenet.blueworldhosting.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Thu, 20 Aug 2026 07:46:26 +0000 (UTC) |
| Injection-Info | dont-email.me; logging-data="3468118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185Yp4tj8Na/bNNxShfJj1I"; posting-host="d46d153320d65deb2c289b81dac51f44" |
| User-Agent | Pan/0.165 (Kostiantynivka) |
| Cancel-Lock | sha1:zFU90vUrZMzJxz+b4XHdjR9hE3w= sha256:ZTOwVWfSLYbvaI0JU/0IpYI41hBmqvsB3Pm3Rn4ExAI= sha1:/gquhOcq7tZ1xhQq87TqGKXtfog= sha256:tEGZY/kQSfDO9iFH4BJ2lKyH2bE4+D3CKbWfsC9qUyQ= |
| Xref | csiph.com comp.sys.mac.system:146453 alt.os.linux:83085 alt.comp.os.windows-11:33842 comp.lang.python:197883 |
Cross-posted to 4 groups.
Show key headers only | View raw
On Wed, 19 Aug 2026 22:33:27 -0800, Maria Sophia wrote:
> # Prerequisite: "nova.db" SQL database file created using the
> # last-known-good-version of the Tesla Coil Nova Launcher 7.0.57
> # <https://mobile.softpedia.com/apk/nova-launcher/7.0.57/>
Why not provide your own commands for initializing a new database
if it doesn’t already exist? Save the user some work.
If you want to see an example of how it’s done, have look at the
“project-tags” script (yes, it’s a Python script) here
<https://gitlab.com/ldo/emacs-prefs>.
> cursor.execute(
> "SELECT DISTINCT screen FROM favorites WHERE container = -100 ORDER BY screen ASC;"
> )
> screens = cursor.fetchall()
You do this sequence of execute/fetch calls 4 times in your script. I
see you reuse the same cursor to save some extra setup work each time.
You can make things a little less fiddly with the help of this routine
(also to be found in the above script):
def db_iter(conn, cmd, mapfn = lambda x : x) :
"executes cmd on a new cursor from connection conn and yields the results in turn."
for item in conn.cursor().execute(cmd) :
yield mapfn(item)
#end for
#end db_iter
With this routine, the above sequence becomes
screens = list(db_iter \
(
conn,
"SELECT DISTINCT screen FROM favorites WHERE container = -100 ORDER BY screen ASC"
))
> for (screen_num,) in screens:
or better still, put the lookup directly into the loop expression:
for screen_num in db_iter \
(
conn,
"SELECT DISTINCT screen FROM favorites WHERE container = -100 ORDER BY screen ASC",
mapfn = lambda x : x[0]
) :
> cursor.execute(
> "SELECT _id, title FROM favorites WHERE container = -100 AND screen = ?"
> " AND intent IS NULL AND title IS NOT NULL AND TRIM(title) != '';",
> (screen_num,),
> )
> folders = cursor.fetchall()
> for folder_id, folder_name in folders:
Again, this can be simplified to
for folder_id, folder_name in db_iter \
(
conn,
"SELECT _id, title FROM favorites WHERE container = -100 AND screen = %d"
" AND intent IS NULL AND title IS NOT NULL AND TRIM(title) != '';"
%
screen_num
) :
and so on.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
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-21 01:54 -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
csiph-web