Re: [PyQt] QtDBus: Calling a method with an Array of Strings signature with Python 3

2011-12-06 Thread Chris Mayo

On 05/12/11 21:31, Phil Thompson wrote:

On Mon, 05 Dec 2011 19:12:33 +, Chris Mayo
cjm...@users.sourceforge.net  wrote:


Try this...

arg = QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add()
arg.endArray()

and pass arg to call().


Doesn't seem to work:

device_iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
'/org/freedesktop/UDisks/devices/sr0', 'org.freedesktop.UDisks.Device',



bus)

arg = QtDBus.QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add()
arg.endArray()

reply = device_iface.call(DriveEject, arg)
print(reply.errorMessage())


Returns:

Unknown option


because  is not a valid option? According to...

http://hal.freedesktop.org/docs/udisks/Device.html#Device.DriveEject

unmount is the only valid option.

Phil


Indeed it does work as:

arg = QtDBus.QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add(unmount)
arg.endArray()


and so does:

arg = QtDBus.QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.endArray()

Experimenting with other calls shows this is the way to create an empty 
Array of Strings.


Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QtDBus: Calling a method with an Array of Strings signature with Python 3

2011-12-05 Thread Chris Mayo




Try this...

arg = QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add()
arg.endArray()

and pass arg to call().


Doesn't seem to work:

device_iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
	'/org/freedesktop/UDisks/devices/sr0', 'org.freedesktop.UDisks.Device', 
bus)


arg = QtDBus.QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add()
arg.endArray()

reply = device_iface.call(DriveEject, arg)
print(reply.errorMessage())


Returns:

Unknown option


PyQt-x11-gpl-snapshot-4.9-512e7813ed74

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QtDBus: Unable to convert Array of Object Paths

2011-12-04 Thread Chris Mayo

On 04/12/11 05:34, Phil Thompson wrote:

On Fri, 02 Dec 2011 17:37:50 +, Chris Mayo
cjm...@users.sourceforge.net  wrote:

On 02/12/11 01:42, Phil Thompson wrote:

On Thu, 01 Dec 2011 20:20:34 +, Chris Mayo
cjm...@users.sourceforge.net   wrote:

Can't get ee8b9c7eb565 to compile:

Generating the C++ source for the QtDBus module...
sip:




/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/sip/QtDBus/qdbusextratypes.sip:95:


A class, exception, namespace or mapped type has already been defined
with the same name
Error: Unable to create the C++ code.


This might have been due to a build problem. Try downloading the

snapshot

again (even though it has the same name).

Phil


After downloading again a lot of different errors, just the first few:


Sorry about that - it isn't triggered the way I normally build. Current
snapshot should be Ok.


No luck with 65564eb2fcf4 either:

x86_64-pc-linux-gnu-g++ -c -march=core2 -msse4.1 -ftree-vectorize -O2 
-pipe -fPIC -Wall -W -D_REENTRANT -DNDEBUG -DSIP_PROTECTED_IS_PUBLIC 
-Dprotected=public -DQT_NO_DEBUG -DQT_CORE_LIB -I. 
-I/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/qpy/QtDBus 
-I/usr/include/python2.7 -I/usr/mkspecs/linux-g++ 
-I/usr/include/qt4/QtDBus -I/usr/include/qt4/QtCore -I/usr/include/qt4 
-o sipQtDBusQDBusObjectPath.o sipQtDBusQDBusObjectPath.cpp
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp: 
In function ‘PyObject* meth_QDBusVariant_variant(PyObject*, PyObject*)’:
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:45:15: 
error: ‘QDBusVariant’ does not name a type
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:47:87: 
error: ‘sipCpp’ was not declared in this scope

...

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QtDBus: Unable to convert Array of Object Paths

2011-12-04 Thread Chris Mayo



No luck with 65564eb2fcf4 either:

x86_64-pc-linux-gnu-g++ -c -march=core2 -msse4.1 -ftree-vectorize -O2
-pipe -fPIC -Wall -W -D_REENTRANT -DNDEBUG -DSIP_PROTECTED_IS_PUBLIC
-Dprotected=public -DQT_NO_DEBUG -DQT_CORE_LIB -I.


-I/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/qpy/QtDBus


-I/usr/include/python2.7 -I/usr/mkspecs/linux-g++
-I/usr/include/qt4/QtDBus -I/usr/include/qt4/QtCore -I/usr/include/qt4
-o sipQtDBusQDBusObjectPath.o sipQtDBusQDBusObjectPath.cpp


/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:


In function ‘PyObject* meth_QDBusVariant_variant(PyObject*, PyObject*)’:


/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:45:15:


error: ‘QDBusVariant’ does not name a type


/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:47:87:


error: ‘sipCpp’ was not declared in this scope
...


I can't reproduce this. This is with Qt v4.8.0rc but I don't think
QDBusVariant or qdbusextratypes.h has changed recently.



The only includes at the top of the generated 
PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp 
are:



#include sipAPIQtDBus.h


#line 241 
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/sip/QtCore/qvariant.sip

#include qvariant.h
#line 35 
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp



If I manually add:
 #include qdbusextratypes.h
make appears to complete.

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QtDBus: Unable to convert Array of Object Paths

2011-12-04 Thread Chris Mayo




The only includes at the top of the generated
PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp
are:


#include sipAPIQtDBus.h


#line 241
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/sip/QtCore/qvariant.sip

#include qvariant.h
#line 35
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111204/work/PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4-2.7/QtDBus/sipQtDBusQDBusVariant.cpp



If I manually add:
#include qdbusextratypes.h
make appears to complete.



All my mistake. In trying to investigate the first compilation problem I 
was zapping out the #include qdbusextratypes.h in qdbusextratypes.sip 
and forget to remove it when trying out the newer snapshots. Sorry for 
wasting your time.


I now have working arrays of object paths.

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] QtDBus: Calling a method with an Array of Strings signature with Python 3

2011-12-04 Thread Chris Mayo

With Python 2 I can do (where /dev/sr0 is a cdrom):

bus = QtDBus.QDBusConnection.systemBus()
device_iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
	'/org/freedesktop/UDisks/devices/sr0', 'org.freedesktop.UDisks.Device', 
bus)

reply = device_iface.call(DriveEject, QStringList())


But with Python 3 this won't work because of QStringList. If I modify it 
with:


reply = device_iface.call(DriveEject, [, ])
print(reply.errorMessage())

I get:

Method DriveEject with signature av on interface 
org.freedesktop.UDisks.Device doesn't exist


Chris

PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QtDBus: Unable to convert Array of Object Paths

2011-12-02 Thread Chris Mayo

On 02/12/11 01:42, Phil Thompson wrote:

On Thu, 01 Dec 2011 20:20:34 +, Chris Mayo
cjm...@users.sourceforge.net  wrote:

Can't get ee8b9c7eb565 to compile:

Generating the C++ source for the QtDBus module...
sip:


/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/sip/QtDBus/qdbusextratypes.sip:95:


A class, exception, namespace or mapped type has already been defined
with the same name
Error: Unable to create the C++ code.


This might have been due to a build problem. Try downloading the snapshot
again (even though it has the same name).

Phil


After downloading again a lot of different errors, just the first few:

x86_64-pc-linux-gnu-g++ -c -march=core2 -msse4.1 -ftree-vectorize -O2 
-pipe -fPIC -Wall -W -D_REENTRANT -DNDEBUG -DSIP_PROTECTED_IS_PUBLIC 
-Dprotected=public -DQT_NO_DEBUG -DQT_CORE_LIB -I. 
-I/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/qpy/QtDBus 
-I/usr/include/python2.7 -I/usr/mkspecs/linux-g++ 
-I/usr/include/qt4/QtDBus -I/usr/include/qt4/QtCore -I/usr/include/qt4 
-o sipQtDBusQDBusObjectPath.o sipQtDBusQDBusObjectPath.cpp
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/QtDBus/sipQtDBusQDBusVariant.cpp: 
In function ‘PyObject* meth_QDBusVariant_variant(PyObject*, PyObject*)’:
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:45:15: 
error: ‘QDBusVariant’ does not name a type
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/QtDBus/sipQtDBusQDBusVariant.cpp:47:87: 
error: ‘sipCpp’ was not declared in this scope
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/QtDBus/sipQtDBusQDBusVariant.cpp: 
In function ‘PyObject* meth_QDBusVariant_setVariant(PyObject*, PyObject*)’:

...

This is with sip-4.13.1-snapshot-98421b9cc511.

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QtDBus: Unable to convert Array of Object Paths

2011-12-01 Thread Chris Mayo

On 30/11/11 16:37, Phil Thompson wrote:

On Sun, 27 Nov 2011 12:58:27 +, Chris Mayo
cjm...@users.sourceforge.net  wrote:

On 27/11/11 12:51, Phil Thompson wrote:

On Sun, 27 Nov 2011 12:47:09 +, Chris Mayo
cjm...@users.sourceforge.net   wrote:

With PyQt-x11-gpl-snapshot-4.9-e8284ed41e49,
sip-4.13.1-snapshot-3b44dc2f0efd and:

bus = QtDBus.QDBusConnection.systemBus()
iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
'/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)

print(iface.call('EnumerateDeviceFiles').arguments())
print(iface.call('EnumerateDevices').arguments())


the end of the output is:

:00:1f.2-scsi-5:0:0:0-part2', '/dev/fd0']]
Traceback (most recent call last):
 File ./objectpath.py, line 10, inmodule
   print(iface.call('EnumerateDevices').arguments())
TypeError: unable to convert a C++ 'QDBusArgument' instance to a

Python

object


EnumerateDeviceFiles returns an Array of Strings, but EnumerateDevices
returns an Array of Object Paths




http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.EnumerateDevices


Python 3.2.2, Qt 4.7.4, udisks 1.0.4, dbus 1.4.16 on amd64 Linux


Can you send me a complete test case?

Thanks,
Phil


That was it! Nearly anyway, in full:

#!/usr/bin/python

from PyQt4 import QtDBus

bus = QtDBus.QDBusConnection.systemBus()
iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
'/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)

print(iface.call('EnumerateDeviceFiles').arguments())
print(iface.call('EnumerateDevices').arguments())


Tonight's snapshot will fix this. However there needs to be some
discussion about the best way to (de)marshall arguments.


Can't get ee8b9c7eb565 to compile:

Generating the C++ source for the QtDBus module...
sip: 
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/sip/QtDBus/qdbusextratypes.sip:95: 
A class, exception, namespace or mapped type has already been defined 
with the same name

Error: Unable to create the C++ code.



I propose that marshalling of composite types uses QDBusArgument (as you
do in C++). However I propose that demarshalling is done automatically,
because...

1. It is Pythonic.
2. The QDBusArgument API will need changing in Python if it is to support
both marshalling and demarshalling.

There remains a question of how far to demarshall automatically. At the
moment your example will return a Python list of QDBusObjectPath instances.
As QDBusObjectPath is just a thin wrapper around QString should this be
removed and just the string returned? The same would apply to
QDBusSignature and QDBusVariant. Is it important to be able to distinguish
between a return value that is a simple string and one that is an object
path?


I'm no dbus expert but certainly I would use the QDBusObjectPath 
instances just as plain strings. Looks like the only advantage is when 
creating QDBusObjectPath it will do some checking for you.



As far as marshalling with QDBusArgument is concerned, I'm inclined to
ignore the shift operators and to implement explicit writeInt32(),
writeUInt32() etc methods - as happens with QDataStream.


Bit beyond me. N.B. if you're not following it there has been some 
activity on

https://bugs.freedesktop.org/show_bug.cgi?id=26420
still a bit of a long shot in terms of dbus-python being resurrected for 
Python 3 maybe but some discussion on types.



Thoughts?

Phil


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] QtDBus: Unable to convert Array of Object Paths

2011-11-27 Thread Chris Mayo
With PyQt-x11-gpl-snapshot-4.9-e8284ed41e49, 
sip-4.13.1-snapshot-3b44dc2f0efd and:


bus = QtDBus.QDBusConnection.systemBus()
iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
'/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)

print(iface.call('EnumerateDeviceFiles').arguments())
print(iface.call('EnumerateDevices').arguments())


the end of the output is:

:00:1f.2-scsi-5:0:0:0-part2', '/dev/fd0']]
Traceback (most recent call last):
  File ./objectpath.py, line 10, in module
print(iface.call('EnumerateDevices').arguments())
TypeError: unable to convert a C++ 'QDBusArgument' instance to a Python 
object



EnumerateDeviceFiles returns an Array of Strings, but EnumerateDevices 
returns an Array of Object Paths

http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.EnumerateDevices

Python 3.2.2, Qt 4.7.4, udisks 1.0.4, dbus 1.4.16 on amd64 Linux

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QtDBus: Unable to convert Array of Object Paths

2011-11-27 Thread Chris Mayo

On 27/11/11 12:51, Phil Thompson wrote:

On Sun, 27 Nov 2011 12:47:09 +, Chris Mayo
cjm...@users.sourceforge.net  wrote:

With PyQt-x11-gpl-snapshot-4.9-e8284ed41e49,
sip-4.13.1-snapshot-3b44dc2f0efd and:

bus = QtDBus.QDBusConnection.systemBus()
iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
'/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)

print(iface.call('EnumerateDeviceFiles').arguments())
print(iface.call('EnumerateDevices').arguments())


the end of the output is:

:00:1f.2-scsi-5:0:0:0-part2', '/dev/fd0']]
Traceback (most recent call last):
File ./objectpath.py, line 10, inmodule
  print(iface.call('EnumerateDevices').arguments())
TypeError: unable to convert a C++ 'QDBusArgument' instance to a Python
object


EnumerateDeviceFiles returns an Array of Strings, but EnumerateDevices
returns an Array of Object Paths


http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.EnumerateDevices


Python 3.2.2, Qt 4.7.4, udisks 1.0.4, dbus 1.4.16 on amd64 Linux


Can you send me a complete test case?

Thanks,
Phil


That was it! Nearly anyway, in full:

#!/usr/bin/python

from PyQt4 import QtDBus

bus = QtDBus.QDBusConnection.systemBus()
iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
'/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)

print(iface.call('EnumerateDeviceFiles').arguments())
print(iface.call('EnumerateDevices').arguments())

Chris
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QSqlTableModel.submitAll() problems with milliseconds and PostgreSQL time field

2009-08-25 Thread Chris Mayo
Chris Mayo wrote:
 If I create a PostgreSQL database 'test' and execute the following:
 CREATE TABLE timetest ( t time );
 INSERT INTO timetest VALUES ('0:0:0');
 

 
 The output is:
 00:00:00.000
 00:12:34.500
 00:12:34.000
 
 The database doesn't get the 500 milliseconds.
 
 
 Even worse if I execute on the database:
 UPDATE timetest SET t = '0:11:22.33';
 
 and then run the Python above I get:
 00:11:22.330
 00:12:34.500
 00:11:22.330
 
 the value from the model doesn't make it into the database at all if the
 time field already has milliseconds.
 
 

I have hacked some C++ together and still get the same result. So it
looks like a Qt problem and will try Nokia.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] QSqlTableModel.submitAll() problems with milliseconds and PostgreSQL time field

2009-08-23 Thread Chris Mayo
If I create a PostgreSQL database 'test' and execute the following:
CREATE TABLE timetest ( t time );
INSERT INTO timetest VALUES ('0:0:0');


run the following Python:

from PyQt4.QtCore import *
from PyQt4.QtSql import *

db = QSqlDatabase.addDatabase(QPSQL)
db.setHostName(localhost)
db.setDatabaseName(test)
db.setUserName(postgres)
db.open()

timetestModel = QSqlTableModel()
timetestModel.setEditStrategy(QSqlTableModel.OnManualSubmit)
timetestModel.setTable(timetest)
timetestModel.select()

print \
timetestModel.record(0).field(t).value().toTime().toString(HH:mm:ss.zzz)

a = QTime(0,12,34,500)
timetestModel.setData(timetestModel.index(0,
timetestModel.fieldIndex(t)), a)
print \
timetestModel.record(0).field(t).value().toTime().toString(HH:mm:ss.zzz)

if not timetestModel.submitAll():
raise Exception, timetestModel.lastError().text()
print \
timetestModel.record(0).field(t).value().toTime().toString(HH:mm:ss.zzz)


The output is:
00:00:00.000
00:12:34.500
00:12:34.000

The database doesn't get the 500 milliseconds.


Even worse if I execute on the database:
UPDATE timetest SET t = '0:11:22.33';

and then run the Python above I get:
00:11:22.330
00:12:34.500
00:11:22.330

the value from the model doesn't make it into the database at all if the
time field already has milliseconds.


Any thoughts?

Chris

Linux amd64, Qt 4.5.2, PyQt4 4.5.4, Sip 4.8.2, PostgreSQL 8.3.7

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt