[BlackBerry-Python] Looking for examples and howto for Python/QML with Tart on BB10

Peter Hansen peter at engcorp.com
Sun Dec 9 15:05:01 EST 2012


On 2012-12-09 13:53, George Ruinelli wrote:
> How would I launch an app from the terminal (PC or SSH)?

As I noted, you can't do it via SSH if it's a full app with a GUI.  You 
can use the blackberry-deploy utility, however, from your PC. Basic 
options are available by running the app with no arguments. Look for the 
-launchApp option.

> Would it be possible to print out the log immediately instead of fetching it
> from the log file?

With beta 3, they changed the way log output works by default. Although 
the previous logs/log file is still where C stdout/stderr are 
redirected, most of the system stuff goes through "slogger2" now.  See 
the slog2.h header for reference, or the slog2.py file in the BB-Tart 
stuff.  There are advantages to using this new mechanism on a mobile 
device, not the least of which is that it writes to a RAM disk 
(basically) and not the flash memory.  The overhead would be far lower, 
and you'd increase the lifetime of the flash memory, etc.

To see the output, you log in via SSH and run "slog2info -w". Type "use 
slog2info" to learn other options. I filter it through a simple "sed" 
command line so it's more readable:

slog2info -w | sed -re '/ LGM - |STARTUP|FPS_WARNING/d;s/^.{7}(\S+) 
([^.]+\.[^.]+\.[^.]+)\.\S+\s+(\S+)\s+(.*)/\1 \2 \3 \4/'

(All on one line, which I stick into a ~/bin/slog shell script so I can 
just SSH in and type "slog", and then all output from all my apps gets 
dumped in real time as it occurs.)

> I wasn’t sure how to understand where this shared folder would be or how I
> could access it over the network with Samba.

You need to enable network access via the Storage and Access settings 
page.  Should work over USB, or WiFi if you set the "Access using Wi-Fi" 
toggle on.  You'll see two network shares, "certs" and "media", and you 
connect to the "media" one, with the folder rooted at 
/accounts/1000/shared.  The same folder appears in all apps' "sandbox" 
(data) folder under the ./shared symlink.

> I am now simply editing my files on the PC and the secure copying them directly
> into the apps folder. Surprisingly I have write access there, so I am going to
> use that way.

That works too, but note that you have to be careful not to assume write 
access to that area in your app. Some people release apps which write 
data there, thinking what they see during development is how the app 
looks when signed.  (Obviously, always test signed apps as fresh 
installs, and as updates if possible, before shipping them.)

> I tried to implement the example QML code from
> https://developer.blackberry.com/cascades/reference/bb__cascades__page.html
> but it fails for no understandable reason and no hint is given...
> I am wondering how you have been able to develop apps this "blind" way.

I'm not blind... definitely get the "slog2info" stuff going and you'll 
see a lot more. :)

> Over all it looks like as if the implemented QML forces one to rewrite the
> complete UI to get it working on BB10 :(

If you're looking at making an existing QtQuick app work under Cascades, 
then yes, you'll have to rewrite the entire UI.  On the other hand, the 
same approach I'm using now should work equally well for a pure Qt app, 
if I release the tart-launch source and someone who's motivated to do so 
modifies it to work with non-Cascades applications. I can't think of any 
reason it wouldn't work equally well.

There's also the PySide approach, though I never got Micke Prag's BB10 
version of that to build so depending on what he's planning with that, 
it might take some work to get it usable by others.

-Peter


More information about the BlackBerry-Python mailing list