* Adeodato Simó <[email protected]> [2009-03-29 20:08]:
> Package: python-pymtp
> Version: 0.0.4-1
> Severity: serious
> X-Debbugs-CC: Rafael Laboissiere <[email protected]>
>
> pymtp hardcodes a dependency on libmtp7, which has been dropped in
> favour of libmtp8. Please take a look into uploading a package with an
> updated dependency, with source changes to adjust to the new library if
> needed.
Source changes are needed. The pymtp module uses ctypes to access the
shared library libmtp, so that runtime errors may occur with source
unchanged.
Below is a debdiff that may work. I did not test it but merely adapted
the code to the changes in the API between libmtp7 and libmtp8.
It seems that upstream has not yet adapted to libmtp8 [1], although it is
staed in the README [2] at the Git repository that "PyMTP 0.1.0 requires
LibMTP 0.3.3 or above".
[1] http://projects.nick125.com/repositories/entry/pymtp/pymtp/main.py
[2] http://projects.nick125.com/repositories/entry/pymtp/README
--
Rafael
diff -u pymtp-0.0.4/build/lib/pymtp.py pymtp-0.0.4/build/lib/pymtp.py
--- pymtp-0.0.4/build/lib/pymtp.py
+++ pymtp-0.0.4/build/lib/pymtp.py
@@ -819,7 +819,7 @@
else:
return LIBMTP_Filetype["UNKNOWN"]
- def send_file_from_file(self, source, target, parent=0, callback=None):
+ def send_file_from_file(self, source, target, callback=None):
"""
Sends a file from the filesystem to the connected device
and stores it at the target filename inside the parent.
@@ -831,9 +831,6 @@
@param source: The path on the filesystem where the file resides
@type target: str
@param target: The target filename on the device
- @type parent: int or 0
- @param parent: The parent directory for the file to go
- into; If 0, the file goes into main directory
@type callback: function or None
@param callback: The function provided to libmtp to
receive callbacks from ptp. Callback function must
@@ -856,7 +853,7 @@
filesize=os.stat(source).st_size)
ret = self.mtp.LIBMTP_Send_File_From_File(self.device, source, \
- ctypes.pointer(metadata), callback, None, parent)
+ ctypes.pointer(metadata), callback, None)
if (ret != 0):
self.debug_stack()
@@ -864,7 +861,7 @@
return metadata.item_id
- def send_track_from_file(self, source, target, metadata, parent=0, callback=None):
+ def send_track_from_file(self, source, target, metadata, callback=None):
"""
Sends a track from the filesystem to the connected
device
@@ -875,9 +872,6 @@
@param target: The target filename on the device
@type metadata: LIBMTP_Track
@param metadata: The track metadata
- @type parent: int or 0
- @param parent: The parent directory for the track;
- if 0, the track will be placed in the base dir.
@type callback: function or None
@param callback: The function provided to libmtp to
receive callbacks from ptp. Callback function must
@@ -1038,7 +1032,7 @@
return ret
- def create_new_playlist(self, metadata, parent=0):
+ def create_new_playlist(self, metadata):
"""
Creates a new playlist based on the metadata object
passed.
@@ -1046,8 +1040,6 @@
@type metadata: LIBMTP_Playlist
@param metadata: A LIBMTP_Playlist object describing
the playlist
- @type parent: int or 0
- @param parent: The parent ID or 0 for base
@rtype: int
@return: The object ID of the new playlist
"""
@@ -1055,7 +1047,7 @@
if (self.device == None):
raise NotConnected
- ret = self.mtp.LIBMTP_Create_New_Playlist(self.device, ctypes.pointer(metadata), parent)
+ ret = self.mtp.LIBMTP_Create_New_Playlist(self.device, ctypes.pointer(metadata))
if (ret == 0):
self.debug_stack()
@@ -1173,7 +1165,7 @@
return ret
- def create_folder(self, name, parent=0):
+ def create_folder(self, name, parent=0, storage=0):
"""
This creates a new folder in the parent. If the parent
is 0, it will go in the main directory.
@@ -1182,6 +1174,9 @@
@param name: The name for the folder
@type parent: int
@param parent: The parent ID or 0 for main directory
+ @type storage: int
+ @param storage: The storage id or 0 to create the new folder
+ on the primary storage
@rtype: int
@return: Returns the object ID of the new folder
"""
@@ -1189,7 +1184,7 @@
if (self.device == None):
raise NotConnected
- ret = self.mtp.LIBMTP_Create_Folder(self.device, name, parent)
+ ret = self.mtp.LIBMTP_Create_Folder(self.device, name, parent, storage)
if (ret == 0):
self.debug_stack()
diff -u pymtp-0.0.4/debian/changelog pymtp-0.0.4/debian/changelog
--- pymtp-0.0.4/debian/changelog
+++ pymtp-0.0.4/debian/changelog
@@ -1,3 +1,16 @@
+pymtp (0.0.4-1.1) unstable; urgency=low
+
+ * Non-maintainer upload
+ * debian/control: Depends on libmtp8
+ * pymtp.py: Adapt to libmtp8. Functions changed:
+ + MTP.send_file_from_file
+ + MTP.send_track_from_file
+ + MTP.create_new_playlist
+ + MTP.create_folder
+ * examples/send{file,track}.py: Adjust
+
+ -- Rafael Laboissiere <[email protected]> Sun, 29 Mar 2009 23:13:36 +0200
+
pymtp (0.0.4-1) unstable; urgency=low
* Initial release (Closes: #489547)
diff -u pymtp-0.0.4/debian/control pymtp-0.0.4/debian/control
--- pymtp-0.0.4/debian/control
+++ pymtp-0.0.4/debian/control
@@ -10,7 +10,7 @@
Package: python-pymtp
Architecture: all
-Depends: python, libmtp7, ${shlibs:Depends}, ${misc:Depends}
+Depends: python, libmtp8, ${shlibs:Depends}, ${misc:Depends}
Description: Pythonic binding to LibMTP to interact with MTP devices
PyMTP is a Pythonic binding to LibMTP that allows Python programs
to interact with LibMTP-supported devices. These devices include
only in patch2:
unchanged:
--- pymtp-0.0.4.orig/pymtp.py
+++ pymtp-0.0.4/pymtp.py
@@ -819,7 +819,7 @@
else:
return LIBMTP_Filetype["UNKNOWN"]
- def send_file_from_file(self, source, target, parent=0, callback=None):
+ def send_file_from_file(self, source, target, callback=None):
"""
Sends a file from the filesystem to the connected device
and stores it at the target filename inside the parent.
@@ -831,9 +831,6 @@
@param source: The path on the filesystem where the file resides
@type target: str
@param target: The target filename on the device
- @type parent: int or 0
- @param parent: The parent directory for the file to go
- into; If 0, the file goes into main directory
@type callback: function or None
@param callback: The function provided to libmtp to
receive callbacks from ptp. Callback function must
@@ -856,7 +853,7 @@
filesize=os.stat(source).st_size)
ret = self.mtp.LIBMTP_Send_File_From_File(self.device, source, \
- ctypes.pointer(metadata), callback, None, parent)
+ ctypes.pointer(metadata), callback, None)
if (ret != 0):
self.debug_stack()
@@ -864,7 +861,7 @@
return metadata.item_id
- def send_track_from_file(self, source, target, metadata, parent=0, callback=None):
+ def send_track_from_file(self, source, target, metadata, callback=None):
"""
Sends a track from the filesystem to the connected
device
@@ -875,9 +872,6 @@
@param target: The target filename on the device
@type metadata: LIBMTP_Track
@param metadata: The track metadata
- @type parent: int or 0
- @param parent: The parent directory for the track;
- if 0, the track will be placed in the base dir.
@type callback: function or None
@param callback: The function provided to libmtp to
receive callbacks from ptp. Callback function must
@@ -1038,7 +1032,7 @@
return ret
- def create_new_playlist(self, metadata, parent=0):
+ def create_new_playlist(self, metadata):
"""
Creates a new playlist based on the metadata object
passed.
@@ -1046,8 +1040,6 @@
@type metadata: LIBMTP_Playlist
@param metadata: A LIBMTP_Playlist object describing
the playlist
- @type parent: int or 0
- @param parent: The parent ID or 0 for base
@rtype: int
@return: The object ID of the new playlist
"""
@@ -1055,7 +1047,7 @@
if (self.device == None):
raise NotConnected
- ret = self.mtp.LIBMTP_Create_New_Playlist(self.device, ctypes.pointer(metadata), parent)
+ ret = self.mtp.LIBMTP_Create_New_Playlist(self.device, ctypes.pointer(metadata))
if (ret == 0):
self.debug_stack()
@@ -1173,7 +1165,7 @@
return ret
- def create_folder(self, name, parent=0):
+ def create_folder(self, name, parent=0, storage=0):
"""
This creates a new folder in the parent. If the parent
is 0, it will go in the main directory.
@@ -1182,6 +1174,9 @@
@param name: The name for the folder
@type parent: int
@param parent: The parent ID or 0 for main directory
+ @type storage: int
+ @param storage: The storage id or 0 to create the new folder
+ on the primary storage
@rtype: int
@return: Returns the object ID of the new folder
"""
@@ -1189,7 +1184,7 @@
if (self.device == None):
raise NotConnected
- ret = self.mtp.LIBMTP_Create_Folder(self.device, name, parent)
+ ret = self.mtp.LIBMTP_Create_Folder(self.device, name, parent, storage)
if (ret == 0):
self.debug_stack()
only in patch2:
unchanged:
--- pymtp-0.0.4.orig/examples/sendtrack.py
+++ pymtp-0.0.4/examples/sendtrack.py
@@ -12,7 +12,7 @@
import pyid3lib
def usage():
- print "Usage: %s <source> <target> <parent>\n(The parent id can be 0 for the root directory)" % (sys.argv[0])
+ print "Usage: %s <source> <target>" % (sys.argv[0])
def main():
if len(sys.argv) <= 3:
@@ -24,7 +24,6 @@
source = sys.argv[1]
target = sys.argv[2]
- parent = int(sys.argv[3])
id3data = pyid3lib.tag(source)
@@ -39,7 +38,7 @@
if (hasattr(id3data, 'tracknum')):
metadata.tracknumber = id3data.tracknum
- track_id = mtp.send_track_from_file(source, target, metadata, parent=parent)
+ track_id = mtp.send_track_from_file(source, target, metadata)
print "Created new track with ID: %s" % (track_id)
mtp.disconnect()
only in patch2:
unchanged:
--- pymtp-0.0.4.orig/examples/sendfile.py
+++ pymtp-0.0.4/examples/sendfile.py
@@ -12,7 +12,7 @@
import pyid3lib
def usage():
- print "Usage: %s <source> <target> <parent>\n(The parent id can be 0 for the root directory)" % (sys.argv[0])
+ print "Usage: %s <source> <target>" % (sys.argv[0])
def main():
if len(sys.argv) <= 3:
@@ -24,9 +24,8 @@
source = sys.argv[1]
target = sys.argv[2]
- parent = int(sys.argv[3])
- file_id = mtp.send_file_from_file(source, target, parent=parent)
+ file_id = mtp.send_file_from_file(source, target)
print "Created new track with ID: %s" % (file_id)
mtp.disconnect()