maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   mbarcode (https://talk.maemo.org/showthread.php?t=34996)

dragly 2010-10-26 11:40

Re: mbarcode
 
I had no idea the firmware upgrade had been released yet. That's good news :) I guess the plugins might have to be recompiled against the latest firmware libraries. I'll try to update and see what happens ;)

donj541 2010-10-26 13:17

Re: mbarcode
 
Thanks dragly. Very usefull app. Looking forward for the new version soon.

dragly 2010-10-26 13:38

Re: mbarcode
 
Looks like it is broken here too. I'll try to push one of the plugins and the mbarcode package to the autobuilder right away to see if that helps.

I think there is some binary incompatibility for plugins between different versions of Qt. Rebuilding both the application and the plugins should hopefully work.

I'll be back with updates soon :)

dragly 2010-10-26 17:34

Re: mbarcode
 
Seems like they only needed to be rebuilt.

All packages are built and available in extras-devel now.

dragly 2010-10-26 19:34

Re: mbarcode
 
Quote:

Originally Posted by lardman (Post 846066)
http://chart.apis.google.com/chart?c...%A9my+Hubscher

This has the BOM encoded at the start to indicate it's UTF-8, which seems to decode properly.


On a completely different note, has anyone else found that you sometimes revert back to continuous scanning until you open the Settings dialog? I thought I'd fixed this but apparently not. Drat! :) - seems to happen to me after I've scanned something. I'll have to check and see what's going wrong there

This has been fixed in version 0.2.4-0. The error was that the continuous scanning setting was only being honoured on first run, leaving it "forgotten" after a successful scan. Now it is checked whenever the camera (video widget) is started.

donj541 2010-10-27 00:47

Re: mbarcode
 
The new version 0.2.3.5 works. Thanks

lardman 2010-10-30 13:28

Re: mbarcode
 
Right, I've got PythonQt plugins working. They now load :)

We need to decide on an API (take a look at the example python code in SVN to see my current ideas) and then check what we can do with Python. E.g. whether we can interact with the UI, which we should be able to do, or whether we'll need to pass the python code a wrapped window that it can draw to if it requests it.

Anyway I hope to soon have this finalised and then you guys can write some Python plugins :)

Edit: I've just pushed the plugin to the build queue, so you can have a mess around with it yourselves in 10min or so (assuming it builds ok! ;)).

Python scripts should go in /usr/share/mbarcode/pythonqt/

The script should contain a class whose name is the same as the filename (case sensitive of course). I'm attaching an example. Please do some testing, etc., and see what you can and can't get it to do and feedback so I can fix things and get this working asap :)


I can't upload the file, so here's a link to the SVN: https://garage.maemo.org/plugins/scm...de&view=markup

lardman 2010-11-01 23:29

Re: mbarcode
 
Hmm pretty much a singular lack of interest, oh well.

I've tried to create a window in my Python plugin without success - I need to hook up the stderr output from the Pytyhon interpreter to see what's going wrong. Help appreciated as ever :)

gri 2010-11-01 23:36

Re: mbarcode
 
Quote:

Originally Posted by lardman (Post 860286)
Hmm pretty much a singular lack of interest, oh well.

I've tried to create a window in my Python plugin without success - I need to hook up the stderr output from the Pytyhon interpreter to see what's going wrong. Help appreciated as ever :)

Did you create the window with a parent from c++? I once tried the same and the program crashed all the time when my python QDialog had a C++ QWidget as parent. Leaving out the parent window worked.

You could also try the sip package for creating a wrapper as I did for my project.

lardman 2010-11-04 08:22

Re: mbarcode
 
I've been trying to work out why I can call some methods of my Python plugin but not others, all the time working on the understanding that Python's stderr should end up in the terminal window. But apparently this is actually not the case.

I've added a sys.stderr = open("logfile", "w") type line to the __init__() method of the plugin class and can now see Python errors caused by my HandleBarcode() method.

Speaking of which, my error seems to be to do with Python not finding QWidget(). I've tried QtGui.QWidget() and also Qt.QWidget() (Qt should provide all the methods and objects provided by PythonQt) but in both cases I get an error.

I was then thinking that I'd just skip trying to get the imports from PythonQt and see if PyQt would work, but I see the version in the repo is marked as for PR1.2 - does it work on Pr1.3, or does it try to pull in the old Qt versions?

So to summarise, Python plugins are working, make sure you set stderr so you can see error output (I'll eventually add this line to the overall setup when the classes are loaded to avoid individuals needing to add this), and do let me know how you get on with it.

LordVan 2010-11-08 10:11

Re: mbarcode
 
when i use mbarcode it reads codes ok, but no plugin (isbn,..) ever comes up with anything i always only get the copy button .. when i start from the console i get messages about isbn plugin getting stuff,.. but still nothing in mBarcode itself .. any ideas?

maybe this is answered somewhere before in this thread but it'S v long and i just briefly read over it.. if so sorry for asking again ..

dragly 2010-11-08 10:21

Re: mbarcode
 
@LordVan: No worries ;)

The reason is most likely some issues with the update to PR1.3. I suggest you reinstall both mbarcode and the plugins package. That should put things back to normal.

Even if you have successfully updated both mbarcode and maemo to the newest version, there seems to be a problem getting the plugins loading. The last report I got was that a reinstall fixed the issue.

LordVan 2010-11-08 12:09

Re: mbarcode
 
Thanks . apt-get remove <insert everything mbarcode here> and then an apt-get install <..> did the job fine for me. This program rocks ;)

btw i was thinkig it'd be really cool to have a plugin which talks to some sort of personal 'library' thing so i scan a manga and it tells me if i go tthat volume or still need vol XX of manga YY .. and put new ones on a wishlist ^^ or is there something like that already?

lardman 2010-11-08 17:33

Re: mbarcode
 
I'm working on it, should have some code out in the next couple of weeks

lardman 2010-11-08 19:05

Re: mbarcode
 
1 Attachment(s)
In fact here's my start at some code (attached).

If anyone fancies doing some hacking on it please help yourselves. The plan is that it runs as a stand-alone Python app and data is passed to it (and it is started if necessary) via a DBus call from mBarcode.

Which leads me onto the second point - this Python plugin is driving me mad! I've decided that it's probably easier for people to write a Python plugin to call QtDbus methods rather than making a rather complex ExternalDBusPlugin plugin for mBarcode (complex because the plugin conf file would need to contain regex expressions to determine what should be done with the barcode contents and how it should be turned into a DBus message - thinking of e.g. converting a geo:// payload to a DBus call to open a lat/lon in the wonderful Ovi Maps)

The Python plugin stuff is curious - despite stdout/stderr not supposed to be redirected, there is no output at the terminal when the plugin is loaded by mBarcode. If, however, in the __init__() method of the Python plugin class I set a redirect for the sys.stderr filehandle, I can write to a file. Very odd, and rather annoying as it then requires the class to at least be initialised before I can see any error output. I need to try setting the redirect in the main Python "workspace" before each plugin script is loaded.

I've been working through this by writing a script which runs at the command line, then trying to work out why it won't run as a plugin - curiously I see no output (which I presume indicates an error before the class is initialised) if I try to import things like PyQt4, which doesn't make me overly optimistic for the use of *Dbus imports.

Any help trying to work out what's going on appreciated as ever.

lardman 2010-11-08 20:54

Re: mbarcode
 
hmm, seems to just be down to "import PyQt4" causing an error, I wonder if the search path is causing troubles (standard packages such as sys,os etc can be imported as can PythonQt itself).

need to do more digging tomorrow

LordVan 2010-11-08 22:33

Re: mbarcode
 
hmmkeeps giving me indentation errors here. maybe will check it out in more detail tomorrow.

LordVan 2010-11-09 06:24

Re: mbarcode
 
1 Attachment(s)
so .. i went and fixed your indentation errors, missing (), 'pass' (empty blocks) and missing self. where u tried to call class methods without that, else if -> elif , missing \ in some places,..

which python version are you testing on? the 2.5 on my N900 only is able to run the version of the file attached now (it does complain about missing .service file but at least it parses now ;))

there r still more bugs i was too lazy to fix with khteditor / pygtkeditor on my n900 but they didn'T stop it parsing the file so i left it for now.

lardman 2010-11-09 08:29

Re: mbarcode
 
I was actually running it with Python2.5 (under Windows XP) on my netbook (as it's easier that way to code and test in front of the TV).

But yeah, I've added some new code recently and not got round to running it so there were no doubt quite a few errors. Thanks for the fixes. I'll stick the code up on SVN which should make it easier for people to add changes.

LordVan 2010-11-09 08:39

Re: mbarcode
 
heh ok, but keep in mind that i just made it parseable there r quite a few bugs left that'll keep it from actually working..

lardman 2010-11-09 12:23

Re: mbarcode
 
I'll do some cleaning up with evening and upload it to the ItemDB Garage SVN, once the project is setup click to be added to the project.

Yeah it also needs the service file to actually do anything useful (which is something that Windows doesn't do - DBus, so I'd not bothered until I had more code down, and indeed until I had a way of passing data to the app over DBus).

LordVan 2010-11-09 12:43

Re: mbarcode
 
actually there is some dbus implementation on windows it comes with kde-installer for win32 in any case ;)

dhanurdhar 2010-11-09 13:36

Re: mbarcode
 
hi
is mbarcode in extras-devel or has it come to extras
thanks

LordVan 2010-11-09 13:44

Re: mbarcode
 
http://maemo.org/packages/view/mbarcode/ says 0.0.8 in -testing and 0.2.4 in -devel (imho the -devel version is so much better ;))

lardman 2010-11-09 15:46

Re: mbarcode
 
The version in -testing is a relic, we'll push through the -devel version to extras proper quite soon (via -testing of course), but I'd like to get Python plugins working first (and we also need to fix a few other odds and sods, including adding some more payload types for 2D barcodes)

lardman 2010-11-16 07:29

Re: mbarcode
 
1 Attachment(s)
Current test Python plugin for use with mbarcode-plugin-pythonqtwrapper 0.0.2 (in extras-devel).

Rename to .py and place in /usr/share/mbarcode/plugins/pythonqt/

Note that I've not worked out how to get any UI items to show, but you should see the text printed out at the terminal. Work in progress. If anyone fancies hacking on this then I'd appreciate the help.

What I'd really like is for the plugin to be able to generate and populate its own window, but I fear the event loop won't run for the Python objects, so I'll have to have a look at the low level code that implements that and see if I can get it working somehow.

lardman 2010-11-16 07:31

Re: mbarcode
 
The alternative method, which is implemented in PythonPluginWrapper (in SVN, note the lack of a Qt in the name, to differentiate the two plugins) is to cast the python plugin to a C++ class and call methods on it directly from C++ (using SIP bindings) - I'm not sure if this is a better approach, but it currently segfaults. If anyone fancies working on that, that would also be useful :)

lardman 2010-11-16 07:41

Re: mbarcode
 
Hmm, regarding these plugins, I guess I may need to use locks when the Python-C functions are called by the sinks assuming the sinks run in different threads (though I need to check that). In that case I'll also need to enable Python threading when I initialise the interpreter.

LordVan 2010-11-16 08:01

Re: mbarcode
 
well i'd love to if i got my scratchbox to compile something useful *and* display tinyx(was it tinyx? nm doesn't matter u know what i mean ;) ;)

flux 2010-11-16 18:31

Re: mbarcode
 
Here is one use case (mine :) ) I feel mbarcode doesn't address adequately presently:
I have a set of storage boxes, which each have a QR-encoded sticker with a URL in them pointing to a page that describes the contents of the box along with a few photos of the contents. I would like to whip out my N900, point it towards the boxes and have my web browser be redirected to the said URL without needing other interaction; should I point to another box, the browser should be redirected to that new page, again without any interaction other than moving the camera.
Now, maybe mbarcode isn't the application for this special use case. But it'd be nice if it were :). An alternative to use mbarcode would in my mind be a fork that would use a webkit widget for displaying the page. That way it could still provide its own menu for options.

lardman 2010-11-16 21:44

Re: mbarcode
 
I see no problem with this usecase. We need to implement a plugin selection dialog in any case, in which one could check the default plugin to handle a given payload. Then all we'd need to do is create a setting such that the results window is not displayed if not wanted (it provides the copy button, but with a default plugin has no other use).

Regarding opening the web-browser, there are two ways it can open - either in a new window, or in the same window; a settings dialog for the qrcode plugin could allow the user to select which of these happens.

I'll add these to my ToDo list :)

lardman 2010-11-16 23:25

Re: mbarcode
 
Right, hugopl (in #pyside) pointed out that my widget variable is being decref'd as soon as the window is created, so simply making the widget a member of the class (e.g. adding it as self.widget in __init__() sorts that out and displays the window).

Looks like Python scripting is go!

I'll come up with an example code tomorrow, and also one which uses DBus to notify/start external apps (e.g. Map apps for geo:// payloads).

LordVan 2010-11-17 06:57

Re: mbarcode
 
@flux might be interesting to see this as an option for mbarcode as a plugin or something but i duno if mbarcode does support automatic action.

lardman 2010-11-17 09:58

Re: mbarcode
 
Quote:

Originally Posted by flux (Post 875289)
I would like to whip out my N900, point it towards the boxes and have my web browser be redirected to the said URL without needing other interaction; should I point to another box, the browser should be redirected to that new page, again without any interaction other than moving the camera.

So you want mBarcode to continue scanning in the background while you view the webpage? Well this is certainly doable once I add the right combination of settings (use default plugin, don't show results page, continuous scanning).


Quote:

Originally Posted by flux (Post 875289)
Now, maybe mbarcode isn't the application for this special use case. But it'd be nice if it were :). An alternative to use mbarcode would in my mind be a fork that would use a webkit widget for displaying the page. That way it could still provide its own menu for options.

You are of course welcome to fork if you really want to, but I'd prefer to add options to mBarcode such that it becomes suitable for your (and anyone else's) usecases.

lardman 2010-11-17 14:32

Re: mbarcode
 
Ok, so MECARD decoding now works, I'll push an update to extras-devel later on today (mbarcode-plugin-qrcode)

rfa 2010-11-18 02:54

Re: mbarcode
 
How would I implement this: http://www.ebayinc.com/content/press...20100623006637 or something like this?

I realise this is an iPhone app, so would RedLaser need to do it, or would I be able to? (If I could write the plugin for mBarcode)

LordVan 2010-11-18 06:34

Re: mbarcode
 
sounds like basically they want to save ppl with iPhones from having to type the EAN,.. code into whatever selling app .. since afaik there's no ebay listing app for the n900 this is not really much of an option - u can of course use mbarcode to read the ean , copy and paste it into ebay-webform .. unless you are planning to write an ebay listing app .. ^^

lardman 2010-11-18 08:37

Re: mbarcode
 
Quote:

Originally Posted by rfa (Post 876703)
How would I implement this: http://www.ebayinc.com/content/press...20100623006637 or something like this?

I realise this is an iPhone app, so would RedLaser need to do it, or would I be able to? (If I could write the plugin for mBarcode)

Yes we could really do with a plugin that takes the EAN, and then does a lookup and search for where and what price you can buy the item. Android has had one of these for ages (and in fact was what prompted me to start writing mBarcode, unfortunately it's taken a while!). i.e. http://scan.jsharkey.org/

Now that we have working Python plugins, it should be significantly easier to do the weblookups/scraping required to do this. If there's any exsiting Python code out there that we could start with to save writing the whole thing from scratch, that would be good :)

lardman 2010-11-18 08:38

Re: mbarcode
 
Quote:

Originally Posted by LordVan (Post 876775)
sounds like basically they want to save ppl with iPhones from having to type the EAN,.. code into whatever selling app .. since afaik there's no ebay listing app for the n900 this is not really much of an option - u can of course use mbarcode to read the ean , copy and paste it into ebay-webform .. unless you are planning to write an ebay listing app .. ^^

It can't be that hard and would also be a worthwhile thing to do, but I've got quite a lot on my plate already so if someone else fancies having a go that would be good :)

E.g. http://developer.ebay.com/devzone/sh...s_nv_json.html

LordVan 2010-11-18 08:51

Re: mbarcode
 
Quote:

Originally Posted by lardman (Post 876848)
It can't be that hard and would also be a worthwhile thing to do, but I've got quite a lot on my plate already so if someone else fancies having a go that would be good :)

E.g. http://developer.ebay.com/devzone/sh...s_nv_json.html

The problem with that (for me) is that whenever ebay has those free listing days they add a note saying that u can't use any listing tools, but have to use the webpage .... suckers ;)


All times are GMT. The time now is 17:51.

vBulletin® Version 3.8.8