#!/usr/bin/python # -* coding: utf8 *- # obexget 0.1 - fetch files via bluetooth # # Copyright 2008 Bernd Wurst, schokokeks.org # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. ''' request a directory-listing from an OBEXftp capable device and move all files to the local folder. Needs ElementTree Python Module (dev-python/elementtree in gentoo) ''' # CONFIG DeviceAddress = '00:00:00:00:00:00' RemoteFolder = 'Speicherkarte\\Tracks' import elementtree.ElementTree as ET import os listing = os.popen("obexftp -b '%s' -l '%s' 2>/dev/null" \ % (DeviceAddress, RemoteFolder), "r").read() # Parse the XML... tree = ET.fromstring(listing) # ... and iterate on all 'file' elements. files = tree.getiterator("file") # We only want file names as strings... files = [file.get('name') for file in files] # ... that must be mangled into command line arguments... params = ["-o '%s' -G '%s\\%s'" % (f, RemoteFolder, f) for f in files] # ...and passed to obexftp os.system( ("obexftp -b '%s' " % DeviceAddress) + (' '.join(params)) + ' 2>/dev/null' )