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


Groups > comp.lang.python > #197883

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

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 2026-08-20 07:46 +0000
Organization A noiseless patient Spider
Message-ID <1166bch$39qqm$2@dont-email.me> (permalink)
References <116673g$ptq$1@nnrp.usenet.blueworldhosting.com>

Cross-posted to 4 groups.

Show all headers | 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


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