How to use the pymtp.MTP function in PyMTP

To help you get started, we’ve selected a few PyMTP examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emdete / python-mtp / examples / View on Github external
def main():
	if 'LIBMTP_DEBUG' in environ: MTP.set_debug(int(environ['LIBMTP_DEBUG']))
	with MTP(False) as mtp:
		print("Welcome to the PyMTP Shell")
		print("You are currently connected to '{}'".format(mtp.get_devicename()))
		print("Your MTP object is '{}'".format("mtp"))
		print("Your progress callback object is '{}'".format("callback"))
		print("To exit, type 'quit'")
		while True:
				if mtp.device:
					result = raw_input("(connected) >>> ")
					result = raw_input("(disconnected) >>> ")
				if result.startswith("quit"):
					exec result
github exaile / exaile / plugins / View on Github external
    def connect(self, panel):
            Connects to the MTP device and loads playlist/track
             info into exaile.
        if self.connecting: self.disconnect()

        self.connecting = True
        self.panel = panel
        self.collection_panel = self.exaile.collection_panel
        self.mtp = pymtp.MTP()
            self.connected = True
            gobject.idle_add(panel.on_error, _("Couldn't connect to the MTP device,"
                                        " wait a few seconds or reconnect the"
                                        " device, then try again."))
            self.connected = False
            self.connecting = False

        self.panel.track_count.set_label(_("Loading tracks..."))
        tracks = self.mtp.get_tracklisting()
        gobject.idle_add(self._load_tracks, tracks)
github akretion / pywebdriver / pywebdriver / plugins / View on Github external
def get_signature_http():

    file_ = None
    data = None

    download_path = config.get('signature_driver', 'download_path') or \
    signature_file = config.get('signature_driver', 'signature_file') or \

        mtp = pymtp.MTP()
    except Exception as err:
        app.logger.error('Unable to connect device %s' % str(err))
        return jsonify(jsonrpc='2.0', result=data)

    for f in mtp.get_filelisting():
        if f.filename == signature_file:
            file_ = f
    if file_:
        dest_file = os.path.join(download_path, signature_file)
            mtp.get_file_to_file(file_.item_id, dest_file)
            app.logger.debug('file downloaded to %s' % dest_file)
            with open(dest_file, 'r') as f:
                data =
github guardianproject / keysync / otrapps / View on Github external
from potr.utils import bytes_to_long
from potr.compatcrypto import DSAKey

if __name__ == '__main__':
    sys.path.insert(0, "../") # so the main() test suite can find otrapps module
import otrapps.errors as errors

# gracefully handle it when pymtp doesn't exist
class MTPDummy():
    def detect_devices(self):
        return []
    import pymtp
    mtp = pymtp.MTP()
    mtp = MTPDummy()
# GNOME GVFS mount point for MTP devices

if sys.platform != 'win32':
    # this crashes windows in the ntpath sys lib
    mtp.gvfs_mountpoint = os.path.join(os.getenv('HOME'), '.gvfs', 'mtp')

HLEN = sha1().digest_size  # length of the hash output

#RSAPrivateKey ::= SEQUENCE {
#  version Version,
#  modulus INTEGER, -- n
#  publicExponent INTEGER, -- e
#  privateExponent INTEGER, -- d