maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Annouce] HealthCheck - Hardware/System checker for the N900 (https://talk.maemo.org/showthread.php?t=45453)

attila77 2010-06-11 10:05

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
In case of Qt and Python vs C++, the code is translatable almost line by line, especially if the C++ original uses Qt constructs like foreach() for looping. There are a few caveats regarding variable scope and garbage collection, but in general it should not be an issue. Python to C++ is a bit more nasty (as C++ simply lacks a lot of the built-in goodies Python has, even with Qt - f.e. list comprehension).

bonsai009 2010-06-12 08:21

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
application crash after starting...
When I start the programm from the xterm, I have this messages:
Nokia-N900:~# python /opt/healthcheck/healthcheck.py
***** Start Imports *****
** Importing qtcore & gui **
** Importing ui.touchstub - accuracy tool **
** Importing sys **
** Importing commands **
** Importing os **
** Importing os.path **
** Importing subprocess **
** Importing dbus.glib **
** Importing Start location**
** Importing Cellinfo **
** Importing Hildon **
** Importing Functions **
** Importing Time **
** Importing GTK **
** Initialize Threads(GTK) **
** Importing Gobject **
***** Finish Imports *****
** Seting global variables **
** Starting Main **
** app = QtGui App** - Running app = QtGui.QApplication(sys.argv) **
/opt/healthcheck/healthcheck.py:1053: GtkWarning: gtk_widget_set_sensitive: assertion `GTK_IS_WIDGET (widget)' failed
app = QtGui.QApplication(sys.argv)
** Setting Main Window**
** Setting tool window #1**
** Starting healthcheckWindow Class **
** Set basic color on rectangle **
** Setting window details and loading form**
** Completed healthcheckWindow Class load **
** Setting tool window #2**
** Setting Video window**
** Set basic color on rectangle **
** Setting window details and loading form**
** Declare the UI**
** Draw everything and start the main function**
** start SetupUi**
Could not parse stylesheet of widget 0x6ff8b8
** Run retranslateUi **
** Show tab1 (0) **
** Show everything**
** Waiting for quit signal - healthcheck loaded **
** Running Update ALL**
** Running tab1 update **
** Start Function - rootfs % used **
** Start Function - rootfs free MB **
** Start Function - MyDocs % Used **
** Start Function - myDocs MB Free **
** Start Function - App Used **
** Start Function - App Free **
** Start Function - Memory Card Used **
** Start Function - Memory Card Free **
** Start Function - CPU Frequency **
** Start Function - Backlight Info **
** Start Function - Backlight Info MAX **
** Start Function - Kernel Core Info **
** Start Function - MMC Cover/latch **
** Start Function - CPU Frequency File **
** Adding CPUQ Frequencies **
** Start Function - Processor Information **
** Start Function - N900 Board Information **
** Start Function - Board Version **
** Start Function - System Locale **
** Start Function - boot count**
** Start Function - FM Transmitter power level **
** Start Function - Boot Reason**
** Start Function - Cam Shutter State **
** Start Function - Keyboard Slider State **
** Start Function - proximity sensor state**
** Start Function - Headphone State **
** Start Function - Battery Current **
** Start Function - battery last charge**
** Start Function - Battery Charge **
** Start Function - system uptime**
** Start Function - load from uptime **
** Start Function - firmware version **
Traceback (most recent call last):
File "/opt/healthcheck/healthcheck.py", line 1076, in <module>
ui.funcUpdateAll()
File "/opt/healthcheck/healthcheck.py", line 890, in funcUpdateAll
self.funcSystemTab()
File "/opt/healthcheck/healthcheck.py", line 848, in funcSystemTab
g = gn_functions.funcMaemoVersion()
File "/opt/healthcheck/gn_functions.py", line 196, in funcMaemoVersion
g = s[2].strip()
IndexError: list index out of range

What is wrong?

noobmonkey 2010-06-12 08:28

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Oooooooooooooooo That's interesting!

Quote:

Originally Posted by bonsai009 (Post 711703)
application crash after starting...

g = gn_functions.funcMaemoVersion()
File "/opt/healthcheck/gn_functions.py", line 196, in funcMaemoVersion
g = s[2].strip()
IndexError: list index out of range

What is wrong?

Can you confirm what version of healthcheck please? :)
It seems to be struggling whilst looking at this command
Code:

dpkg -l mp-fremantle-* | grep ii
If you fancy trying that in terminal, it will be interesting to see how your version string looks.

bonsai009 2010-06-12 08:46

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Nokia-N900:~# dpkg -l mp-fremantle-* | grep ii
Nokia-N900:~#

soryy, i see nothing.

bonsai009 2010-06-12 08:49

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Nokia-N900:~# dpkg -l mp-fremantle-*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=============================-=============================-================================================== ========================
pn mp-fremantle-generic-pr <none> (no description available)

sorry for bad english, I´m a german-people

Venemo 2010-06-12 08:49

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Quote:

Originally Posted by noobmonkey (Post 710126)
Any examples will help - i'm getting used to translating examples from GTK and c++! :)

Okay, I'm sold!
I don't guarantee syntax rightness, though, because I'm typing it rigt in here, not into my IDE. :p

I also only write my idea, I guess the "..."s will make sense.

MainWindow.h
Code:

...

//include whatever...

class MainWindow
{
    ...
private:
    QTimer *timer;
    ...   
public:
    MainWindow(...); // constructor
    void updateAll(); // method that updates all
    ...
private slots:
    void on_timer_timeout(); // the method
    ...
}

UpdaterRunnable.h
Code:

#include "MainWindow.h"

class UpdaterRunnable : private QRunnable
{
private:
    MainWindow *myWindow;
public:
    UpdaterRunnable(MainWindow *window);
    void run();
}

MainWindow.cpp
Code:


#include "MainWindow.h"
#include "UpdaterRunnable.h"

MainWindow::MainWindow(...)
{
    // creating a new timer instance on the heap
    timer = new QTimer(this);
    // connecting to its signal
    connect(timer, SIGNAL(timeout()), this, SLOT(on_timer_timeout()));
    // running the timeout method - to fill up values on the beginning
    on_timer_timeout();
    // starting the timer with a nice interval
    timer->start(3000);
   
    ...
}

void MainWindow::updateAll()
{
    // This is the method in which you update all your labels
}

void MainWindow::on_timer_timeout()
{
    // makes the thread pool start updating asynchronously
    // note that the QRunnable instance will be deleted by the thread pool, so this is not a memory leak
    QThreadPool::globalInstance()->start(new UpdaterRunnable(this));
}

UpdaterRunnable.cpp
Code:

#include "UpdaterRunnable.h"

UpdaterRunnable::UpdaterRunnable(MainWindow *window)
    : QRunnable(), myWindow(window)
{
}

void UpdaterRunnable::run()
{
    myWindow->updateAll();
}

Rougly this is what I was speaking about - I really hope it helps.

I also recommend setting the default caption of all labels to "Updating...", and start updating them asynchonously. It just adds a feeling of responsiveness to the UI. (This is why there is a call to the timeout method in the constructor of my example.)

noobmonkey 2010-06-12 09:03

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Quote:

Originally Posted by bonsai009 (Post 711731)
Nokia-N900:~# dpkg -l mp-fremantle-*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=============================-=============================-================================================== ========================
pn mp-fremantle-generic-pr <none> (no description available)

sorry for bad english, I´m a german-people

thank you very much! don't worry, i can understand you.

it is very odd though. it looks like you do not have maemo installed! never expected no value being returned! anyone else got any suggestions?

Venemo 2010-06-12 09:08

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Quote:

Originally Posted by noobmonkey (Post 711743)
it is very odd though. it looks like you do not have maemo installed! never expected no value being returned! anyone else got any suggestions?

If you break some dependencies, the first thing apt-get is going to do is uninstalling the "mp-fremantle-*" package.

Eg. install some apps from the debian repos or the SDK repo, and there you go with it.

mikec 2010-06-12 09:13

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
Quote:

Originally Posted by Venemo (Post 711732)
Okay, I'm sold!
I don't guarantee syntax rightness, though, because I'm typing it rigt in here, not into my IDE. :p

I also only write my idea, I guess the "..."s will make sense.

MainWindow.h
Code:

...

//include whatever...

class MainWindow
{
    ...
private:
    QTimer *timer;
    ...   
public:
    MainWindow(...); // constructor
    void updateAll(); // method that updates all
    ...
private slots:
    void on_timer_timeout(); // the method
    ...
}

UpdaterRunnable.h
Code:

#include "MainWindow.h"

class UpdaterRunnable : private QRunnable
{
private:
    MainWindow *myWindow;
public:
    UpdaterRunnable(MainWindow *window);
    void run();
}

MainWindow.cpp
Code:


#include "MainWindow.h"
#include "UpdaterRunnable.h"

MainWindow::MainWindow(...)
{
    // creating a new timer instance on the heap
    timer = new QTimer(this);
    // connecting to its signal
    connect(timer, SIGNAL(timeout()), this, SLOT(on_timer_timeout()));
    // running the timeout method - to fill up values on the beginning
    on_timer_timeout();
    // starting the timer with a nice interval
    timer->start(3000);
   
    ...
}

void MainWindow::updateAll()
{
    // This is the method in which you update all your labels
}

void MainWindow::on_timer_timeout()
{
    // makes the thread pool start updating asynchronously
    // note that the QRunnable instance will be deleted by the thread pool, so this is not a memory leak
    QThreadPool::globalInstance()->start(new UpdaterRunnable(this));
}

UpdaterRunnable.cpp
Code:

#include "UpdaterRunnable.h"

UpdaterRunnable::UpdaterRunnable(MainWindow *window)
    : QRunnable(), myWindow(window)
{
}

void UpdaterRunnable::run()
{
    myWindow->updateAll();
}

Rougly this is what I was speaking about - I really hope it helps.

I also recommend setting the default caption of all labels to "Updating...", and start updating them asynchonously. It just adds a feeling of responsiveness to the UI. (This is why there is a call to the timeout method in the constructor of my example.)

Very Timely as I am struggling with a performance problem with Maesynth where I think I need to move to a threading solution. Too many sounds playing at the same time :D

noobmonkey 2010-06-12 09:30

Re: [Annouce] HealthCheck - Hardware/System checker for the N900
 
mike, got a python version working with threading, will copy the code when i get near a pc. bit laggy, as i am calling so many functions! hehe


All times are GMT. The time now is 21:34.

vBulletin® Version 3.8.8